tracking.hpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef OPENCV_CONTRIB_TRACKING_HPP
  5. #define OPENCV_CONTRIB_TRACKING_HPP
  6. #include "opencv2/core.hpp"
  7. #include "opencv2/video/tracking.hpp"
  8. namespace cv {
  9. #ifndef CV_DOXYGEN
  10. inline namespace tracking {
  11. #endif
  12. /** @defgroup tracking Tracking API
  13. @{
  14. @defgroup tracking_detail Tracking API implementation details
  15. @defgroup tracking_legacy Legacy Tracking API
  16. @}
  17. */
  18. /** @addtogroup tracking
  19. @{
  20. Tracking is an important issue for many computer vision applications in real world scenario.
  21. The development in this area is very fragmented and this API is an interface useful for plug several algorithms and compare them.
  22. */
  23. /** @brief the CSRT tracker
  24. The implementation is based on @cite Lukezic_IJCV2018 Discriminative Correlation Filter with Channel and Spatial Reliability
  25. */
  26. class CV_EXPORTS_W TrackerCSRT : public Tracker
  27. {
  28. protected:
  29. TrackerCSRT(); // use ::create()
  30. public:
  31. virtual ~TrackerCSRT() CV_OVERRIDE;
  32. struct CV_EXPORTS_W_SIMPLE Params
  33. {
  34. CV_WRAP Params();
  35. CV_PROP_RW bool use_hog;
  36. CV_PROP_RW bool use_color_names;
  37. CV_PROP_RW bool use_gray;
  38. CV_PROP_RW bool use_rgb;
  39. CV_PROP_RW bool use_channel_weights;
  40. CV_PROP_RW bool use_segmentation;
  41. CV_PROP_RW std::string window_function; //!< Window function: "hann", "cheb", "kaiser"
  42. CV_PROP_RW float kaiser_alpha;
  43. CV_PROP_RW float cheb_attenuation;
  44. CV_PROP_RW float template_size;
  45. CV_PROP_RW float gsl_sigma;
  46. CV_PROP_RW float hog_orientations;
  47. CV_PROP_RW float hog_clip;
  48. CV_PROP_RW float padding;
  49. CV_PROP_RW float filter_lr;
  50. CV_PROP_RW float weights_lr;
  51. CV_PROP_RW int num_hog_channels_used;
  52. CV_PROP_RW int admm_iterations;
  53. CV_PROP_RW int histogram_bins;
  54. CV_PROP_RW float histogram_lr;
  55. CV_PROP_RW int background_ratio;
  56. CV_PROP_RW int number_of_scales;
  57. CV_PROP_RW float scale_sigma_factor;
  58. CV_PROP_RW float scale_model_max_area;
  59. CV_PROP_RW float scale_lr;
  60. CV_PROP_RW float scale_step;
  61. CV_PROP_RW float psr_threshold; //!< we lost the target, if the psr is lower than this.
  62. };
  63. /** @brief Create CSRT tracker instance
  64. @param parameters CSRT parameters TrackerCSRT::Params
  65. */
  66. static CV_WRAP
  67. Ptr<TrackerCSRT> create(const TrackerCSRT::Params &parameters = TrackerCSRT::Params());
  68. //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE;
  69. //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE;
  70. CV_WRAP virtual void setInitialMask(InputArray mask) = 0;
  71. };
  72. /** @brief the KCF (Kernelized Correlation Filter) tracker
  73. * KCF is a novel tracking framework that utilizes properties of circulant matrix to enhance the processing speed.
  74. * This tracking method is an implementation of @cite KCF_ECCV which is extended to KCF with color-names features (@cite KCF_CN).
  75. * The original paper of KCF is available at <http://www.robots.ox.ac.uk/~joao/publications/henriques_tpami2015.pdf>
  76. * as well as the matlab implementation. For more information about KCF with color-names features, please refer to
  77. * <http://www.cvl.isy.liu.se/research/objrec/visualtracking/colvistrack/index.html>.
  78. */
  79. class CV_EXPORTS_W TrackerKCF : public Tracker
  80. {
  81. protected:
  82. TrackerKCF(); // use ::create()
  83. public:
  84. virtual ~TrackerKCF() CV_OVERRIDE;
  85. /**
  86. * \brief Feature type to be used in the tracking grayscale, colornames, compressed color-names
  87. * The modes available now:
  88. - "GRAY" -- Use grayscale values as the feature
  89. - "CN" -- Color-names feature
  90. */
  91. enum MODE {
  92. GRAY = (1 << 0),
  93. CN = (1 << 1),
  94. CUSTOM = (1 << 2)
  95. };
  96. struct CV_EXPORTS_W_SIMPLE Params
  97. {
  98. CV_WRAP Params();
  99. CV_PROP_RW float detect_thresh; //!< detection confidence threshold
  100. CV_PROP_RW float sigma; //!< gaussian kernel bandwidth
  101. CV_PROP_RW float lambda; //!< regularization
  102. CV_PROP_RW float interp_factor; //!< linear interpolation factor for adaptation
  103. CV_PROP_RW float output_sigma_factor; //!< spatial bandwidth (proportional to target)
  104. CV_PROP_RW float pca_learning_rate; //!< compression learning rate
  105. CV_PROP_RW bool resize; //!< activate the resize feature to improve the processing speed
  106. CV_PROP_RW bool split_coeff; //!< split the training coefficients into two matrices
  107. CV_PROP_RW bool wrap_kernel; //!< wrap around the kernel values
  108. CV_PROP_RW bool compress_feature; //!< activate the pca method to compress the features
  109. CV_PROP_RW int max_patch_size; //!< threshold for the ROI size
  110. CV_PROP_RW int compressed_size; //!< feature size after compression
  111. CV_PROP_RW int desc_pca; //!< compressed descriptors of TrackerKCF::MODE
  112. CV_PROP_RW int desc_npca; //!< non-compressed descriptors of TrackerKCF::MODE
  113. };
  114. /** @brief Create KCF tracker instance
  115. @param parameters KCF parameters TrackerKCF::Params
  116. */
  117. static CV_WRAP
  118. Ptr<TrackerKCF> create(const TrackerKCF::Params &parameters = TrackerKCF::Params());
  119. //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE;
  120. //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE;
  121. // FIXIT use interface
  122. typedef void (*FeatureExtractorCallbackFN)(const Mat, const Rect, Mat&);
  123. virtual void setFeatureExtractor(FeatureExtractorCallbackFN callback, bool pca_func = false) = 0;
  124. };
  125. //! @}
  126. #ifndef CV_DOXYGEN
  127. }
  128. #endif
  129. } // namespace
  130. #endif // OPENCV_CONTRIB_TRACKING_HPP