1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
11 // For Open Source Computer Vision Library
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.
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
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.
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.
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.
43 #ifndef __OPENCV_HIGHGUI_HPP__
44 #define __OPENCV_HIGHGUI_HPP__
46 #include "opencv2/core/core.hpp"
47 #include "opencv2/highgui/highgui_c.h"
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
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
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();
74 CV_EXPORTS_W int startWindowThread();
76 CV_EXPORTS_W int waitKey(int delay = 0);
78 CV_EXPORTS_W void imshow(const string& winname, InputArray mat);
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);
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
95 EVENT_LBUTTONDBLCLK =7,
96 EVENT_RBUTTONDBLCLK =8,
97 EVENT_MBUTTONDBLCLK =9
102 EVENT_FLAG_LBUTTON =1,
103 EVENT_FLAG_RBUTTON =2,
104 EVENT_FLAG_MBUTTON =4,
105 EVENT_FLAG_CTRLKEY =8,
106 EVENT_FLAG_SHIFTKEY =16,
107 EVENT_FLAG_ALTKEY =32
110 typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata);
112 //! assigns callback for mouse events
113 CV_EXPORTS void setMouseCallback(const string& winname, MouseCallback onMouse, void* userdata = 0);
116 typedef void (CV_CDECL *TrackbarCallback)(int pos, void* userdata);
118 CV_EXPORTS int createTrackbar(const string& trackbarname, const string& winname,
119 int* value, int count,
120 TrackbarCallback onChange = 0,
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);
128 typedef void (CV_CDECL *OpenGlDrawCallback)(void* userdata);
129 CV_EXPORTS void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
131 CV_EXPORTS void setOpenGlContext(const string& winname);
133 CV_EXPORTS void updateWindow(const string& winname);
137 CV_EXPORTS CvFont fontQt(const string& nameFont, int pointSize=-1,
138 Scalar color=Scalar::all(0), int weight=CV_FONT_NORMAL,
139 int style=CV_STYLE_NORMAL, int spacing=0);
140 CV_EXPORTS void addText( const Mat& img, const string& text, Point org, CvFont font);
142 CV_EXPORTS void displayOverlay(const string& winname, const string& text, int delayms CV_DEFAULT(0));
143 CV_EXPORTS void displayStatusBar(const string& winname, const string& text, int delayms CV_DEFAULT(0));
145 CV_EXPORTS void saveWindowParameters(const string& windowName);
146 CV_EXPORTS void loadWindowParameters(const string& windowName);
147 CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
148 CV_EXPORTS void stopLoop();
150 typedef void (CV_CDECL *ButtonCallback)(int state, void* userdata);
151 CV_EXPORTS int createButton( const string& bar_name, ButtonCallback on_change,
152 void* userdata=NULL, int type=CV_PUSH_BUTTON,
153 bool initial_button_state=0);
155 //-------------------------
159 // 8bit, color or not
160 IMREAD_UNCHANGED =-1,
173 IMWRITE_JPEG_QUALITY =1,
174 IMWRITE_PNG_COMPRESSION =16,
175 IMWRITE_PNG_STRATEGY =17,
176 IMWRITE_PNG_BILEVEL =18,
177 IMWRITE_PNG_STRATEGY_DEFAULT =0,
178 IMWRITE_PNG_STRATEGY_FILTERED =1,
179 IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2,
180 IMWRITE_PNG_STRATEGY_RLE =3,
181 IMWRITE_PNG_STRATEGY_FIXED =4,
182 IMWRITE_PXM_BINARY =32
185 CV_EXPORTS_W Mat imread( const string& filename, int flags=1 );
186 CV_EXPORTS_W bool imwrite( const string& filename, InputArray img,
187 const vector<int>& params=vector<int>());
188 CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
189 CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst );
190 CV_EXPORTS_W bool imencode( const string& ext, InputArray img,
191 CV_OUT vector<uchar>& buf,
192 const vector<int>& params=vector<int>());
194 #ifndef CV_NO_VIDEO_CAPTURE_CPP_API
196 template<> void CV_EXPORTS Ptr<CvCapture>::delete_obj();
197 template<> void CV_EXPORTS Ptr<CvVideoWriter>::delete_obj();
199 class CV_EXPORTS_W VideoCapture
202 CV_WRAP VideoCapture();
203 CV_WRAP VideoCapture(const string& filename);
204 CV_WRAP VideoCapture(int device);
206 virtual ~VideoCapture();
207 CV_WRAP virtual bool open(const string& filename);
208 CV_WRAP virtual bool open(int device);
209 CV_WRAP virtual bool isOpened() const;
210 CV_WRAP virtual void release();
212 CV_WRAP virtual bool grab();
213 CV_WRAP virtual bool retrieve(CV_OUT Mat& image, int channel=0);
214 virtual VideoCapture& operator >> (CV_OUT Mat& image);
215 CV_WRAP virtual bool read(CV_OUT Mat& image);
217 CV_WRAP virtual bool set(int propId, double value);
218 CV_WRAP virtual double get(int propId);
225 class CV_EXPORTS_W VideoWriter
228 CV_WRAP VideoWriter();
229 CV_WRAP VideoWriter(const string& filename, int fourcc, double fps,
230 Size frameSize, bool isColor=true);
232 virtual ~VideoWriter();
233 CV_WRAP virtual bool open(const string& filename, int fourcc, double fps,
234 Size frameSize, bool isColor=true);
235 CV_WRAP virtual bool isOpened() const;
236 CV_WRAP virtual void release();
237 virtual VideoWriter& operator << (const Mat& image);
238 CV_WRAP virtual void write(const Mat& image);
241 Ptr<CvVideoWriter> writer;