91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

自己訓(xùn)練的分類器導(dǎo)入進(jìn)行視頻行人檢測 代碼親測可行,算法需要再完善 提高實(shí)時(shí)性

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?



//繼承自CvSVM的類,因?yàn)樯蓅etSVMDetector()中用到的檢測子參數(shù)時(shí),需要用到訓(xùn)練好的SVM的decision_func參數(shù),??
//但通過查看CvSVM源碼可知decision_func參數(shù)是protected類型變量,無法直接訪問到,只能繼承之后通過函數(shù)訪問?

class?MySVM?:?public?CvSVM
{

public:
//獲得SVM的決策函數(shù)中的alpha數(shù)組??
double?*?get_alpha_vector()
{
return?this->decision_func->alpha;
}

//獲得SVM的決策函數(shù)中的rho參數(shù)即偏移量??
float?get_rho()
{
return?this->decision_func->rho;
}
};
int?main()
{
//檢測窗口(64128)塊尺寸(1616)塊步長(88)cell尺寸(88)直方圖bin個(gè)數(shù)9
HOGDescriptor?hog(Size(64?64)?Size(16?16)?Size(8?8)?Size(8?8)?9);//HOG檢測器,用來計(jì)算HOG描述子的
int?DescriptorDim;//HOG描述子的維數(shù),由圖片大小、檢測窗口大小、塊大小、細(xì)胞單元中直方圖bin個(gè)數(shù)決定
MySVM?svm;//SVM分類器
svm.load(“D:/vs2013projects/cpractice/hogtrainsvm/hogtrainsvm/SVM_HOG.xml“);//從xml文件讀取訓(xùn)練好的SVM模型

/*************************************************************************************************
線性SVM訓(xùn)練完成后得到的xml文件里面,有一個(gè)數(shù)組,叫做support?vector,還有一個(gè)數(shù)組,叫做alpha有一個(gè)浮點(diǎn)數(shù),叫做rho;
將alpha矩陣同support?vector相乘,注意,alpha*supportVector將得到一個(gè)列向量。之后,再該列向量的最后添加一個(gè)元素rho。
如此,變得到了一個(gè)分類器,利用該分類器,直接替換opencv中行人檢測默認(rèn)的那個(gè)分類器(cv::HOGDescriptor::setSVMDetector()),
就可以利用你的訓(xùn)練樣本訓(xùn)練出來的分類器進(jìn)行行人檢測了。
***************************************************************************************************/
DescriptorDim?=?svm.get_var_count();//特征向量的維數(shù),即HOG描述子的維數(shù)
int?supportVectorNum?=?svm.get_support_vector_count();//支持向量的個(gè)數(shù)
cout?<
Mat?alphaMat?=?Mat::zeros(1?supportVectorNum?CV_32FC1);//alpha向量,長度等于支持向量個(gè)數(shù)
Mat?supportVectorMat?=?Mat::zeros(supportVectorNum?DescriptorDim?CV_32FC1);//支持向量矩陣
Mat?resultMat?=?Mat::zeros(1?DescriptorDim?CV_32FC1);//alpha向量乘以支持向量矩陣的結(jié)果

//將支持向量的數(shù)據(jù)復(fù)制到supportVectorMat矩陣中
for?(int?i?=?0;?i {
const?float?*?pSVData?=?svm.get_support_vector(i);//返回第i個(gè)支持向量的數(shù)據(jù)指針
for?(int?j?=?0;?jriptorDim;?j++)
{
//cout< supportVectorMat.at(i?j)?=?pSVData[j];
}
}

//將alpha向量的數(shù)據(jù)復(fù)制到alphaMat中
double?*?pAlphaData?=?svm.get_alpha_vector();//返回SVM的決策函數(shù)中的alpha向量
for?(int?i?=?0;?i {
alphaMat.at(0?i)?=?pAlphaData[i];
}

//計(jì)算-(alphaMat?*?supportVectorMat)結(jié)果放到resultMat中
//gemm(alphaMat?supportVectorMat?-1?0?1?resultMat);//不知道為什么加負(fù)號(hào)?
resultMat?=?-1?*?alphaMat?*?supportVectorMat;

//得到最終的setSVMDetector(const?vector&?detector)參數(shù)中可用的檢測子
vector?myDetector;
//將resultMat中的數(shù)據(jù)復(fù)制到數(shù)組myDetector中
for?(int?i?=?0;?iriptorDim;?i++)
{
myDetector.push_back(resultMat.at(0?i));
}
//最后添加偏移量rho,得到檢測子
myDetector.push_back(svm.get_rho());
cout?< //設(shè)置HOGDescriptor的檢測子
????HOGDescriptor?

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-09-12?10:06??videopeopledetect\
?????目錄???????????0??2018-07-18?15:43??videopeopledetect\Debug\
?????文件??????128512??2018-08-31?10:43??videopeopledetect\Debug\videopeopledetect.exe
?????文件?????1477776??2018-08-31?10:43??videopeopledetect\Debug\videopeopledetect.ilk
?????文件?????2715648??2018-08-31?10:43??videopeopledetect\Debug\videopeopledetect.pdb
?????目錄???????????0??2018-09-12?10:32??videopeopledetect\videopeopledetect\
?????目錄???????????0??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\
?????文件??????609280??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\vc120.idb
?????文件?????1404928??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\vc120.pdb
?????目錄???????????0??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\
?????文件???????11376??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\CL.read.1.tlog
?????文件?????????502??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\CL.write.1.tlog
?????文件?????????780??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\cl.command.1.tlog
?????文件????????2234??2018-08-31?10:43??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\link.command.1.tlog
?????文件????????4520??2018-08-31?10:43??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\link.read.1.tlog
?????文件?????????640??2018-08-31?10:43??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\link.write.1.tlog
?????文件???????????0??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\unsuccessfulbuild
?????文件?????????179??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\videopeo.E976BEEB.tlog\videopeopledetect.lastbuildstate
?????文件????????5342??2018-09-12?10:04??videopeopledetect\videopeopledetect\Debug\videopeopledetect.log
?????文件???????20652??2018-08-31?10:43??videopeopledetect\videopeopledetect\HOGDetectorForOpenCV.txt
?????文件????????6689??2018-09-12?10:32??videopeopledetect\videopeopledetect\videopeopledetect.cpp
?????文件????????4107??2018-07-17?17:52??videopeopledetect\videopeopledetect\videopeopledetect.vcxproj
?????文件?????????958??2018-07-17?17:52??videopeopledetect\videopeopledetect\videopeopledetect.vcxproj.filters
?????文件????18481152??2018-09-12?10:06??videopeopledetect\videopeopledetect.sdf
?????文件?????????997??2018-07-16?20:48??videopeopledetect\videopeopledetect.sln
?????文件???????24064??2018-09-12?10:06??videopeopledetect\videopeopledetect.v12.suo

評論

共有 條評論