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.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
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.
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.
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.
47 /****************************************************************************************\
49 \****************************************************************************************/
51 class CV_EXPORTS CvCamShiftTracker
56 virtual ~CvCamShiftTracker();
58 /**** Characteristics of the object that are calculated by track_object method *****/
59 float get_orientation() const // orientation of the object in degrees
60 { return m_box.angle; }
61 float get_length() const // the larger linear size of the object
62 { return m_box.size.height; }
63 float get_width() const // the smaller linear size of the object
64 { return m_box.size.width; }
65 CvPoint2D32f get_center() const // center of the object
66 { return m_box.center; }
67 CvRect get_window() const // bounding rectangle for the object
68 { return m_comp.rect; }
70 /*********************** Tracking parameters ************************/
71 int get_threshold() const // thresholding value that applied to back project
72 { return m_threshold; }
74 int get_hist_dims( int* dims = 0 ) const // returns number of histogram dimensions and sets
75 { return m_hist ? cvGetDims( m_hist->bins, dims ) : 0; }
77 int get_min_ch_val( int channel ) const // get the minimum allowed value of the specified channel
78 { return m_min_ch_val[channel]; }
80 int get_max_ch_val( int channel ) const // get the maximum allowed value of the specified channel
81 { return m_max_ch_val[channel]; }
83 // set initial object rectangle (must be called before initial calculation of the histogram)
84 bool set_window( CvRect window)
85 { m_comp.rect = window; return true; }
87 bool set_threshold( int threshold ) // threshold applied to the histogram bins
88 { m_threshold = threshold; return true; }
90 bool set_hist_bin_range( int dim, int min_val, int max_val );
92 bool set_hist_dims( int c_dims, int* dims );// set the histogram parameters
94 bool set_min_ch_val( int channel, int val ) // set the minimum allowed value of the specified channel
95 { m_min_ch_val[channel] = val; return true; }
96 bool set_max_ch_val( int channel, int val ) // set the maximum allowed value of the specified channel
97 { m_max_ch_val[channel] = val; return true; }
99 /************************ The processing methods *********************************/
100 // update object position
101 virtual bool track_object( const IplImage* cur_frame );
103 // update object histogram
104 virtual bool update_histogram( const IplImage* cur_frame );
107 virtual void reset_histogram();
109 /************************ Retrieving internal data *******************************/
110 // get back project image
111 virtual IplImage* get_back_project()
112 { return m_back_project; }
114 float query( int* bin ) const
115 { return m_hist ? (float)cvGetRealND(m_hist->bins, bin) : 0.f; }
119 // internal method for color conversion: fills m_color_planes group
120 virtual void color_transform( const IplImage* img );
125 CvConnectedComp m_comp;
127 float m_hist_ranges_data[CV_MAX_DIM][2];
128 float* m_hist_ranges[CV_MAX_DIM];
130 int m_min_ch_val[CV_MAX_DIM];
131 int m_max_ch_val[CV_MAX_DIM];
134 IplImage* m_color_planes[CV_MAX_DIM];
135 IplImage* m_back_project;
140 #endif /* __cplusplus */
142 #endif /* __CVAUX_HPP__ */