-
大小: 8.23MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2023-10-09
- 語言: C/C++
- 標(biāo)簽: TLD??C++??OpenCV3.0.0??VS2013??
資源簡介
本代碼是TLD C++版本在opencv3.0.0上的實現(xiàn),代碼都來自別人,其中針對opencv3.0.0作了一些修改,比如一些宏改成在opencv3.0.0下的形式,壓縮包中是我的vs2013工程,還加了我的OpenCV3.0.0.props屬性設(shè)置文件,大家把opencv路徑必成自已的就可以跑起來了,用的是本地視頻,其中在debug版本下運(yùn)行慢,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???????votes?+=?posteriors[i][fern[i]];
??}
??return?votes;
}
void?FerNNClassifier::update(const?vector&?fern?int?C?int?N)?{
??int?idx;
??for?(int?i?=?0;?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個文件信息
評論
共有 條評論