1 #ifndef KCF_HEADER_6565467831231
2 #define KCF_HEADER_6565467831231
4 #include <opencv2/opencv.hpp>
9 #include "complexmat.cuh"
10 #include "cuda_functions.cuh"
11 #include "cuda/cuda_error_check.cuh"
12 #include <cuda_runtime.h>
14 #include "complexmat.hpp"
19 #include "scale_vars.hpp"
25 inline void scale(double factor)
33 inline void scale_x(double factor)
39 inline void scale_y(double factor)
45 inline cv::Rect get_rect()
47 return cv::Rect(cx-w/2., cy-h/2., w, h);
56 bool m_use_scale {true};
57 bool m_use_color {true};
59 bool m_use_multithreading {true};
61 bool m_use_multithreading {false};
63 bool m_use_subpixel_localization {true};
64 bool m_use_subgrid_scale {true};
65 bool m_use_cnfeat {true};
66 bool m_use_linearkernel {false};
68 bool m_use_big_batch {true};
70 bool m_use_big_batch {false};
73 bool m_use_cuda {true};
75 bool m_use_cuda {false};
79 padding ... extra area surrounding the target (1.5)
80 kernel_sigma ... gaussian kernel bandwidth (0.5)
81 lambda ... regularization (1e-4)
82 interp_factor ... linear interpolation factor for adaptation (0.02)
83 output_sigma_factor ... spatial bandwidth (proportional to target) (0.1)
84 cell_size ... hog cell size (4)
86 KCF_Tracker(double padding, double kernel_sigma, double lambda, double interp_factor, double output_sigma_factor, int cell_size);
90 // Init/re-init methods
91 void init(cv::Mat & img, const cv::Rect & bbox, int fit_size_x, int fit_size_y);
92 void init_scale_vars();
93 void setTrackerPose(BBox_c & bbox, cv::Mat & img, int fit_size_x, int fit_size_y);
94 void updateTrackerPosition(BBox_c & bbox);
96 // frame-to-frame object tracking
97 void track(cv::Mat & img);
104 bool p_resize_image = false;
105 bool p_fit_to_pw2 = false;
109 const double p_downscale_factor = 0.5;
110 double p_scale_factor_x = 1;
111 double p_scale_factor_y = 1;
113 double p_padding = 1.5;
114 double p_output_sigma_factor = 0.1;
115 double p_output_sigma;
116 double p_kernel_sigma = 0.5; //def = 0.5
117 double p_lambda = 1e-4; //regularization in learning step
118 double p_interp_factor = 0.02; //def = 0.02, linear interpolation factor for adaptation
119 int p_cell_size = 4; //4 for hog (= bin_size)
120 int p_windows_size[2];
121 int p_num_scales {7};
122 double p_scale_step = 1.02;
123 double p_current_scale = 1.;
124 double p_min_max_scale[2];
125 std::vector<double> p_scales;
129 int p_roi_height, p_roi_width;
131 std::vector<Scale_vars> scale_vars;
135 ComplexMat p_model_alphaf;
136 ComplexMat p_model_alphaf_num;
137 ComplexMat p_model_alphaf_den;
138 ComplexMat p_model_xf;
140 void scale_track(Scale_vars & vars, cv::Mat & input_rgb, cv::Mat & input_gray, double scale);
141 cv::Mat get_subwindow(const cv::Mat & input, int cx, int cy, int size_x, int size_y);
142 cv::Mat gaussian_shaped_labels(double sigma, int dim1, int dim2);
143 void gaussian_correlation(struct Scale_vars &vars, const ComplexMat & xf, const ComplexMat & yf, double sigma, bool auto_correlation = false);
144 cv::Mat circshift(const cv::Mat & patch, int x_rot, int y_rot);
145 cv::Mat cosine_window_function(int dim1, int dim2);
146 void get_features(cv::Mat & input_rgb, cv::Mat & input_gray, int cx, int cy, int size_x, int size_y, Scale_vars & vars, double scale = 1.);
147 cv::Point2f sub_pixel_peak(cv::Point & max_loc, cv::Mat & response);
148 double sub_grid_scale(int index = -1);
152 #endif //KCF_HEADER_6565467831231