• 大小: 184KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: 其他
  • 标签: mean  shift  track  跟踪  

资源简介

http://blog.csdn.net/luckydongbin/article/details/1534192

资源截图

代码片段和文件信息

//colourModel.cpp - the colourModel object
//Iain Wallace 16/08/05

//Modified by xdb 2007-03-19
#include “stdafx.h“
#include “colourModel.h“
#include 
#include 
//using namespace cimg_library;
using namespace std;
colourModel::colourModel()
{
//model must be initialised to 0
memset( m_model ‘\0‘ sizeof(m_model) );
//Se we can tell if the memory‘s been allocated
binsInit = false;
}
colourModel::~colourModel()
{
//Free the bins memory if it‘s assigned.
if (binsInit)
{
if( bins != NULL )
{
for (unsigned int i=0; i< mX_dim; i++)
{
if( bins[i] != NULL )
delete[] bins[i];
}
delete[] bins;
}
bins = NULL;
binsInit = false;
memset( m_model ‘\0‘ sizeof(m_model) );
}
}
double colourModel::operator[](unsigned int bin)
{
//Use GTE as index is from 0
if (bin >= NUMBINS)
{
cerr << “ERROR! Tried to access a model bin that doesn‘t exit!“ << endl;
return 0;
}
return m_model[bin];
}
unsigned int colourModel::findBin(unsigned char Runsigned char Gunsigned char B)
{
//return the bin number of a pixel according to its RGB value.
//Note that the constants defined in the header file and this function
//control the only real tuning of the tracker.
//scale the colours
unsigned int rgb;
r = (unsigned int)floor( (float)(R/BINSIZE) );
g = (unsigned int)floor( (float)(G/BINSIZE) );
b = (unsigned int)floor( (float)(B/BINSIZE) );
//If for example the blue channel is not to be used then change for:
//b = 0;
return (r + BPC*g + BPC*BPC*b);
}
void colourModel::clearModel()
{
memset( m_model ‘\0‘ sizeof(m_model) );
}

//This performs the function described by eqn(2) and eqn(4) (effectively the same)
//It saves the bin that each pixel is allocated too as this prevents it being
//re-calculated when the weights are updated.
//void colourModel::updateModel(cimg_library::CImg* image //The image in question
//   unsigned int centreX //X co-ord of centre
//   unsigned int centreY //Y co-ord of centre
//   int half_x //half the x-size of the window
//   int half_y //half the y-size of the window
//   double*** kArray) //the kernel
//{
// clearModel();
// //first time this is called create bins with the size of the window
// //NOTE: more cunning memory management would be required for reszizing windows!
// if (!binsInit)
// {
// cout << “Allocating a bin allocation table“ << endl;
// //allocate the memory
// mX_dim = 2*half_x+1;
// mY_dim = 2*half_y+1;
// bins = new unsigned int*[mX_dim];
// for (unsigned int i=0;i// bins[i] = new unsigned int[mY_dim];
// binsInit = true;
// }
// for (int x = -half_x;x <= half_x;++x)
// {
// for (int y = -half_y;y <= half_y;++y)
// {
// //update the bin allocation table at the same time
// int iX = centreX + x;
// int iY = centreY + y;
// bins[x+half_x][y+half_y] = findBin((*image)(iXi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1190403  2007-03-08 15:09  mean\CImg.h

     文件       6409  2007-03-21 20:32  mean\colourModel.cpp

     文件       2364  2007-03-20 10:17  mean\colourModel.h

     文件      10516  2007-03-21 20:25  mean\MsTracker.cpp

     文件       1508  2007-03-22 16:10  mean\MsTracker.h

     文件        662  2008-04-06 21:27  mean\Rademe.txt

     目录          0  2007-04-28 20:25  mean

----------- ---------  ---------- -----  ----

              1211862                    7


评论

共有 条评论