-
大小: 8.23MB文件类型: .rar金币: 2下载: 0 次发布日期: 2023-10-09
- 语言: C/C++
- 标签: TLD C++ OpenCV3.0.0 VS2013
资源简介
本代码是TLD C++版本在opencv3.0.0上的实现,代码都来自别人,其中针对opencv3.0.0作了一些修改,比如一些宏改成在opencv3.0.0下的形式,压缩包中是我的vs2013工程,还加了我的OpenCV3.0.0.props属性设置文件,大家把opencv路径必成自已的就可以跑起来了,用的是本地视频,其中在debug版本下运行慢,release下速度快很多。

代码片段和文件信息
/*
* FerNNClassifier.cpp
*
* Created on: Jun 14 2011
* Author: alantrrs
*/
#include “FerNNClassifier.h“
using namespace cv;
using namespace std;
void FerNNClassifier::read(const FileNode& file){
///Classifier Parameters
valid = (float)file[“valid“];
ncc_thesame = (float)file[“ncc_thesame“];
nstructs = (int)file[“num_trees“];
structSize = (int)file[“num_features“];
thr_fern = (float)file[“thr_fern“];
thr_nn = (float)file[“thr_nn“];
thr_nn_valid = (float)file[“thr_nn_valid“];
}
void FerNNClassifier::prepare(const vector& scales){
acum = 0;
//Initialize test locations for features
int totalFeatures = nstructs*structSize;
features = vector >(scales.size()vector (totalFeatures));
RNG& rng = theRNG();
float x1fx2fy1fy2f;
int x1 x2 y1 y2;
for (int i=0;i x1f = (float)rng;
y1f = (float)rng;
x2f = (float)rng;
y2f = (float)rng;
for (int s=0;s x1 = (int)(x1f * scales[s].width);
y1 = (int)(y1f * scales[s].height);
x2 = (int)(x2f * scales[s].width);
y2 = (int)(y2f * scales[s].height);
features[s][i] = Feature(x1 y1 x2 y2);
}
}
//Thresholds
thrN = 0.5f*nstructs;
//Initialize Posteriors
for (int i = 0; i posteriors.push_back(vector(pow(2.0structSize) 0));
pCounter.push_back(vector(pow(2.0structSize) 0));
nCounter.push_back(vector(pow(2.0structSize) 0));
}
}
void FerNNClassifier::getFeatures(const cv::Mat& imageconst int& scale_idx vector& fern){
int leaf;
for (int t=0;t leaf=0;
for (int f=0; f leaf = (leaf << 1) + features[scale_idx][t*nstructs+f](image);
}
fern[t]=leaf;
}
}
float FerNNClassifier::measure_forest(vector fern) {
float votes = 0;
for (int i = 0; i < nstructs; i++) {
votes += posteriors[i][fern[i]];
}
return votes;
}
void FerNNClassifier::update(const vector& fern int C int N) {
int idx;
for (int i = 0; i < nstructs; i++) {
idx = fern[i];
(C==1) ? pCounter[i][idx] += N : nCounter[i][idx] += N;
if (pCounter[i][idx]==0) {
posteriors[i][idx] = 0;
} else {
posteriors[i][idx] = ((float)(pCounter[i][idx]))/(pCounter[i][idx] + nCounter[i][idx]);
}
}
}
void FerNNClassifier::trainF(const vectorint> >& fernsint resample){
// Conf = function(2XYMarginBootstrapIdx)
// 0 1 2 3 4 5
// double *X = mxGetPr(prhs[1]); -> ferns[i].first
// int numX = mxGetN(prhs[1]); -> ferns.size()
// double *Y = mxGetPr(prhs[2]); ->ferns[i].second
// double thrP = *mxGetPr(prhs[3]) * nTREES; ->threshold*nstructs
// int bootstrap = (int) *mxGetPr(prhs[4]); ->resample
thrP = thr_fern*nstructs; // int step = n
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 552960 2016-10-10 19:34 TLD\Debug\TLD.exe
文件 1999592 2016-10-10 19:34 TLD\Debug\TLD.ilk
文件 3623936 2016-10-10 19:34 TLD\Debug\TLD.pdb
文件 101888 2016-10-10 19:36 TLD\Release\TLD.exe
文件 1346560 2016-10-10 19:36 TLD\Release\TLD.pdb
文件 20766 2016-10-10 19:37 TLD\TLD\bounding_boxes.txt
文件 1075200 2011-12-04 05:39 TLD\TLD\car.mpg
文件 1107609 2016-10-10 19:27 TLD\TLD\Debug\FerNNClassifier.obj
文件 395653 2016-10-10 19:27 TLD\TLD\Debug\LKTracker.obj
文件 261302 2016-10-10 19:27 TLD\TLD\Debug\PatchGenerator.obj
文件 707076 2016-10-10 19:34 TLD\TLD\Debug\run_tld.obj
文件 2145 2016-10-10 19:34 TLD\TLD\Debug\TLD.log
文件 2061720 2016-10-10 19:27 TLD\TLD\Debug\TLD.obj
文件 3698 2016-10-10 19:34 TLD\TLD\Debug\TLD.tlog\cl.command.1.tlog
文件 119284 2016-10-10 19:34 TLD\TLD\Debug\TLD.tlog\CL.read.1.tlog
文件 2716 2016-10-10 19:34 TLD\TLD\Debug\TLD.tlog\CL.write.1.tlog
文件 1852 2016-10-10 19:34 TLD\TLD\Debug\TLD.tlog\li
文件 3812 2016-10-10 19:34 TLD\TLD\Debug\TLD.tlog\li
文件 876 2016-10-10 19:34 TLD\TLD\Debug\TLD.tlog\li
文件 160 2016-10-10 19:34 TLD\TLD\Debug\TLD.tlog\TLD.lastbuildstate
文件 417986 2016-10-10 19:27 TLD\TLD\Debug\tld_utils.obj
文件 805888 2016-10-10 19:34 TLD\TLD\Debug\vc120.idb
文件 1224704 2016-10-10 19:34 TLD\TLD\Debug\vc120.pdb
文件 8596 2016-10-10 17:27 TLD\TLD\FerNNClassifier.cpp
文件 1970 2011-12-04 21:39 TLD\TLD\FerNNClassifier.h
文件 15 2011-12-04 05:39 TLD\TLD\init.txt
文件 3442 2016-10-10 17:27 TLD\TLD\LKTracker.cpp
文件 790 2016-01-24 14:18 TLD\TLD\LKTracker.h
文件 954 2016-10-10 19:22 TLD\TLD\OpenCV3.0.0.props
文件 524 2011-12-04 21:39 TLD\TLD\parameters.yml
............此处省略38个文件信息
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论