-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-//#ifdef WIN32\r
-\r
-#ifndef _CV_HPP_\r
-#define _CV_HPP_\r
-\r
-#include "cv.h"\r
-\r
-#ifdef __cplusplus\r
-\r
-/****************************************************************************************\\r
-* Image class *\r
-\****************************************************************************************/\r
-\r
-struct CV_DLL_ENTRY CvImage : public IplImage\r
-{\r
- CvImage();\r
- CvImage( CvSize size, int depth, int channels );\r
- ~CvImage();\r
-\r
- uchar* image_data();\r
- const uchar* image_data() const;\r
-\r
- CvSize image_roi_size() const;\r
- int byte_per_pixel() const;\r
-\r
- CvImage& operator = ( const CvImage& another )\r
- { return copy( another ); }\r
- \r
- CvImage& copy( const CvImage& another );\r
-};\r
-\r
-\r
-class CV_DLL_ENTRY CvImageGroup\r
-{\r
-public:\r
- enum{ max_count = 7 };\r
- \r
- CvImageGroup( int _count = 0 )\r
- { assert( _count < max_count ); clear(); operator=(_count); }\r
-\r
-\r
- ~CvImageGroup() { destroy(); }\r
- \r
- CvImage& operator[]( int count ) { return (CvImage&)*image[count]; }\r
-\r
- CvImageGroup& operator=( const CvImageGroup& another )\r
- { return copy( another ); }\r
-\r
- CvImageGroup& operator=( const CvImage& another )\r
- { return copy( another ); }\r
-\r
- CvImageGroup& copy( const CvImageGroup& another );\r
-\r
- CvImageGroup& copy( const CvImage& another );\r
- CvImageGroup& operator=( int _count );\r
-\r
- int get_count() const { return count; }\r
-\r
- void destroy();\r
- void clear() { for( int i = 0; i < max_count; i++ ) image[i] = 0; }\r
- IplImage** get_group() { return &image[0]; };\r
-\r
-protected:\r
- int count;\r
- IplImage* image[max_count];\r
-};\r
-\r
-\r
-class CV_DLL_ENTRY CvCamShiftTracker\r
-{\r
-public:\r
- \r
- // constructor\r
- CvCamShiftTracker();\r
- // destructor\r
- virtual ~CvCamShiftTracker();\r
- \r
- // get- properties\r
- \r
- // Characteristics of the object, \r
- // which are calculated by track_object method\r
- float get_orientation() // orientation of the object in degrees \r
- { return orientation; }\r
- float get_length() // the larger linear size of the object\r
- { return length; }\r
- float get_width() // the smaller linear size of the object\r
- { return width; }\r
- CvRect get_window() // bounding rectangle for the object\r
- { return window; }\r
- \r
- // Tracking parameters\r
- int get_threshold() // thresholding value that applied to back project\r
- { return threshold; }\r
- int get_hist_dims( int* dims = 0 ); // returns number of histogram dimensions and sets\r
- // dims[0] to number of bins on 1st dimension,\r
- // dims[1] -||- on 2nd dimension etc. \r
- // (if dims pointer is not 0).\r
- \r
- int get_min_ch_val( int channel ) // Given channel index, returns \r
- { return min_ch_val[channel]; } // the minimum value of that channel, \r
- // starting from which the pixel\r
- // is counted during histogram calculation.\r
- \r
- int get_max_ch_val( int channel ) // Get maximum channel value.\r
- { return max_ch_val[channel]; }\r
- \r
- \r
- // Background differencing parameters\r
- \r
- // set- properties\r
- // Object characteristics\r
- bool set_window( CvRect _window) // set initial bounding rectangle for the object\r
- { window = _window; return true; }\r
- \r
- // Tracking parameters\r
- bool set_threshold( int _threshold ) // threshold level that applied \r
- { threshold = _threshold; return true; }\r
-\r
- // to back project.\r
- bool set_hist_dims( int c_dims, int* dims );// histogram dimensions.\r
- \r
- bool set_min_ch_val( int channel, int val ) // Given channel index, sets \r
- { min_ch_val[channel] = val; return true; } // the minimum value of that channel, \r
- // starting from which the pixel\r
- // is counted during histogram calculation.\r
- \r
- bool set_max_ch_val( int channel, int val ) // Set maximum value for the channel.\r
- { max_ch_val[channel] = val; return true; }\r
-\r
- bool set_thresh( int channel, int min, int max );\r
- \r
- bool set_hist_mapping( int* /*channels*/ )\r
- { return 0; }\r
- // selects the channels from\r
- // resulting image \r
- // (before histogram/back prj calculation)\r
- // for using them in histogram/back prj\r
- // calculation. \r
- // That is, channel #(channels[0]) is \r
- // corresponds to first histogram \r
- // dimension, channel #(channels[1])\r
- // to 2nd etc.\r
- \r
- // Backgournd differencing ...\r
- \r
- // can be used (and overrided) if histogram is built from several frames\r
- virtual void reset_histogram() { cvClearHist( hist ); }\r
- \r
- // main pipeline for object tracking \r
- virtual void track_object( CvImage* src_image )\r
- {\r
- trackobj_find( calc_back_project( trackobj_post_color(\r
- trackobj_color_transform( trackobj_pre_color( src_image )))));\r
- }\r
- \r
- // main pipeline for histogram calculation\r
- virtual void update_histogram( CvImage* src_image )\r
- {\r
- calc_histogram( hist_post_color(\r
- hist_color_transform( hist_pre_color( src_image ))));\r
- }\r
-\r
-\r
- virtual CvImage* get_back_project()\r
- { return &calc_back_project_image; }\r
-\r
-\r
- virtual int get_shift_parameter()\r
- { return shift; }\r
-\r
-\r
- virtual bool set_shift_parameter(int _shift)\r
- { shift = _shift; return true; }\r
-\r
-\r
- virtual int query( int bin )\r
- { return cvRound(cvQueryHistValue_1D( hist, bin )); }\r
- \r
-protected:\r
- typedef CvHistogram hist_type;\r
-\r
- hist_type* hist;\r
-\r
- float orientation;\r
- float width;\r
- float length;\r
- CvRect window;\r
-\r
- int min_ch_val[6];\r
- int max_ch_val[6];\r
-\r
- int shift;\r
-\r
- float* thresh[CvImageGroup::max_count];\r
- float thresh_buf[CvImageGroup::max_count*2];\r
- int threshold;\r
-\r
- CvImageGroup color_transform_image_group;\r
- CvImage trackobj_pre_color_image;\r
- CvImage calc_back_project_image;\r
- \r
- // Internal pipeline functions\r
- \r
- // Common\r
- \r
- // common color transform\r
- virtual CvImageGroup* color_transform( CvImage* src_image );\r
- \r
- // Specific for object tracking\r
- // preprocessing before color transformation\r
- virtual CvImage* trackobj_pre_color( CvImage* src_image );\r
- \r
- // color transformation. do common transform by default\r
- virtual CvImageGroup* trackobj_color_transform( CvImage* src_image )\r
- { return color_transform( src_image ); }\r
- \r
- // postprocessing after color transformation before back project\r
- virtual CvImageGroup* trackobj_post_color( CvImageGroup* src_image );\r
- \r
- // calculation of back project\r
- virtual CvImage* calc_back_project( CvImageGroup* src_image );\r
- \r
- // apply camshift algorithm to calculate object parameters\r
- virtual void trackobj_find( CvImage* src_image );\r
- \r
- \r
- // Specific for histogram calculation \r
- \r
- // preprocessing before color transformation\r
- virtual CvImage* hist_pre_color( CvImage* src_image )\r
- { return trackobj_pre_color( src_image ); }\r
-\r
- // color transformation. do common transform by default\r
- virtual CvImageGroup* hist_color_transform( CvImage* src_image )\r
- { return color_transform( src_image ); }\r
- \r
- // postprocessing after color transformation before back project\r
- virtual CvImageGroup* hist_post_color( CvImageGroup* src_image )\r
- { return trackobj_post_color( src_image ); }\r
- \r
- // histogram calculation\r
- virtual void calc_histogram( CvImageGroup* src_image );\r
- \r
- \r
-};\r
-\r
-#endif /* __cplusplus */\r
-\r
-#endif /* _CV_HPP */\r
-\r
-\r
-/* End of file. */\r
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+//#ifdef WIN32
+
+#ifndef _CV_HPP_
+#define _CV_HPP_
+
+#include "cv.h"
+
+#ifdef __cplusplus
+
+/****************************************************************************************\
+* Image class *
+\****************************************************************************************/
+
+struct CV_DLL_ENTRY CvImage : public IplImage
+{
+ CvImage();
+ CvImage( CvSize size, int depth, int channels );
+ ~CvImage();
+
+ uchar* image_data();
+ const uchar* image_data() const;
+
+ CvSize image_roi_size() const;
+ int byte_per_pixel() const;
+
+ CvImage& operator = ( const CvImage& another )
+ { return copy( another ); }
+
+ CvImage& copy( const CvImage& another );
+};
+
+
+class CV_DLL_ENTRY CvImageGroup
+{
+public:
+ enum{ max_count = 7 };
+
+ CvImageGroup( int _count = 0 )
+ { assert( _count < max_count ); clear(); operator=(_count); }
+
+
+ ~CvImageGroup() { destroy(); }
+
+ CvImage& operator[]( int count ) { return (CvImage&)*image[count]; }
+
+ CvImageGroup& operator=( const CvImageGroup& another )
+ { return copy( another ); }
+
+ CvImageGroup& operator=( const CvImage& another )
+ { return copy( another ); }
+
+ CvImageGroup& copy( const CvImageGroup& another );
+
+ CvImageGroup& copy( const CvImage& another );
+ CvImageGroup& operator=( int _count );
+
+ int get_count() const { return count; }
+
+ void destroy();
+ void clear() { for( int i = 0; i < max_count; i++ ) image[i] = 0; }
+ IplImage** get_group() { return &image[0]; };
+
+protected:
+ int count;
+ IplImage* image[max_count];
+};
+
+
+class CV_DLL_ENTRY CvCamShiftTracker
+{
+public:
+
+ // constructor
+ CvCamShiftTracker();
+ // destructor
+ virtual ~CvCamShiftTracker();
+
+ // get- properties
+
+ // Characteristics of the object,
+ // which are calculated by track_object method
+ float get_orientation() // orientation of the object in degrees
+ { return orientation; }
+ float get_length() // the larger linear size of the object
+ { return length; }
+ float get_width() // the smaller linear size of the object
+ { return width; }
+ CvRect get_window() // bounding rectangle for the object
+ { return window; }
+
+ // Tracking parameters
+ int get_threshold() // thresholding value that applied to back project
+ { return threshold; }
+ int get_hist_dims( int* dims = 0 ); // returns number of histogram dimensions and sets
+ // dims[0] to number of bins on 1st dimension,
+ // dims[1] -||- on 2nd dimension etc.
+ // (if dims pointer is not 0).
+
+ int get_min_ch_val( int channel ) // Given channel index, returns
+ { return min_ch_val[channel]; } // the minimum value of that channel,
+ // starting from which the pixel
+ // is counted during histogram calculation.
+
+ int get_max_ch_val( int channel ) // Get maximum channel value.
+ { return max_ch_val[channel]; }
+
+
+ // Background differencing parameters
+
+ // set- properties
+ // Object characteristics
+ bool set_window( CvRect _window) // set initial bounding rectangle for the object
+ { window = _window; return true; }
+
+ // Tracking parameters
+ bool set_threshold( int _threshold ) // threshold level that applied
+ { threshold = _threshold; return true; }
+
+ // to back project.
+ bool set_hist_dims( int c_dims, int* dims );// histogram dimensions.
+
+ bool set_min_ch_val( int channel, int val ) // Given channel index, sets
+ { min_ch_val[channel] = val; return true; } // the minimum value of that channel,
+ // starting from which the pixel
+ // is counted during histogram calculation.
+
+ bool set_max_ch_val( int channel, int val ) // Set maximum value for the channel.
+ { max_ch_val[channel] = val; return true; }
+
+ bool set_thresh( int channel, int min, int max );
+
+ bool set_hist_mapping( int* /*channels*/ )
+ { return 0; }
+ // selects the channels from
+ // resulting image
+ // (before histogram/back prj calculation)
+ // for using them in histogram/back prj
+ // calculation.
+ // That is, channel #(channels[0]) is
+ // corresponds to first histogram
+ // dimension, channel #(channels[1])
+ // to 2nd etc.
+
+ // Backgournd differencing ...
+
+ // can be used (and overrided) if histogram is built from several frames
+ virtual void reset_histogram() { cvClearHist( hist ); }
+
+ // main pipeline for object tracking
+ virtual void track_object( CvImage* src_image )
+ {
+ trackobj_find( calc_back_project( trackobj_post_color(
+ trackobj_color_transform( trackobj_pre_color( src_image )))));
+ }
+
+ // main pipeline for histogram calculation
+ virtual void update_histogram( CvImage* src_image )
+ {
+ calc_histogram( hist_post_color(
+ hist_color_transform( hist_pre_color( src_image ))));
+ }
+
+
+ virtual CvImage* get_back_project()
+ { return &calc_back_project_image; }
+
+
+ virtual int get_shift_parameter()
+ { return shift; }
+
+
+ virtual bool set_shift_parameter(int _shift)
+ { shift = _shift; return true; }
+
+
+ virtual int query( int bin )
+ { return cvRound(cvQueryHistValue_1D( hist, bin )); }
+
+protected:
+ typedef CvHistogram hist_type;
+
+ hist_type* hist;
+
+ float orientation;
+ float width;
+ float length;
+ CvRect window;
+
+ int min_ch_val[6];
+ int max_ch_val[6];
+
+ int shift;
+
+ float* thresh[CvImageGroup::max_count];
+ float thresh_buf[CvImageGroup::max_count*2];
+ int threshold;
+
+ CvImageGroup color_transform_image_group;
+ CvImage trackobj_pre_color_image;
+ CvImage calc_back_project_image;
+
+ // Internal pipeline functions
+
+ // Common
+
+ // common color transform
+ virtual CvImageGroup* color_transform( CvImage* src_image );
+
+ // Specific for object tracking
+ // preprocessing before color transformation
+ virtual CvImage* trackobj_pre_color( CvImage* src_image );
+
+ // color transformation. do common transform by default
+ virtual CvImageGroup* trackobj_color_transform( CvImage* src_image )
+ { return color_transform( src_image ); }
+
+ // postprocessing after color transformation before back project
+ virtual CvImageGroup* trackobj_post_color( CvImageGroup* src_image );
+
+ // calculation of back project
+ virtual CvImage* calc_back_project( CvImageGroup* src_image );
+
+ // apply camshift algorithm to calculate object parameters
+ virtual void trackobj_find( CvImage* src_image );
+
+
+ // Specific for histogram calculation
+
+ // preprocessing before color transformation
+ virtual CvImage* hist_pre_color( CvImage* src_image )
+ { return trackobj_pre_color( src_image ); }
+
+ // color transformation. do common transform by default
+ virtual CvImageGroup* hist_color_transform( CvImage* src_image )
+ { return color_transform( src_image ); }
+
+ // postprocessing after color transformation before back project
+ virtual CvImageGroup* hist_post_color( CvImageGroup* src_image )
+ { return trackobj_post_color( src_image ); }
+
+ // histogram calculation
+ virtual void calc_histogram( CvImageGroup* src_image );
+
+
+};
+
+#endif /* __cplusplus */
+
+#endif /* _CV_HPP */
+
+
+/* End of file. */