]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blob - src/threadctx.hpp
Move scale_track method from KCF to ThreadCtx
[hercules2020/kcf.git] / src / threadctx.hpp
1 #ifndef SCALE_VARS_HPP
2 #define SCALE_VARS_HPP
3
4 #include <future>
5 #include "dynmem.hpp"
6 #include "kcf.h"
7
8 #ifdef CUFFT
9 #include "complexmat.cuh"
10 #else
11 #include "complexmat.hpp"
12 #endif
13
14 class KCF_Tracker;
15
16 struct ThreadCtx {
17   public:
18     ThreadCtx(cv::Size roi, uint num_channels, uint num_of_scales
19 #ifndef BIG_BATCH
20               , double scale
21 #endif
22              )
23         : roi(roi)
24         , num_channels(num_channels)
25         , num_of_scales(num_of_scales)
26 #ifndef BIG_BATCH
27         , scale(scale)
28 #endif
29     {}
30
31     ThreadCtx(ThreadCtx &&) = default;
32
33     void track(const KCF_Tracker &kcf, cv::Mat &input_rgb, cv::Mat &input_gray);
34 private:
35     cv::Size roi;
36     uint num_channels;
37     uint num_of_scales;
38     cv::Size freq_size = Fft::freq_size(roi);
39
40
41     KCF_Tracker::GaussianCorrelation gaussian_correlation{roi, num_of_scales, num_channels};
42
43     MatDynMem ifft2_res{roi, CV_32FC(int(num_channels))};
44
45     ComplexMat zf{uint(freq_size.height), uint(freq_size.width), num_channels, num_of_scales};
46     ComplexMat kzf{uint(freq_size.height), uint(freq_size.width), num_of_scales};
47
48 public:
49 #ifdef ASYNC
50     std::future<void> async_res;
51 #endif
52
53     MatDynMem response{roi, CV_32FC(int(num_of_scales))};
54
55 #ifdef BIG_BATCH
56     // Stores value of responses, location of maximal response and response maps for each scale
57     std::vector<double> max_responses = std::vector<double>(num_of_scales);
58     std::vector<cv::Point2i> max_locs = std::vector<cv::Point2i>(num_of_scales);
59     std::vector<cv::Mat> response_maps = std::vector<cv::Mat>(num_of_scales);
60 #else
61     cv::Point2i max_loc;
62     double max_val, max_response;
63     const double scale;
64 #endif
65 };
66
67 #endif // SCALE_VARS_HPP