1 #ifndef KCF_HEADER_6565467831231
2 #define KCF_HEADER_6565467831231
4 #include <opencv2/opencv.hpp>
10 #include "complexmat.cuh"
11 #include "cuda_functions.cuh"
12 #include "cuda/cuda_error_check.cuh"
13 #include <cuda_runtime.h>
15 #include "complexmat.hpp"
20 #include "threadctx.hpp"
25 double cx, cy, w, h, a;
27 inline void scale(double factor)
35 inline void scale_x(double factor)
41 inline void scale_y(double factor)
47 inline cv::Rect get_rect()
49 return cv::Rect(int(cx-w/2.), int(cy-h/2.), int(w), int(h));
58 bool m_use_scale {false};
59 bool m_use_angle {true};
60 bool m_use_color {true};
62 bool m_use_multithreading {true};
64 bool m_use_multithreading {false};
66 bool m_use_subpixel_localization {true};
67 bool m_use_subgrid_scale {true};
68 bool m_use_cnfeat {true};
69 bool m_use_linearkernel {false};
71 bool m_use_big_batch {true};
73 bool m_use_big_batch {false};
76 bool m_use_cuda {true};
78 bool m_use_cuda {false};
82 padding ... extra area surrounding the target (1.5)
83 kernel_sigma ... gaussian kernel bandwidth (0.5)
84 lambda ... regularization (1e-4)
85 interp_factor ... linear interpolation factor for adaptation (0.02)
86 output_sigma_factor ... spatial bandwidth (proportional to target) (0.1)
87 cell_size ... hog cell size (4)
89 KCF_Tracker(double padding, double kernel_sigma, double lambda, double interp_factor, double output_sigma_factor, int cell_size);
93 // Init/re-init methods
94 void init(cv::Mat & img, const cv::Rect & bbox, int fit_size_x, int fit_size_y);
95 void setTrackerPose(BBox_c & bbox, cv::Mat & img, int fit_size_x, int fit_size_y);
96 void updateTrackerPosition(BBox_c & bbox);
98 // frame-to-frame object tracking
99 void track(cv::Mat & img);
106 bool p_resize_image = false;
107 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;
112 double p_floating_error = 0.0001;
114 double p_padding = 1.5;
115 double p_output_sigma_factor = 0.1;
116 double p_output_sigma;
117 double p_kernel_sigma = 0.5; //def = 0.5
118 double p_lambda = 1e-4; //regularization in learning step
119 double p_interp_factor = 0.02; //def = 0.02, linear interpolation factor for adaptation
120 int p_cell_size = 4; //4 for hog (= bin_size)
121 cv::Size p_windows_size;
122 int p_num_scales {7};
123 double p_scale_step = 1.02;
124 double p_current_scale = 1.;
125 double p_min_max_scale[2];
126 std::vector<double> p_scales;
127 int p_num_angles {5};
128 int p_current_angle = 0;
129 int p_angle_step = 10;
130 std::vector<double> p_angles;
134 int p_roi_height, p_roi_width;
136 std::list<std::unique_ptr<ThreadCtx>> p_threadctxs;
139 cv::Mat p_rot_labels;
140 DynMem p_rot_labels_data;
144 ComplexMat p_model_alphaf;
145 ComplexMat p_model_alphaf_num;
146 ComplexMat p_model_alphaf_den;
147 ComplexMat p_model_xf;
150 void scale_track(ThreadCtx & vars, cv::Mat & input_rgb, cv::Mat & input_gray, double scale);
151 cv::Mat get_subwindow(const cv::Mat & input, int cx, int cy, int size_x, int size_y, int angle);
152 cv::Mat gaussian_shaped_labels(double sigma, int dim1, int dim2);
153 void gaussian_correlation(struct ThreadCtx &vars, const ComplexMat & xf, const ComplexMat & yf, double sigma, bool auto_correlation = false);
154 cv::Mat circshift(const cv::Mat & patch, int x_rot, int y_rot);
155 cv::Mat cosine_window_function(int dim1, int dim2);
156 void get_features(cv::Mat & input_rgb, cv::Mat & input_gray, int cx, int cy, int size_x, int size_y, ThreadCtx & vars, double scale = 1., int angle = 0);
157 cv::Point2f sub_pixel_peak(cv::Point & max_loc, cv::Mat & response);
158 double sub_grid_scale(int index = -1);
162 #endif //KCF_HEADER_6565467831231