View difference between Paste ID: dpbCxLgK and 9FdJa0mK
SHOW: | | - or go back to the newest paste.
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
42
#ifndef __OPENCV_HIGHGUI_H__
43
#define __OPENCV_HIGHGUI_H__
44
45
#include "opencv2/core/core_c.h"
46
#if defined WIN32 || defined _WIN32
47
   	#include <windows.h>
48
	#undef min
49
	#undef max
50
#endif
51
52
#ifdef __cplusplus
53
extern "C" {
54
#endif /* __cplusplus */
55
56
/****************************************************************************************\
57
*                                  Basic GUI functions                                   *
58
\****************************************************************************************/
59
//YV
60
//-----------New for Qt
61
/* For font */
62
enum {	CV_FONT_LIGHT 			= 25,//QFont::Light,
63
		CV_FONT_NORMAL 			= 50,//QFont::Normal,
64
		CV_FONT_DEMIBOLD 		= 63,//QFont::DemiBold,
65
		CV_FONT_BOLD 			= 75,//QFont::Bold,
66
		CV_FONT_BLACK 			= 87 //QFont::Black
67
};
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
75
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
76
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
77
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));
78
79
CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2);
80
81
CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms);
82
CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms);
83
84
typedef void (CV_CDECL *CvOpenGLCallback)(void* userdata);
85
CVAPI(void) cvCreateOpenGLCallback( const char* window_name, CvOpenGLCallback callbackOpenGL, void* userdata CV_DEFAULT(NULL), double angle CV_DEFAULT(-1), double zmin CV_DEFAULT(-1), double zmax CV_DEFAULT(-1));
86
87
CVAPI(void) cvSaveWindowParameters(const char* name);
88
CVAPI(void) cvLoadWindowParameters(const char* name);
89
CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
90
CVAPI(void) cvStopLoop();
91
92
typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
93
enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
94
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));
95
//----------------------
96
97
98
/* this function is used to set some external parameters in case of X Window */
99
CVAPI(int) cvInitSystem( int argc, char** argv );
100
101
CVAPI(int) cvStartWindowThread();
102
103
// ---------  YV ---------
104
enum
105
{
106
	//These 3 flags are used by cvSet/GetWindowProperty
107
	CV_WND_PROP_FULLSCREEN = 0,//to change/get window's fullscreen property
108
	CV_WND_PROP_AUTOSIZE   = 1,//to change/get window's autosize property
109
	CV_WND_PROP_ASPECTRATIO= 2,//to change/get window's aspectratio property
110
	//
111
	//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
112
	CV_WINDOW_NORMAL       = 0x00000000,//the user can resize the window (no constraint)  / also use to switch a fullscreen window to a normal size
113
	CV_WINDOW_AUTOSIZE 	   = 0x00000001,//the user cannot resize the window, the size is constrainted by the image displayed
114
	//
115
	//Those flags are only for Qt
116
	CV_GUI_EXPANDED 		= 0x00000000,//status bar and tool bar
117
	CV_GUI_NORMAL 			= 0x00000010,//old fashious way
118
	//
119
	//These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
120
	CV_WINDOW_FULLSCREEN   = 1,//change the window to fullscreen
121
	CV_WINDOW_FREERATIO	   = 0x00000100,//the image expends as much as it can (no ratio constraint)
122
	CV_WINDOW_KEEPRATIO    = 0x00000000//the ration image is respected.
123
};
124
125
/* create window */
126
CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
127
128
/* Set and Get Property of the window */
129
CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
130
CVAPI(double) cvGetWindowProperty(const char* name, int prop_id);
131
132
/* display image within window (highgui windows remember their content) */
133
CVAPI(void) cvShowImage( const char* name, const CvArr* image );
134
135
/* resize/move window */
136
CVAPI(void) cvResizeWindow( const char* name, int width, int height );
137
CVAPI(void) cvMoveWindow( const char* name, int x, int y );
138
139
140
/* destroy window and all the trackers associated with it */
141
CVAPI(void) cvDestroyWindow( const char* name );
142
143
CVAPI(void) cvDestroyAllWindows(void);
144
145
/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */
146
CVAPI(void*) cvGetWindowHandle( const char* name );
147
148
/* get name of highgui window given its native handle */
149
CVAPI(const char*) cvGetWindowName( void* window_handle );
150
151
152
typedef void (CV_CDECL *CvTrackbarCallback)(int pos);
153
154
/* create trackbar and display it on top of given window, set callback */
155
CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name,
156
                             int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
157
158
typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata);
159
160
CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
161
                              int* value, int count, CvTrackbarCallback2 on_change,
162
                              void* userdata CV_DEFAULT(0));
163
164
/* retrieve or set trackbar position */
165
CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* windw_name );
166
CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
167
168
enum
169
{
170
	CV_EVENT_MOUSEMOVE      =0,
171
	CV_EVENT_LBUTTONDOWN    =1,
172
	CV_EVENT_RBUTTONDOWN    =2,
173
	CV_EVENT_MBUTTONDOWN    =3,
174
	CV_EVENT_LBUTTONUP      =4,
175
	CV_EVENT_RBUTTONUP      =5,
176
	CV_EVENT_MBUTTONUP      =6,
177
	CV_EVENT_LBUTTONDBLCLK  =7,
178
	CV_EVENT_RBUTTONDBLCLK  =8,
179
	CV_EVENT_MBUTTONDBLCLK  =9
180
};
181
182
enum
183
{
184
	CV_EVENT_FLAG_LBUTTON   =1,
185
	CV_EVENT_FLAG_RBUTTON   =2,
186
	CV_EVENT_FLAG_MBUTTON   =4,
187
	CV_EVENT_FLAG_CTRLKEY   =8,
188
	CV_EVENT_FLAG_SHIFTKEY  =16,
189
	CV_EVENT_FLAG_ALTKEY    =32
190
};
191
192
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
193
194
/* assign callback for mouse events */
195
CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
196
                                void* param CV_DEFAULT(NULL));
197
198
enum
199
{
200
/* 8bit, color or not */
201
	CV_LOAD_IMAGE_UNCHANGED  =-1,
202
/* 8bit, gray */
203
	CV_LOAD_IMAGE_GRAYSCALE  =0,
204
/* ?, color */
205
	CV_LOAD_IMAGE_COLOR      =1,
206
/* any depth, ? */
207
	CV_LOAD_IMAGE_ANYDEPTH   =2,
208
/* ?, any color */
209
	CV_LOAD_IMAGE_ANYCOLOR   =4
210
};
211
212
/* load image from file
213
  iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED
214
  overrides the other flags
215
  using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED
216
  unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit
217
*/
218
CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
219
CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
220
221
enum
222
{
223
	CV_IMWRITE_JPEG_QUALITY =1,
224
	CV_IMWRITE_PNG_COMPRESSION =16,
225
	CV_IMWRITE_PXM_BINARY =32
226
};
227
228
/* save image to file */
229
CVAPI(int) cvSaveImage( const char* filename, const CvArr* image,
230
                        const int* params CV_DEFAULT(0) );
231
232
/* decode image stored in the buffer */
233
CVAPI(IplImage*) cvDecodeImage( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
234
CVAPI(CvMat*) cvDecodeImageM( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
235
236
/* encode image and store the result as a byte vector (single-row 8uC1 matrix) */
237
CVAPI(CvMat*) cvEncodeImage( const char* ext, const CvArr* image,
238
                             const int* params CV_DEFAULT(0) );
239
240
enum
241
{
242
	CV_CVTIMG_FLIP      =1,
243
	CV_CVTIMG_SWAP_RB   =2
244
};
245
246
/* utility function: convert one image to another with optional vertical flip */
247
CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0));
248
249
/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
250
CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
251
252
/****************************************************************************************\
253
*                         Working with Video Files and Cameras                           *
254
\****************************************************************************************/
255
256
/* "black box" capture structure */
257
typedef struct CvCapture CvCapture;
258
259
/* start capturing frames from video file */
260
CVAPI(CvCapture*) cvCreateFileCapture( const char* filename );
261
262
enum
263
{
264
	CV_CAP_ANY      =0,     // autodetect
265
266
	CV_CAP_MIL      =100,   // MIL proprietary drivers
267
268
	CV_CAP_VFW      =200,   // platform native
269
	CV_CAP_V4L      =200,
270
	CV_CAP_V4L2     =200,
271
272
	CV_CAP_FIREWARE =300,   // IEEE 1394 drivers
273
	CV_CAP_FIREWIRE =300,
274
	CV_CAP_IEEE1394 =300,
275
	CV_CAP_DC1394   =300,
276
	CV_CAP_CMU1394  =300,
277
278
	CV_CAP_STEREO   =400,   // TYZX proprietary drivers
279
	CV_CAP_TYZX     =400,
280
	CV_TYZX_LEFT    =400,
281
	CV_TYZX_RIGHT   =401,
282
	CV_TYZX_COLOR   =402,
283
	CV_TYZX_Z       =403,
284
285
	CV_CAP_QT       =500,   // QuickTime
286
287
	CV_CAP_UNICAP   =600,   // Unicap drivers
288
289
	CV_CAP_DSHOW    =700,   // DirectShow (via videoInput)
290
291
	CV_CAP_PVAPI    =800   // PvAPI, Prosilica GigE SDK
292
};
293
294
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
295
CVAPI(CvCapture*) cvCreateCameraCapture( int index );
296
297
/* grab a frame, return 1 on success, 0 on fail.
298
  this function is thought to be fast               */
299
CVAPI(int) cvGrabFrame( CvCapture* capture );
300
301
/* get the frame grabbed with cvGrabFrame(..)
302
  This function may apply some frame processing like
303
  frame decompression, flipping etc.
304
  !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
305
CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture, int streamIdx CV_DEFAULT(0) );
306
307
/* Just a combination of cvGrabFrame and cvRetrieveFrame
308
   !!!DO NOT RELEASE or MODIFY the retrieved frame!!!      */
309
CVAPI(IplImage*) cvQueryFrame( CvCapture* capture );
310
311
/* stop capturing/reading and free resources */
312
CVAPI(void) cvReleaseCapture( CvCapture** capture );
313
314
enum
315
{
316
	CV_CAP_PROP_POS_MSEC       =0,
317
	CV_CAP_PROP_POS_FRAMES     =1,
318
	CV_CAP_PROP_POS_AVI_RATIO  =2,
319
	CV_CAP_PROP_FRAME_WIDTH    =3,
320
	CV_CAP_PROP_FRAME_HEIGHT   =4,
321
	CV_CAP_PROP_FPS            =5,
322
	CV_CAP_PROP_FOURCC         =6,
323
	CV_CAP_PROP_FRAME_COUNT    =7,
324
	CV_CAP_PROP_FORMAT         =8,
325
	CV_CAP_PROP_MODE           =9,
326
	CV_CAP_PROP_BRIGHTNESS    =10,
327
	CV_CAP_PROP_CONTRAST      =11,
328
	CV_CAP_PROP_SATURATION    =12,
329
	CV_CAP_PROP_HUE           =13,
330
	CV_CAP_PROP_GAIN          =14,
331
	CV_CAP_PROP_EXPOSURE      =15,
332
	CV_CAP_PROP_CONVERT_RGB   =16,
333
	CV_CAP_PROP_WHITE_BALANCE =17,
334
	CV_CAP_PROP_RECTIFICATION =18,
335
	CV_CAP_PROP_MONOCROME	  =19
336
};
337
338
/* retrieve or set capture properties */
339
CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
340
CVAPI(int)    cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
341
342
// Return the type of the capturer (eg, CV_CAP_V4W, CV_CAP_UNICAP), which is unknown if created with CV_CAP_ANY
343
CVAPI(int)    cvGetCaptureDomain( CvCapture* capture);  
344
345
/* "black box" video file writer structure */
346
typedef struct CvVideoWriter CvVideoWriter;
347
348
CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
349
{
350
	return (c1 & 255) + ((c2 & 255) << 8) + ((c3 &255) << 16) + ((c4 & 255) << 24);
351
}
352
353
#define CV_FOURCC_PROMPT -1  /* Open Codec Selection Dialog (Windows only) */
354
#define CV_FOURCC_DEFAULT CV_FOURCC('I', 'Y', 'U', 'V') /* Use default codec for specified filename (Linux only) */
355
356
/* initialize video file writer */
357
CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc,
358
                                           double fps, CvSize frame_size,
359
                                           int is_color CV_DEFAULT(1));
360
361
//CVAPI(CvVideoWriter*) cvCreateImageSequenceWriter( const char* filename,
362
//                                                   int is_color CV_DEFAULT(1));
363
364
/* write frame to video file */
365
CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image );
366
367
/* close video file writer */
368
CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer );
369
370
/****************************************************************************************\
371
*                              Obsolete functions/synonyms                               *
372
\****************************************************************************************/
373
374
#define cvCaptureFromFile cvCreateFileCapture
375
#define cvCaptureFromCAM cvCreateCameraCapture
376
#define cvCaptureFromAVI cvCaptureFromFile
377
#define cvCreateAVIWriter cvCreateVideoWriter
378
#define cvWriteToAVI cvWriteFrame
379
#define cvAddSearchPath(path)
380
#define cvvInitSystem cvInitSystem
381
#define cvvNamedWindow cvNamedWindow
382
#define cvvShowImage cvShowImage
383
#define cvvResizeWindow cvResizeWindow
384
#define cvvDestroyWindow cvDestroyWindow
385
#define cvvCreateTrackbar cvCreateTrackbar
386
#define cvvLoadImage(name) cvLoadImage((name),1)
387
#define cvvSaveImage cvSaveImage
388
#define cvvAddSearchPath cvAddSearchPath
389
#define cvvWaitKey(name) cvWaitKey(0)
390
#define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
391
#define cvvConvertImage cvConvertImage
392
#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
393
#define set_preprocess_func cvSetPreprocessFuncWin32
394
#define set_postprocess_func cvSetPostprocessFuncWin32
395
396
#if defined WIN32 || defined _WIN32
397
398
typedef int (CV_CDECL * CvWin32WindowCallback)(HWND, UINT, WPARAM, LPARAM, int*);
399
CVAPI(void) cvSetPreprocessFuncWin32( CvWin32WindowCallback on_preprocess );
400
CVAPI(void) cvSetPostprocessFuncWin32( CvWin32WindowCallback on_postprocess );
401
402
#endif
403
404
#ifdef __cplusplus
405
}
406
#endif
407
408
#endif