]> rtime.felk.cvut.cz Git - opencv.git/blob - opencv/include/opencv/cv.hpp
imported from a new release
[opencv.git] / opencv / include / opencv / cv.hpp
1 /*M///////////////////////////////////////////////////////////////////////////////////////\r
2 //\r
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
4 //\r
5 //  By downloading, copying, installing or using the software you agree to this license.\r
6 //  If you do not agree to this license, do not download, install,\r
7 //  copy or use the software.\r
8 //\r
9 //\r
10 //                        Intel License Agreement\r
11 //                For Open Source Computer Vision Library\r
12 //\r
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.\r
14 // Third party copyrights are property of their respective owners.\r
15 //\r
16 // Redistribution and use in source and binary forms, with or without modification,\r
17 // are permitted provided that the following conditions are met:\r
18 //\r
19 //   * Redistribution's of source code must retain the above copyright notice,\r
20 //     this list of conditions and the following disclaimer.\r
21 //\r
22 //   * Redistribution's in binary form must reproduce the above copyright notice,\r
23 //     this list of conditions and the following disclaimer in the documentation\r
24 //     and/or other materials provided with the distribution.\r
25 //\r
26 //   * The name of Intel Corporation may not be used to endorse or promote products\r
27 //     derived from this software without specific prior written permission.\r
28 //\r
29 // This software is provided by the copyright holders and contributors "as is" and\r
30 // any express or implied warranties, including, but not limited to, the implied\r
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.\r
32 // In no event shall the Intel Corporation or contributors be liable for any direct,\r
33 // indirect, incidental, special, exemplary, or consequential damages\r
34 // (including, but not limited to, procurement of substitute goods or services;\r
35 // loss of use, data, or profits; or business interruption) however caused\r
36 // and on any theory of liability, whether in contract, strict liability,\r
37 // or tort (including negligence or otherwise) arising in any way out of\r
38 // the use of this software, even if advised of the possibility of such damage.\r
39 //\r
40 //M*/\r
41 \r
42 //#ifdef WIN32\r
43 \r
44 #ifndef _CV_HPP_\r
45 #define _CV_HPP_\r
46 \r
47 #include "cv.h"\r
48 \r
49 #ifdef __cplusplus\r
50 \r
51 /****************************************************************************************\\r
52 *                                      Image class                                       *\r
53 \****************************************************************************************/\r
54 \r
55 struct CV_DLL_ENTRY CvImage : public IplImage\r
56 {\r
57     CvImage();\r
58     CvImage( CvSize size, int depth, int channels );\r
59     ~CvImage();\r
60 \r
61     uchar* image_data();\r
62     const uchar* image_data() const;\r
63 \r
64     CvSize image_roi_size() const;\r
65     int    byte_per_pixel() const;\r
66 \r
67     CvImage& operator = ( const CvImage& another )\r
68     { return copy( another ); }\r
69     \r
70     CvImage& copy( const CvImage& another );\r
71 };\r
72 \r
73 \r
74 class CV_DLL_ENTRY CvImageGroup\r
75 {\r
76 public:\r
77     enum{ max_count = 7 };\r
78     \r
79     CvImageGroup( int _count = 0 )\r
80     { assert( _count < max_count ); clear(); operator=(_count); }\r
81 \r
82 \r
83     ~CvImageGroup() { destroy(); }\r
84     \r
85     CvImage& operator[]( int count ) { return (CvImage&)*image[count]; }\r
86 \r
87     CvImageGroup& operator=( const CvImageGroup& another )\r
88     { return copy( another ); }\r
89 \r
90     CvImageGroup& operator=( const CvImage& another )\r
91     { return copy( another ); }\r
92 \r
93     CvImageGroup& copy( const CvImageGroup& another );\r
94 \r
95     CvImageGroup& copy( const CvImage& another );\r
96     CvImageGroup& operator=( int _count );\r
97 \r
98     int get_count() const { return count; }\r
99 \r
100     void destroy();\r
101     void clear() { for( int i = 0; i < max_count; i++ ) image[i] = 0; }\r
102     IplImage** get_group() { return &image[0]; };\r
103 \r
104 protected:\r
105     int       count;\r
106     IplImage* image[max_count];\r
107 };\r
108 \r
109 \r
110 class CV_DLL_ENTRY CvCamShiftTracker\r
111 {\r
112 public:\r
113     \r
114     // constructor\r
115     CvCamShiftTracker();\r
116     // destructor\r
117     virtual ~CvCamShiftTracker();\r
118     \r
119     // get- properties\r
120     \r
121     // Characteristics of the object, \r
122     // which are calculated by track_object method\r
123     float   get_orientation()  // orientation of the object in degrees \r
124     { return orientation; }\r
125     float   get_length()       // the larger linear size of the object\r
126     { return length; }\r
127     float   get_width()        // the smaller linear size of the object\r
128     { return width; }\r
129     CvRect get_window()       // bounding rectangle for the object\r
130     { return window; }\r
131     \r
132     // Tracking parameters\r
133     int     get_threshold()  // thresholding value that applied to back project\r
134     { return threshold; }\r
135     int     get_hist_dims( int* dims = 0 ); // returns number of histogram dimensions and sets\r
136     // dims[0] to number of bins on 1st dimension,\r
137     // dims[1] -||- on 2nd dimension etc. \r
138     // (if dims pointer is not 0).\r
139     \r
140     int     get_min_ch_val( int channel )  // Given channel index, returns \r
141     { return min_ch_val[channel]; }        // the minimum value of that channel, \r
142                                            // starting from which the pixel\r
143                                            // is counted during histogram calculation.\r
144     \r
145     int     get_max_ch_val( int channel )  // Get maximum channel value.\r
146     { return max_ch_val[channel]; }\r
147     \r
148     \r
149     // Background differencing parameters\r
150     \r
151     // set- properties\r
152     // Object characteristics\r
153     bool    set_window( CvRect _window) // set initial bounding rectangle for the object\r
154     { window = _window; return true; }\r
155     \r
156     // Tracking parameters\r
157     bool    set_threshold( int _threshold ) // threshold level that applied \r
158     { threshold = _threshold; return true; }\r
159 \r
160     // to back project.\r
161     bool    set_hist_dims( int c_dims, int* dims );// histogram dimensions.\r
162     \r
163     bool    set_min_ch_val( int channel, int val ) // Given channel index, sets \r
164     { min_ch_val[channel] = val; return true; }    // the minimum value of that channel, \r
165                                                    // starting from which the pixel\r
166                                                    // is counted during histogram calculation.\r
167     \r
168     bool    set_max_ch_val( int channel, int val ) // Set maximum value for the channel.\r
169     { max_ch_val[channel] = val; return true; }\r
170 \r
171     bool    set_thresh( int channel, int min, int max );\r
172     \r
173     bool    set_hist_mapping( int* /*channels*/ )\r
174     { return 0; }\r
175     // selects the channels from\r
176     // resulting image \r
177     // (before histogram/back prj calculation)\r
178     // for using them in histogram/back prj\r
179     // calculation. \r
180     // That is, channel #(channels[0]) is \r
181     // corresponds to first histogram \r
182     // dimension, channel #(channels[1])\r
183     // to 2nd etc.\r
184     \r
185     // Backgournd differencing ...\r
186     \r
187     // can be used (and overrided) if histogram is built from several frames\r
188     virtual void  reset_histogram() { cvClearHist( hist ); }\r
189     \r
190     // main pipeline for object tracking \r
191     virtual void  track_object( CvImage* src_image )\r
192     {\r
193         trackobj_find( calc_back_project( trackobj_post_color(\r
194             trackobj_color_transform( trackobj_pre_color( src_image )))));\r
195     }\r
196     \r
197     // main pipeline for histogram calculation\r
198     virtual void update_histogram( CvImage* src_image )\r
199     {\r
200         calc_histogram( hist_post_color(\r
201             hist_color_transform( hist_pre_color( src_image ))));\r
202     }\r
203 \r
204 \r
205     virtual CvImage* get_back_project()\r
206     { return &calc_back_project_image; }\r
207 \r
208 \r
209     virtual int get_shift_parameter()\r
210     { return shift; }\r
211 \r
212 \r
213     virtual bool set_shift_parameter(int _shift)\r
214     { shift = _shift; return true; }\r
215 \r
216 \r
217     virtual int query( int bin )\r
218     { return cvRound(cvQueryHistValue_1D( hist, bin )); }\r
219     \r
220 protected:\r
221     typedef CvHistogram  hist_type;\r
222 \r
223     hist_type* hist;\r
224 \r
225     float      orientation;\r
226     float      width;\r
227     float      length;\r
228     CvRect     window;\r
229 \r
230     int        min_ch_val[6];\r
231     int        max_ch_val[6];\r
232 \r
233     int        shift;\r
234 \r
235     float*     thresh[CvImageGroup::max_count];\r
236     float      thresh_buf[CvImageGroup::max_count*2];\r
237     int        threshold;\r
238 \r
239     CvImageGroup   color_transform_image_group;\r
240     CvImage        trackobj_pre_color_image;\r
241     CvImage        calc_back_project_image;\r
242     \r
243     // Internal pipeline functions\r
244     \r
245     // Common\r
246     \r
247     // common color transform\r
248     virtual CvImageGroup* color_transform( CvImage* src_image );\r
249     \r
250     // Specific for object tracking\r
251     // preprocessing before color transformation\r
252     virtual CvImage* trackobj_pre_color( CvImage* src_image );\r
253     \r
254     // color transformation. do common transform by default\r
255     virtual CvImageGroup* trackobj_color_transform( CvImage* src_image )\r
256     { return color_transform( src_image ); }\r
257     \r
258     // postprocessing after color transformation before back project\r
259     virtual CvImageGroup* trackobj_post_color( CvImageGroup* src_image );\r
260     \r
261     // calculation of back project\r
262     virtual CvImage* calc_back_project( CvImageGroup* src_image );\r
263     \r
264     // apply camshift algorithm to calculate object parameters\r
265     virtual void  trackobj_find( CvImage* src_image );\r
266     \r
267     \r
268     // Specific for histogram calculation   \r
269     \r
270     // preprocessing before color transformation\r
271     virtual CvImage* hist_pre_color( CvImage* src_image )\r
272     { return trackobj_pre_color( src_image ); }\r
273 \r
274     // color transformation. do common transform by default\r
275     virtual CvImageGroup* hist_color_transform( CvImage* src_image )\r
276     { return color_transform( src_image ); }\r
277     \r
278     // postprocessing after color transformation before back project\r
279     virtual CvImageGroup* hist_post_color( CvImageGroup* src_image )\r
280     { return trackobj_post_color( src_image ); }\r
281     \r
282     // histogram calculation\r
283     virtual void calc_histogram( CvImageGroup* src_image );\r
284     \r
285     \r
286 };\r
287 \r
288 #endif /* __cplusplus */\r
289 \r
290 #endif /* _CV_HPP */\r
291 \r
292 \r
293 /* End of file. */\r