]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blobdiff - src/kcf.h
Implement sub-gird angle estimation
[hercules2020/kcf.git] / src / kcf.h
index 70662d7920ea7849038ea5bfef9aa5a91227c8d3..18f132d76215a9bf608ffe879b4d2a85b596d006 100644 (file)
--- a/src/kcf.h
+++ b/src/kcf.h
@@ -43,13 +43,15 @@ struct BBox_c
 class KCF_Tracker
 {
     friend ThreadCtx;
+    friend Kcf_Tracker_Private;
 public:
     bool m_debug {false};
-    bool m_visual_debug {false};
+    enum class vd {NONE, PATCH, RESPONSE} m_visual_debug {vd::NONE};
     const bool m_use_scale {true};
     const bool m_use_color {true};
     const bool m_use_subpixel_localization {true};
     const bool m_use_subgrid_scale {true};
+    const bool m_use_subgrid_angle {true};
     const bool m_use_cnfeat {true};
     const bool m_use_linearkernel {false};
     const int p_cell_size = 4;            //4 for hog (= bin_size)
@@ -86,6 +88,7 @@ private:
     // Information to calculate current pose of the tracked object
     cv::Point2d p_current_center;
     double p_current_scale = 1.;
+    double p_current_angle = 0.;
 
     double max_response = -1.;
 
@@ -103,19 +106,19 @@ private:
     cv::Size p_windows_size;              // size of the patch to find the tracked object in
     cv::Size fit_size;                    // size to which rescale the patch for better FFT performance
 
-    const uint p_num_scales = m_use_scale ? 7 : 1;
-    const double p_scale_step = 1.02;
+    const uint p_num_scales = m_use_scale ? 5 : 1;
+    const double p_scale_step = 1.03;
     double p_min_max_scale[2];
     std::vector<double> p_scales;
 
-    const uint p_num_angles = 1;
+    const uint p_num_angles = 3;
     const int p_angle_step = 10;
     std::vector<double> p_angles;
 
     const int p_num_of_feats = 31 + (m_use_color ? 3 : 0) + (m_use_cnfeat ? 10 : 0);
     cv::Size feature_size;
 
-    Kcf_Tracker_Private &d;
+    std::unique_ptr<Kcf_Tracker_Private> d;
 
     class Model {
         cv::Size feature_size;
@@ -163,17 +166,18 @@ private:
 
     //helping functions
     void scale_track(ThreadCtx &vars, cv::Mat &input_rgb, cv::Mat &input_gray);
-    cv::Mat get_subwindow(const cv::Mat &input, int cx, int cy, int size_x, int size_y) const;
+    cv::Mat get_subwindow(const cv::Mat &input, int cx, int cy, int size_x, int size_y, double angle) const;
     cv::Mat gaussian_shaped_labels(double sigma, int dim1, int dim2);
     std::unique_ptr<GaussianCorrelation> gaussian_correlation;
     cv::Mat circshift(const cv::Mat &patch, int x_rot, int y_rot) const;
     cv::Mat cosine_window_function(int dim1, int dim2);
-    cv::Mat get_features(cv::Mat &input_rgb, cv::Mat &input_gray, cv::Mat *dbg_patch, int cx, int cy, int size_x, int size_y, double scale) const;
+    cv::Mat get_features(cv::Mat &input_rgb, cv::Mat &input_gray, cv::Mat *dbg_patch, int cx, int cy, int size_x, int size_y, double scale, double angle) const;
     cv::Point2f sub_pixel_peak(cv::Point &max_loc, cv::Mat &response) const;
     double sub_grid_scale(uint index);
     void resizeImgs(cv::Mat &input_rgb, cv::Mat &input_gray);
     void train(cv::Mat input_rgb, cv::Mat input_gray, double interp_factor);
     double findMaxReponse(uint &max_idx, cv::Point2d &new_location) const;
+    double sub_grid_angle(uint max_index);
 };
 
 #endif //KCF_HEADER_6565467831231