您的位置:首页 > 编程语言 > MATLAB

TLD的Matlab源码学习

2014-03-20 09:56 267 查看
转载/article/7804925.html

在源代码中,compile.m文件的作用,主要是将lk.cpp ,tld.cpp,fern.cpp, linkagemex.cpp, bb_overlap.cpp, warp.cpp, distance.cpp,

转换为:lk.mexw64, fern.mexw64, linkagemex.mexw64, bb_overlap.mexw64,warp.mexw64, distance.mexw64

bb_overlap.cpp

/边框盒子的重叠(两个盒子的四个角进行判断)

double bb_overlap(double *bb1, double *bb2) {}

void mexFunction(int nlhs,mxArray *plhs[], int nrhs, const mxArray *prhs[])

{}

distance.cpp

大概就是要计算相关性和欧几里得距离

//相关性

// correlation

double ccorr(double*f1,double *f2,int numDim) {}

//相关性归一化

// correlation normalized

double ccorr_normed(double*f1,double *f2,int numDim) {} //f1=[1,2,3], f2=[4,5,6] f1*f2

//欧几里得距离

// euclidean distance

double euclidean(double*f1,double *f2,int numDim) {} //向量f1=[1,2,3,2],向量f2=[4,5,6,7]→D(a,b)=sqrt((1-4)^2+(2-5)^2+..+(2-7)^2)

//distance.cpp的输入口函数

void mexFunction(int nlhs,mxArray *plhs[], int nrhs, const mxArray *prhs[])

fern.cpp

//nlhs:输出参数个数;plhs:输出参数指针;nrhs:输入参数个数;prhs:输入参数指针

void mexFunction(int nlhs,mxArray *plhs[], int nrhs, const mxArray *prhs[])

{}

linkagemex.cpp

//目的:创建一个层次聚类树

template<class TEMPL>

void mexLinkageTEMPLATE(

//左手边

//右手边

int nlhs, /* Number ofleft hand side (output) arguments */

mxArray *plhs[], /* Array of left handside (output) arguments */

int nrhs, /* Number ofright hand side (input) arguments */

const mxArray *prhs[],/* Array of right hand side (input)arguments */

int call_pdist,

TEMPL classDummy

){}

//主函数入口

void mexFunction( /* GATEWAY FUNCTION */

int nlhs, /* Number ofleft hand side (output) arguments */

mxArray *plhs[], /* Array of left handside (output) arguments */

int nrhs, /* Number ofright hand side (input) arguments */

const mxArray *prhs[] /* Array of right hand side (input)arguments */

)

{

...

/* call the TEMPLATE function */

//如何输入的第一个参数为double类型

if (mxIsDouble(prhs[0]))

//执行模板函数

mexLinkageTEMPLATE(nlhs,plhs,nrhs,prhs,(nrhs==3),(double)(1.0));

else

//如果不是double类型,single

mexLinkageTEMPLATE(nlhs,plhs,nrhs,prhs,(nrhs==3),(float )(1.0));

}

lk.cpp

首次出现了Opencv的东西

功能:大概是把matlab图像转换为opencv能处理的图像,然后利用光流法跟踪,也有模板匹配。

//从matlab中加载图像到 image

void loadImageFromMatlab(const mxArray *mxImage, IplImage *image)

//欧几里得距离的计算

void euclideanDistance (CvPoint2D32f *point1, CvPoint2D32f *point2, float *match, int nPts)

//交叉相关:cross - correlation

void normCrossCorrelation

//lk.cpp的入口行数

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[]){}

tld.cpp

warp.cpp

设置感兴趣区域,并且转换为matlab格式的图像数据

//设置图像的感兴趣区域

voidwarp_image_roi(unsigned char *image, int w, int h, double *H,

double xmin, double xmax,double ymin, double ymax,

double fill, double*result)

//将图像转换为matlab表示的图像

mxArray*to_matlab(const double *image, int num_cols, int num_rows)

{}

//warp.cpp的输入口函数

void mexFunction(int nlhs, mxArray *plhs [], int nrhs, const mxArray *prhs [])

{ …

//转换为matlab类型的的图像数据输出

plhs[0]=to_matlab(result,(int)(xmax-xmin+1), (int)(ymax-ymin+1));

}

其实下面两个文件并没有使用到哦。

ii.cpp文件:

得到积分图像

void mexFunction(intnlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[])

ii2.cpp文件:

得到积分图像

void mexFunction(intnlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[])
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐