cvaux.hpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. // Intel License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000, Intel Corporation, all rights reserved.
  14. // Third party copyrights are property of their respective owners.
  15. //
  16. // Redistribution and use in source and binary forms, with or without modification,
  17. // are permitted provided that the following conditions are met:
  18. //
  19. // * Redistribution's of source code must retain the above copyright notice,
  20. // this list of conditions and the following disclaimer.
  21. //
  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.
  25. //
  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.
  28. //
  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.
  39. //
  40. //M*/
  41. #ifndef __CVAUX_HPP__
  42. #define __CVAUX_HPP__
  43. #ifdef __cplusplus
  44. /****************************************************************************************\
  45. * Image class *
  46. \****************************************************************************************/
  47. class CV_EXPORTS CvCamShiftTracker
  48. {
  49. public:
  50. CvCamShiftTracker();
  51. virtual ~CvCamShiftTracker();
  52. /**** Characteristics of the object that are calculated by track_object method *****/
  53. float get_orientation() const // orientation of the object in degrees
  54. { return m_box.angle; }
  55. float get_length() const // the larger linear size of the object
  56. { return m_box.size.height; }
  57. float get_width() const // the smaller linear size of the object
  58. { return m_box.size.width; }
  59. CvPoint2D32f get_center() const // center of the object
  60. { return m_box.center; }
  61. CvRect get_window() const // bounding rectangle for the object
  62. { return m_comp.rect; }
  63. /*********************** Tracking parameters ************************/
  64. int get_threshold() const // thresholding value that applied to back project
  65. { return m_threshold; }
  66. int get_hist_dims( int* dims = 0 ) const // returns number of histogram dimensions and sets
  67. { return m_hist ? cvGetDims( m_hist->bins, dims ) : 0; }
  68. int get_min_ch_val( int channel ) const // get the minimum allowed value of the specified channel
  69. { return m_min_ch_val[channel]; }
  70. int get_max_ch_val( int channel ) const // get the maximum allowed value of the specified channel
  71. { return m_max_ch_val[channel]; }
  72. // set initial object rectangle (must be called before initial calculation of the histogram)
  73. bool set_window( CvRect window)
  74. { m_comp.rect = window; return true; }
  75. bool set_threshold( int threshold ) // threshold applied to the histogram bins
  76. { m_threshold = threshold; return true; }
  77. bool set_hist_bin_range( int dim, int min_val, int max_val );
  78. bool set_hist_dims( int c_dims, int* dims );// set the histogram parameters
  79. bool set_min_ch_val( int channel, int val ) // set the minimum allowed value of the specified channel
  80. { m_min_ch_val[channel] = val; return true; }
  81. bool set_max_ch_val( int channel, int val ) // set the maximum allowed value of the specified channel
  82. { m_max_ch_val[channel] = val; return true; }
  83. /************************ The processing methods *********************************/
  84. // update object position
  85. virtual bool track_object( const IplImage* cur_frame );
  86. // update object histogram
  87. virtual bool update_histogram( const IplImage* cur_frame );
  88. // reset histogram
  89. virtual void reset_histogram();
  90. /************************ Retrieving internal data *******************************/
  91. // get back project image
  92. virtual IplImage* get_back_project()
  93. { return m_back_project; }
  94. float query( int* bin ) const
  95. { return m_hist ? cvQueryHistValue_nD( m_hist, bin ) : 0.f; }
  96. protected:
  97. // internal method for color conversion: fills m_color_planes group
  98. virtual void color_transform( const IplImage* img );
  99. CvHistogram* m_hist;
  100. CvBox2D m_box;
  101. CvConnectedComp m_comp;
  102. float m_hist_ranges_data[CV_MAX_DIM][2];
  103. float* m_hist_ranges[CV_MAX_DIM];
  104. int m_min_ch_val[CV_MAX_DIM];
  105. int m_max_ch_val[CV_MAX_DIM];
  106. int m_threshold;
  107. IplImage* m_color_planes[CV_MAX_DIM];
  108. IplImage* m_back_project;
  109. IplImage* m_temp;
  110. IplImage* m_mask;
  111. };
  112. #endif /* __cplusplus */
  113. #endif /* __CVAUX_HPP__ */
  114. /* End of file. */