-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompressive_tracker.h
84 lines (75 loc) · 2.89 KB
/
compressive_tracker.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
/************************************************************************
* File: CompressiveTracker.h
* Brief: C++ demo for paper: Kaihua Zhang, Lei Zhang, Ming-Hsuan Yang,"Real-Time Compressive Tracking," ECCV 2012.
* Version: 1.0
* Author: Yang Xian
* Email: [email protected]
* Date: 2012/08/03
* History:
* Revised by Kaihua Zhang on 14/8/2012
* Email: [email protected]
* Homepage: http://www4.comp.polyu.edu.hk/~cskhzhang/
************************************************************************/
#pragma once
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <vector>
typedef unsigned char uint8;
using std::vector;
using namespace cv;
//---------------------------------------------------
class CompressiveTracker {
public:
CompressiveTracker(void);
~CompressiveTracker(void);
private:
int featureMinNumRect;
int featureMaxNumRect;
int featureNum;
vector<vector<Rect> > features;
vector<vector<float> > featuresWeight;
int rOuterPositive;
vector<Rect> samplePositiveBox;
vector<Rect> sampleNegativeBox;
int rSearchWindow;
Mat imageIntegral;
Mat samplePositiveFeatureValue;
Mat sampleNegativeFeatureValue;
vector<float> muPositive;
vector<float> sigmaPositive;
vector<float> muNegative;
vector<float> sigmaNegative;
float learnRate;
vector<Rect> detectBox;
Mat detectFeatureValue;
RNG rng;
private:
void HaarFeature(Rect& _objectBox, int _numFeature);
void sampleRect(Mat& _image, Rect& _objectBox, float _rInner, float _rOuter, int _maxSampleNum, vector<Rect>& _sampleBox);
void sampleRect(Mat& _image, Rect& _objectBox, float _srw, vector<Rect>& _sampleBox);
void getFeatureValue(Mat& _imageIntegral, vector<Rect>& _sampleBox, Mat& _sampleFeatureValue);
void classifierUpdate(Mat& _sampleFeatureValue, vector<float>& _mu, vector<float>& _sigma, float _learnRate);
void ratioClassifier(vector<float>& _muPos, vector<float>& _sigmaPos, vector<float>& _muNeg, vector<float>& _sigmaNeg, Mat& _sampleFeatureValue, float& _ratioMax, int& _ratioMaxIndex);
public:
void processFrame(Mat& _frame, Rect& _objectBox);
void init(Mat& _frame, Rect& _objectBox);
void init_wrap(vector<vector<uint8> > &_frame, vector<int> &_objectBox);
void process_frame_wrap(vector<vector<uint8> > &_frame, vector<int> &_objectBox);
};
void c_get_feature_values_v1(
vector<vector<double> > &feature_values,
vector<vector<int> > boxes,
vector<vector<vector<int> > > features,
vector<vector<double> > weights,
vector<vector<double> > integral_image);
void c_get_feature_values(
vector<vector<double> > &feature_values,
vector<Rect> boxes,
vector<vector<Rect> > features,
vector<vector<double> > weights,
vector<vector<double> > integral_image);
void c_ratio_classifier(
int &index_ratio_max, double &ratio_max,
vector<double> mu_pos, vector<double> sigma_pos,
vector<double> mu_neg, vector<double> sigma_neg,
vector<vector<double> > feature_values);