b923d5b94ac4510522ba47c8989d9809c8ab9c82
[opencv] / include / opencv / highgui.hpp
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 _HIGHGUI_HPP_
44 #define _HIGHGUI_HPP_
45
46 #ifdef __cplusplus
47
48 namespace cv
49 {
50
51 // To be extended
52
53 CV_EXPORTS void namedWindow( const string& winname, int flags );
54 CV_EXPORTS void imshow( const string& winname, const Mat& mat );
55
56 typedef CvTrackbarCallback2 TrackbarCallback;
57
58 CV_EXPORTS int createTrackbar( const string& trackbarname, const string& winname,
59                                int* value, int count,
60                                TrackbarCallback onChange CV_DEFAULT(0),
61                                void* userdata CV_DEFAULT(0));
62
63 CV_EXPORTS int getTrackbarPos( const string& trackbarname, const string& winname );
64 CV_EXPORTS void setTrackbarPos( const string& trackbarname, const string& winname, int pos );
65
66 CV_EXPORTS Mat imread( const string& filename, int flags=1 );
67 CV_EXPORTS bool imwrite( const string& filename, const Mat& img,
68               const vector<int>& params=vector<int>());
69 CV_EXPORTS Mat imdecode( const Mat& buf, int flags );
70 CV_EXPORTS bool imencode( const string& ext, const Mat& img,
71                           vector<uchar>& buf,
72                           const vector<int>& params=vector<int>());
73
74 CV_EXPORTS int waitKey(int delay=0);
75
76 #ifndef CV_NO_VIDEO_CAPTURE_CPP_API
77
78 template<> inline void Ptr<CvCapture>::delete_obj()
79 { cvReleaseCapture(&obj); }
80     
81 template<> inline void Ptr<CvVideoWriter>::delete_obj()
82 { cvReleaseVideoWriter(&obj); }
83
84 class CV_EXPORTS VideoCapture
85 {
86 public:
87     VideoCapture();
88     VideoCapture(const string& filename);
89     VideoCapture(int device);
90     
91     virtual ~VideoCapture();
92     virtual bool open(const string& filename);
93     virtual bool open(int device);
94     virtual bool isOpened() const;
95     virtual void release();
96     
97     virtual bool grab();
98     virtual bool retrieve(Mat& image, int channel=0);
99     virtual VideoCapture& operator >> (Mat& image);
100     
101     virtual bool set(int propId, double value);
102     virtual double get(int propId);
103     
104 protected:
105     Ptr<CvCapture> cap;
106 };
107
108     
109 class CV_EXPORTS VideoWriter
110 {
111 public:    
112     VideoWriter();
113     VideoWriter(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true);
114     
115     virtual ~VideoWriter();
116     virtual bool open(const string& filename, int fourcc, double fps, Size frameSize, bool isColor=true);
117     virtual bool isOpened() const;
118     virtual VideoWriter& operator << (const Mat& image);
119     
120 protected:
121     Ptr<CvVideoWriter> writer;
122 };
123
124 #endif
125
126 }
127
128 #endif
129
130 #endif /* _HIGHGUI_HPP_ */