highgui.hpp
Go to the documentation of this 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 // License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
22 //
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
26 //
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42 
43 #ifndef __OPENCV_HIGHGUI_HPP__
44 #define __OPENCV_HIGHGUI_HPP__
45 
46 #include "opencv2/core/core.hpp"
48 
49 #ifdef __cplusplus
50 
51 struct CvCapture;
52 struct CvVideoWriter;
53 
54 namespace cv
55 {
56 
57 enum {
58  // Flags for namedWindow
59  WINDOW_NORMAL = CV_WINDOW_NORMAL, // the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
60  WINDOW_AUTOSIZE = CV_WINDOW_AUTOSIZE, // the user cannot resize the window, the size is constrainted by the image displayed
61  WINDOW_OPENGL = CV_WINDOW_OPENGL, // window with opengl support
62 
63  // Flags for set / getWindowProperty
64  WND_PROP_FULLSCREEN = CV_WND_PROP_FULLSCREEN, // fullscreen property
65  WND_PROP_AUTOSIZE = CV_WND_PROP_AUTOSIZE, // autosize property
66  WND_PROP_ASPECT_RATIO = CV_WND_PROP_ASPECTRATIO, // window's aspect ration
67  WND_PROP_OPENGL = CV_WND_PROP_OPENGL // opengl support
68 };
69 
70 CV_EXPORTS_W void namedWindow(const string& winname, int flags = WINDOW_AUTOSIZE);
71 CV_EXPORTS_W void destroyWindow(const string& winname);
72 CV_EXPORTS_W void destroyAllWindows();
73 
74 CV_EXPORTS_W int startWindowThread();
75 
76 CV_EXPORTS_W int waitKey(int delay = 0);
77 
78 CV_EXPORTS_W void imshow(const string& winname, InputArray mat);
79 
80 CV_EXPORTS_W void resizeWindow(const string& winname, int width, int height);
81 CV_EXPORTS_W void moveWindow(const string& winname, int x, int y);
82 
83 CV_EXPORTS_W void setWindowProperty(const string& winname, int prop_id, double prop_value);//YV
84 CV_EXPORTS_W double getWindowProperty(const string& winname, int prop_id);//YV
85 
86 enum
87 {
98 };
99 
100 enum
101 {
108 };
109 
110 typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata);
111 
113 CV_EXPORTS void setMouseCallback(const string& winname, MouseCallback onMouse, void* userdata = 0);
114 
115 
116 typedef void (CV_CDECL *TrackbarCallback)(int pos, void* userdata);
117 
118 CV_EXPORTS int createTrackbar(const string& trackbarname, const string& winname,
119  int* value, int count,
120  TrackbarCallback onChange = 0,
121  void* userdata = 0);
122 
123 CV_EXPORTS_W int getTrackbarPos(const string& trackbarname, const string& winname);
124 CV_EXPORTS_W void setTrackbarPos(const string& trackbarname, const string& winname, int pos);
125 
126 // OpenGL support
127 
128 typedef void (*OpenGlDrawCallback)(void* userdata);
129 CV_EXPORTS void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
130 
131 CV_EXPORTS void setOpenGlContext(const string& winname);
132 
133 CV_EXPORTS void updateWindow(const string& winname);
134 
135 // < Deperecated
136 CV_EXPORTS void pointCloudShow(const string& winname, const GlCamera& camera, const GlArrays& arr);
137 CV_EXPORTS void pointCloudShow(const string& winname, const GlCamera& camera, InputArray points, InputArray colors = noArray());
138 // >
139 
140 //Only for Qt
141 
142 CV_EXPORTS CvFont fontQt(const string& nameFont, int pointSize=-1,
143  Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL,
144  int style=CV_STYLE_NORMAL, int spacing=0);
145 CV_EXPORTS void addText( const Mat& img, const string& text, Point org, CvFont font);
146 
147 CV_EXPORTS void displayOverlay(const string& winname, const string& text, int delayms CV_DEFAULT(0));
148 CV_EXPORTS void displayStatusBar(const string& winname, const string& text, int delayms CV_DEFAULT(0));
149 
150 CV_EXPORTS void saveWindowParameters(const string& windowName);
151 CV_EXPORTS void loadWindowParameters(const string& windowName);
152 CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
153 CV_EXPORTS void stopLoop();
154 
155 typedef void (CV_CDECL *ButtonCallback)(int state, void* userdata);
156 CV_EXPORTS int createButton( const string& bar_name, ButtonCallback on_change,
157  void* userdata=NULL, int type=CV_PUSH_BUTTON,
158  bool initial_button_state=0);
159 
160 //-------------------------
161 
162 enum
163 {
164  // 8bit, color or not
166  // 8bit, gray
168  // ?, color
170  // any depth, ?
172  // ?, any color
174 };
175 
176 enum
177 {
188 };
189 
190 CV_EXPORTS_W Mat imread( const string& filename, int flags=1 );
191 CV_EXPORTS_W bool imwrite( const string& filename, InputArray img,
192  const vector<int>& params=vector<int>());
193 CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
194 CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst );
195 CV_EXPORTS_W bool imencode( const string& ext, InputArray img,
196  CV_OUT vector<uchar>& buf,
197  const vector<int>& params=vector<int>());
198 
199 #ifndef CV_NO_VIDEO_CAPTURE_CPP_API
200 
201 template<> void CV_EXPORTS Ptr<CvCapture>::delete_obj();
202 template<> void CV_EXPORTS Ptr<CvVideoWriter>::delete_obj();
203 
204 class CV_EXPORTS_W VideoCapture
205 {
206 public:
207  CV_WRAP VideoCapture();
208  CV_WRAP VideoCapture(const string& filename);
209  CV_WRAP VideoCapture(int device);
210 
211  virtual ~VideoCapture();
212  CV_WRAP virtual bool open(const string& filename);
213  CV_WRAP virtual bool open(int device);
214  CV_WRAP virtual bool isOpened() const;
215  CV_WRAP virtual void release();
216 
217  CV_WRAP virtual bool grab();
218  CV_WRAP virtual bool retrieve(CV_OUT Mat& image, int channel=0);
219  virtual VideoCapture& operator >> (CV_OUT Mat& image);
220  CV_WRAP virtual bool read(CV_OUT Mat& image);
221 
222  CV_WRAP virtual bool set(int propId, double value);
223  CV_WRAP virtual double get(int propId);
224 
225 protected:
227 };
228 
229 
230 class CV_EXPORTS_W VideoWriter
231 {
232 public:
233  CV_WRAP VideoWriter();
234  CV_WRAP VideoWriter(const string& filename, int fourcc, double fps,
235  Size frameSize, bool isColor=true);
236 
237  virtual ~VideoWriter();
238  CV_WRAP virtual bool open(const string& filename, int fourcc, double fps,
239  Size frameSize, bool isColor=true);
240  CV_WRAP virtual bool isOpened() const;
241  CV_WRAP virtual void release();
242  virtual VideoWriter& operator << (const Mat& image);
243  CV_WRAP virtual void write(const Mat& image);
244 
245 protected:
247 };
248 
249 #endif
250 
251 }
252 
253 #endif
254 
255 #endif
CV_EXPORTS_W Mat imread(const string &filename, int flags=1)
CV_EXPORTS void updateWindow(const string &winname)
GLenum GLint GLint y
Definition: core_c.h:613
Definition: highgui.hpp:167
const char * text
Definition: core_c.h:1407
CV_EXPORTS_W Mat imdecode(InputArray buf, int flags)
Definition: highgui.hpp:93
const char const char ** filename
Definition: core_c.h:1750
CV_EXPORTS void setMouseCallback(const string &winname, MouseCallback onMouse, void *userdata=0)
assigns callback for mouse events
int double fps
Definition: highgui_c.h:598
CV_EXPORTS_W void destroyAllWindows()
CV_EXPORTS_W void moveWindow(const string &winname, int x, int y)
Definition: highgui.hpp:180
Ptr< CvVideoWriter > writer
Definition: highgui.hpp:246
CV_EXPORTS int createTrackbar(const string &trackbarname, const string &winname, int *value, int count, TrackbarCallback onChange=0, void *userdata=0)
CV_EXPORTS_W double getWindowProperty(const string &winname, int prop_id)
struct CvVideoWriter CvVideoWriter
Definition: highgui_c.h:585
Definition: highgui.hpp:107
const CvMat CvMat int method CV_DEFAULT(CV_FM_RANSAC)
void delete_obj()
deletes the object. Override if needed
Definition: operations.hpp:2612
CV_EXPORTS CvFont fontQt(const string &nameFont, int pointSize=-1, Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL, int style=CV_STYLE_NORMAL, int spacing=0)
Definition: highgui_c.h:102
Definition: highgui_c.h:85
Definition: highgui.hpp:165
Definition: highgui.hpp:67
void(* MouseCallback)(int event, int x, int y, int flags, void *userdata)
Definition: highgui.hpp:110
CV_EXPORTS_W void setTrackbarPos(const string &trackbarname, const string &winname, int pos)
Definition: highgui.hpp:182
GLenum GLsizei width
int int int flags
Definition: highgui_c.h:186
CV_EXPORTS int createButton(const string &bar_name, ButtonCallback on_change, void *userdata=NULL, int type=CV_PUSH_BUTTON, bool initial_button_state=0)
Definition: highgui_c.h:99
Definition: highgui.hpp:169
GLXDrawable GLXDrawable read
Definition: highgui_c.h:64
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: highgui_c.h:230
CV_EXPORTS void addText(const Mat &img, const string &text, Point org, CvFont font)
CV_EXPORTS_W void write(FileStorage &fs, const string &name, int value)
CV_EXPORTS_W int waitKey(int delay=0)
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1312
Definition: highgui.hpp:204
int fourcc
Definition: highgui_c.h:598
The 2D size class.
Definition: core.hpp:81
typedef void(CV_CDECL *CvMouseCallback)(int event
OpenGL Arrays.
Definition: opengl_interop_deprecated.hpp:166
CV_EXPORTS void set(Mat &dst, const Scalar &gamma, const Mat &mask=Mat())
int prop_id
Definition: highgui_c.h:123
CV_EXPORTS void displayOverlay(const string &winname, const string &text, int delayms CV_DEFAULT(0))
Definition: highgui.hpp:183
Definition: highgui.hpp:104
Definition: highgui.hpp:171
GLint GLvoid * img
Definition: legacy.hpp:1150
Definition: highgui.hpp:230
CV_EXPORTS_W void setWindowProperty(const string &winname, int prop_id, double prop_value)
CvMemStoragePos * pos
Definition: core_c.h:933
CV_EXPORTS std::ostream & operator<<(std::ostream &out, const TickMeter &tm)
Definition: highgui.hpp:186
CV_EXPORTS void setOpenGlContext(const string &winname)
const char CvPoint const CvFont * font
Definition: core_c.h:1407
OpenGL camera.
Definition: opengl_interop_deprecated.hpp:274
struct CvCapture CvCapture
Definition: highgui_c.h:267
CV_EXPORTS_W void imshow(const string &winname, InputArray mat)
const _InputArray & InputArray
Definition: core.hpp:1447
Definition: highgui.hpp:105
CV_EXPORTS_W bool imwrite(const string &filename, InputArray img, const vector< int > &params=vector< int >())
CV_EXPORTS_W int getTrackbarPos(const string &trackbarname, const string &winname)
Definition: highgui.hpp:106
CV_EXPORTS_W void destroyWindow(const string &winname)
CV_EXPORTS void setOpenGlDrawCallback(const string &winname, OpenGlDrawCallback onOpenGlDraw, void *userdata=0)
CvArr const CvMat * mat
Definition: core_c.h:700
Definition: highgui.hpp:94
Definition: highgui.hpp:92
GLenum GLsizei GLsizei height
CV_EXPORTS void loadWindowParameters(const string &windowName)
CV_EXPORTS void stopLoop()
Definition: highgui.hpp:59
Definition: highgui.hpp:173
Definition: highgui.hpp:89
Definition: highgui.hpp:60
Definition: highgui.hpp:90
Ptr< CvCapture > cap
Definition: highgui.hpp:226
GLenum GLint x
Definition: core_c.h:632
CV_EXPORTS void saveWindowParameters(const string &windowName)
GLuint GLuint GLsizei count
Definition: core_c.h:973
CV_EXPORTS void pointCloudShow(const string &winname, const GlCamera &camera, const GlArrays &arr)
Definition: highgui.hpp:179
const char CvPoint org
Definition: core_c.h:1407
Definition: highgui.hpp:97
Definition: highgui.hpp:96
Definition: highgui.hpp:178
Definition: core_c.h:1375
The Core Functionality.
Definition: highgui_c.h:58
The n-dimensional matrix class.
Definition: core.hpp:1688
Definition: highgui_c.h:101
void(* OpenGlDrawCallback)(void *userdata)
Definition: highgui.hpp:128
int int y
Definition: highgui_c.h:186
Definition: highgui_c.h:107
Definition: highgui.hpp:181
GLsizei const GLfloat * value
Definition: core_c.h:341
static Scalar_< double > all(doublev0)
returns a scalar with all elements set to v0
CV_EXPORTS_W void namedWindow(const string &winname, int flags=WINDOW_AUTOSIZE)
Definition: highgui.hpp:102
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
GLenum const GLfloat * params
Definition: compat.hpp:688
Definition: highgui.hpp:103
Definition: highgui.hpp:184
int int channel
Definition: highgui.hpp:65
template 2D point class.
Definition: core.hpp:82
int double prop_value
Definition: highgui_c.h:123
char int argc
Definition: highgui_c.h:81
Definition: highgui.hpp:95
Definition: highgui.hpp:66
char * argv[]
Definition: highgui_c.h:81
void(CV_CDECL * ButtonCallback)(int state, void *userdata)
Definition: highgui.hpp:155
CvArr * arr
Definition: core_c.h:649
GLuint dst
Definition: calib3d.hpp:134
void(CV_CDECL * TrackbarCallback)(int pos, void *userdata)
Definition: highgui.hpp:116
CV_EXPORTS void displayStatusBar(const string &winname, const string &text, int delayms CV_DEFAULT(0))
Definition: highgui_c.h:100
Definition: highgui.hpp:91
GLsizei const GLfloat * points
int x
Definition: highgui_c.h:186
const CvArr CvArr CvStereoBMState * state
Definition: calib3d.hpp:353
Definition: highgui.hpp:88
CV_EXPORTS_W bool imencode(const string &ext, InputArray img, CV_OUT vector< uchar > &buf, const vector< int > &params=vector< int >())
CV_EXPORTS int startLoop(int(*pt2Func)(int argc, char *argv[]), int argc, char *argv[])
CvMemStorage CvSeq CvCmpFunc void * userdata
Definition: core_c.h:1083
CV_EXPORTS OutputArray noArray()
Definition: highgui.hpp:185
const char int int CvTrackbarCallback2 on_change
Definition: highgui_c.h:154
CV_EXPORTS_W void resizeWindow(const string &winname, int width, int height)
Definition: highgui_c.h:105
CV_EXPORTS_W int startWindowThread()
Definition: highgui_c.h:106
Definition: highgui.hpp:64
Definition: highgui.hpp:61
Definition: highgui.hpp:187
GLuint color
Definition: core_c.h:1276