-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCT2tracker.h
145 lines (113 loc) · 3.8 KB
/
LCT2tracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// Created by YangYuqi on 2020/7/22.
//
#pragma once
#ifndef LCT2_LCT2TRACKER_H
#define LCT2_LCT2TRACKER_H
#endif //LCT2_LCT2TRACKER_H
#include <opencv2/opencv.hpp>
#include <string>
#include "util.h"
#include"fhog.h"
#include "assignToBins1.h"
#include "detector.h"
const int featuremax= 300;
cv::Mat doWork(cv::InputArray _src,cv::Size ksize,int nbins);
//complex calculating
cv::Mat multichafft(const cv::Mat &input, bool inverse);
cv::Mat complexDivision(const cv::Mat& a, const cv::Mat &b);
cv::Mat complexDivisionReal(const cv::Mat &a, const cv::Mat& b);
cv::Mat complexMultiplication(const cv::Mat& a, const cv::Mat &b, bool conj);
class LCT2tracker
{
public:
//Constructor
LCT2tracker();
//initialize the tracker
void init(const cv::Rect &roi, cv::Mat Image);
//get the feature
cv::Mat get_feature(const cv::Mat &Image, bool hann);
//initialize the size of window
void search_window(int target_x, int target_y, int image_x, int image_y);
//create hanning map
cv::Mat create_hanning();
//create a gaussian Peak
cv::Mat create_gaussian_label(float sigma, int col, int row);
//do the gaussian correlation, get the kernelized function
cv::Mat gaussian_correlation(const cv::Mat &xf, const cv::Mat &yf, float sigma);
//get the scaled sample
cv::Mat get_scale_sample(const cv::Mat &image, cv::Rect base_target,const float *scale_factor, cv::Size model_sz, bool window);
std::pair<cv::Point, std::pair<float, float>> do_correlation(cv::Mat image, int pos_x, int pos_y, cv::Size window_sz, bool window, bool app);
//online trainning and detection
cv::Point detect(cv::Mat image);
//use detector to find pos
std::pair<cv::Point, std::pair<float, float> > refine_pos(cv::Mat image, int pos_x, int pos_y, bool app);
//get the high quality samples for the svm
void get_high_quality(const cv::Mat &image, int pos_x, int pos_y, cv::Size window_sz);
//all frame search when lost the object
std::pair<cv::Point, float> search_from_whole(const cv::Mat &image);
bool isgray = true;
float padding; //area surrounding the target
float lambda; //regularization
float output_sigma_factor; //spatial bandwidth
float interp_factor;
float scale_inter;
float kernal_sigma;
bool resize_image;
int window_x;int window_y;//size of the motion window
int app_x;int app_y;//size of the appreance window
float output_sigma;
float alpha_pt;
//hog features
int hog_orientations;
int cell_size; //hog grid cell
int window_size; //hoi local region
int nbins; //bins of HOI
//threshold
double motion_thresh;
double appearance_thresh_min;
double appearance_thresh_max;
double accept_thresh;
double max_mean, min_mean;
//threshold for APCE
double APCE_motion_thresh;
double APCE_appearance_thresh_max;
double APCE_appearance_thresh_min;
double APCE_accept_thresh;
double APCE_max_mean, APCE_min_mean;
cv::Rect _roi;
//scalefactor
int nScale;
float scale_factor[40];
float scale_sigma;
cv::Size scale_model_sz;
float currentscalefactor;
float max_scalefactor;
float min_scalefactor;
float scale_step;
//detector
int lost = 0;
detector det;
float m_response;
std::vector<cv::Mat> highquality;
std::vector<int> labels;
float det_scalefactor[10];
float det_scalestep;
int det_nScale;
int count = 0;
std::pair<double, double> responce_sum = std::make_pair(0, 0);
std::pair<double, double> responce_mean = std::make_pair(0, 0);
private:
int size_patch[3];
//feature data
cv::Mat win_xf;
cv::Mat _alphaf;
cv::Mat app_xf;
cv::Mat app_alphaf;
cv::Mat sf_num;
cv::Mat sf_den;
//gaussian target
cv::Mat tar;
cv::Mat app_tar;
cv::Mat scale_tar;
};