将下载的TLD的C++源码,调试运行起来。
1、新建工程添加源文件和头文件,并将opencv2的配置文件加载好,在工程目录下放入datasets、parameters.yml。
2、将报错的include后的< >换成" "
vs不支持这种动态数组分配,将
float L[c-1]; //Level
int nodes[c-1][2];
int belongs[c];
改成指针和动态分配内存
float *L = new float [c-1]; //Level
int **nodes = new int *[c-1];
for(int i = 0; i < 2 ;i ++)
nodes[i] = new int [c-1];
int *belongs = new int [c];
并在函数末释放分配的内存
delete [] L;
L = NULL;
for (int i = 0; i < 2; ++i)
{
delete [] nodes[i];
nodes[i] = NULL;
}
delete []nodes;
nodes = NULL;
delete [] belongs;
belongs = NULL;
3、在mian函数前面定义一下函数; void read_options2(VideoCapture& capture,FileStorage &fs) { char* parameterB="../datasets/06_car/init.txt"; readBB(parameterB); gotBB = true; string videoS = "../datasets/06_car/car.mpg"; capture.open(videoS); fromfile = true; string parameterP="../parameters.yml"; fs.open(parameterP, FileStorage::READ); } 然后在mian函数中注释掉read_options(argc,argv,capture,fs);这个函数 而添加上read_options2(capture,fs);这个函数,并将上述3个路径换为文件所在路径。若运行无反应可注释掉capture.open(0);即可看见效果。