资源简介

摄像头物体跟踪,采用CT算法,vs2010直接打开

资源截图

代码片段和文件信息

#include “CompressiveTracker.h“
#include 
#include 
using namespace cv;
using namespace std;

//------------------------------------------------
CompressiveTracker::CompressiveTracker(void)
{
featureMinNumRect = 2;
featureMaxNumRect = 4; // number of rectangle from 2 to 4
featureNum = 50; // number of all weaker classifiers i.efeature pool
rOuterPositive = 4; // radical scope of positive samples
rSearchWindow = 25; // size of search window
muPositive = vector(featureNum 0.0f);
muNegative = vector(featureNum 0.0f);
sigmaPositive = vector(featureNum 1.0f);
sigmaNegative = vector(featureNum 1.0f);
learnRate = 0.85f; // Learning rate parameter
}

CompressiveTracker::~CompressiveTracker(void)
{
}


void CompressiveTracker::HaarFeature(Rect& _objectBox int _numFeature)
/*Description: compute Haar features
  Arguments:
  -_objectBox: [x y width height] object rectangle
  -_numFeature: total number of features.The default is 50.
*/
{
features = vector>(_numFeature vector());
featuresWeight = vector>(_numFeature vector());

int numRect;
Rect rectTemp;
float weightTemp;
      
for (int i=0; i<_numFeature; i++)
{
numRect = cvFloor(rng.uniform((double)featureMinNumRect (double)featureMaxNumRect));
    
//int c = 1;
for (int j=0; j {

rectTemp.x = cvFloor(rng.uniform(0.0 (double)(_objectBox.width - 3)));
rectTemp.y = cvFloor(rng.uniform(0.0 (double)(_objectBox.height - 3)));
rectTemp.width = cvCeil(rng.uniform(0.0 (double)(_objectBox.width - rectTemp.x - 2)));
rectTemp.height = cvCeil(rng.uniform(0.0 (double)(_objectBox.height - rectTemp.y - 2)));
features[i].push_back(rectTemp);

weightTemp = (float)pow(-1.0 cvFloor(rng.uniform(0.0 2.0))) / sqrt(float(numRect));
            //weightTemp = (float)pow(-1.0 c);

featuresWeight[i].push_back(weightTemp);
           
}
}
}


void CompressiveTracker::sampleRect(Mat& _image Rect& _objectBox float _rInner float _rOuter int _maxSampleNum vector& _sampleBox)
/* Description: compute the coordinate of positive and negative sample image templates
   Arguments:
   -_image:        processing frame
   -_objectBox:    recent object position 
   -_rInner:       inner sampling radius
   -_rOuter:       Outer sampling radius
   -_maxSampleNum: maximal number of sampled images
   -_sampleBox:    Storing the rectangle coordinates of the sampled images.
*/
{
int rowsz = _image.rows - _objectBox.height - 1;
int colsz = _image.cols - _objectBox.width - 1;
float inradsq = _rInner*_rInner;
float outradsq = _rOuter*_rOuter;

  
int dist;

int minrow = max(0(int)_objectBox.y-(int)_rInner);
int maxrow = min((int)rowsz-1(int)_objectBox.y+(int)_rInner);
int mincol = max(0(int)_objectBox.x-(int)_rInner);
int maxcol = min((int)colsz-1(int)_objectBox.x+(int)_rInne

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-08-27 17:26  CTFromCam_v0\
     目录           0  2012-08-27 17:26  CTFromCam_v0\CompressiveTracking\
     文件        9132  2012-08-24 13:15  CTFromCam_v0\CompressiveTracking\CompressiveTracker.cpp
     文件        2163  2012-08-23 17:59  CTFromCam_v0\CompressiveTracking\CompressiveTracker.h
     文件        4005  2012-08-07 09:58  CTFromCam_v0\CompressiveTracking\CompressiveTracking.vcproj
     文件        1449  2012-08-24 10:47  CTFromCam_v0\CompressiveTracking\CompressiveTracking.vcproj.HP98402794308.Administrator.user
     文件        1427  2012-08-24 13:46  CTFromCam_v0\CompressiveTracking\CompressiveTracking.vcproj.PC-201008102047.Administrator.user
     目录           0  2012-08-27 17:28  CTFromCam_v0\CompressiveTracking\Debug\
     目录           0  2012-08-27 17:28  CTFromCam_v0\CompressiveTracking\Release\
     文件        4286  2012-08-24 12:49  CTFromCam_v0\CompressiveTracking\RunTracker.cpp
     文件      962560  2011-12-04 05:39  CTFromCam_v0\CompressiveTracking\david.mpg
     文件          12  2012-08-07 14:56  CTFromCam_v0\CompressiveTracking\init.txt
     文件     9440256  2012-08-24 13:46  CTFromCam_v0\CompressiveTracking.ncb
     文件         923  2012-08-24 10:43  CTFromCam_v0\CompressiveTracking.sln
     文件       17408  2012-08-24 13:46  CTFromCam_v0\CompressiveTracking.suo
     目录           0  2012-08-27 17:26  CTFromCam_v0\Release\
     文件       39936  2012-08-24 13:15  CTFromCam_v0\Release\CompressiveTracking.exe
     文件      822272  2012-08-24 13:15  CTFromCam_v0\Release\CompressiveTracking.pdb
     文件      962560  2011-12-04 05:39  CTFromCam_v0\Release\david.mpg
     文件          12  2012-08-07 14:56  CTFromCam_v0\Release\init.txt

评论

共有 条评论