PageRenderTime 55ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/external/opencv/otherlibs/highgui/highgui.h

https://bitbucket.org/rlyspn/androidrr
C Header | 385 lines | 233 code | 72 blank | 80 comment | 11 complexity | c5f647445ae2bece532b27c9303c02f8 MD5 | raw file
  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 _HIGH_GUI_
  42. #define _HIGH_GUI_
  43. #ifndef SKIP_INCLUDES
  44. #include "cxcore.h"
  45. #if defined WIN32 || defined WIN64
  46. #include <windows.h>
  47. #endif
  48. #else // SKIP_INCLUDES
  49. #if defined WIN32 || defined WIN64
  50. #define CV_CDECL __cdecl
  51. #define CV_STDCALL __stdcall
  52. #else
  53. #define CV_CDECL
  54. #define CV_STDCALL
  55. #endif
  56. #ifndef CV_EXTERN_C
  57. #ifdef __cplusplus
  58. #define CV_EXTERN_C extern "C"
  59. #define CV_DEFAULT(val) = val
  60. #else
  61. #define CV_EXTERN_C
  62. #define CV_DEFAULT(val)
  63. #endif
  64. #endif
  65. #ifndef CV_EXTERN_C_FUNCPTR
  66. #ifdef __cplusplus
  67. #define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; }
  68. #else
  69. #define CV_EXTERN_C_FUNCPTR(x) typedef x
  70. #endif
  71. #endif
  72. #ifndef CV_INLINE
  73. #if defined __cplusplus
  74. #define CV_INLINE inline
  75. #elif (defined WIN32 || defined WIN64) && !defined __GNUC__
  76. #define CV_INLINE __inline
  77. #else
  78. #define CV_INLINE static
  79. #endif
  80. #endif /* CV_INLINE */
  81. #if (defined WIN32 || defined WIN64) && defined CVAPI_EXPORTS
  82. #define CV_EXPORTS __declspec(dllexport)
  83. #else
  84. #define CV_EXPORTS
  85. #endif
  86. #ifndef CVAPI
  87. #define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
  88. #endif
  89. #endif // SKIP_INCLUDES
  90. #if defined(_CH_)
  91. #pragma package <chopencv>
  92. #include <chdl.h>
  93. LOAD_CHDL(highgui)
  94. #endif
  95. #ifdef __cplusplus
  96. extern "C" {
  97. #endif /* __cplusplus */
  98. #define CV_EVENT_MOUSEMOVE 0
  99. #define CV_EVENT_LBUTTONDOWN 1
  100. #define CV_EVENT_RBUTTONDOWN 2
  101. #define CV_EVENT_MBUTTONDOWN 3
  102. #define CV_EVENT_LBUTTONUP 4
  103. #define CV_EVENT_RBUTTONUP 5
  104. #define CV_EVENT_MBUTTONUP 6
  105. #define CV_EVENT_LBUTTONDBLCLK 7
  106. #define CV_EVENT_RBUTTONDBLCLK 8
  107. #define CV_EVENT_MBUTTONDBLCLK 9
  108. #define CV_EVENT_FLAG_LBUTTON 1
  109. #define CV_EVENT_FLAG_RBUTTON 2
  110. #define CV_EVENT_FLAG_MBUTTON 4
  111. #define CV_EVENT_FLAG_CTRLKEY 8
  112. #define CV_EVENT_FLAG_SHIFTKEY 16
  113. #define CV_EVENT_FLAG_ALTKEY 32
  114. /* 8bit, color or not */
  115. #define CV_LOAD_IMAGE_UNCHANGED -1
  116. /* 8bit, gray */
  117. #define CV_LOAD_IMAGE_GRAYSCALE 0
  118. /* ?, color */
  119. #define CV_LOAD_IMAGE_COLOR 1
  120. /* any depth, ? */
  121. #define CV_LOAD_IMAGE_ANYDEPTH 2
  122. /* ?, any color */
  123. #define CV_LOAD_IMAGE_ANYCOLOR 4
  124. /* load image from file
  125. iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED
  126. overrides the other flags
  127. using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED
  128. unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit
  129. */
  130. CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
  131. CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
  132. /* save image to file */
  133. CVAPI(int) cvSaveImage( const char* filename, const CvArr* image );
  134. #define CV_CVTIMG_FLIP 1
  135. #define CV_CVTIMG_SWAP_RB 2
  136. /* utility function: convert one image to another with optional vertical flip */
  137. CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0));
  138. /* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
  139. CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
  140. /****************************************************************************************\
  141. * Working with Video Files and Cameras *
  142. \****************************************************************************************/
  143. /* "black box" capture structure */
  144. typedef struct CvCapture CvCapture;
  145. /* start capturing frames from video file */
  146. CVAPI(CvCapture*) cvCreateSocketCapture( const char *address, const char* port, int width, int height );
  147. /* grab a frame, return 1 on success, 0 on fail.
  148. this function is thought to be fast */
  149. CVAPI(int) cvGrabFrame( CvCapture* capture );
  150. /* get the frame grabbed with cvGrabFrame(..)
  151. This function may apply some frame processing like
  152. frame decompression, flipping etc.
  153. !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
  154. CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture );
  155. /* Just a combination of cvGrabFrame and cvRetrieveFrame
  156. !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
  157. CVAPI(IplImage*) cvQueryFrame( CvCapture* capture );
  158. /* stop capturing/reading and free resources */
  159. CVAPI(void) cvReleaseCapture( CvCapture** capture );
  160. #define CV_CAP_PROP_POS_MSEC 0
  161. #define CV_CAP_PROP_POS_FRAMES 1
  162. #define CV_CAP_PROP_POS_AVI_RATIO 2
  163. #define CV_CAP_PROP_FRAME_WIDTH 3
  164. #define CV_CAP_PROP_FRAME_HEIGHT 4
  165. #define CV_CAP_PROP_FPS 5
  166. #define CV_CAP_PROP_FOURCC 6
  167. #define CV_CAP_PROP_FRAME_COUNT 7
  168. #define CV_CAP_PROP_FORMAT 8
  169. #define CV_CAP_PROP_MODE 9
  170. #define CV_CAP_PROP_BRIGHTNESS 10
  171. #define CV_CAP_PROP_CONTRAST 11
  172. #define CV_CAP_PROP_SATURATION 12
  173. #define CV_CAP_PROP_HUE 13
  174. #define CV_CAP_PROP_GAIN 14
  175. #define CV_CAP_PROP_CONVERT_RGB 15
  176. /* retrieve or set capture properties */
  177. CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
  178. CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
  179. /****************************************************************************************\
  180. * Obsolete functions/synonyms *
  181. \****************************************************************************************/
  182. #ifndef HIGHGUI_NO_BACKWARD_COMPATIBILITY
  183. #define HIGHGUI_BACKWARD_COMPATIBILITY
  184. #endif
  185. #ifdef HIGHGUI_BACKWARD_COMPATIBILITY
  186. #define cvCaptureFromFile cvCreateFileCapture
  187. #define cvCaptureFromCAM cvCreateCameraCapture
  188. #define cvCaptureFromAVI cvCaptureFromFile
  189. #define cvCreateAVIWriter cvCreateVideoWriter
  190. #define cvWriteToAVI cvWriteFrame
  191. #define cvAddSearchPath(path)
  192. #define cvvInitSystem cvInitSystem
  193. #define cvvNamedWindow cvNamedWindow
  194. #define cvvResizeWindow cvResizeWindow
  195. #define cvvDestroyWindow cvDestroyWindow
  196. #define cvvCreateTrackbar cvCreateTrackbar
  197. #define cvvLoadImage(name) cvLoadImage((name),1)
  198. #define cvvSaveImage cvSaveImage
  199. #define cvvAddSearchPath cvAddSearchPath
  200. #define cvvWaitKey(name) cvWaitKey(0)
  201. #define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
  202. #define cvvConvertImage cvConvertImage
  203. #define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
  204. #define set_preprocess_func cvSetPreprocessFuncWin32
  205. #define set_postprocess_func cvSetPostprocessFuncWin32
  206. #ifdef WIN32
  207. typedef int (CV_CDECL * CvWin32WindowCallback)(HWND, UINT, WPARAM, LPARAM, int*);
  208. CVAPI(void) cvSetPreprocessFuncWin32( CvWin32WindowCallback on_preprocess );
  209. CVAPI(void) cvSetPostprocessFuncWin32( CvWin32WindowCallback on_postprocess );
  210. CV_INLINE int iplWidth( const IplImage* img );
  211. CV_INLINE int iplWidth( const IplImage* img )
  212. {
  213. return !img ? 0 : !img->roi ? img->width : img->roi->width;
  214. }
  215. CV_INLINE int iplHeight( const IplImage* img );
  216. CV_INLINE int iplHeight( const IplImage* img )
  217. {
  218. return !img ? 0 : !img->roi ? img->height : img->roi->height;
  219. }
  220. #endif
  221. #endif /* obsolete functions */
  222. /* For use with Win32 */
  223. #ifdef WIN32
  224. CV_INLINE RECT NormalizeRect( RECT r );
  225. CV_INLINE RECT NormalizeRect( RECT r )
  226. {
  227. int t;
  228. if( r.left > r.right )
  229. {
  230. t = r.left;
  231. r.left = r.right;
  232. r.right = t;
  233. }
  234. if( r.top > r.bottom )
  235. {
  236. t = r.top;
  237. r.top = r.bottom;
  238. r.bottom = t;
  239. }
  240. return r;
  241. }
  242. CV_INLINE CvRect RectToCvRect( RECT sr );
  243. CV_INLINE CvRect RectToCvRect( RECT sr )
  244. {
  245. sr = NormalizeRect( sr );
  246. return cvRect( sr.left, sr.top, sr.right - sr.left, sr.bottom - sr.top );
  247. }
  248. CV_INLINE RECT CvRectToRect( CvRect sr );
  249. CV_INLINE RECT CvRectToRect( CvRect sr )
  250. {
  251. RECT dr;
  252. dr.left = sr.x;
  253. dr.top = sr.y;
  254. dr.right = sr.x + sr.width;
  255. dr.bottom = sr.y + sr.height;
  256. return dr;
  257. }
  258. CV_INLINE IplROI RectToROI( RECT r );
  259. CV_INLINE IplROI RectToROI( RECT r )
  260. {
  261. IplROI roi;
  262. r = NormalizeRect( r );
  263. roi.xOffset = r.left;
  264. roi.yOffset = r.top;
  265. roi.width = r.right - r.left;
  266. roi.height = r.bottom - r.top;
  267. roi.coi = 0;
  268. return roi;
  269. }
  270. #endif /* WIN32 */
  271. #ifdef __cplusplus
  272. } /* end of extern "C" */
  273. #endif /* __cplusplus */
  274. #if defined __cplusplus && (!defined WIN32 || !defined (__GNUC__)) && !defined CV_NO_CVV_IMAGE
  275. #define CImage CvvImage
  276. /* CvvImage class definition */
  277. class CV_EXPORTS CvvImage
  278. {
  279. public:
  280. CvvImage();
  281. virtual ~CvvImage();
  282. /* Create image (BGR or grayscale) */
  283. virtual bool Create( int width, int height, int bits_per_pixel, int image_origin = 0 );
  284. /* Load image from specified file */
  285. virtual bool Load( const char* filename, int desired_color = 1 );
  286. /* Load rectangle from the file */
  287. virtual bool LoadRect( const char* filename,
  288. int desired_color, CvRect r );
  289. #ifdef WIN32
  290. virtual bool LoadRect( const char* filename,
  291. int desired_color, RECT r )
  292. {
  293. return LoadRect( filename, desired_color,
  294. cvRect( r.left, r.top, r.right - r.left, r.bottom - r.top ));
  295. }
  296. #endif
  297. /* Save entire image to specified file. */
  298. virtual bool Save( const char* filename );
  299. /* Get copy of input image ROI */
  300. virtual void CopyOf( CvvImage& image, int desired_color = -1 );
  301. virtual void CopyOf( IplImage* img, int desired_color = -1 );
  302. IplImage* GetImage() { return m_img; };
  303. virtual void Destroy(void);
  304. /* width and height of ROI */
  305. int Width() { return !m_img ? 0 : !m_img->roi ? m_img->width : m_img->roi->width; };
  306. int Height() { return !m_img ? 0 : !m_img->roi ? m_img->height : m_img->roi->height;};
  307. int Bpp() { return m_img ? (m_img->depth & 255)*m_img->nChannels : 0; };
  308. virtual void Fill( int color );
  309. protected:
  310. IplImage* m_img;
  311. };
  312. #endif /* __cplusplus */
  313. #endif /* _HIGH_GUI_ */