9 #include "complexmat.cuh"
11 #include "complexmat.hpp"
18 ThreadCtx(cv::Size roi, uint num_of_feats, double scale, uint num_of_scales)
22 uint cells_size = roi.width * roi.height * sizeof(float);
24 #if defined(CUFFT) || defined(FFTW)
25 this->gauss_corr_res = DynMem(cells_size * num_of_scales);
26 this->data_features = DynMem(cells_size * num_of_feats);
28 uint width_freq = roi.width / 2 + 1;
30 this->in_all = cv::Mat(roi.height * num_of_scales, roi.width, CV_32F, this->gauss_corr_res.hostMem());
31 this->fw_all = cv::Mat(roi.height * num_of_feats, roi.width, CV_32F, this->data_features.hostMem());
33 uint width_freq = roi.width;
35 this->in_all = cv::Mat(roi, CV_32F);
38 this->data_i_features = DynMem(cells_size * num_of_feats);
39 this->data_i_1ch = DynMem(cells_size * num_of_scales);
41 this->ifft2_res = cv::Mat(roi, CV_32FC(num_of_feats), this->data_i_features.hostMem());
42 this->response = cv::Mat(roi, CV_32FC(num_of_scales), this->data_i_1ch.hostMem());
45 this->zf.create(roi.height, width_freq, num_of_feats, num_of_scales);
46 this->kzf.create(roi.height, width_freq, num_of_scales);
47 this->kf.create(roi.height, width_freq, num_of_scales);
49 this->zf.create(roi.height, width_freq, num_of_feats, num_of_scales);
50 this->kzf.create(roi.height, width_freq, num_of_scales);
51 this->kf.create(roi.height, width_freq, num_of_scales);
55 if (num_of_scales > 1) {
56 this->max_responses.reserve(num_of_scales);
57 this->max_locs.reserve(num_of_scales);
58 this->response_maps.reserve(num_of_scales);
62 ThreadCtx(ThreadCtx &&) = default;
66 std::future<void> async_res;
69 class gaussian_correlation_data {
70 friend void KCF_Tracker::gaussian_correlation(struct ThreadCtx &vars, const ComplexMat &xf, const ComplexMat &yf, double sigma, bool auto_correlation);
72 DynMem yf_sqr_norm{sizeof(float)};
75 gaussian_correlation_data(uint num_of_scales) : xf_sqr_norm(num_of_scales * sizeof(float)) {}
78 cv::Mat in_all, fw_all, ifft2_res, response;
79 ComplexMat zf, kzf, kf, xyf;
81 DynMem data_i_features, data_i_1ch;
82 // CuFFT and FFTW variables
83 DynMem gauss_corr_res, data_features;
86 ComplexMat model_alphaf, model_xf;
88 // Variables used during non big batch mode and in big batch mode with ThreadCtx in p_threadctxs in kcf on zero index.
90 double max_val, max_response;
93 // Stores value of responses, location of maximal response and response maps for each scale
94 std::vector<double> max_responses;
95 std::vector<cv::Point2i> max_locs;
96 std::vector<cv::Mat> response_maps;
100 #endif // SCALE_VARS_HPP