1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge pull request #22754 from mshabunin:c-cleanup

C-API cleanup for OpenCV 5.x (imgproc, highgui)

* imgproc: C-API cleanup

* imgproc: increase cvtColor test diff threshold

* imgproc: C-API cleanup pt.2

* imgproc: C-API cleanup pt.3

* imgproc: C-API cleanup pt.4

* imgproc: C-API cleanup pt.5

* imgproc: C-API cleanup pt.5

* imgproc: C-API cleanup pt.6

* highgui: C-API cleanup

* highgui: C-API cleanup pt.2

* highgui: C-API cleanup pt.3

* highgui: C-API cleanup pt.3

* imgproc: C-API cleanup pt.7

* fixup! highgui: C-API cleanup pt.3

* fixup! imgproc: C-API cleanup pt.6

* imgproc: C-API cleanup pt.8

* imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9
This commit is contained in:
Maksim Shabunin
2022-12-14 21:57:08 +03:00
committed by GitHub
parent d49958141e
commit 8a62b03761
87 changed files with 1374 additions and 12887 deletions
+1 -3
View File
@@ -167,8 +167,6 @@ It provides easy interface to:
cv::createTrackbar("Twin brother", windowName, &state, 100, callbackTwin);
}
@endcode
@defgroup highgui_c C API
@}
*/
@@ -797,7 +795,7 @@ CV_EXPORTS_W void displayOverlay(const String& winname, const String& text, int
The function displayStatusBar displays useful information/tips on top of the window for a certain
amount of time *delayms* . This information is displayed on the window statusbar (the window must be
created with the CV_GUI_EXPANDED flags).
created with the cv::WINDOW_GUI_EXPANDED flags).
@param winname Name of the window.
@param text Text to write on the window statusbar.
@@ -1,251 +0,0 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef OPENCV_HIGHGUI_H
#define OPENCV_HIGHGUI_H
#include "opencv2/core/core_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @addtogroup highgui_c
@{
*/
/****************************************************************************************\
* Basic GUI functions *
\****************************************************************************************/
//YV
//-----------New for Qt
/* For font */
enum { CV_FONT_LIGHT = 25,//QFont::Light,
CV_FONT_NORMAL = 50,//QFont::Normal,
CV_FONT_DEMIBOLD = 63,//QFont::DemiBold,
CV_FONT_BOLD = 75,//QFont::Bold,
CV_FONT_BLACK = 87 //QFont::Black
};
enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
CV_STYLE_ITALIC = 1,//QFont::StyleItalic,
CV_STYLE_OBLIQUE = 2 //QFont::StyleOblique
};
/* ---------*/
//for color cvScalar(blue_component, green_component, red_component[, alpha_component])
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
CVAPI(CvFont) cvFontQt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL), int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0));
CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2);
CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0));
CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0));
CVAPI(void) cvSaveWindowParameters(const char* name);
CVAPI(void) cvLoadWindowParameters(const char* name);
CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
CVAPI(void) cvStopLoop( void );
typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0));
//----------------------
/* this function is used to set some external parameters in case of X Window */
CVAPI(int) cvInitSystem( int argc, char** argv );
CVAPI(int) cvStartWindowThread( void );
// --------- YV ---------
enum
{
//These 3 flags are used by cvSet/GetWindowProperty
CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property
CV_WND_PROP_AUTOSIZE = 1, //to change/get window's autosize property
CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property
CV_WND_PROP_OPENGL = 3, //to change/get window's opengl support
CV_WND_PROP_VISIBLE = 4,
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
CV_WINDOW_NORMAL = 0x00000000, //the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
CV_WINDOW_AUTOSIZE = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed
CV_WINDOW_OPENGL = 0x00001000, //window with opengl support
//Those flags are only for Qt
CV_GUI_EXPANDED = 0x00000000, //status bar and tool bar
CV_GUI_NORMAL = 0x00000010, //old fashious way
//These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen
CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint)
CV_WINDOW_KEEPRATIO = 0x00000000//the ration image is respected.
};
/* create window */
CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
/* Set and Get Property of the window */
CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
CVAPI(double) cvGetWindowProperty(const char* name, int prop_id);
/* display image within window (highgui windows remember their content) */
CVAPI(void) cvShowImage( const char* name, const CvArr* image );
/* resize/move window */
CVAPI(void) cvResizeWindow( const char* name, int width, int height );
CVAPI(void) cvMoveWindow( const char* name, int x, int y );
/* destroy window and all the trackers associated with it */
CVAPI(void) cvDestroyWindow( const char* name );
CVAPI(void) cvDestroyAllWindows(void);
/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */
CVAPI(void*) cvGetWindowHandle( const char* name );
/* get name of highgui window given its native handle */
CVAPI(const char*) cvGetWindowName( void* window_handle );
typedef void (CV_CDECL *CvTrackbarCallback)(int pos);
/* create trackbar and display it on top of given window, set callback */
CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name,
int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata);
CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
int* value, int count, CvTrackbarCallback2 on_change,
void* userdata CV_DEFAULT(0));
/* retrieve or set trackbar position */
CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval);
CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval);
enum
{
CV_EVENT_MOUSEMOVE =0,
CV_EVENT_LBUTTONDOWN =1,
CV_EVENT_RBUTTONDOWN =2,
CV_EVENT_MBUTTONDOWN =3,
CV_EVENT_LBUTTONUP =4,
CV_EVENT_RBUTTONUP =5,
CV_EVENT_MBUTTONUP =6,
CV_EVENT_LBUTTONDBLCLK =7,
CV_EVENT_RBUTTONDBLCLK =8,
CV_EVENT_MBUTTONDBLCLK =9,
CV_EVENT_MOUSEWHEEL =10,
CV_EVENT_MOUSEHWHEEL =11
};
enum
{
CV_EVENT_FLAG_LBUTTON =1,
CV_EVENT_FLAG_RBUTTON =2,
CV_EVENT_FLAG_MBUTTON =4,
CV_EVENT_FLAG_CTRLKEY =8,
CV_EVENT_FLAG_SHIFTKEY =16,
CV_EVENT_FLAG_ALTKEY =32
};
#define CV_GET_WHEEL_DELTA(flags) ((short)((flags >> 16) & 0xffff)) // upper 16 bits
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
/* assign callback for mouse events */
CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
void* param CV_DEFAULT(NULL));
/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
// OpenGL support
typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata);
CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL));
CVAPI(void) cvSetOpenGlContext(const char* window_name);
CVAPI(void) cvUpdateWindow(const char* window_name);
/****************************************************************************************\
* Obsolete functions/synonyms *
\****************************************************************************************/
#define cvAddSearchPath(path)
#define cvvInitSystem cvInitSystem
#define cvvNamedWindow cvNamedWindow
#define cvvShowImage cvShowImage
#define cvvResizeWindow cvResizeWindow
#define cvvDestroyWindow cvDestroyWindow
#define cvvCreateTrackbar cvCreateTrackbar
#define cvvAddSearchPath cvAddSearchPath
#define cvvWaitKey(name) cvWaitKey(0)
#define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
#define set_preprocess_func cvSetPreprocessFuncWin32
#define set_postprocess_func cvSetPostprocessFuncWin32
#if defined _WIN32
CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback);
CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback);
#define cvSetPreprocessFuncWin32(callback) cvSetPreprocessFuncWin32_((const void*)(callback))
#define cvSetPostprocessFuncWin32(callback) cvSetPostprocessFuncWin32_((const void*)(callback))
#endif
/** @} highgui_c */
#ifdef __cplusplus
}
#endif
#endif
+28 -1
View File
@@ -58,7 +58,6 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui_c.h"
#include <stdlib.h>
#include <stdio.h>
@@ -89,6 +88,34 @@
#define CV_WINDOW_MAGIC_VAL 0x00420042
#define CV_TRACKBAR_MAGIC_VAL 0x00420043
// Obsolete but widely used types and functions hidden here
typedef void (CV_CDECL *CvTrackbarCallback)(int pos);
int namedWindowImpl(const char* name, int flags = cv::WINDOW_AUTOSIZE);
void showImageImpl( const char* name, const CvArr* image );
void resizeWindowImpl( const char* name, int width, int height );
void moveWindowImpl( const char* name, int x, int y );
void destroyWindowImpl(const char* name);
void destroyAllWindowsImpl(void);
int waitKeyImpl(int delay);
int getTrackbarPosImpl( const char* trackbar_name, const char* window_name );
void setTrackbarPosImpl( const char* trackbar_name, const char* window_name, int pos );
void setTrackbarMaxImpl(const char* trackbar_name, const char* window_name, int maxval);
void setTrackbarMinImpl(const char* trackbar_name, const char* window_name, int minval);
typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata);
int createTrackbar2Impl( const char* trackbar_name, const char* window_name,
int* value, int count, CvTrackbarCallback2 on_change,
void* userdata CV_DEFAULT(0));
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
void setMouseCallbackImpl( const char* window_name, CvMouseCallback on_mouse, void* param);
typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata);
void setOpenGLDrawCallbackImpl(const char* window_name, CvOpenGlDrawCallback callback, void* userdata);
void setOpenGLContextImpl(const char* window_name);
void updateWindowImpl(const char* window_name);
//Yannick Verdie 2010, Max Kostin 2015
void cvSetModeWindow_W32(const char* name, double prop_value);
void cvSetModeWindow_GTK(const char* name, double prop_value);
+104 -246
View File
@@ -187,10 +187,10 @@ static void deprecateNotFoundNoOpBehavior()
#define CV_NOT_FOUND_DEPRECATION deprecateNotFoundNoOpBehavior()
#endif
CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_value)
void cv::setWindowProperty(const String& name, int prop_id, double prop_value)
{
CV_TRACE_FUNCTION();
CV_Assert(name);
CV_Assert(!name.empty());
{
auto window = findWindow_(name);
@@ -217,34 +217,34 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
switch(prop_id)
{
//change between fullscreen or not.
case CV_WND_PROP_FULLSCREEN:
case cv::WND_PROP_FULLSCREEN:
if (prop_value != CV_WINDOW_NORMAL && prop_value != CV_WINDOW_FULLSCREEN) // bad argument
if (prop_value != cv::WINDOW_NORMAL && prop_value != cv::WINDOW_FULLSCREEN) // bad argument
break;
#if defined (HAVE_QT)
cvSetModeWindow_QT(name,prop_value);
cvSetModeWindow_QT(name.c_str(),prop_value);
#elif defined(HAVE_WIN32UI)
cvSetModeWindow_W32(name,prop_value);
cvSetModeWindow_W32(name.c_str(),prop_value);
#elif defined (HAVE_GTK)
cvSetModeWindow_GTK(name,prop_value);
cvSetModeWindow_GTK(name.c_str(),prop_value);
#elif defined (HAVE_COCOA)
cvSetModeWindow_COCOA(name,prop_value);
cvSetModeWindow_COCOA(name.c_str(),prop_value);
#elif defined (WINRT)
cvSetModeWindow_WinRT(name, prop_value);
cvSetModeWindow_WinRT(name.c_str(), prop_value);
#endif
break;
case CV_WND_PROP_AUTOSIZE:
case cv::WND_PROP_AUTOSIZE:
#if defined (HAVE_QT)
cvSetPropWindow_QT(name,prop_value);
cvSetPropWindow_QT(name.c_str(),prop_value);
#endif
break;
case CV_WND_PROP_ASPECTRATIO:
case cv::WND_PROP_ASPECT_RATIO:
#if defined (HAVE_QT)
cvSetRatioWindow_QT(name,prop_value);
cvSetRatioWindow_QT(name.c_str(),prop_value);
#endif
break;
@@ -252,9 +252,9 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
#if defined (HAVE_QT)
// nothing
#elif defined(HAVE_WIN32UI)
cvSetPropTopmost_W32(name, (prop_value != 0 ? true : false));
cvSetPropTopmost_W32(name.c_str(), (prop_value != 0 ? true : false));
#elif defined(HAVE_COCOA)
cvSetPropTopmost_COCOA(name, (prop_value != 0 ? true : false));
cvSetPropTopmost_COCOA(name.c_str(), (prop_value != 0 ? true : false));
#endif
break;
@@ -262,7 +262,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
#if defined (HAVE_QT)
// nothing
#elif defined (HAVE_WIN32UI)
cvSetPropVsync_W32(name, (prop_value != 0));
cvSetPropVsync_W32(name.c_str(), (prop_value != 0));
#else
// not implemented yet for other toolkits
#endif
@@ -273,11 +273,10 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
#endif
}
/* return -1 if error */
CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
double cv::getWindowProperty(const String& name, int prop_id)
{
CV_TRACE_FUNCTION();
CV_Assert(name);
CV_Assert(!name.empty());
{
auto window = findWindow_(name);
@@ -305,67 +304,67 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#else
switch(prop_id)
{
case CV_WND_PROP_FULLSCREEN:
case cv::WND_PROP_FULLSCREEN:
#if defined (HAVE_QT)
return cvGetModeWindow_QT(name);
return cvGetModeWindow_QT(name.c_str());
#elif defined(HAVE_WIN32UI)
return cvGetModeWindow_W32(name);
return cvGetModeWindow_W32(name.c_str());
#elif defined (HAVE_GTK)
return cvGetModeWindow_GTK(name);
return cvGetModeWindow_GTK(name.c_str());
#elif defined (HAVE_COCOA)
return cvGetModeWindow_COCOA(name);
return cvGetModeWindow_COCOA(name.c_str());
#elif defined (WINRT)
return cvGetModeWindow_WinRT(name);
return cvGetModeWindow_WinRT(name.c_str());
#else
return -1;
#endif
break;
case CV_WND_PROP_AUTOSIZE:
case cv::WND_PROP_AUTOSIZE:
#if defined (HAVE_QT)
return cvGetPropWindow_QT(name);
return cvGetPropWindow_QT(name.c_str());
#elif defined(HAVE_WIN32UI)
return cvGetPropWindowAutoSize_W32(name);
return cvGetPropWindowAutoSize_W32(name.c_str());
#elif defined (HAVE_GTK)
return cvGetPropWindowAutoSize_GTK(name);
return cvGetPropWindowAutoSize_GTK(name.c_str());
#else
return -1;
#endif
break;
case CV_WND_PROP_ASPECTRATIO:
case cv::WND_PROP_ASPECT_RATIO:
#if defined (HAVE_QT)
return cvGetRatioWindow_QT(name);
return cvGetRatioWindow_QT(name.c_str());
#elif defined(HAVE_WIN32UI)
return cvGetRatioWindow_W32(name);
return cvGetRatioWindow_W32(name.c_str());
#elif defined (HAVE_GTK)
return cvGetRatioWindow_GTK(name);
return cvGetRatioWindow_GTK(name.c_str());
#else
return -1;
#endif
break;
case CV_WND_PROP_OPENGL:
case cv::WND_PROP_OPENGL:
#if defined (HAVE_QT)
return cvGetOpenGlProp_QT(name);
return cvGetOpenGlProp_QT(name.c_str());
#elif defined(HAVE_WIN32UI)
return cvGetOpenGlProp_W32(name);
return cvGetOpenGlProp_W32(name.c_str());
#elif defined (HAVE_GTK)
return cvGetOpenGlProp_GTK(name);
return cvGetOpenGlProp_GTK(name.c_str());
#else
return -1;
#endif
break;
case CV_WND_PROP_VISIBLE:
case cv::WND_PROP_VISIBLE:
#if defined (HAVE_QT)
return cvGetPropVisible_QT(name);
return cvGetPropVisible_QT(name.c_str());
#elif defined(HAVE_WIN32UI)
return cvGetPropVisible_W32(name);
return cvGetPropVisible_W32(name.c_str());
#else
return -1;
#endif
@@ -375,9 +374,9 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT)
return -1;
#elif defined(HAVE_WIN32UI)
return cvGetPropTopmost_W32(name);
return cvGetPropTopmost_W32(name.c_str());
#elif defined(HAVE_COCOA)
return cvGetPropTopmost_COCOA(name);
return cvGetPropTopmost_COCOA(name.c_str());
#else
return -1;
#endif
@@ -387,7 +386,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#if defined (HAVE_QT)
return -1;
#elif defined (HAVE_WIN32UI)
return cvGetPropVsync_W32(name);
return cvGetPropVsync_W32(name.c_str());
#else
return -1;
#endif
@@ -478,7 +477,7 @@ void cv::namedWindow( const String& winname, int flags )
}
}
cvNamedWindow( winname.c_str(), flags );
namedWindowImpl( winname.c_str(), flags );
}
void cv::destroyWindow( const String& winname )
@@ -495,7 +494,7 @@ void cv::destroyWindow( const String& winname )
}
}
cvDestroyWindow( winname.c_str() );
destroyWindowImpl( winname.c_str() );
}
void cv::destroyAllWindows()
@@ -513,7 +512,7 @@ void cv::destroyAllWindows()
}
}
cvDestroyAllWindows();
destroyAllWindowsImpl();
}
void cv::resizeWindow( const String& winname, int width, int height )
@@ -541,14 +540,14 @@ void cv::resizeWindow( const String& winname, int width, int height )
}
return;
#else
cvResizeWindow( winname.c_str(), width, height );
resizeWindowImpl( winname.c_str(), width, height );
#endif
}
void cv::resizeWindow(const String& winname, const cv::Size& size)
{
CV_TRACE_FUNCTION();
cvResizeWindow(winname.c_str(), size.width, size.height);
resizeWindowImpl(winname.c_str(), size.width, size.height);
}
void cv::moveWindow( const String& winname, int x, int y )
@@ -576,7 +575,7 @@ void cv::moveWindow( const String& winname, int x, int y )
}
return;
#else
cvMoveWindow( winname.c_str(), x, y );
moveWindowImpl( winname.c_str(), x, y );
#endif
}
@@ -622,17 +621,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
#endif
}
void cv::setWindowProperty(const String& winname, int prop_id, double prop_value)
{
CV_TRACE_FUNCTION();
cvSetWindowProperty( winname.c_str(), prop_id, prop_value);
}
double cv::getWindowProperty(const String& winname, int prop_id)
{
CV_TRACE_FUNCTION();
return cvGetWindowProperty(winname.c_str(), prop_id);
}
int cv::waitKeyEx(int delay)
{
@@ -647,7 +636,7 @@ int cv::waitKeyEx(int delay)
}
}
return cvWaitKey(delay);
return waitKeyImpl(delay);
}
int cv::waitKey(int delay)
@@ -686,7 +675,7 @@ int cv::pollKey()
return pollKey_W32();
#else
// fallback. please implement a proper polling function
return cvWaitKey(1);
return waitKeyImpl(1);
#endif
}
@@ -746,7 +735,7 @@ int cv::createTrackbar(const String& trackbarName, const String& winName,
}
return 0;
#else
return cvCreateTrackbar2(trackbarName.c_str(), winName.c_str(),
return createTrackbar2Impl(trackbarName.c_str(), winName.c_str(),
value, count, callback, userdata);
#endif
}
@@ -779,7 +768,7 @@ void cv::setTrackbarPos( const String& trackbarName, const String& winName, int
}
return;
#else
cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value );
setTrackbarPosImpl(trackbarName.c_str(), winName.c_str(), value );
#endif
}
@@ -813,7 +802,7 @@ void cv::setTrackbarMax(const String& trackbarName, const String& winName, int m
}
return;
#else
cvSetTrackbarMax(trackbarName.c_str(), winName.c_str(), maxval);
setTrackbarMaxImpl(trackbarName.c_str(), winName.c_str(), maxval);
#endif
}
@@ -847,7 +836,7 @@ void cv::setTrackbarMin(const String& trackbarName, const String& winName, int m
}
return;
#else
cvSetTrackbarMin(trackbarName.c_str(), winName.c_str(), minval);
setTrackbarMinImpl(trackbarName.c_str(), winName.c_str(), minval);
#endif
}
@@ -879,7 +868,7 @@ int cv::getTrackbarPos( const String& trackbarName, const String& winName )
}
return -1;
#else
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
return getTrackbarPosImpl(trackbarName.c_str(), winName.c_str());
#endif
}
@@ -909,40 +898,42 @@ void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void
}
return;
#else
cvSetMouseCallback(windowName.c_str(), onMouse, param);
setMouseCallbackImpl(windowName.c_str(), onMouse, param);
#endif
}
int cv::getMouseWheelDelta( int flags )
{
CV_TRACE_FUNCTION();
return CV_GET_WHEEL_DELTA(flags);
return ((short)((flags >> 16) & 0xffff)); // upper 16 bits
}
#if !defined (HAVE_GTK)
int cv::startWindowThread()
{
CV_TRACE_FUNCTION();
return cvStartWindowThread();
return 0;
}
#endif // !GTK
// OpenGL support
void cv::setOpenGlDrawCallback(const String& name, OpenGlDrawCallback callback, void* userdata)
{
CV_TRACE_FUNCTION();
cvSetOpenGlDrawCallback(name.c_str(), callback, userdata);
setOpenGLDrawCallbackImpl(name.c_str(), callback, userdata);
}
void cv::setOpenGlContext(const String& windowName)
{
CV_TRACE_FUNCTION();
cvSetOpenGlContext(windowName.c_str());
setOpenGLContextImpl(windowName.c_str());
}
void cv::updateWindow(const String& windowName)
{
CV_TRACE_FUNCTION();
cvUpdateWindow(windowName.c_str());
updateWindowImpl(windowName.c_str());
}
#ifdef HAVE_OPENGL
@@ -1003,7 +994,7 @@ void cv::imshow( const String& winname, InputArray _img )
{
Mat img = _img.getMat();
CvMat c_img = cvMat(img);
cvShowImage(winname.c_str(), &c_img);
showImageImpl(winname.c_str(), &c_img);
}
#else
const double useGl = getWindowProperty(winname, WND_PROP_OPENGL);
@@ -1012,7 +1003,7 @@ void cv::imshow( const String& winname, InputArray _img )
{
Mat img = _img.getMat();
CvMat c_img = cvMat(img);
cvShowImage(winname.c_str(), &c_img);
showImageImpl(winname.c_str(), &c_img);
}
else
{
@@ -1089,86 +1080,31 @@ void cv::imshow(const String& winname, const ogl::Texture2D& _tex)
#endif
}
// Without OpenGL
//========================= OpenGL fallback =========================
#ifndef HAVE_OPENGL
CV_IMPL void cvSetOpenGlDrawCallback(const char*, CvOpenGlDrawCallback, void*)
void setOpenGLDrawCallbackImpl(const char*, CvOpenGlDrawCallback, void*)
{
CV_Error(CV_OpenGlNotSupported, "The library is compiled without OpenGL support");
}
CV_IMPL void cvSetOpenGlContext(const char*)
void setOpenGLContextImpl(const char*)
{
CV_Error(CV_OpenGlNotSupported, "The library is compiled without OpenGL support");
}
CV_IMPL void cvUpdateWindow(const char*)
void updateWindowImpl(const char*)
{
CV_Error(CV_OpenGlNotSupported, "The library is compiled without OpenGL support");
}
#endif // !HAVE_OPENGL
#if defined (HAVE_QT)
//========================= Qt fallback =========================
cv::QtFont cv::fontQt(const String& nameFont, int pointSize, Scalar color, int weight, int style, int spacing)
{
CvFont f = cvFontQt(nameFont.c_str(), pointSize, cvScalar(color), weight, style, spacing);
void* pf = &f; // to suppress strict-aliasing
return *(cv::QtFont*)pf;
}
void cv::addText( const Mat& img, const String& text, Point org, const QtFont& font)
{
CvMat _img = cvMat(img);
cvAddText( &_img, text.c_str(), cvPoint(org), (CvFont*)&font);
}
void cv::addText( const Mat& img, const String& text, Point org, const String& nameFont,
int pointSize, Scalar color, int weight, int style, int spacing)
{
CvFont f = cvFontQt(nameFont.c_str(), pointSize, cvScalar(color), weight, style, spacing);
CvMat _img = cvMat(img);
cvAddText( &_img, text.c_str(), cvPoint(org), &f);
}
void cv::displayStatusBar(const String& name, const String& text, int delayms)
{
cvDisplayStatusBar(name.c_str(),text.c_str(), delayms);
}
void cv::displayOverlay(const String& name, const String& text, int delayms)
{
cvDisplayOverlay(name.c_str(),text.c_str(), delayms);
}
int cv::startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[])
{
return cvStartLoop(pt2Func, argc, argv);
}
void cv::stopLoop()
{
cvStopLoop();
}
void cv::saveWindowParameters(const String& windowName)
{
cvSaveWindowParameters(windowName.c_str());
}
void cv::loadWindowParameters(const String& windowName)
{
cvLoadWindowParameters(windowName.c_str());
}
int cv::createButton(const String& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state )
{
return cvCreateButton(button_name.c_str(), on_change, userdata, button_type , initial_button_state );
}
#else
// moved to window_QT.cpp
#ifndef HAVE_QT
static const char* NO_QT_ERR_MSG = "The library is compiled without QT support";
@@ -1222,16 +1158,13 @@ int cv::createButton(const String&, ButtonCallback, void*, int , bool )
CV_Error(CV_StsNotImplemented, NO_QT_ERR_MSG);
}
#endif
#endif // !HAVE_QT
#if defined (HAVE_WIN32UI) // see window_w32.cpp
#elif defined (HAVE_GTK) // see window_gtk.cpp
#elif defined (HAVE_COCOA) // see window_cocoa.mm
#elif defined (HAVE_QT) // see window_QT.cpp
#elif defined (HAVE_WAYLAND) // see window_wayland.cpp
#elif defined (WINRT) && !defined (WINRT_8_0) // see window_winrt.cpp
#else
//========================= NO GUI fallback =========================
#if !defined (HAVE_WIN32UI) && !defined (HAVE_GTK) && !defined (HAVE_COCOA) && !defined (HAVE_QT) \
&& !defined (HAVE_WAYLAND) && !defined (WINRT) && !defined (WINRT_8_0)
// No windowing system present at compile time ;-(
//
@@ -1248,148 +1181,73 @@ int cv::createButton(const String&, ButtonCallback, void*, int , bool )
funcname, __FILE__, __LINE__)
CV_IMPL int cvNamedWindow( const char*, int )
int namedWindowImpl( const char*, int )
{
CV_NO_GUI_ERROR("cvNamedWindow");
CV_NO_GUI_ERROR("namedWindowImpl");
}
CV_IMPL void cvDestroyWindow( const char* )
void destroyWindowImpl( const char* )
{
CV_NO_GUI_ERROR( "cvDestroyWindow" );
CV_NO_GUI_ERROR( "destroyWindowImpl" );
}
CV_IMPL void
cvDestroyAllWindows( void )
void destroyAllWindowsImpl( void )
{
CV_NO_GUI_ERROR( "cvDestroyAllWindows" );
CV_NO_GUI_ERROR( "destroyAllWindowsImpl" );
}
CV_IMPL void
cvShowImage( const char*, const CvArr* )
void showImageImpl( const char*, const CvArr* )
{
CV_NO_GUI_ERROR( "cvShowImage" );
CV_NO_GUI_ERROR( "showImageImpl" );
}
CV_IMPL void cvResizeWindow( const char*, int, int )
void resizeWindowImpl( const char*, int, int )
{
CV_NO_GUI_ERROR( "cvResizeWindow" );
CV_NO_GUI_ERROR( "resizeWindowImpl" );
}
CV_IMPL void cvMoveWindow( const char*, int, int )
void moveWindowImpl( const char*, int, int )
{
CV_NO_GUI_ERROR( "cvMoveWindow" );
CV_NO_GUI_ERROR( "moveWindowImpl" );
}
CV_IMPL int
cvCreateTrackbar( const char*, const char*,
int*, int, CvTrackbarCallback )
{
CV_NO_GUI_ERROR( "cvCreateTrackbar" );
}
CV_IMPL int
cvCreateTrackbar2( const char* /*trackbar_name*/, const char* /*window_name*/,
int createTrackbar2Impl( const char* /*trackbar_name*/, const char* /*window_name*/,
int* /*val*/, int /*count*/, CvTrackbarCallback2 /*on_notify2*/,
void* /*userdata*/ )
{
CV_NO_GUI_ERROR( "cvCreateTrackbar2" );
CV_NO_GUI_ERROR( "createTrackbar2Impl" );
}
CV_IMPL void
cvSetMouseCallback( const char*, CvMouseCallback, void* )
void setMouseCallbackImpl( const char*, CvMouseCallback, void* )
{
CV_NO_GUI_ERROR( "cvSetMouseCallback" );
CV_NO_GUI_ERROR( "setMouseCallbackImpl" );
}
CV_IMPL int cvGetTrackbarPos( const char*, const char* )
int getTrackbarPosImpl( const char*, const char* )
{
CV_NO_GUI_ERROR( "cvGetTrackbarPos" );
CV_NO_GUI_ERROR( "getTrackbarPosImpl" );
}
CV_IMPL void cvSetTrackbarPos( const char*, const char*, int )
void setTrackbarPosImpl( const char*, const char*, int )
{
CV_NO_GUI_ERROR( "cvSetTrackbarPos" );
CV_NO_GUI_ERROR( "setTrackbarPosImpl" );
}
CV_IMPL void cvSetTrackbarMax(const char*, const char*, int)
void setTrackbarMaxImpl(const char*, const char*, int)
{
CV_NO_GUI_ERROR( "cvSetTrackbarMax" );
CV_NO_GUI_ERROR( "setTrackbarMaxImpl" );
}
CV_IMPL void cvSetTrackbarMin(const char*, const char*, int)
void setTrackbarMinImpl(const char*, const char*, int)
{
CV_NO_GUI_ERROR( "cvSetTrackbarMin" );
CV_NO_GUI_ERROR( "setTrackbarMinImpl" );
}
CV_IMPL void* cvGetWindowHandle( const char* )
int waitKeyImpl( int )
{
CV_NO_GUI_ERROR( "cvGetWindowHandle" );
CV_NO_GUI_ERROR( "waitKeyImpl" );
}
CV_IMPL const char* cvGetWindowName( void* )
{
CV_NO_GUI_ERROR( "cvGetWindowName" );
}
CV_IMPL int cvWaitKey( int )
{
CV_NO_GUI_ERROR( "cvWaitKey" );
}
CV_IMPL int cvInitSystem( int , char** )
{
CV_NO_GUI_ERROR( "cvInitSystem" );
}
CV_IMPL int cvStartWindowThread()
{
CV_NO_GUI_ERROR( "cvStartWindowThread" );
}
//-------- Qt ---------
CV_IMPL void cvAddText( const CvArr*, const char*, CvPoint , CvFont* )
{
CV_NO_GUI_ERROR("cvAddText");
}
CV_IMPL void cvDisplayStatusBar(const char* , const char* , int )
{
CV_NO_GUI_ERROR("cvDisplayStatusBar");
}
CV_IMPL void cvDisplayOverlay(const char* , const char* , int )
{
CV_NO_GUI_ERROR("cvNamedWindow");
}
CV_IMPL int cvStartLoop(int (*)(int argc, char *argv[]), int , char* argv[])
{
CV_UNUSED(argv);
CV_NO_GUI_ERROR("cvStartLoop");
}
CV_IMPL void cvStopLoop()
{
CV_NO_GUI_ERROR("cvStopLoop");
}
CV_IMPL void cvSaveWindowParameters(const char* )
{
CV_NO_GUI_ERROR("cvSaveWindowParameters");
}
// CV_IMPL void cvLoadWindowParameterss(const char* name)
// {
// CV_NO_GUI_ERROR("cvLoadWindowParameters");
// }
CV_IMPL int cvCreateButton(const char*, void (*)(int, void*), void*, int, int)
{
CV_NO_GUI_ERROR("cvCreateButton");
}
#endif
#endif // NO_GUI
/* End of file. */
+157 -220
View File
@@ -124,40 +124,120 @@ Qt::ConnectionType autoBlockingConnection() {
: Qt::DirectConnection;
}
CV_IMPL CvFont cvFontQt(const char* nameFont, int pointSize,CvScalar color,int weight,int style, int spacing)
cv::QtFont cv::fontQt(const String& nameFont, int pointSize, Scalar color, int weight, int style, int spacing)
{
/*
//nameFont <- only Qt
//CvScalar color <- only Qt (blue_component, green_component, red\_component[, alpha_component])
int font_face;//<- style in Qt
const int* ascii;
const int* greek;
const int* cyrillic;
float hscale, vscale;
float shear;
int thickness;//<- weight in Qt
float dx;//spacing letter in Qt (0 default) in pixel
int line_type;//<- pointSize in Qt
*/
CvFont f = {nameFont,color,style,NULL,NULL,NULL,0,0,0,weight, (float)spacing, pointSize};
return f;
QtFont res = {
nameFont.c_str(), color, style, NULL, NULL, NULL, 0,0,0, weight, (float)spacing, pointSize
};
return res;
}
void cv::addText( const Mat& img, const String& text, Point org, const QtFont& font)
{
CV_IMPL void cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont* font)
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
CvMat _img = cvMat(img);
QMetaObject::invokeMethod(
guiMainThread,
"putText",
autoBlockingConnection(),
Q_ARG(void*, (void*)&_img),
Q_ARG(QString,QString::fromUtf8(text.c_str())),
Q_ARG(QPoint, QPoint(org.x,org.y)),
Q_ARG(void*,(void*)&font)
);
}
void cv::addText( const Mat& img, const String& text, Point org, const String& nameFont,
int pointSize, Scalar color, int weight, int style, int spacing)
{
cv::QtFont f = cv::fontQt(nameFont.c_str(), pointSize, cvScalar(color), weight, style, spacing);
cv::addText(img, text, org, f);
}
void cv::displayStatusBar(const String& name, const String& text, int delayms)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"putText",
"displayStatusBar",
autoBlockingConnection(),
Q_ARG(void*, (void*) img),
Q_ARG(QString,QString::fromUtf8(text)),
Q_ARG(QPoint, QPoint(org.x,org.y)),
Q_ARG(void*,(void*) font));
Q_ARG(QString, QString(name.c_str())),
Q_ARG(QString, QString(text.c_str())),
Q_ARG(int, delayms));
}
void cv::displayOverlay(const String& name, const String& text, int delayms)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"displayInfo",
autoBlockingConnection(),
Q_ARG(QString, QString(name.c_str())),
Q_ARG(QString, QString(text.c_str())),
Q_ARG(int, delayms));
}
//Yannick Verdie
//This function is experimental and some functions (such as cvSet/getWindowProperty will not work)
//We recommend not using this function for now
int cv::startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[])
{
multiThreads = true;
QFuture<int> future = QtConcurrent::run(pt2Func, argc, argv);
return guiMainThread->start();
}
void cv::stopLoop()
{
qApp->exit();
}
void cv::saveWindowParameters(const String& windowName)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"saveWindowParameters",
autoBlockingConnection(),
Q_ARG(QString, QString(windowName.c_str())));
}
void cv::loadWindowParameters(const String& windowName)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"loadWindowParameters",
autoBlockingConnection(),
Q_ARG(QString, QString(windowName.c_str())));
}
int cv::createButton(const String& button_name, ButtonCallback on_change, void* userdata, int button_type , bool initial_button_state )
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"addButton",
autoBlockingConnection(),
Q_ARG(QString, QString(button_name.c_str())),
Q_ARG(int, button_type),
Q_ARG(int, initial_button_state ? 1 : 0),
Q_ARG(void*, (void*)on_change),
Q_ARG(void*, userdata));
return 1;//dummy value
}
double cvGetRatioWindow_QT(const char* name)
{
@@ -287,60 +367,7 @@ double cvGetModeWindow_QT(const char* name)
return result;
}
CV_IMPL void cvDisplayOverlay(const char* name, const char* text, int delayms)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"displayInfo",
autoBlockingConnection(),
Q_ARG(QString, QString(name)),
Q_ARG(QString, QString(text)),
Q_ARG(int, delayms));
}
CV_IMPL void cvSaveWindowParameters(const char* name)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"saveWindowParameters",
autoBlockingConnection(),
Q_ARG(QString, QString(name)));
}
CV_IMPL void cvLoadWindowParameters(const char* name)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"loadWindowParameters",
autoBlockingConnection(),
Q_ARG(QString, QString(name)));
}
CV_IMPL void cvDisplayStatusBar(const char* name, const char* text, int delayms)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"displayStatusBar",
autoBlockingConnection(),
Q_ARG(QString, QString(name)),
Q_ARG(QString, QString(text)),
Q_ARG(int, delayms));
}
CV_IMPL int cvWaitKey(int delay)
int waitKeyImpl(int delay)
{
int result = -1;
@@ -414,24 +441,6 @@ CV_IMPL int cvWaitKey(int delay)
return result;
}
//Yannick Verdie
//This function is experimental and some functions (such as cvSet/getWindowProperty will not work)
//We recommend not using this function for now
CV_IMPL int cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[])
{
multiThreads = true;
QFuture<int> future = QtConcurrent::run(pt2Func, argc, argv);
return guiMainThread->start();
}
CV_IMPL void cvStopLoop()
{
qApp->exit();
}
static CvWindow* icvFindWindowByName(QString name)
{
CvWindow* window = 0;
@@ -494,10 +503,10 @@ static CvTrackbar* icvFindTrackBarByName(const char* name_trackbar, const char*
if (!w)
CV_Error(CV_StsNullPtr, "NULL window handler");
if (w->param_gui_mode == CV_GUI_NORMAL)
if (w->param_gui_mode == cv::WINDOW_GUI_NORMAL)
return (CvTrackbar*) icvFindBarByName(w->myBarLayout, nameQt, type_CvTrackbar);
if (w->param_gui_mode == CV_GUI_EXPANDED)
if (w->param_gui_mode == cv::WINDOW_GUI_EXPANDED)
{
CvBar* result = icvFindBarByName(w->myBarLayout, nameQt, type_CvTrackbar);
@@ -545,15 +554,7 @@ static int icvInitSystem(int* c, char** v)
return 0;
}
CV_IMPL int cvInitSystem(int, char**)
{
icvInitSystem(&parameterSystemC, parameterSystemV);
return 0;
}
CV_IMPL int cvNamedWindow(const char* name, int flags)
int namedWindowImpl(const char* name, int flags)
{
if (!guiMainThread)
guiMainThread = new GuiReceiver;
@@ -572,7 +573,7 @@ CV_IMPL int cvNamedWindow(const char* name, int flags)
}
CV_IMPL void cvDestroyWindow(const char* name)
void destroyWindowImpl(const char* name)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
@@ -584,7 +585,7 @@ CV_IMPL void cvDestroyWindow(const char* name)
}
CV_IMPL void cvDestroyAllWindows()
void destroyAllWindowsImpl()
{
if (!guiMainThread)
return;
@@ -595,25 +596,7 @@ CV_IMPL void cvDestroyAllWindows()
}
CV_IMPL void* cvGetWindowHandle(const char* name)
{
if (!name)
CV_Error( CV_StsNullPtr, "NULL name string" );
return (void*) icvFindWindowByName(QLatin1String(name));
}
CV_IMPL const char* cvGetWindowName(void* window_handle)
{
if( !window_handle )
CV_Error( CV_StsNullPtr, "NULL window handler" );
return ((CvWindow*)window_handle)->objectName().toLatin1().data();
}
CV_IMPL void cvMoveWindow(const char* name, int x, int y)
void moveWindowImpl(const char* name, int x, int y)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
@@ -625,7 +608,7 @@ CV_IMPL void cvMoveWindow(const char* name, int x, int y)
Q_ARG(int, y));
}
CV_IMPL void cvResizeWindow(const char* name, int width, int height)
void resizeWindowImpl(const char* name, int width, int height)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
@@ -638,7 +621,7 @@ CV_IMPL void cvResizeWindow(const char* name, int width, int height)
}
CV_IMPL int cvCreateTrackbar2(const char* name_bar, const char* window_name, int* val, int count, CvTrackbarCallback2 on_notify, void* userdata)
int createTrackbar2Impl(const char* name_bar, const char* window_name, int* val, int count, CvTrackbarCallback2 on_notify, void* userdata)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
@@ -656,53 +639,7 @@ CV_IMPL int cvCreateTrackbar2(const char* name_bar, const char* window_name, int
return 1; //dummy value
}
CV_IMPL int cvStartWindowThread()
{
return 0;
}
CV_IMPL int cvCreateTrackbar(const char* name_bar, const char* window_name, int* value, int count, CvTrackbarCallback on_change)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
QMetaObject::invokeMethod(guiMainThread,
"addSlider",
autoBlockingConnection(),
Q_ARG(QString, QString(name_bar)),
Q_ARG(QString, QString(window_name)),
Q_ARG(void*, (void*)value),
Q_ARG(int, count),
Q_ARG(void*, (void*)on_change));
return 1; //dummy value
}
CV_IMPL int cvCreateButton(const char* button_name, CvButtonCallback on_change, void* userdata, int button_type, int initial_button_state)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
if (initial_button_state < 0 || initial_button_state > 1)
return 0;
QMetaObject::invokeMethod(guiMainThread,
"addButton",
autoBlockingConnection(),
Q_ARG(QString, QString(button_name)),
Q_ARG(int, button_type),
Q_ARG(int, initial_button_state),
Q_ARG(void*, (void*)on_change),
Q_ARG(void*, userdata));
return 1;//dummy value
}
CV_IMPL int cvGetTrackbarPos(const char* name_bar, const char* window_name)
int getTrackbarPosImpl(const char* name_bar, const char* window_name)
{
int result = -1;
@@ -715,7 +652,7 @@ CV_IMPL int cvGetTrackbarPos(const char* name_bar, const char* window_name)
}
CV_IMPL void cvSetTrackbarPos(const char* name_bar, const char* window_name, int pos)
void setTrackbarPosImpl(const char* name_bar, const char* window_name, int pos)
{
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
@@ -724,7 +661,7 @@ CV_IMPL void cvSetTrackbarPos(const char* name_bar, const char* window_name, int
}
CV_IMPL void cvSetTrackbarMax(const char* name_bar, const char* window_name, int maxval)
void setTrackbarMaxImpl(const char* name_bar, const char* window_name, int maxval)
{
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
if (t)
@@ -734,7 +671,7 @@ CV_IMPL void cvSetTrackbarMax(const char* name_bar, const char* window_name, int
}
CV_IMPL void cvSetTrackbarMin(const char* name_bar, const char* window_name, int minval)
void setTrackbarMinImpl(const char* name_bar, const char* window_name, int minval)
{
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
if (t)
@@ -745,7 +682,7 @@ CV_IMPL void cvSetTrackbarMin(const char* name_bar, const char* window_name, int
/* assign callback for mouse events */
CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mouse, void* param)
void setMouseCallbackImpl(const char* window_name, CvMouseCallback on_mouse, void* param)
{
QPointer<CvWindow> w = icvFindWindowByName(QLatin1String(window_name));
@@ -757,7 +694,7 @@ CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mous
}
CV_IMPL void cvShowImage(const char* name, const CvArr* arr)
void showImageImpl(const char* name, const CvArr* arr)
{
if (!guiMainThread)
guiMainThread = new GuiReceiver;
@@ -777,7 +714,7 @@ CV_IMPL void cvShowImage(const char* name, const CvArr* arr)
#ifdef HAVE_QT_OPENGL
CV_IMPL void cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata)
void setOpenGLDrawCallbackImpl(const char* window_name, CvOpenGlDrawCallback callback, void* userdata)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
@@ -791,7 +728,7 @@ CV_IMPL void cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallba
}
CV_IMPL void cvSetOpenGlContext(const char* window_name)
void setOpenGLContextImpl(const char* window_name)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
@@ -803,7 +740,7 @@ CV_IMPL void cvSetOpenGlContext(const char* window_name)
}
CV_IMPL void cvUpdateWindow(const char* window_name)
void updateWindowImpl(const char* window_name)
{
if (!guiMainThread)
CV_Error( CV_StsNullPtr, "NULL guiReceiver (please create a window)" );
@@ -889,7 +826,7 @@ void GuiReceiver::putText(void* arr, QString text, QPoint org, void* arg2)
QImage qimg(mat->data.ptr, mat->cols, mat->rows, mat->step, QImage::Format_RGB888);
CvFont* font = (CvFont*)arg2;
QtFont* font = (QtFont*)arg2;
QPainter qp(&qimg);
if (font)
@@ -989,7 +926,7 @@ void GuiReceiver::setWindowTitle(QString name, QString title)
if (!w)
{
cvNamedWindow(name.toLatin1().data());
namedWindowImpl(name.toLatin1().data());
w = icvFindWindowByName(name);
}
@@ -1016,7 +953,7 @@ double GuiReceiver::isFullScreen(QString name)
if (!w)
return -1;
return w->isFullScreen() ? CV_WINDOW_FULLSCREEN : CV_WINDOW_NORMAL;
return w->isFullScreen() ? cv::WINDOW_FULLSCREEN : cv::WINDOW_NORMAL;
}
@@ -1046,7 +983,7 @@ void GuiReceiver::createWindow(QString name, int flags)
nb_windows++;
new CvWindow(name, flags);
cvWaitKey(1);
waitKeyImpl(1);
}
@@ -1080,7 +1017,7 @@ void GuiReceiver::showImage(QString name, void* arr)
if (!w) //as observed in the previous implementation (W32, GTK), create a new window is the pointer returned is null
{
cvNamedWindow(name.toLatin1().data());
namedWindowImpl(name.toLatin1().data());
w = icvFindWindowByName(name);
}
@@ -1228,7 +1165,7 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu
// unset buttonbar flag
button_type = button_type & ~cv::QT_NEW_BUTTONBAR;
b->addButton(button_name, (CvButtonCallback) on_change, userdata, button_type, initial_button_state);
b->addButton(button_name, (ButtonCallback) on_change, userdata, button_type, initial_button_state);
}
@@ -1491,7 +1428,7 @@ void CvButtonbar::setLabel()
}
void CvButtonbar::addButton(QString name, CvButtonCallback call, void* userdata, int button_type, int initial_button_state)
void CvButtonbar::addButton(QString name, cv::ButtonCallback call, void* userdata, int button_type, int initial_button_state)
{
QString button_name = name;
@@ -1500,13 +1437,13 @@ void CvButtonbar::addButton(QString name, CvButtonCallback call, void* userdata,
QPointer<QAbstractButton> button;
if (button_type == CV_PUSH_BUTTON)
if (button_type == cv::QT_PUSH_BUTTON)
button = (QAbstractButton*) new CvPushButton(this, button_name,call, userdata);
if (button_type == CV_CHECKBOX)
if (button_type == cv::QT_CHECKBOX)
button = (QAbstractButton*) new CvCheckBox(this, button_name,call, userdata, initial_button_state);
if (button_type == CV_RADIOBOX)
if (button_type == cv::QT_RADIOBOX)
{
button = (QAbstractButton*) new CvRadioButton(this, button_name,call, userdata, initial_button_state);
group_button->addButton(button);
@@ -1514,7 +1451,7 @@ void CvButtonbar::addButton(QString name, CvButtonCallback call, void* userdata,
if (button)
{
if (button_type == CV_PUSH_BUTTON)
if (button_type == cv::QT_PUSH_BUTTON)
QObject::connect(button, SIGNAL(clicked(bool)), button, SLOT(callCallBack(bool)));
else
QObject::connect(button, SIGNAL(toggled(bool)), button, SLOT(callCallBack(bool)));
@@ -1529,7 +1466,7 @@ void CvButtonbar::addButton(QString name, CvButtonCallback call, void* userdata,
//buttons here
CvPushButton::CvPushButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4)
CvPushButton::CvPushButton(CvButtonbar* arg1, QString arg2, ButtonCallback arg3, void* arg4)
{
myparent = arg1;
button_name = arg2;
@@ -1551,7 +1488,7 @@ void CvPushButton::callCallBack(bool checked)
}
CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, int initial_button_state)
CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, ButtonCallback arg3, void* arg4, int initial_button_state)
{
myparent = arg1;
button_name = arg2;
@@ -1574,7 +1511,7 @@ void CvCheckBox::callCallBack(bool checked)
}
CvRadioButton::CvRadioButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, int initial_button_state)
CvRadioButton::CvRadioButton(CvButtonbar* arg1, QString arg2, ButtonCallback arg3, void* arg4, int initial_button_state)
{
myparent = arg1;
button_name = arg2;
@@ -1701,19 +1638,19 @@ CvWindow::CvWindow(QString name, int arg2)
//3: my view
#ifndef HAVE_QT_OPENGL
if (arg2 & CV_WINDOW_OPENGL)
if (arg2 & cv::WINDOW_OPENGL)
CV_Error( CV_OpenGlNotSupported, "Library was built without OpenGL support" );
mode_display = CV_MODE_NORMAL;
#else
mode_display = arg2 & CV_WINDOW_OPENGL ? CV_MODE_OPENGL : CV_MODE_NORMAL;
mode_display = arg2 & cv::WINDOW_OPENGL ? CV_MODE_OPENGL : CV_MODE_NORMAL;
if (mode_display == CV_MODE_OPENGL)
param_gui_mode = CV_GUI_NORMAL;
param_gui_mode = cv::WINDOW_GUI_NORMAL;
#endif
createView();
//4: shortcuts and actions
//5: toolBar and statusbar
if (param_gui_mode == CV_GUI_EXPANDED)
if (param_gui_mode == cv::WINDOW_GUI_EXPANDED)
{
createActions();
createShortcuts();
@@ -1836,13 +1773,13 @@ void CvWindow::setPropWindow(int flags)
switch(flags)
{
case CV_WINDOW_NORMAL:
case cv::WINDOW_NORMAL:
myGlobalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
param_flags = flags;
break;
case CV_WINDOW_AUTOSIZE:
case cv::WINDOW_AUTOSIZE:
myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize);
param_flags = flags;
@@ -1855,14 +1792,14 @@ void CvWindow::setPropWindow(int flags)
void CvWindow::toggleFullScreen(int flags)
{
if (isFullScreen() && flags == CV_WINDOW_NORMAL)
if (isFullScreen() && flags == cv::WINDOW_NORMAL)
{
showTools();
showNormal();
return;
}
if (!isFullScreen() && flags == CV_WINDOW_FULLSCREEN)
if (!isFullScreen() && flags == cv::WINDOW_FULLSCREEN)
{
hideTools();
showFullScreen();
@@ -2012,9 +1949,9 @@ void CvWindow::createGlobalLayout()
#endif
setMinimumSize(1, 1);
if (param_flags == CV_WINDOW_AUTOSIZE)
if (param_flags == cv::WINDOW_AUTOSIZE)
myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize);
else if (param_flags == CV_WINDOW_NORMAL)
else if (param_flags == cv::WINDOW_NORMAL)
myGlobalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
}
@@ -2463,23 +2400,23 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
// icvmouseHandler called with flags == 0 where it really need.
//flags = 0;
if(modifiers & Qt::ShiftModifier)
flags |= CV_EVENT_FLAG_SHIFTKEY;
flags |= cv::EVENT_FLAG_SHIFTKEY;
if(modifiers & Qt::ControlModifier)
flags |= CV_EVENT_FLAG_CTRLKEY;
flags |= cv::EVENT_FLAG_CTRLKEY;
if(modifiers & Qt::AltModifier)
flags |= CV_EVENT_FLAG_ALTKEY;
flags |= cv::EVENT_FLAG_ALTKEY;
if(buttons & Qt::LeftButton)
flags |= CV_EVENT_FLAG_LBUTTON;
flags |= cv::EVENT_FLAG_LBUTTON;
if(buttons & Qt::RightButton)
flags |= CV_EVENT_FLAG_RBUTTON;
flags |= cv::EVENT_FLAG_RBUTTON;
if(buttons & Qt_MiddleButton)
flags |= CV_EVENT_FLAG_MBUTTON;
flags |= cv::EVENT_FLAG_MBUTTON;
if (cv_event == -1) {
if (category == mouse_wheel) {
QWheelEvent *we = (QWheelEvent *) evnt;
cv_event = ((wheelEventOrientation(we) == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
cv_event = ((wheelEventOrientation(we) == Qt::Vertical) ? cv::EVENT_MOUSEWHEEL : cv::EVENT_MOUSEHWHEEL);
flags |= (wheelEventDelta(we) & 0xffff)<<16;
return;
}
@@ -2487,18 +2424,18 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
{
case Qt::LeftButton:
cv_event = tableMouseButtons[category][0];
flags |= CV_EVENT_FLAG_LBUTTON;
flags |= cv::EVENT_FLAG_LBUTTON;
break;
case Qt::RightButton:
cv_event = tableMouseButtons[category][1];
flags |= CV_EVENT_FLAG_RBUTTON;
flags |= cv::EVENT_FLAG_RBUTTON;
break;
case Qt_MiddleButton:
cv_event = tableMouseButtons[category][2];
flags |= CV_EVENT_FLAG_MBUTTON;
flags |= cv::EVENT_FLAG_MBUTTON;
break;
default:
cv_event = CV_EVENT_MOUSEMOVE;
cv_event = cv::EVENT_MOUSEMOVE;
}
}
}
@@ -2603,7 +2540,7 @@ void DefaultViewPort::setRatio(int flags)
return;
//if valid flags
if (flags == CV_WINDOW_FREERATIO || flags == CV_WINDOW_KEEPRATIO)
if (flags == cv::WINDOW_FREERATIO || flags == cv::WINDOW_KEEPRATIO)
{
centralWidget->param_ratio_mode = flags;
param_keepRatio = flags;
@@ -2814,7 +2751,7 @@ void DefaultViewPort::resizeEvent(QResizeEvent* evnt)
ratioX = width() / float(image2Draw_mat->cols);
ratioY = height() / float(image2Draw_mat->rows);
if (param_keepRatio == CV_WINDOW_KEEPRATIO)//to keep the same aspect ratio
if (param_keepRatio == cv::WINDOW_KEEPRATIO)//to keep the same aspect ratio
{
QSize newSize = QSize(image2Draw_mat->cols, image2Draw_mat->rows);
newSize.scale(evnt->size(), Qt::KeepAspectRatio);
+12 -12
View File
@@ -182,7 +182,7 @@ class CvButtonbar : public CvBar
public:
CvButtonbar(QWidget* arg, QString bar_name);
void addButton(QString button_name, CvButtonCallback call, void* userdata, int button_type, int initial_button_state);
void addButton(QString button_name, cv::ButtonCallback call, void* userdata, int button_type, int initial_button_state);
private:
void setLabel();
@@ -196,12 +196,12 @@ class CvPushButton : public QPushButton
{
Q_OBJECT
public:
CvPushButton(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata);
CvPushButton(CvButtonbar* par, QString button_name, cv::ButtonCallback call, void* userdata);
private:
CvButtonbar* myparent;
QString button_name ;
CvButtonCallback callback;
cv::ButtonCallback callback;
void* userdata;
private slots:
@@ -213,12 +213,12 @@ class CvCheckBox : public QCheckBox
{
Q_OBJECT
public:
CvCheckBox(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata, int initial_button_state);
CvCheckBox(CvButtonbar* par, QString button_name, cv::ButtonCallback call, void* userdata, int initial_button_state);
private:
CvButtonbar* myparent;
QString button_name ;
CvButtonCallback callback;
cv::ButtonCallback callback;
void* userdata;
private slots:
@@ -230,12 +230,12 @@ class CvRadioButton : public QRadioButton
{
Q_OBJECT
public:
CvRadioButton(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata, int initial_button_state);
CvRadioButton(CvButtonbar* par, QString button_name, cv::ButtonCallback call, void* userdata, int initial_button_state);
private:
CvButtonbar* myparent;
QString button_name ;
CvButtonCallback callback;
cv::ButtonCallback callback;
void* userdata;
private slots:
@@ -297,7 +297,7 @@ class CvWindow : public CvWinModel
{
Q_OBJECT
public:
CvWindow(QString arg2, int flag = CV_WINDOW_NORMAL);
CvWindow(QString arg2, int flag = cv::WINDOW_NORMAL);
~CvWindow();
void setMouseCallBack(CvMouseCallback m, void* param);
@@ -384,10 +384,10 @@ private slots:
enum type_mouse_event { mouse_up = 0, mouse_down = 1, mouse_dbclick = 2, mouse_move = 3, mouse_wheel = 4 };
static const int tableMouseButtons[][3]={
{CV_EVENT_LBUTTONUP, CV_EVENT_RBUTTONUP, CV_EVENT_MBUTTONUP}, //mouse_up
{CV_EVENT_LBUTTONDOWN, CV_EVENT_RBUTTONDOWN, CV_EVENT_MBUTTONDOWN}, //mouse_down
{CV_EVENT_LBUTTONDBLCLK, CV_EVENT_RBUTTONDBLCLK, CV_EVENT_MBUTTONDBLCLK}, //mouse_dbclick
{CV_EVENT_MOUSEMOVE, CV_EVENT_MOUSEMOVE, CV_EVENT_MOUSEMOVE}, //mouse_move
{cv::EVENT_LBUTTONUP, cv::EVENT_RBUTTONUP, cv::EVENT_MBUTTONUP}, //mouse_up
{cv::EVENT_LBUTTONDOWN, cv::EVENT_RBUTTONDOWN, cv::EVENT_MBUTTONDOWN}, //mouse_down
{cv::EVENT_LBUTTONDBLCLK, cv::EVENT_RBUTTONDBLCLK, cv::EVENT_MBUTTONDBLCLK}, //mouse_dbclick
{cv::EVENT_MOUSEMOVE, cv::EVENT_MOUSEMOVE, cv::EVENT_MOUSEMOVE}, //mouse_move
{0, 0, 0} //mouse_wheel, to prevent exceptions in code
};
+74 -107
View File
@@ -48,26 +48,21 @@
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
/*** begin IPhone OS Stubs ***/
// When highgui functions are referred to on iPhone OS, they will fail silently.
CV_IMPL int cvInitSystem( int argc, char** argv) { return 0;}
CV_IMPL int cvStartWindowThread(){ return 0; }
CV_IMPL void cvDestroyWindow( const char* name) {}
CV_IMPL void cvDestroyAllWindows( void ) {}
CV_IMPL void cvShowImage( const char* name, const CvArr* arr) {}
CV_IMPL void cvResizeWindow( const char* name, int width, int height) {}
CV_IMPL void cvMoveWindow( const char* name, int x, int y){}
CV_IMPL int cvCreateTrackbar (const char* trackbar_name,const char* window_name,
int* val, int count, CvTrackbarCallback on_notify) {return 0;}
CV_IMPL int cvCreateTrackbar2(const char* trackbar_name,const char* window_name,
static int cocoa_InitSystem( int argc, char** argv) { return 0;}
void destroyWindowImpl( const char* name) {}
void destroyAllWindowsImpl( void ) {}
void showImageImpl( const char* name, const CvArr* arr) {}
void resizeWindowImpl( const char* name, int width, int height) {}
void moveWindowImpl( const char* name, int x, int y){}
int createTrackbar2Impl(const char* trackbar_name,const char* window_name,
int* val, int count, CvTrackbarCallback2 on_notify2, void* userdata) {return 0;}
CV_IMPL void cvSetMouseCallback( const char* name, CvMouseCallback function, void* info) {}
CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name ) {return 0;}
CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name, int pos) {}
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval) {}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval) {}
CV_IMPL void* cvGetWindowHandle( const char* name ) {return NULL;}
CV_IMPL const char* cvGetWindowName( void* window_handle ) {return NULL;}
CV_IMPL int cvNamedWindow( const char* name, int flags ) {return 0; }
CV_IMPL int cvWaitKey (int maxWait) {return 0;}
void setMouseCallbackImpl( const char* name, CvMouseCallback function, void* info) {}
int getTrackbarPosImpl( const char* trackbar_name, const char* window_name ) {return 0;}
void setTrackbarPosImpl(const char* trackbar_name, const char* window_name, int pos) {}
void setTrackbarMaxImpl(const char* trackbar_name, const char* window_name, int maxval) {}
void setTrackbarMinImpl(const char* trackbar_name, const char* window_name, int minval) {}
int namedWindowImpl( const char* name, int flags ) {return 0; }
int waitKeyImpl (int maxWait) {return 0;}
//*** end IphoneOS Stubs ***/
#else
@@ -137,16 +132,16 @@ static bool wasInitialized = false;
//cout << "icvCocoaCleanup" << endl;
if( application )
{
cvDestroyAllWindows();
destroyAllWindowsImpl();
//[application terminate:nil];
application = 0;
[pool release];
}
}*/
CV_IMPL int cvInitSystem( int , char** )
static int cocoa_InitSystem( int , char** )
{
//cout << "cvInitSystem" << endl;
//cout << "cocoa_InitSystem" << endl;
wasInitialized = true;
pool = [[NSAutoreleasePool alloc] init];
@@ -182,17 +177,11 @@ static CVWindow *cvGetWindow(const char *name) {
return retval;
}
CV_IMPL int cvStartWindowThread()
{
//cout << "cvStartWindowThread" << endl;
return 0;
}
CV_IMPL void cvDestroyWindow( const char* name)
void destroyWindowImpl( const char* name)
{
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
//cout << "cvDestroyWindow" << endl;
//cout << "destroyWindowImpl" << endl;
CVWindow *window = cvGetWindow(name);
if(window) {
[window close];
@@ -202,26 +191,26 @@ CV_IMPL void cvDestroyWindow( const char* name)
}
CV_IMPL void cvDestroyAllWindows( void )
void destroyAllWindowsImpl( void )
{
//cout << "cvDestroyAllWindows" << endl;
//cout << "destroyAllWindowsImpl" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
NSDictionary* list = [NSDictionary dictionaryWithDictionary:windows];
for(NSString *key in list) {
cvDestroyWindow([key cStringUsingEncoding:NSASCIIStringEncoding]);
destroyWindowImpl([key cStringUsingEncoding:NSASCIIStringEncoding]);
}
[localpool drain];
}
CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
void showImageImpl( const char* name, const CvArr* arr)
{
//cout << "cvShowImage" << endl;
//cout << "showImageImpl" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
CVWindow *window = cvGetWindow(name);
if(!window)
{
cvNamedWindow(name, CV_WINDOW_AUTOSIZE);
namedWindowImpl(name, cv::WINDOW_AUTOSIZE);
window = cvGetWindow(name);
}
@@ -276,10 +265,10 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
[localpool drain];
}
CV_IMPL void cvResizeWindow( const char* name, int width, int height)
void resizeWindowImpl( const char* name, int width, int height)
{
//cout << "cvResizeWindow" << endl;
//cout << "resizeWindowImpl" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
CVWindow *window = cvGetWindow(name);
if(window && ![window autosize]) {
@@ -290,9 +279,9 @@ CV_IMPL void cvResizeWindow( const char* name, int width, int height)
[localpool drain];
}
CV_IMPL void cvMoveWindow( const char* name, int x, int y)
void moveWindowImpl( const char* name, int x, int y)
{
CV_FUNCNAME("cvMoveWindow");
CV_FUNCNAME("moveWindowImpl");
__BEGIN__;
NSAutoreleasePool* localpool1 = [[NSAutoreleasePool alloc] init];
@@ -300,7 +289,7 @@ CV_IMPL void cvMoveWindow( const char* name, int x, int y)
if(name == NULL)
CV_ERROR( CV_StsNullPtr, "NULL window name" );
//cout << "cvMoveWindow"<< endl;
//cout << "moveWindowImpl"<< endl;
window = cvGetWindow(name);
if(window) {
if([window firstContent]) {
@@ -317,12 +306,12 @@ CV_IMPL void cvMoveWindow( const char* name, int x, int y)
__END__;
}
CV_IMPL int cvCreateTrackbar (const char* trackbar_name,
static int cocoa_CreateTrackbar (const char* trackbar_name,
const char* window_name,
int* val, int count,
CvTrackbarCallback on_notify)
{
CV_FUNCNAME("cvCreateTrackbar");
CV_FUNCNAME("cocoa_CreateTrackbar");
int result = 0;
@@ -336,7 +325,7 @@ CV_IMPL int cvCreateTrackbar (const char* trackbar_name,
if(window_name == NULL)
CV_ERROR( CV_StsNullPtr, "NULL window name" );
//cout << "cvCreateTrackbar" << endl ;
//cout << "cocoa_CreateTrackbar" << endl ;
window = cvGetWindow(window_name);
if(window) {
[window createSliderWithName:trackbar_name
@@ -351,15 +340,15 @@ CV_IMPL int cvCreateTrackbar (const char* trackbar_name,
}
CV_IMPL int cvCreateTrackbar2(const char* trackbar_name,
int createTrackbar2Impl(const char* trackbar_name,
const char* window_name,
int* val, int count,
CvTrackbarCallback2 on_notify2,
void* userdata)
{
//cout <<"cvCreateTrackbar2" << endl;
//cout <<"createTrackbar2Impl" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
int res = cvCreateTrackbar(trackbar_name, window_name, val, count, NULL);
int res = cocoa_CreateTrackbar(trackbar_name, window_name, val, count, NULL);
if(res) {
CVWindow *window = cvGetWindow(window_name);
if (window && [window respondsToSelector:@selector(sliders)]) {
@@ -373,15 +362,14 @@ CV_IMPL int cvCreateTrackbar2(const char* trackbar_name,
}
CV_IMPL void
cvSetMouseCallback( const char* name, CvMouseCallback function, void* info)
void setMouseCallbackImpl( const char* name, CvMouseCallback function, void* info)
{
CV_FUNCNAME("cvSetMouseCallback");
CV_FUNCNAME("setMouseCallbackImpl");
CVWindow *window = nil;
NSAutoreleasePool* localpool3 = nil;
__BEGIN__;
//cout << "cvSetMouseCallback" << endl;
//cout << "setMouseCallbackImpl" << endl;
if (localpool3 != nil) [localpool3 drain];
localpool3 = [[NSAutoreleasePool alloc] init];
@@ -399,16 +387,16 @@ cvSetMouseCallback( const char* name, CvMouseCallback function, void* info)
__END__;
}
CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name )
int getTrackbarPosImpl( const char* trackbar_name, const char* window_name )
{
CV_FUNCNAME("cvGetTrackbarPos");
CV_FUNCNAME("getTrackbarPosImpl");
CVWindow *window = nil;
int pos = -1;
NSAutoreleasePool* localpool4 = nil;
__BEGIN__;
//cout << "cvGetTrackbarPos" << endl;
//cout << "getTrackbarPosImpl" << endl;
if(trackbar_name == NULL || window_name == NULL)
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name" );
@@ -427,16 +415,16 @@ cvSetMouseCallback( const char* name, CvMouseCallback function, void* info)
return pos;
}
CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name, int pos)
void setTrackbarPosImpl(const char* trackbar_name, const char* window_name, int pos)
{
CV_FUNCNAME("cvSetTrackbarPos");
CV_FUNCNAME("setTrackbarPosImpl");
CVWindow *window = nil;
CVSlider *slider = nil;
NSAutoreleasePool* localpool5 = nil;
__BEGIN__;
//cout << "cvSetTrackbarPos" << endl;
//cout << "setTrackbarPosImpl" << endl;
if(trackbar_name == NULL || window_name == NULL)
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name" );
@@ -458,16 +446,16 @@ CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name
__END__;
}
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval)
void setTrackbarMaxImpl(const char* trackbar_name, const char* window_name, int maxval)
{
CV_FUNCNAME("cvSetTrackbarMax");
CV_FUNCNAME("setTrackbarMaxImpl");
CVWindow *window = nil;
CVSlider *slider = nil;
NSAutoreleasePool* localpool5 = nil;
__BEGIN__;
//cout << "cvSetTrackbarPos" << endl;
//cout << "setTrackbarPosImpl" << endl;
if(trackbar_name == NULL || window_name == NULL)
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name" );
@@ -490,9 +478,9 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
__END__;
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
void setTrackbarMinImpl(const char* trackbar_name, const char* window_name, int minval)
{
CV_FUNCNAME("cvSetTrackbarMin");
CV_FUNCNAME("setTrackbarMinImpl");
CVWindow *window = nil;
CVSlider *slider = nil;
@@ -521,38 +509,17 @@ CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name
__END__;
}
CV_IMPL void* cvGetWindowHandle( const char* name )
{
//cout << "cvGetWindowHandle" << endl;
return cvGetWindow(name);
}
CV_IMPL const char* cvGetWindowName( void* window_handle )
{
//cout << "cvGetWindowName" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
for(NSString *key in windows) {
if([windows valueForKey:key] == window_handle) {
[localpool drain];
return [key UTF8String];
}
}
[localpool drain];
return 0;
}
CV_IMPL int cvNamedWindow( const char* name, int flags )
int namedWindowImpl( const char* name, int flags )
{
if( !wasInitialized )
cvInitSystem(0, 0);
cocoa_InitSystem(0, 0);
//cout << "cvNamedWindow" << endl;
//cout << "namedWindowImpl" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
CVWindow *window = cvGetWindow(name);
if( window )
{
[window setAutosize:(flags == CV_WINDOW_AUTOSIZE)];
[window setAutosize:(flags == cv::WINDOW_AUTOSIZE)];
[localpool drain];
return 0;
}
@@ -590,7 +557,7 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
[window setTitle:windowName];
[window makeKeyAndOrderFront:nil];
[window setAutosize:(flags == CV_WINDOW_AUTOSIZE)];
[window setAutosize:(flags == cv::WINDOW_AUTOSIZE)];
[windows setValue:window forKey:windowName];
@@ -598,9 +565,9 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
return [windows count]-1;
}
CV_IMPL int cvWaitKey (int maxWait)
int waitKeyImpl (int maxWait)
{
//cout << "cvWaitKey" << endl;
//cout << "waitKeyImpl" << endl;
int returnCode = -1;
NSAutoreleasePool *localpool = [[NSAutoreleasePool alloc] init];
double start = [[NSDate date] timeIntervalSince1970];
@@ -721,15 +688,15 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value )
localpool = [[NSAutoreleasePool alloc] init];
fullscreenOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSFullScreenModeSetting];
if ( [[window contentView] isInFullScreenMode] && prop_value==CV_WINDOW_NORMAL )
if ( [[window contentView] isInFullScreenMode] && prop_value==cv::WINDOW_NORMAL )
{
[[window contentView] exitFullScreenModeWithOptions:fullscreenOptions];
window.status=CV_WINDOW_NORMAL;
window.status=cv::WINDOW_NORMAL;
}
else if( ![[window contentView] isInFullScreenMode] && prop_value==CV_WINDOW_FULLSCREEN )
else if( ![[window contentView] isInFullScreenMode] && prop_value==cv::WINDOW_FULLSCREEN )
{
[[window contentView] enterFullScreenMode:[NSScreen mainScreen] withOptions:fullscreenOptions];
window.status=CV_WINDOW_FULLSCREEN;
window.status=cv::WINDOW_FULLSCREEN;
}
[localpool drain];
@@ -879,20 +846,20 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
return;
int flags = 0;
if([event modifierFlags] & NSShiftKeyMask) flags |= CV_EVENT_FLAG_SHIFTKEY;
if([event modifierFlags] & NSControlKeyMask) flags |= CV_EVENT_FLAG_CTRLKEY;
if([event modifierFlags] & NSAlternateKeyMask) flags |= CV_EVENT_FLAG_ALTKEY;
if([event modifierFlags] & NSShiftKeyMask) flags |= cv::EVENT_FLAG_SHIFTKEY;
if([event modifierFlags] & NSControlKeyMask) flags |= cv::EVENT_FLAG_CTRLKEY;
if([event modifierFlags] & NSAlternateKeyMask) flags |= cv::EVENT_FLAG_ALTKEY;
if([event type] == NSLeftMouseDown) {[self cvSendMouseEvent:event type:CV_EVENT_LBUTTONDOWN flags:flags | CV_EVENT_FLAG_LBUTTON];}
if([event type] == NSLeftMouseUp) {[self cvSendMouseEvent:event type:CV_EVENT_LBUTTONUP flags:flags | CV_EVENT_FLAG_LBUTTON];}
if([event type] == NSRightMouseDown){[self cvSendMouseEvent:event type:CV_EVENT_RBUTTONDOWN flags:flags | CV_EVENT_FLAG_RBUTTON];}
if([event type] == NSRightMouseUp) {[self cvSendMouseEvent:event type:CV_EVENT_RBUTTONUP flags:flags | CV_EVENT_FLAG_RBUTTON];}
if([event type] == NSOtherMouseDown){[self cvSendMouseEvent:event type:CV_EVENT_MBUTTONDOWN flags:flags];}
if([event type] == NSOtherMouseUp) {[self cvSendMouseEvent:event type:CV_EVENT_MBUTTONUP flags:flags];}
if([event type] == NSMouseMoved) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags];}
if([event type] == NSLeftMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_LBUTTON];}
if([event type] == NSRightMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_RBUTTON];}
if([event type] == NSOtherMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_MBUTTON];}
if([event type] == NSLeftMouseDown) {[self cvSendMouseEvent:event type:cv::EVENT_LBUTTONDOWN flags:flags | cv::EVENT_FLAG_LBUTTON];}
if([event type] == NSLeftMouseUp) {[self cvSendMouseEvent:event type:cv::EVENT_LBUTTONUP flags:flags | cv::EVENT_FLAG_LBUTTON];}
if([event type] == NSRightMouseDown){[self cvSendMouseEvent:event type:cv::EVENT_RBUTTONDOWN flags:flags | cv::EVENT_FLAG_RBUTTON];}
if([event type] == NSRightMouseUp) {[self cvSendMouseEvent:event type:cv::EVENT_RBUTTONUP flags:flags | cv::EVENT_FLAG_RBUTTON];}
if([event type] == NSOtherMouseDown){[self cvSendMouseEvent:event type:cv::EVENT_MBUTTONDOWN flags:flags];}
if([event type] == NSOtherMouseUp) {[self cvSendMouseEvent:event type:cv::EVENT_MBUTTONUP flags:flags];}
if([event type] == NSMouseMoved) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags];}
if([event type] == NSLeftMouseDragged) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags | cv::EVENT_FLAG_LBUTTON];}
if([event type] == NSRightMouseDragged) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags | cv::EVENT_FLAG_RBUTTON];}
if([event type] == NSOtherMouseDragged) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags | cv::EVENT_FLAG_MBUTTON];}
}
- (void)keyDown:(NSEvent *)theEvent {
//cout << "keyDown" << endl;
+84 -132
View File
@@ -71,6 +71,7 @@
#endif
#include <opencv2/core/utils/logger.hpp>
#include "opencv2/core/utils/trace.hpp"
#include "opencv2/imgproc.hpp"
using namespace cv;
@@ -150,7 +151,8 @@ void cvImageWidgetSetImage(CvImageWidget * widget, const CvArr *arr)
CV_Assert(origin == 0);
convertToShow(cv::cvarrToMat(arr), widget->original_image);
if(widget->scaled_image){
cvResize( widget->original_image, widget->scaled_image, CV_INTER_AREA );
cv::Mat dst = cv::cvarrToMat(widget->scaled_image);
cv::resize(cv::cvarrToMat(widget->original_image), dst, dst.size(), 0, 0, cv::INTER_AREA );
}
// window does not refresh without this
@@ -268,7 +270,7 @@ cvImageWidget_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
if(image_widget->original_image != NULL) {
*minimal_width = (image_widget->flags & CV_WINDOW_AUTOSIZE) != CV_WINDOW_AUTOSIZE ?
*minimal_width = (image_widget->flags & cv::WINDOW_AUTOSIZE) != cv::WINDOW_AUTOSIZE ?
gdk_window_get_width(gtk_widget_get_window(widget)) : image_widget->original_image->cols;
}
else {
@@ -292,7 +294,7 @@ cvImageWidget_get_preferred_height (GtkWidget *widget, gint *minimal_height, gin
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
if(image_widget->original_image != NULL) {
*minimal_height = (image_widget->flags & CV_WINDOW_AUTOSIZE) != CV_WINDOW_AUTOSIZE ?
*minimal_height = (image_widget->flags & cv::WINDOW_AUTOSIZE) != cv::WINDOW_AUTOSIZE ?
gdk_window_get_height(gtk_widget_get_window(widget)) : image_widget->original_image->rows;
}
else {
@@ -316,9 +318,9 @@ cvImageWidget_size_request (GtkWidget *widget,
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
//printf("cvImageWidget_size_request ");
// the case the first time cvShowImage called or when AUTOSIZE
// the case the first time showImageImpl called or when AUTOSIZE
if( image_widget->original_image &&
((image_widget->flags & CV_WINDOW_AUTOSIZE) ||
((image_widget->flags & cv::WINDOW_AUTOSIZE) ||
(image_widget->flags & CV_WINDOW_NO_IMAGE)))
{
//printf("original ");
@@ -331,7 +333,7 @@ cvImageWidget_size_request (GtkWidget *widget,
requisition->width = image_widget->scaled_image->cols;
requisition->height = image_widget->scaled_image->rows;
}
// the case before cvShowImage called
// the case before showImageImpl called
else{
//printf("default ");
requisition->width = 320;
@@ -347,7 +349,7 @@ static void cvImageWidget_set_size(GtkWidget * widget, int max_width, int max_he
//printf("cvImageWidget_set_size %d %d\n", max_width, max_height);
// don't allow to set the size
if(image_widget->flags & CV_WINDOW_AUTOSIZE) return;
if(image_widget->flags & cv::WINDOW_AUTOSIZE) return;
if(!image_widget->original_image) return;
CvSize scaled_image_size = cvImageWidget_calc_size( image_widget->original_image->cols,
@@ -386,7 +388,7 @@ cvImageWidget_size_allocate (GtkWidget *widget,
image_widget = CV_IMAGE_WIDGET (widget);
if( (image_widget->flags & CV_WINDOW_AUTOSIZE)==0 && image_widget->original_image ){
if( (image_widget->flags & cv::WINDOW_AUTOSIZE)==0 && image_widget->original_image ){
// (re) allocated scaled image
if( image_widget->flags & CV_WINDOW_NO_IMAGE ){
cvImageWidget_set_size( widget, image_widget->original_image->cols,
@@ -395,7 +397,10 @@ cvImageWidget_size_allocate (GtkWidget *widget,
else{
cvImageWidget_set_size( widget, allocation->width, allocation->height );
}
cvResize( image_widget->original_image, image_widget->scaled_image, CV_INTER_AREA );
{
cv::Mat dst = cv::cvarrToMat(image_widget->scaled_image);
cv::resize( cv::cvarrToMat(image_widget->original_image), dst, dst.size(), 0, 0, cv::INTER_AREA );
}
}
if (gtk_widget_get_realized (widget))
@@ -403,7 +408,7 @@ cvImageWidget_size_allocate (GtkWidget *widget,
image_widget = CV_IMAGE_WIDGET (widget);
if( image_widget->original_image &&
((image_widget->flags & CV_WINDOW_AUTOSIZE) ||
((image_widget->flags & cv::WINDOW_AUTOSIZE) ||
(image_widget->flags & CV_WINDOW_NO_IMAGE)) )
{
#if defined (GTK_VERSION3)
@@ -620,7 +625,7 @@ std::vector< std::shared_ptr<CvWindow> >& getGTKWindows()
return g_windows;
}
CV_IMPL int cvInitSystem( int argc, char** argv )
static int gtk_InitSystem( int argc, char** argv )
{
static int wasInitialized = 0;
static bool hasError = false;
@@ -654,9 +659,10 @@ CV_IMPL int cvInitSystem( int argc, char** argv )
return 0;
}
CV_IMPL int cvStartWindowThread(){
int cv::startWindowThread(){
CV_TRACE_FUNCTION();
#ifdef HAVE_GTHREAD
cvInitSystem(0,NULL);
gtk_InitSystem(0,NULL);
if (!thread_started)
{
#if !GLIB_CHECK_VERSION(2, 32, 0) // https://github.com/GNOME/glib/blame/b4d58a7105bb9d75907233968bb534b38f9a6e43/glib/deprecated/gthread.h#L274
@@ -733,19 +739,6 @@ std::shared_ptr<CvWindow> icvFindWindowByName(const char* name)
return icvFindWindowByName(std::string(name));
}
static CvWindow* icvWindowByWidget( GtkWidget* widget )
{
auto& g_windows = getGTKWindows();
for (size_t i = 0; i < g_windows.size(); ++i)
{
CvWindow* window = g_windows[i].get();
if (window->widget == widget || window->frame == widget || window->paned == widget)
return window;
}
return NULL;
}
static Rect getImageRect_(const std::shared_ptr<CvWindow>& window);
CvRect cvGetWindowRect_GTK(const char* name)
@@ -824,7 +817,7 @@ void cvSetModeWindow_GTK( const char* name, double prop_value)//Yannick Verdie
static bool setModeWindow_(const std::shared_ptr<CvWindow>& window, int mode)
{
if (window->flags & CV_WINDOW_AUTOSIZE) //if the flag CV_WINDOW_AUTOSIZE is set
if (window->flags & cv::WINDOW_AUTOSIZE) //if the flag cv::WINDOW_AUTOSIZE is set
return false;
//so easy to do fullscreen here, Linux rocks !
@@ -832,17 +825,17 @@ static bool setModeWindow_(const std::shared_ptr<CvWindow>& window, int mode)
if (window->status == mode)
return true;
if (window->status==CV_WINDOW_FULLSCREEN && mode==CV_WINDOW_NORMAL)
if (window->status==cv::WINDOW_FULLSCREEN && mode==cv::WINDOW_NORMAL)
{
gtk_window_unfullscreen(GTK_WINDOW(window->frame));
window->status=CV_WINDOW_NORMAL;
window->status=cv::WINDOW_NORMAL;
return true;
}
if (window->status==CV_WINDOW_NORMAL && mode==CV_WINDOW_FULLSCREEN)
if (window->status==cv::WINDOW_NORMAL && mode==cv::WINDOW_FULLSCREEN)
{
gtk_window_fullscreen(GTK_WINDOW(window->frame));
window->status=CV_WINDOW_FULLSCREEN;
window->status=cv::WINDOW_FULLSCREEN;
return true;
}
@@ -875,7 +868,7 @@ double cvGetPropWindowAutoSize_GTK(const char* name)
if (!window)
return -1; // keep silence here
double result = window->flags & CV_WINDOW_AUTOSIZE;
double result = window->flags & cv::WINDOW_AUTOSIZE;
return result;
}
@@ -1098,9 +1091,10 @@ static gboolean cvImageWidget_expose(GtkWidget* widget, GdkEventExpose* event, g
#endif //GTK_VERSION3
static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags);
CV_IMPL int cvNamedWindow( const char* name, int flags )
int namedWindowImpl( const char* name, int flags )
{
cvInitSystem(name ? 1 : 0,(char**)&name);
gtk_InitSystem(name ? 1 : 0,(char**)&name);
CV_Assert(name && "NULL name string");
CV_LOCK_MUTEX();
@@ -1116,12 +1110,12 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags)
{
cvInitSystem(0, NULL);
gtk_InitSystem(0, NULL);
auto window_ptr = std::make_shared<CvWindow>(name);
CvWindow* window = window_ptr.get();
window->flags = flags;
window->status = CV_WINDOW_NORMAL;//YV
window->status = cv::WINDOW_NORMAL;//YV
window->frame = gtk_window_new( GTK_WINDOW_TOPLEVEL );
@@ -1133,10 +1127,10 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
gtk_widget_show( window->paned );
#ifndef HAVE_OPENGL
if (flags & CV_WINDOW_OPENGL)
if (flags & cv::WINDOW_OPENGL)
CV_Error( CV_OpenGlNotSupported, "Library was built without OpenGL support" );
#else
if (flags & CV_WINDOW_OPENGL)
if (flags & cv::WINDOW_OPENGL)
createGlContext(window);
window->glDrawCallback = 0;
@@ -1181,7 +1175,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
getGTKWindows().push_back(window_ptr);
}
bool b_nautosize = ((flags & CV_WINDOW_AUTOSIZE) == 0);
bool b_nautosize = ((flags & cv::WINDOW_AUTOSIZE) == 0);
gtk_window_set_resizable( GTK_WINDOW(window->frame), b_nautosize );
// allow window to be resized
@@ -1195,7 +1189,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
#ifdef HAVE_OPENGL
if (window->useGl)
cvSetOpenGlContext(name.c_str());
setOpenGLContextImpl(name.c_str());
#endif
return window_ptr;
@@ -1204,7 +1198,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
#ifdef HAVE_OPENGL
CV_IMPL void cvSetOpenGlContext(const char* name)
void setOpenGLContextImpl(const char* name)
{
GdkGLContext* glcontext;
GdkGLDrawable* gldrawable;
@@ -1227,7 +1221,7 @@ CV_IMPL void cvSetOpenGlContext(const char* name)
CV_Error( CV_OpenGlApiCallError, "Can't Activate The GL Rendering Context" );
}
CV_IMPL void cvUpdateWindow(const char* name)
void updateWindowImpl(const char* name)
{
CV_Assert(name && "NULL name string");
@@ -1241,7 +1235,7 @@ CV_IMPL void cvUpdateWindow(const char* name)
gtk_widget_queue_draw( GTK_WIDGET(window->widget) );
}
CV_IMPL void cvSetOpenGlDrawCallback(const char* name, CvOpenGlDrawCallback callback, void* userdata)
void setOpenGLDrawCallbackImpl(const char* name, CvOpenGlDrawCallback callback, void* userdata)
{
CV_Assert(name && "NULL name string");
@@ -1283,7 +1277,7 @@ static void checkLastWindow()
#ifdef HAVE_GTHREAD
if( thread_started )
{
// send key press signal to jump out of any waiting cvWaitKey's
// send key press signal to jump out of any waiting waitKeyImpl's
g_cond_broadcast( cond_have_key );
}
else
@@ -1324,7 +1318,7 @@ void icvDeleteWindow_( CvWindow* window )
checkLastWindow();
}
CV_IMPL void cvDestroyWindow( const char* name )
void destroyWindowImpl( const char* name )
{
CV_Assert(name && "NULL name string");
@@ -1347,8 +1341,7 @@ CV_IMPL void cvDestroyWindow( const char* name )
}
CV_IMPL void
cvDestroyAllWindows( void )
void destroyAllWindowsImpl( void )
{
CV_LOCK_MUTEX();
@@ -1368,8 +1361,7 @@ cvDestroyAllWindows( void )
// return window_size;
// }
CV_IMPL void
cvShowImage( const char* name, const CvArr* arr )
void showImageImpl( const char* name, const CvArr* arr )
{
CV_Assert(name && "NULL name string");
@@ -1378,7 +1370,7 @@ cvShowImage( const char* name, const CvArr* arr )
auto window = icvFindWindowByName(name);
if(!window)
{
cvNamedWindow(name, 1);
namedWindowImpl(name, 1);
window = icvFindWindowByName(name);
}
CV_Assert(window);
@@ -1399,7 +1391,7 @@ cvShowImage( const char* name, const CvArr* arr )
}
static void resizeWindow_(const std::shared_ptr<CvWindow>& window, int width, int height);
CV_IMPL void cvResizeWindow(const char* name, int width, int height )
void resizeWindowImpl(const char* name, int width, int height )
{
CV_Assert(name && "NULL name string");
@@ -1417,7 +1409,7 @@ void resizeWindow_(const std::shared_ptr<CvWindow>& window, int width, int heigh
{
CV_Assert(window);
CvImageWidget* image_widget = CV_IMAGE_WIDGET( window->widget );
//if(image_widget->flags & CV_WINDOW_AUTOSIZE)
//if(image_widget->flags & cv::WINDOW_AUTOSIZE)
//EXIT;
gtk_window_set_resizable( GTK_WINDOW(window->frame), 1 );
@@ -1429,7 +1421,7 @@ void resizeWindow_(const std::shared_ptr<CvWindow>& window, int width, int heigh
}
CV_IMPL void cvMoveWindow( const char* name, int x, int y )
void moveWindowImpl( const char* name, int x, int y )
{
CV_Assert(name && "NULL name string");
@@ -1528,16 +1520,7 @@ icvCreateTrackbar( const char* trackbar_name, const char* window_name,
return 1;
}
CV_IMPL int
cvCreateTrackbar( const char* trackbar_name, const char* window_name,
int* val, int count, CvTrackbarCallback on_notify )
{
return icvCreateTrackbar(trackbar_name, window_name, val, count,
on_notify, 0, 0);
}
CV_IMPL int
cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
int createTrackbar2Impl( const char* trackbar_name, const char* window_name,
int* val, int count, CvTrackbarCallback2 on_notify2,
void* userdata )
{
@@ -1592,8 +1575,7 @@ std::shared_ptr<CvTrackbar> createTrackbar_(
}
CV_IMPL void
cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* param )
void setMouseCallbackImpl( const char* window_name, CvMouseCallback on_mouse, void* param )
{
CV_Assert(window_name && "NULL window name");
@@ -1608,7 +1590,7 @@ cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* par
}
CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name )
int getTrackbarPosImpl( const char* trackbar_name, const char* window_name )
{
CV_Assert(window_name && "NULL window name");
CV_Assert(trackbar_name && "NULL trackbar name");
@@ -1627,7 +1609,7 @@ CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name
}
static void setTrackbarPos_(const std::shared_ptr<CvTrackbar>& trackbar, int pos);
CV_IMPL void cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos )
void setTrackbarPosImpl( const char* trackbar_name, const char* window_name, int pos )
{
CV_Assert(window_name && "NULL window name");
CV_Assert(trackbar_name && "NULL trackbar name");
@@ -1659,7 +1641,7 @@ static void setTrackbarPos_(const std::shared_ptr<CvTrackbar>& trackbar, int pos
}
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval)
void setTrackbarMaxImpl(const char* trackbar_name, const char* window_name, int maxval)
{
CV_Assert(window_name && "NULL window name");
CV_Assert(trackbar_name && "NULL trackbar name");
@@ -1680,7 +1662,7 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
void setTrackbarMinImpl(const char* trackbar_name, const char* window_name, int minval)
{
CV_Assert(window_name && "NULL window name");
CV_Assert(trackbar_name && "NULL trackbar name");
@@ -1700,34 +1682,6 @@ CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name
gtk_range_set_range(GTK_RANGE(trackbar->widget), trackbar->minval, trackbar->maxval);
}
CV_IMPL void* cvGetWindowHandle( const char* window_name )
{
CV_Assert(window_name && "NULL window name");
CV_LOCK_MUTEX();
const auto window = icvFindWindowByName(window_name);
if(!window)
return NULL;
return (void*)window->widget;
}
CV_IMPL const char* cvGetWindowName( void* window_handle )
{
CV_Assert(window_handle && "NULL window handle");
CV_LOCK_MUTEX();
CvWindow* window = icvWindowByWidget( (GtkWidget*)window_handle );
if (window)
return window->name.c_str();
return ""; // FIXME: NULL?
}
static GtkFileFilter* icvMakeGtkFilter(const char* name, const char* patterns, GtkFileFilter* images)
{
GtkFileFilter* filter = gtk_file_filter_new();
@@ -1930,7 +1884,7 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
{
GdkEventMotion* event_motion = (GdkEventMotion*)event;
cv_event = CV_EVENT_MOUSEMOVE;
cv_event = cv::EVENT_MOUSEMOVE;
pt32f.x = cvFloor(event_motion->x);
pt32f.y = cvFloor(event_motion->y);
state = event_motion->state;
@@ -1946,21 +1900,21 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
if( event_button->type == GDK_BUTTON_PRESS )
{
cv_event = event_button->button == 1 ? CV_EVENT_LBUTTONDOWN :
event_button->button == 2 ? CV_EVENT_MBUTTONDOWN :
event_button->button == 3 ? CV_EVENT_RBUTTONDOWN : 0;
cv_event = event_button->button == 1 ? cv::EVENT_LBUTTONDOWN :
event_button->button == 2 ? cv::EVENT_MBUTTONDOWN :
event_button->button == 3 ? cv::EVENT_RBUTTONDOWN : 0;
}
else if( event_button->type == GDK_BUTTON_RELEASE )
{
cv_event = event_button->button == 1 ? CV_EVENT_LBUTTONUP :
event_button->button == 2 ? CV_EVENT_MBUTTONUP :
event_button->button == 3 ? CV_EVENT_RBUTTONUP : 0;
cv_event = event_button->button == 1 ? cv::EVENT_LBUTTONUP :
event_button->button == 2 ? cv::EVENT_MBUTTONUP :
event_button->button == 3 ? cv::EVENT_RBUTTONUP : 0;
}
else if( event_button->type == GDK_2BUTTON_PRESS )
{
cv_event = event_button->button == 1 ? CV_EVENT_LBUTTONDBLCLK :
event_button->button == 2 ? CV_EVENT_MBUTTONDBLCLK :
event_button->button == 3 ? CV_EVENT_RBUTTONDBLCLK : 0;
cv_event = event_button->button == 1 ? cv::EVENT_LBUTTONDBLCLK :
event_button->button == 2 ? cv::EVENT_MBUTTONDBLCLK :
event_button->button == 3 ? cv::EVENT_RBUTTONDBLCLK : 0;
}
state = event_button->state;
}
@@ -1973,9 +1927,9 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
#if defined(GTK_VERSION3_4)
// NOTE: in current implementation doesn't possible to put into callback function delta_x and delta_y separately
double delta = (event->scroll.delta_x + event->scroll.delta_y);
cv_event = (event->scroll.delta_x==0) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL;
cv_event = (event->scroll.delta_x==0) ? cv::EVENT_MOUSEWHEEL : cv::EVENT_MOUSEHWHEEL;
#else
cv_event = CV_EVENT_MOUSEWHEEL;
cv_event = cv::EVENT_MOUSEWHEEL;
#endif //GTK_VERSION3_4
state = event->scroll.state;
@@ -1985,11 +1939,11 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
case GDK_SCROLL_SMOOTH: flags |= (((int)delta << 16));
break;
#endif //GTK_VERSION3_4
case GDK_SCROLL_LEFT: cv_event = CV_EVENT_MOUSEHWHEEL;
case GDK_SCROLL_LEFT: cv_event = cv::EVENT_MOUSEHWHEEL;
/* FALLTHRU */
case GDK_SCROLL_UP: flags |= ~0xffff;
break;
case GDK_SCROLL_RIGHT: cv_event = CV_EVENT_MOUSEHWHEEL;
case GDK_SCROLL_RIGHT: cv_event = cv::EVENT_MOUSEHWHEEL;
/* FALLTHRU */
case GDK_SCROLL_DOWN: flags |= (((int)1 << 16));
break;
@@ -2000,7 +1954,7 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
if( cv_event >= 0 )
{
// scale point if image is scaled
if( (image_widget->flags & CV_WINDOW_AUTOSIZE)==0 &&
if( (image_widget->flags & cv::WINDOW_AUTOSIZE)==0 &&
image_widget->original_image &&
image_widget->scaled_image )
{
@@ -2029,16 +1983,16 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
{
// handle non-keyboard (mouse) modifiers first
flags |=
BIT_MAP(state, GDK_BUTTON1_MASK, CV_EVENT_FLAG_LBUTTON) |
BIT_MAP(state, GDK_BUTTON2_MASK, CV_EVENT_FLAG_MBUTTON) |
BIT_MAP(state, GDK_BUTTON3_MASK, CV_EVENT_FLAG_RBUTTON);
BIT_MAP(state, GDK_BUTTON1_MASK, cv::EVENT_FLAG_LBUTTON) |
BIT_MAP(state, GDK_BUTTON2_MASK, cv::EVENT_FLAG_MBUTTON) |
BIT_MAP(state, GDK_BUTTON3_MASK, cv::EVENT_FLAG_RBUTTON);
// keyboard modifiers
state &= gtk_accelerator_get_default_mod_mask();
flags |=
BIT_MAP(state, GDK_SHIFT_MASK, CV_EVENT_FLAG_SHIFTKEY) |
BIT_MAP(state, GDK_CONTROL_MASK, CV_EVENT_FLAG_CTRLKEY) |
BIT_MAP(state, GDK_MOD1_MASK, CV_EVENT_FLAG_ALTKEY) |
BIT_MAP(state, GDK_MOD2_MASK, CV_EVENT_FLAG_ALTKEY);
BIT_MAP(state, GDK_SHIFT_MASK, cv::EVENT_FLAG_SHIFTKEY) |
BIT_MAP(state, GDK_CONTROL_MASK, cv::EVENT_FLAG_CTRLKEY) |
BIT_MAP(state, GDK_MOD1_MASK, cv::EVENT_FLAG_ALTKEY) |
BIT_MAP(state, GDK_MOD2_MASK, cv::EVENT_FLAG_ALTKEY);
window->on_mouse( cv_event, pt.x, pt.y, flags, window->on_mouse_param );
}
}
@@ -2054,7 +2008,7 @@ static gboolean icvAlarm( gpointer user_data )
}
CV_IMPL int cvWaitKey( int delay )
int waitKeyImpl( int delay )
{
#ifdef HAVE_GTHREAD
if (thread_started && g_thread_self() != window_thread)
@@ -2166,20 +2120,19 @@ public:
{
auto window = window_.lock();
CV_Assert(window);
// see cvGetWindowProperty
switch (prop)
{
case CV_WND_PROP_FULLSCREEN:
case cv::WND_PROP_FULLSCREEN:
return (double)window->status;
case CV_WND_PROP_AUTOSIZE:
return (window->flags & CV_WINDOW_AUTOSIZE) ? 1.0 : 0.0;
case cv::WND_PROP_AUTOSIZE:
return (window->flags & cv::WINDOW_AUTOSIZE) ? 1.0 : 0.0;
case CV_WND_PROP_ASPECTRATIO:
case cv::WND_PROP_ASPECT_RATIO:
return getRatioWindow_(window);
#ifdef HAVE_OPENGL
case CV_WND_PROP_OPENGL:
case cv::WND_PROP_OPENGL:
return window->useGl ? 1.0 : 0.0;
#endif
@@ -2193,11 +2146,10 @@ public:
{
auto window = window_.lock();
CV_Assert(window);
// see cvSetWindowProperty
switch (prop)
{
case CV_WND_PROP_FULLSCREEN:
if (value != CV_WINDOW_NORMAL && value != CV_WINDOW_FULLSCREEN) // bad arg
case cv::WND_PROP_FULLSCREEN:
if (value != cv::WINDOW_NORMAL && value != cv::WINDOW_FULLSCREEN) // bad arg
break;
setModeWindow_(window, value);
return true;
@@ -2352,7 +2304,7 @@ public:
void destroyAllWindows() CV_OVERRIDE
{
cvDestroyAllWindows();
destroyAllWindowsImpl();
}
// namedWindow
@@ -2369,11 +2321,11 @@ public:
int waitKeyEx(int delay) CV_OVERRIDE
{
return cvWaitKey(delay);
return waitKeyImpl(delay);
}
int pollKey() CV_OVERRIDE
{
return cvWaitKey(1); // TODO
return waitKeyImpl(1); // TODO
}
}; // GTKBackendUI
+73 -140
View File
@@ -309,12 +309,12 @@ static const char* const mainHighGUIclassName = "Main HighGUI class";
static void icvCleanupHighgui()
{
cvDestroyAllWindows();
destroyAllWindowsImpl();
UnregisterClass(highGUIclassName, hg_hinstance);
UnregisterClass(mainHighGUIclassName, hg_hinstance);
}
CV_IMPL int cvInitSystem(int, char**)
static int win32_InitSystem(int, char**)
{
static int wasInitialized = 0;
@@ -355,11 +355,6 @@ CV_IMPL int cvInitSystem(int, char**)
return 0;
}
CV_IMPL int cvStartWindowThread(){
return 0;
}
static std::shared_ptr<CvWindow> icvWindowByHWND(HWND hwnd)
{
AutoLock lock(getWindowMutex());
@@ -587,7 +582,7 @@ void cvSetModeWindow_W32(const char* name, double prop_value)//Yannick Verdie
static bool setModeWindow_(CvWindow& window, int mode)
{
if (window.flags & CV_WINDOW_AUTOSIZE)//if the flag CV_WINDOW_AUTOSIZE is set
if (window.flags & cv::WINDOW_AUTOSIZE)//if the flag cv::WINDOW_AUTOSIZE is set
return false;
if (window.status == mode)
@@ -597,18 +592,18 @@ static bool setModeWindow_(CvWindow& window, int mode)
DWORD dwStyle = (DWORD)GetWindowLongPtr(window.frame, GWL_STYLE);
CvRect position;
if (window.status == CV_WINDOW_FULLSCREEN && mode == CV_WINDOW_NORMAL)
if (window.status == cv::WINDOW_FULLSCREEN && mode == cv::WINDOW_NORMAL)
{
icvLoadWindowPos(window.name.c_str(), position);
SetWindowLongPtr(window.frame, GWL_STYLE, dwStyle | WS_CAPTION | WS_THICKFRAME);
SetWindowPos(window.frame, HWND_TOP, position.x, position.y , position.width,position.height, SWP_NOZORDER | SWP_FRAMECHANGED);
window.status=CV_WINDOW_NORMAL;
window.status=cv::WINDOW_NORMAL;
return true;
}
if (window.status == CV_WINDOW_NORMAL && mode == CV_WINDOW_FULLSCREEN)
if (window.status == cv::WINDOW_NORMAL && mode == cv::WINDOW_FULLSCREEN)
{
//save dimension
RECT rect = { 0 };
@@ -630,7 +625,7 @@ static bool setModeWindow_(CvWindow& window, int mode)
SetWindowLongPtr(window.frame, GWL_STYLE, dwStyle & ~WS_CAPTION & ~WS_THICKFRAME);
SetWindowPos(window.frame, HWND_TOP, position.x, position.y , position.width,position.height, SWP_NOZORDER | SWP_FRAMECHANGED);
window.status=CV_WINDOW_FULLSCREEN;
window.status=cv::WINDOW_FULLSCREEN;
return true;
}
@@ -836,7 +831,7 @@ double cvGetPropWindowAutoSize_W32(const char* name)
if (!window)
CV_Error_(Error::StsNullPtr, ("NULL window: '%s'", name));
result = window->flags & CV_WINDOW_AUTOSIZE;
result = window->flags & cv::WINDOW_AUTOSIZE;
return result;
}
@@ -1018,9 +1013,9 @@ namespace
static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags);
CV_IMPL int cvNamedWindow(const char* name, int flags)
int namedWindowImpl(const char* name, int flags)
{
CV_FUNCNAME("cvNamedWindow");
CV_FUNCNAME("namedWindowImpl");
AutoLock lock(getWindowMutex());
@@ -1042,7 +1037,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
{
AutoLock lock(getWindowMutex());
cvInitSystem(0,0);
win32_InitSystem(0,0);
HWND hWnd, mainhWnd;
DWORD defStyle = WS_VISIBLE | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
@@ -1055,11 +1050,11 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
CvRect rect;
icvLoadWindowPos(name.c_str(), rect);
if (!(flags & CV_WINDOW_AUTOSIZE))//YV add border in order to resize the window
if (!(flags & cv::WINDOW_AUTOSIZE))//YV add border in order to resize the window
defStyle |= WS_SIZEBOX;
#ifdef HAVE_OPENGL
if (flags & CV_WINDOW_OPENGL)
if (flags & cv::WINDOW_OPENGL)
defStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
#endif
@@ -1076,14 +1071,14 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
CV_Error(Error::StsError, "Frame window can not be created");
#ifndef HAVE_OPENGL
if (flags & CV_WINDOW_OPENGL)
if (flags & cv::WINDOW_OPENGL)
CV_Error(Error::OpenGlNotSupported, "Library was built without OpenGL support");
#else
useGl = false;
hGLDC = 0;
hGLRC = 0;
if (flags & CV_WINDOW_OPENGL)
if (flags & cv::WINDOW_OPENGL)
createGlContext(hWnd, hGLDC, hGLRC, useGl);
#endif
@@ -1117,7 +1112,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
#endif
window->last_key = 0;
window->status = CV_WINDOW_NORMAL;//YV
window->status = cv::WINDOW_NORMAL;//YV
window->on_mouse = 0;
window->on_mouse_param = 0;
@@ -1136,9 +1131,9 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
#ifdef HAVE_OPENGL
CV_IMPL void cvSetOpenGlContext(const char* name)
void setOpenGLContextImpl(const char* name)
{
CV_FUNCNAME("cvSetOpenGlContext");
CV_FUNCNAME("setOpenGLContextImpl");
AutoLock lock(getWindowMutex());
@@ -1156,9 +1151,9 @@ CV_IMPL void cvSetOpenGlContext(const char* name)
CV_Error(Error::OpenGlApiCallError, "Can't Activate The GL Rendering Context");
}
CV_IMPL void cvUpdateWindow(const char* name)
void updateWindowImpl(const char* name)
{
CV_FUNCNAME("cvUpdateWindow");
CV_FUNCNAME("updateWindowImpl");
AutoLock lock(getWindowMutex());
@@ -1172,7 +1167,7 @@ CV_IMPL void cvUpdateWindow(const char* name)
InvalidateRect(window->hwnd, 0, 0);
}
CV_IMPL void cvSetOpenGlDrawCallback(const char* name, CvOpenGlDrawCallback callback, void* userdata)
void setOpenGLDrawCallbackImpl(const char* name, CvOpenGlDrawCallback callback, void* userdata)
{
CV_FUNCNAME("cvCreateOpenGLCallback");
@@ -1247,9 +1242,9 @@ static void icvRemoveWindow(const std::shared_ptr<CvWindow>& window_)
}
CV_IMPL void cvDestroyWindow(const char* name)
void destroyWindowImpl(const char* name)
{
CV_FUNCNAME("cvDestroyWindow");
CV_FUNCNAME("destroyWindowImpl");
AutoLock lock(getWindowMutex());
@@ -1338,7 +1333,7 @@ static void icvUpdateWindowPos(CvWindow& window)
{
RECT rect = { 0 };
if ((window.flags & CV_WINDOW_AUTOSIZE) && window.image)
if ((window.flags & cv::WINDOW_AUTOSIZE) && window.image)
{
int i;
SIZE size = {0,0};
@@ -1368,10 +1363,9 @@ static void icvUpdateWindowPos(CvWindow& window)
static void showImage_(CvWindow& window, const Mat& image);
CV_IMPL void
cvShowImage(const char* name, const CvArr* arr)
void showImageImpl(const char* name, const CvArr* arr)
{
CV_FUNCNAME("cvShowImage");
CV_FUNCNAME("showImageImpl");
if (!name)
CV_Error(Error::StsNullPtr, "NULL name");
@@ -1383,7 +1377,7 @@ cvShowImage(const char* name, const CvArr* arr)
window = icvFindWindowByName(name);
if (!window)
{
cvNamedWindow(name, CV_WINDOW_AUTOSIZE);
namedWindowImpl(name, cv::WINDOW_AUTOSIZE);
window = icvFindWindowByName(name);
}
}
@@ -1459,9 +1453,9 @@ static void showImage_(CvWindow& window, const Mat& image)
static void resizeWindow_(CvWindow& window, const Size& size);
CV_IMPL void cvResizeWindow(const char* name, int width, int height)
void resizeWindowImpl(const char* name, int width, int height)
{
CV_FUNCNAME("cvResizeWindow");
CV_FUNCNAME("resizeWindowImpl");
AutoLock lock(getWindowMutex());
@@ -1501,9 +1495,9 @@ static void resizeWindow_(CvWindow& window, const Size& size)
static void moveWindow_(CvWindow& window, const Point& pt);
CV_IMPL void cvMoveWindow(const char* name, int x, int y)
void moveWindowImpl(const char* name, int x, int y)
{
CV_FUNCNAME("cvMoveWindow");
CV_FUNCNAME("moveWindowImpl");
AutoLock lock(getWindowMutex());
@@ -1548,7 +1542,7 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case WM_GETMINMAXINFO:
if (!(window.flags & CV_WINDOW_AUTOSIZE))
if (!(window.flags & cv::WINDOW_AUTOSIZE))
{
MINMAXINFO* minmax = (MINMAXINFO*)lParam;
RECT rect = { 0 };
@@ -1579,7 +1573,7 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
MoveWindow(window.toolbar.toolbar, 0, 0, pos->cx, rect.bottom - rect.top, TRUE);
}
if (!(window.flags & CV_WINDOW_AUTOSIZE))
if (!(window.flags & cv::WINDOW_AUTOSIZE))
icvUpdateWindowPos(window);
break;
@@ -1624,13 +1618,13 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_MOUSEHWHEEL:
if (window.on_mouse)
{
int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
(wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
(wParam & MK_MBUTTON ? CV_EVENT_FLAG_MBUTTON : 0)|
(wParam & MK_CONTROL ? CV_EVENT_FLAG_CTRLKEY : 0)|
(wParam & MK_SHIFT ? CV_EVENT_FLAG_SHIFTKEY : 0)|
(GetKeyState(VK_MENU) < 0 ? CV_EVENT_FLAG_ALTKEY : 0);
int event = (uMsg == WM_MOUSEWHEEL ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
int flags = (wParam & MK_LBUTTON ? cv::EVENT_FLAG_LBUTTON : 0)|
(wParam & MK_RBUTTON ? cv::EVENT_FLAG_RBUTTON : 0)|
(wParam & MK_MBUTTON ? cv::EVENT_FLAG_MBUTTON : 0)|
(wParam & MK_CONTROL ? cv::EVENT_FLAG_CTRLKEY : 0)|
(wParam & MK_SHIFT ? cv::EVENT_FLAG_SHIFTKEY : 0)|
(GetKeyState(VK_MENU) < 0 ? cv::EVENT_FLAG_ALTKEY : 0);
int event = (uMsg == WM_MOUSEWHEEL ? cv::EVENT_MOUSEWHEEL : cv::EVENT_MOUSEHWHEEL);
// Set the wheel delta of mouse wheel to be in the upper word of 'event'
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
@@ -1822,22 +1816,22 @@ static LRESULT CALLBACK HighGUIProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
{
POINT pt;
int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
(wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
(wParam & MK_MBUTTON ? CV_EVENT_FLAG_MBUTTON : 0)|
(wParam & MK_CONTROL ? CV_EVENT_FLAG_CTRLKEY : 0)|
(wParam & MK_SHIFT ? CV_EVENT_FLAG_SHIFTKEY : 0)|
(GetKeyState(VK_MENU) < 0 ? CV_EVENT_FLAG_ALTKEY : 0);
int event = uMsg == WM_LBUTTONDOWN ? CV_EVENT_LBUTTONDOWN :
uMsg == WM_RBUTTONDOWN ? CV_EVENT_RBUTTONDOWN :
uMsg == WM_MBUTTONDOWN ? CV_EVENT_MBUTTONDOWN :
uMsg == WM_LBUTTONUP ? CV_EVENT_LBUTTONUP :
uMsg == WM_RBUTTONUP ? CV_EVENT_RBUTTONUP :
uMsg == WM_MBUTTONUP ? CV_EVENT_MBUTTONUP :
uMsg == WM_LBUTTONDBLCLK ? CV_EVENT_LBUTTONDBLCLK :
uMsg == WM_RBUTTONDBLCLK ? CV_EVENT_RBUTTONDBLCLK :
uMsg == WM_MBUTTONDBLCLK ? CV_EVENT_MBUTTONDBLCLK :
CV_EVENT_MOUSEMOVE;
int flags = (wParam & MK_LBUTTON ? cv::EVENT_FLAG_LBUTTON : 0)|
(wParam & MK_RBUTTON ? cv::EVENT_FLAG_RBUTTON : 0)|
(wParam & MK_MBUTTON ? cv::EVENT_FLAG_MBUTTON : 0)|
(wParam & MK_CONTROL ? cv::EVENT_FLAG_CTRLKEY : 0)|
(wParam & MK_SHIFT ? cv::EVENT_FLAG_SHIFTKEY : 0)|
(GetKeyState(VK_MENU) < 0 ? cv::EVENT_FLAG_ALTKEY : 0);
int event = uMsg == WM_LBUTTONDOWN ? cv::EVENT_LBUTTONDOWN :
uMsg == WM_RBUTTONDOWN ? cv::EVENT_RBUTTONDOWN :
uMsg == WM_MBUTTONDOWN ? cv::EVENT_MBUTTONDOWN :
uMsg == WM_LBUTTONUP ? cv::EVENT_LBUTTONUP :
uMsg == WM_RBUTTONUP ? cv::EVENT_RBUTTONUP :
uMsg == WM_MBUTTONUP ? cv::EVENT_MBUTTONUP :
uMsg == WM_LBUTTONDBLCLK ? cv::EVENT_LBUTTONDBLCLK :
uMsg == WM_RBUTTONDBLCLK ? cv::EVENT_RBUTTONDBLCLK :
uMsg == WM_MBUTTONDBLCLK ? cv::EVENT_MBUTTONDBLCLK :
cv::EVENT_MOUSEMOVE;
if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN || uMsg == WM_MBUTTONDOWN)
SetCapture(hwnd);
if (uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONUP)
@@ -1846,7 +1840,7 @@ static LRESULT CALLBACK HighGUIProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
if (window.flags & CV_WINDOW_AUTOSIZE)
if (window.flags & cv::WINDOW_AUTOSIZE)
{
// As user can't change window size, do not scale window coordinates. Underlying windowing system
// may prevent full window from being displayed and in this case coordinates should not be scaled.
@@ -1908,7 +1902,7 @@ static LRESULT CALLBACK HighGUIProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
SetDIBColorTable(window.dc, 0, 255, table);
}
if (window.flags & CV_WINDOW_AUTOSIZE)
if (window.flags & cv::WINDOW_AUTOSIZE)
{
BitBlt(hdc, 0, 0, size.cx, size.cy, window.dc, 0, 0, SRCCOPY);
}
@@ -2097,8 +2091,7 @@ static LRESULT CALLBACK HGToolbarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
}
CV_IMPL void
cvDestroyAllWindows(void)
void destroyAllWindowsImpl(void)
{
std::vector< std::shared_ptr<CvWindow> > g_windows;
{
@@ -2296,8 +2289,7 @@ int pollKey_W32()
}
}
CV_IMPL int
cvWaitKey(int delay)
int waitKeyImpl(int delay)
{
int64 time0 = cv::getTickCount();
int64 timeEnd = time0 + (int64)(delay * 0.001f * cv::getTickFrequency());
@@ -2537,16 +2529,7 @@ std::shared_ptr<CvTrackbar> createTrackbar_(CvWindow& window, const std::string&
return trackbar;
}
CV_IMPL int
cvCreateTrackbar(const char* trackbar_name, const char* window_name,
int* val, int count, CvTrackbarCallback on_notify)
{
return icvCreateTrackbar(trackbar_name, window_name, val, count,
on_notify, 0, 0);
}
CV_IMPL int
cvCreateTrackbar2(const char* trackbar_name, const char* window_name,
int createTrackbar2Impl(const char* trackbar_name, const char* window_name,
int* val, int count, CvTrackbarCallback2 on_notify2,
void* userdata)
{
@@ -2554,10 +2537,9 @@ cvCreateTrackbar2(const char* trackbar_name, const char* window_name,
0, on_notify2, userdata);
}
CV_IMPL void
cvSetMouseCallback(const char* name, CvMouseCallback on_mouse, void* param)
void setMouseCallbackImpl(const char* name, CvMouseCallback on_mouse, void* param)
{
CV_FUNCNAME("cvSetMouseCallback");
CV_FUNCNAME("setMouseCallbackImpl");
if (!name)
CV_Error(Error::StsNullPtr, "NULL window name");
@@ -2573,9 +2555,9 @@ cvSetMouseCallback(const char* name, CvMouseCallback on_mouse, void* param)
}
CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
int getTrackbarPosImpl(const char* trackbar_name, const char* window_name)
{
CV_FUNCNAME("cvGetTrackbarPos");
CV_FUNCNAME("getTrackbarPosImpl");
AutoLock lock(getWindowMutex());
@@ -2594,9 +2576,9 @@ CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
}
CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name, int pos)
void setTrackbarPosImpl(const char* trackbar_name, const char* window_name, int pos)
{
CV_FUNCNAME("cvSetTrackbarPos");
CV_FUNCNAME("setTrackbarPosImpl");
AutoLock lock(getWindowMutex());
@@ -2624,9 +2606,9 @@ CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name
}
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval)
void setTrackbarMaxImpl(const char* trackbar_name, const char* window_name, int maxval)
{
CV_FUNCNAME("cvSetTrackbarMax");
CV_FUNCNAME("setTrackbarMaxImpl");
if (trackbar_name == 0 || window_name == 0)
{
@@ -2653,9 +2635,9 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
void setTrackbarMinImpl(const char* trackbar_name, const char* window_name, int minval)
{
CV_FUNCNAME("cvSetTrackbarMin");
CV_FUNCNAME("setTrackbarMinImpl");
if (trackbar_name == 0 || window_name == 0)
{
@@ -2682,53 +2664,6 @@ CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name
}
CV_IMPL void* cvGetWindowHandle(const char* window_name)
{
CV_FUNCNAME("cvGetWindowHandle");
AutoLock lock(getWindowMutex());
if (window_name == 0)
CV_Error(Error::StsNullPtr, "NULL window name");
auto window = icvFindWindowByName(window_name);
if (!window)
CV_Error_(Error::StsNullPtr, ("NULL window: '%s'", window_name));
return (void*)window->hwnd;
}
// FIXIT: result is not safe to use
CV_IMPL const char* cvGetWindowName(void* window_handle)
{
CV_FUNCNAME("cvGetWindowName");
AutoLock lock(getWindowMutex());
if (window_handle == 0)
CV_Error(Error::StsNullPtr, "NULL window handle");
auto window = icvWindowByHWND((HWND)window_handle);
if (!window)
CV_Error_(Error::StsNullPtr, ("NULL window: '%p'", window_handle));
return window->name.c_str();
}
CV_IMPL void
cvSetPreprocessFuncWin32_(const void* callback)
{
hg_on_preprocess = (CvWin32WindowCallback)callback;
}
CV_IMPL void
cvSetPostprocessFuncWin32_(const void* callback)
{
hg_on_postprocess = (CvWin32WindowCallback)callback;
}
namespace cv { namespace impl {
@@ -2789,7 +2724,6 @@ public:
auto window_ptr = window_.lock();
CV_Assert(window_ptr);
CvWindow& window = *window_ptr;
// see cvGetWindowProperty
switch ((WindowPropertyFlags)prop)
{
case WND_PROP_FULLSCREEN:
@@ -2827,7 +2761,6 @@ public:
auto window_ptr = window_.lock();
CV_Assert(window_ptr);
CvWindow& window = *window_ptr;
// see cvSetWindowProperty
switch ((WindowPropertyFlags)prop)
{
case WND_PROP_FULLSCREEN:
@@ -3007,7 +2940,7 @@ public:
void destroyAllWindows() CV_OVERRIDE
{
cvDestroyAllWindows();
destroyAllWindowsImpl();
}
// namedWindow
@@ -3024,7 +2957,7 @@ public:
int waitKeyEx(int delay) CV_OVERRIDE
{
return cvWaitKey(delay);
return waitKeyImpl(delay);
}
int pollKey() CV_OVERRIDE
{
+31 -55
View File
@@ -1442,18 +1442,18 @@ cv::Rect cv_wl_titlebar::draw(void *data, cv::Size const &size, bool force) {
cv::putText(
buf_, window_->get_title(),
origin, title_.face, title_.scale,
CV_RGB(0xff, 0xff, 0xff), title_.thickness, CV_AA
CV_RGB(0xff, 0xff, 0xff), title_.thickness, cv::LINE_AA
);
}
buf_(cv::Rect(btn_min_.tl(), cv::Size(titlebar_min_width, size.height))) = bg_color_;
cv::line(buf_, btn_cls.tl(), btn_cls.br(), line_color_, 1, CV_AA);
cv::line(buf_, btn_cls.tl(), btn_cls.br(), line_color_, 1, cv::LINE_AA);
cv::line(buf_, btn_cls.tl() + cv::Point(btn_cls.width, 0), btn_cls.br() - cv::Point(btn_cls.width, 0),
line_color_, 1, CV_AA);
cv::rectangle(buf_, btn_max.tl(), btn_max.br(), line_color_, 1, CV_AA);
line_color_, 1, cv::LINE_AA);
cv::rectangle(buf_, btn_max.tl(), btn_max.br(), line_color_, 1, cv::LINE_AA);
cv::line(buf_, cv::Point(btn_min_.x + 8, btn_min_.height / 2),
cv::Point(btn_min_.x + btn_min_.width - 8, btn_min_.height / 2), line_color_, 1, CV_AA);
cv::line(buf_, cv::Point(0, 0), cv::Point(buf_.size().width, 0), border_color_, 1, CV_AA);
cv::Point(btn_min_.x + btn_min_.width - 8, btn_min_.height / 2), line_color_, 1, cv::LINE_AA);
cv::line(buf_, cv::Point(0, 0), cv::Point(buf_.size().width, 0), border_color_, 1, cv::LINE_AA);
write_mat_to_xrgb8888(buf_, data);
last_size_ = size;
@@ -1475,7 +1475,7 @@ cv_wl_viewer::cv_wl_viewer(cv_wl_window *window, int flags)
void cv_wl_viewer::set_image(cv::Mat const &image) {
if (image.type() == CV_8UC1) {
cv::Mat bgr;
cv::cvtColor(image, bgr, CV_GRAY2BGR);
cv::cvtColor(image, bgr, cv::COLOR_GRAY2BGR);
image_ = bgr.clone();
} else {
image_ = image.clone();
@@ -1509,7 +1509,7 @@ void cv_wl_viewer::get_preferred_height_for_width(int width, int &minimum, int &
minimum = natural = image_.size().height;
} else {
natural = static_cast<int>(width * aspect_ratio(image_.size()));
minimum = (flags_ & CV_WINDOW_FREERATIO ? 0 : natural);
minimum = (flags_ & cv::WINDOW_FREERATIO ? 0 : natural);
}
}
@@ -1548,11 +1548,11 @@ cv::Rect cv_wl_viewer::draw(void *data, cv::Size const &size, bool force) {
CV_Assert(image_.size() == size);
write_mat_to_xrgb8888(image_, data);
} else {
if (flags_ & CV_WINDOW_FREERATIO) {
if (flags_ & cv::WINDOW_FREERATIO) {
cv::Mat resized;
cv::resize(image_, resized, size);
write_mat_to_xrgb8888(resized, data);
} else /* CV_WINDOW_KEEPRATIO */ {
} else /* cv::WINDOW_KEEPRATIO */ {
auto rect = cv::Rect(cv::Point(0, 0), size);
if (aspect_ratio(size) >= aspect_ratio(image_.size())) {
rect.height = static_cast<int>(image_.size().height * ((double) rect.width / image_.size().width));
@@ -1657,12 +1657,12 @@ cv::Rect cv_wl_trackbar::draw(void *data, cv::Size const &size, bool force) {
data_,
(name_ + ": " + std::to_string(slider_.value)),
bar_.text_orig, bar_.fontface, bar_.fontscale,
CV_RGB(0x00, 0x00, 0x00), bar_.font_thickness, CV_AA);
CV_RGB(0x00, 0x00, 0x00), bar_.font_thickness, cv::LINE_AA);
cv::line(data_, bar_.left, bar_.right, color_.bg, bar_.thickness + 3, CV_AA);
cv::line(data_, bar_.left, bar_.right, color_.fg, bar_.thickness, CV_AA);
cv::circle(data_, slider_.pos, slider_.radius, color_.fg, -1, CV_AA);
cv::circle(data_, slider_.pos, slider_.radius, color_.bg, 1, CV_AA);
cv::line(data_, bar_.left, bar_.right, color_.bg, bar_.thickness + 3, cv::LINE_AA);
cv::line(data_, bar_.left, bar_.right, color_.fg, bar_.thickness, cv::LINE_AA);
cv::circle(data_, slider_.pos, slider_.radius, color_.fg, -1, cv::LINE_AA);
cv::circle(data_, slider_.pos, slider_.radius, color_.bg, 1, cv::LINE_AA);
write_mat_to_xrgb8888(data_, data);
damage = cv::Rect(cv::Point(0, 0), size);
@@ -2310,57 +2310,33 @@ protected:
std::shared_ptr<cv_wl_core> CvWlCore::sInstance = nullptr;
CV_IMPL int cvStartWindowThread() {
return 0;
}
CV_IMPL int cvNamedWindow(const char *name, int flags) {
int namedWindowImpl(const char *name, int flags) {
return CvWlCore::getInstance().create_window(name, flags);
}
CV_IMPL void cvDestroyWindow(const char *name) {
void destroyWindowImpl(const char *name) {
CvWlCore::getInstance().destroy_window(name);
}
CV_IMPL void cvDestroyAllWindows() {
void destroyAllWindowsImpl() {
CvWlCore::getInstance().destroy_all_windows();
}
CV_IMPL void *cvGetWindowHandle(const char *name) {
return CvWlCore::getInstance().get_window_handle(name);
}
CV_IMPL const char *cvGetWindowName(void *window_handle) {
return CvWlCore::getInstance().get_window_name(window_handle).c_str();
}
CV_IMPL void cvMoveWindow(const char *name, int x, int y) {
void moveWindowImpl(const char *name, int x, int y) {
CV_UNUSED(name);
CV_UNUSED(x);
CV_UNUSED(y);
CV_LOG_ONCE_WARNING(nullptr, "Function not implemented: User cannot move window surfaces in Wayland");
}
CV_IMPL void cvResizeWindow(const char *name, int width, int height) {
void resizeWindowImpl(const char *name, int width, int height) {
if (auto window = CvWlCore::getInstance().get_window(name))
window->show(cv::Size(width, height));
else
throw_system_error("Could not get window name", errno)
}
CV_IMPL int cvCreateTrackbar(const char *name_bar, const char *window_name, int *value, int count,
CvTrackbarCallback on_change) {
CV_UNUSED(name_bar);
CV_UNUSED(window_name);
CV_UNUSED(value);
CV_UNUSED(count);
CV_UNUSED(on_change);
CV_LOG_ONCE_WARNING(nullptr, "Not implemented, use cvCreateTrackbar2");
return 0;
}
CV_IMPL int cvCreateTrackbar2(const char *trackbar_name, const char *window_name, int *val, int count,
int createTrackbar2Impl(const char *trackbar_name, const char *window_name, int *val, int count,
CvTrackbarCallback2 on_notify, void *userdata) {
if (auto window = CvWlCore::getInstance().get_window(window_name))
window->create_trackbar(trackbar_name, val, count, on_notify, userdata);
@@ -2368,7 +2344,7 @@ CV_IMPL int cvCreateTrackbar2(const char *trackbar_name, const char *window_name
return 0;
}
CV_IMPL int cvGetTrackbarPos(const char *trackbar_name, const char *window_name) {
int getTrackbarPosImpl(const char *trackbar_name, const char *window_name) {
if (auto window = CvWlCore::getInstance().get_window(window_name)) {
auto trackbar_ptr = window->get_trackbar(trackbar_name);
if (auto trackbar = trackbar_ptr.lock())
@@ -2378,7 +2354,7 @@ CV_IMPL int cvGetTrackbarPos(const char *trackbar_name, const char *window_name)
return -1;
}
CV_IMPL void cvSetTrackbarPos(const char *trackbar_name, const char *window_name, int pos) {
void setTrackbarPosImpl(const char *trackbar_name, const char *window_name, int pos) {
if (auto window = CvWlCore::getInstance().get_window(window_name)) {
auto trackbar_ptr = window->get_trackbar(trackbar_name);
if (auto trackbar = trackbar_ptr.lock())
@@ -2386,7 +2362,7 @@ CV_IMPL void cvSetTrackbarPos(const char *trackbar_name, const char *window_name
}
}
CV_IMPL void cvSetTrackbarMax(const char *trackbar_name, const char *window_name, int maxval) {
void setTrackbarMaxImpl(const char *trackbar_name, const char *window_name, int maxval) {
if (auto window = CvWlCore::getInstance().get_window(window_name)) {
auto trackbar_ptr = window->get_trackbar(trackbar_name);
if (auto trackbar = trackbar_ptr.lock())
@@ -2394,18 +2370,18 @@ CV_IMPL void cvSetTrackbarMax(const char *trackbar_name, const char *window_name
}
}
CV_IMPL void cvSetTrackbarMin(const char *trackbar_name, const char *window_name, int minval) {
void setTrackbarMinImpl(const char *trackbar_name, const char *window_name, int minval) {
CV_UNUSED(trackbar_name);
CV_UNUSED(window_name);
CV_UNUSED(minval);
}
CV_IMPL void cvSetMouseCallback(const char *window_name, CvMouseCallback on_mouse, void *param) {
void setMouseCallbackImpl(const char *window_name, CvMouseCallback on_mouse, void *param) {
if (auto window = CvWlCore::getInstance().get_window(window_name))
window->set_mouse_callback(on_mouse, param);
}
CV_IMPL void cvShowImage(const char *name, const CvArr *arr) {
void showImageImpl(const char *name, const CvArr *arr) {
auto cv_core = CvWlCore::getInstance();
auto window = cv_core.get_window(name);
if (!window) {
@@ -2423,7 +2399,7 @@ void setWindowTitle_WAYLAND(const cv::String &winname, const cv::String &title)
window->set_title(title);
}
CV_IMPL int cvWaitKey(int delay) {
int waitKeyImpl(int delay) {
int key = -1;
auto limit = ch::duration_cast<ch::nanoseconds>(ch::milliseconds(delay));
auto start_time = ch::duration_cast<ch::nanoseconds>(
@@ -2462,13 +2438,13 @@ CV_IMPL int cvWaitKey(int delay) {
}
#ifdef HAVE_OPENGL
CV_IMPL void cvSetOpenGlDrawCallback(const char *, CvOpenGlDrawCallback, void *) {
void setOpenGLDrawCallbackImpl(const char *, CvOpenGlDrawCallback, void *) {
}
CV_IMPL void cvSetOpenGlContext(const char *) {
void setOpenGLContextImpl(const char *) {
}
CV_IMPL void cvUpdateWindow(const char *) {
void updateWindowImpl(const char *) {
}
#endif // HAVE_OPENGL
+27 -50
View File
@@ -56,9 +56,9 @@ void cv::winrt_initContainer(::Windows::UI::Xaml::Controls::Panel^ _container)
/********************************** API Implementation *********************************************************/
CV_IMPL void cvShowImage(const char* name, const CvArr* arr)
void showImageImpl(const char* name, const CvArr* arr)
{
CV_FUNCNAME("cvShowImage");
CV_FUNCNAME("showImageImpl");
__BEGIN__;
@@ -75,7 +75,7 @@ CV_IMPL void cvShowImage(const char* name, const CvArr* arr)
CV_CALL(image = cvGetMat(arr, &stub));
//TODO: use approach from window_w32.cpp or cv::Mat(.., .., CV_8UC4)
// and cvtColor(.., .., CV_BGR2BGRA) to convert image here
// and cvtColor(.., .., cv::COLOR_BGR2BGRA) to convert image here
// than beforehand.
window->updateImage(image);
@@ -84,9 +84,9 @@ CV_IMPL void cvShowImage(const char* name, const CvArr* arr)
__END__;
}
CV_IMPL int cvNamedWindow(const char* name, int flags)
int namedWindowImpl(const char* name, int flags)
{
CV_FUNCNAME("cvNamedWindow");
CV_FUNCNAME("namedWindowImpl");
if (!name)
CV_ERROR(CV_StsNullPtr, "NULL name");
@@ -96,9 +96,9 @@ CV_IMPL int cvNamedWindow(const char* name, int flags)
return CV_OK;
}
CV_IMPL void cvDestroyWindow(const char* name)
void destroyWindowImpl(const char* name)
{
CV_FUNCNAME("cvDestroyWindow");
CV_FUNCNAME("destroyWindowImpl");
if (!name)
CV_ERROR(CV_StsNullPtr, "NULL name string");
@@ -106,15 +106,15 @@ CV_IMPL void cvDestroyWindow(const char* name)
HighguiBridge::getInstance().destroyWindow(name);
}
CV_IMPL void cvDestroyAllWindows()
void destroyAllWindowsImpl()
{
HighguiBridge::getInstance().destroyAllWindows();
}
CV_IMPL int cvCreateTrackbar2(const char* trackbar_name, const char* window_name,
int createTrackbar2Impl(const char* trackbar_name, const char* window_name,
int* val, int count, CvTrackbarCallback2 on_notify, void* userdata)
{
CV_FUNCNAME("cvCreateTrackbar2");
CV_FUNCNAME("createTrackbar2Impl");
int pos = 0;
@@ -136,9 +136,9 @@ CV_IMPL int cvCreateTrackbar2(const char* trackbar_name, const char* window_name
return CV_OK;
}
CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name, int pos)
void setTrackbarPosImpl(const char* trackbar_name, const char* window_name, int pos)
{
CV_FUNCNAME("cvSetTrackbarPos");
CV_FUNCNAME("setTrackbarPosImpl");
CvTrackbar* trackbar = 0;
@@ -153,9 +153,9 @@ CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name
trackbar->setPosition(pos);
}
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval)
void setTrackbarMaxImpl(const char* trackbar_name, const char* window_name, int maxval)
{
CV_FUNCNAME("cvSetTrackbarMax");
CV_FUNCNAME("setTrackbarMaxImpl");
if (maxval >= 0)
{
@@ -169,9 +169,9 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
}
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
void setTrackbarMinImpl(const char* trackbar_name, const char* window_name, int minval)
{
CV_FUNCNAME("cvSetTrackbarMin");
CV_FUNCNAME("setTrackbarMinImpl");
if (minval >= 0)
{
@@ -185,11 +185,11 @@ CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name
}
}
CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
int getTrackbarPosImpl(const char* trackbar_name, const char* window_name)
{
int pos = -1;
CV_FUNCNAME("cvGetTrackbarPos");
CV_FUNCNAME("getTrackbarPosImpl");
if (trackbar_name == 0 || window_name == 0)
CV_ERROR(CV_StsNullPtr, "NULL trackbar or window name");
@@ -204,9 +204,9 @@ CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
/********************************** Not YET implemented API ****************************************************/
CV_IMPL int cvWaitKey(int delay)
int waitKeyImpl(int delay)
{
CV_WINRT_NO_GUI_ERROR("cvWaitKey");
CV_WINRT_NO_GUI_ERROR("waitKeyImpl");
// see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724411(v=vs.85).aspx
int time0 = GetTickCount64();
@@ -222,11 +222,11 @@ CV_IMPL int cvWaitKey(int delay)
}
}
CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mouse, void* param)
void setMouseCallbackImpl(const char* window_name, CvMouseCallback on_mouse, void* param)
{
CV_WINRT_NO_GUI_ERROR("cvSetMouseCallback");
CV_WINRT_NO_GUI_ERROR("setMouseCallbackImpl");
CV_FUNCNAME("cvSetMouseCallback");
CV_FUNCNAME("setMouseCallbackImpl");
if (!window_name)
CV_ERROR(CV_StsNullPtr, "NULL window name");
@@ -240,32 +240,14 @@ CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mous
/********************************** Disabled or not supported API **********************************************/
CV_IMPL void cvMoveWindow(const char* name, int x, int y)
void moveWindowImpl(const char* name, int x, int y)
{
CV_WINRT_NO_GUI_ERROR("cvMoveWindow");
CV_WINRT_NO_GUI_ERROR("moveWindowImpl");
}
CV_IMPL void cvResizeWindow(const char* name, int width, int height)
void resizeWindowImpl(const char* name, int width, int height)
{
CV_WINRT_NO_GUI_ERROR("cvResizeWindow");
}
CV_IMPL int cvInitSystem(int, char**)
{
CV_WINRT_NO_GUI_ERROR("cvInitSystem");
return CV_StsNotImplemented;
}
CV_IMPL void* cvGetWindowHandle(const char*)
{
CV_WINRT_NO_GUI_ERROR("cvGetWindowHandle");
return (void*) CV_StsNotImplemented;
}
CV_IMPL const char* cvGetWindowName(void*)
{
CV_WINRT_NO_GUI_ERROR("cvGetWindowName");
return (const char*) CV_StsNotImplemented;
CV_WINRT_NO_GUI_ERROR("resizeWindowImpl");
}
void cvSetModeWindow_WinRT(const char* name, double prop_value) {
@@ -276,8 +258,3 @@ double cvGetModeWindow_WinRT(const char* name) {
CV_WINRT_NO_GUI_ERROR("cvGetModeWindow");
return CV_StsNotImplemented;
}
CV_IMPL int cvStartWindowThread() {
CV_WINRT_NO_GUI_ERROR("cvStartWindowThread");
return CV_StsNotImplemented;
}
+1 -1
View File
@@ -167,7 +167,7 @@ private:
class CvWindow
{
public:
CvWindow(cv::String name, int flag = CV_WINDOW_NORMAL);
CvWindow(cv::String name, int flag = cv::WINDOW_NORMAL);
~CvWindow();
/** @brief NOTE: prototype.