-
Notifications
You must be signed in to change notification settings - Fork 6
/
CompressiveTracker.h
60 lines (57 loc) · 2.11 KB
/
CompressiveTracker.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
/************************************************************************
* 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>
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 radioClassifier(vector<float>& _muPos, vector<float>& _sigmaPos, vector<float>& _muNeg, vector<float>& _sigmaNeg,
Mat& _sampleFeatureValue, float& _radioMax, int& _radioMaxIndex);
public:
void processFrame(Mat& _frame, Rect& _objectBox);
void init(Mat& _frame, Rect& _objectBox);
};