highgui_c.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // Intel License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000, Intel Corporation, all rights reserved.
  14. // Third party copyrights are property of their respective owners.
  15. //
  16. // Redistribution and use in source and binary forms, with or without modification,
  17. // are permitted provided that the following conditions are met:
  18. //
  19. // * Redistribution's of source code must retain the above copyright notice,
  20. // this list of conditions and the following disclaimer.
  21. //
  22. // * Redistribution's in binary form must reproduce the above copyright notice,
  23. // this list of conditions and the following disclaimer in the documentation
  24. // and/or other materials provided with the distribution.
  25. //
  26. // * The name of Intel Corporation may not be used to endorse or promote products
  27. // derived from this software without specific prior written permission.
  28. //
  29. // This software is provided by the copyright holders and contributors "as is" and
  30. // any express or implied warranties, including, but not limited to, the implied
  31. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  32. // In no event shall the Intel Corporation or contributors be liable for any direct,
  33. // indirect, incidental, special, exemplary, or consequential damages
  34. // (including, but not limited to, procurement of substitute goods or services;
  35. // loss of use, data, or profits; or business interruption) however caused
  36. // and on any theory of liability, whether in contract, strict liability,
  37. // or tort (including negligence or otherwise) arising in any way out of
  38. // the use of this software, even if advised of the possibility of such damage.
  39. //
  40. //M*/
  41. #ifndef OPENCV_HIGHGUI_H
  42. #define OPENCV_HIGHGUI_H
  43. #include "opencv2/core/core_c.h"
  44. #include "opencv2/imgproc/imgproc_c.h"
  45. #ifdef HAVE_OPENCV_IMGCODECS
  46. #include "opencv2/imgcodecs/imgcodecs_c.h"
  47. #endif
  48. #ifdef HAVE_OPENCV_VIDEOIO
  49. #include "opencv2/videoio/videoio_c.h"
  50. #endif
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif /* __cplusplus */
  54. /** @addtogroup highgui_c
  55. @{
  56. */
  57. /****************************************************************************************\
  58. * Basic GUI functions *
  59. \****************************************************************************************/
  60. //YV
  61. //-----------New for Qt
  62. /* For font */
  63. enum { CV_FONT_LIGHT = 25,//QFont::Light,
  64. CV_FONT_NORMAL = 50,//QFont::Normal,
  65. CV_FONT_DEMIBOLD = 63,//QFont::DemiBold,
  66. CV_FONT_BOLD = 75,//QFont::Bold,
  67. CV_FONT_BLACK = 87 //QFont::Black
  68. };
  69. enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
  70. CV_STYLE_ITALIC = 1,//QFont::StyleItalic,
  71. CV_STYLE_OBLIQUE = 2 //QFont::StyleOblique
  72. };
  73. /* ---------*/
  74. //for color cvScalar(blue_component, green_component, red_component[, alpha_component])
  75. //and alpha= 0 <-> 0xFF (not transparent <-> transparent)
  76. 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));
  77. CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2);
  78. CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0));
  79. CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0));
  80. CVAPI(void) cvSaveWindowParameters(const char* name);
  81. CVAPI(void) cvLoadWindowParameters(const char* name);
  82. CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
  83. CVAPI(void) cvStopLoop( void );
  84. typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
  85. enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
  86. 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));
  87. //----------------------
  88. /* this function is used to set some external parameters in case of X Window */
  89. CVAPI(int) cvInitSystem( int argc, char** argv );
  90. CVAPI(int) cvStartWindowThread( void );
  91. // --------- YV ---------
  92. enum
  93. {
  94. //These 3 flags are used by cvSet/GetWindowProperty
  95. CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property
  96. CV_WND_PROP_AUTOSIZE = 1, //to change/get window's autosize property
  97. CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property
  98. CV_WND_PROP_OPENGL = 3, //to change/get window's opengl support
  99. CV_WND_PROP_VISIBLE = 4,
  100. //These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
  101. CV_WINDOW_NORMAL = 0x00000000, //the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
  102. CV_WINDOW_AUTOSIZE = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed
  103. CV_WINDOW_OPENGL = 0x00001000, //window with opengl support
  104. //Those flags are only for Qt
  105. CV_GUI_EXPANDED = 0x00000000, //status bar and tool bar
  106. CV_GUI_NORMAL = 0x00000010, //old fashious way
  107. //These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
  108. CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen
  109. CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint)
  110. CV_WINDOW_KEEPRATIO = 0x00000000//the ration image is respected.
  111. };
  112. /* create window */
  113. CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
  114. /* Set and Get Property of the window */
  115. CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
  116. CVAPI(double) cvGetWindowProperty(const char* name, int prop_id);
  117. /* Get window image rectangle coordinates, width and height */
  118. CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
  119. /* display image within window (highgui windows remember their content) */
  120. CVAPI(void) cvShowImage( const char* name, const CvArr* image );
  121. /* resize/move window */
  122. CVAPI(void) cvResizeWindow( const char* name, int width, int height );
  123. CVAPI(void) cvMoveWindow( const char* name, int x, int y );
  124. /* destroy window and all the trackers associated with it */
  125. CVAPI(void) cvDestroyWindow( const char* name );
  126. CVAPI(void) cvDestroyAllWindows(void);
  127. /* get native window handle (HWND in case of Win32 and Widget in case of X Window) */
  128. CVAPI(void*) cvGetWindowHandle( const char* name );
  129. /* get name of highgui window given its native handle */
  130. CVAPI(const char*) cvGetWindowName( void* window_handle );
  131. typedef void (CV_CDECL *CvTrackbarCallback)(int pos);
  132. /* create trackbar and display it on top of given window, set callback */
  133. CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name,
  134. int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
  135. typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata);
  136. CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
  137. int* value, int count, CvTrackbarCallback2 on_change,
  138. void* userdata CV_DEFAULT(0));
  139. /* retrieve or set trackbar position */
  140. CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
  141. CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
  142. CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval);
  143. CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval);
  144. enum
  145. {
  146. CV_EVENT_MOUSEMOVE =0,
  147. CV_EVENT_LBUTTONDOWN =1,
  148. CV_EVENT_RBUTTONDOWN =2,
  149. CV_EVENT_MBUTTONDOWN =3,
  150. CV_EVENT_LBUTTONUP =4,
  151. CV_EVENT_RBUTTONUP =5,
  152. CV_EVENT_MBUTTONUP =6,
  153. CV_EVENT_LBUTTONDBLCLK =7,
  154. CV_EVENT_RBUTTONDBLCLK =8,
  155. CV_EVENT_MBUTTONDBLCLK =9,
  156. CV_EVENT_MOUSEWHEEL =10,
  157. CV_EVENT_MOUSEHWHEEL =11
  158. };
  159. enum
  160. {
  161. CV_EVENT_FLAG_LBUTTON =1,
  162. CV_EVENT_FLAG_RBUTTON =2,
  163. CV_EVENT_FLAG_MBUTTON =4,
  164. CV_EVENT_FLAG_CTRLKEY =8,
  165. CV_EVENT_FLAG_SHIFTKEY =16,
  166. CV_EVENT_FLAG_ALTKEY =32
  167. };
  168. #define CV_GET_WHEEL_DELTA(flags) ((short)((flags >> 16) & 0xffff)) // upper 16 bits
  169. typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
  170. /* assign callback for mouse events */
  171. CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
  172. void* param CV_DEFAULT(NULL));
  173. /* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
  174. CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
  175. // OpenGL support
  176. typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata);
  177. CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL));
  178. CVAPI(void) cvSetOpenGlContext(const char* window_name);
  179. CVAPI(void) cvUpdateWindow(const char* window_name);
  180. /****************************************************************************************\
  181. * Obsolete functions/synonyms *
  182. \****************************************************************************************/
  183. #define cvAddSearchPath(path)
  184. #define cvvInitSystem cvInitSystem
  185. #define cvvNamedWindow cvNamedWindow
  186. #define cvvShowImage cvShowImage
  187. #define cvvResizeWindow cvResizeWindow
  188. #define cvvDestroyWindow cvDestroyWindow
  189. #define cvvCreateTrackbar cvCreateTrackbar
  190. #define cvvAddSearchPath cvAddSearchPath
  191. #define cvvWaitKey(name) cvWaitKey(0)
  192. #define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
  193. #define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
  194. #define set_preprocess_func cvSetPreprocessFuncWin32
  195. #define set_postprocess_func cvSetPostprocessFuncWin32
  196. #if defined _WIN32
  197. CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback);
  198. CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback);
  199. #define cvSetPreprocessFuncWin32(callback) cvSetPreprocessFuncWin32_((const void*)(callback))
  200. #define cvSetPostprocessFuncWin32(callback) cvSetPostprocessFuncWin32_((const void*)(callback))
  201. #endif
  202. /** @} highgui_c */
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif