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

資源簡介

HOG+SVM的行人(圖片和視頻)檢測,在大量的訓(xùn)練樣本的基礎(chǔ)上得到行人檢測描述子,在此基礎(chǔ)上調(diào)用測試樣本(圖片及視頻),檢測效果不錯(cuò),在機(jī)器學(xué)習(xí)訓(xùn)練過程花費(fèi)大量時(shí)間。已測試碼源可用。

資源截圖

代碼片段和文件信息

//?3.cpp?:?定義控制臺應(yīng)用程序的入口點(diǎn)。
//
#include?
//#include?
#include???
#include?
#include?
#include???
#include???
#include???
#include???
#include???
#include?
#include?
#include?
#include?
#include??
using?namespace?std;
using?namespace?cv;
char?filename[1024];
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;
}
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void?main()
{
CvCapture*?cap?=?cvCreateFileCapture(“G:\\vsgc\\2.avi“);?//?讀入視頻
HOGDescriptor?hog(Size(64?128)?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(“G:\\opencv\\11.xml“);//從xml文件讀取訓(xùn)練好的SVM模型??//G:\\opencv\\11.xml?2400pes?12000neg?hardexample?4435?
//G:\\Data\\1.xml??2400pes?12000neg???????????G:\\opencv\\1500P2000N.xml?????G:\\opencv\\2400P12000N.xml
//G:\\Data\\2.xml??hog_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ù)號???
resultMat?=?-1?*?alphaMat?*?supportVectorMat;

//得到最終的setSVMDetector(const?v

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-06-11?01:40??shipinceshi\
?????目錄???????????0??2017-06-11?01:37??shipinceshi\3\
?????文件????????7893??2017-06-11?01:37??shipinceshi\3\3.cpp
?????文件????????4647??2017-04-17?13:57??shipinceshi\3\3.vcxproj
?????文件????????1308??2017-04-17?11:31??shipinceshi\3\3.vcxproj.filters
?????文件???????24102??2017-04-17?14:22??shipinceshi\3\3.zip
?????文件???????44073??2017-06-11?01:40??shipinceshi\3\HOGDetectorForOpenCV.txt
?????文件????????1468??2017-04-17?11:31??shipinceshi\3\ReadMe.txt
?????文件????23380170??2017-06-11?01:11??shipinceshi\3\out?-1.avi
?????文件????22864278??2017-06-11?01:40??shipinceshi\3\out.avi
?????文件?????????207??2017-04-17?11:31??shipinceshi\3\stdafx.cpp
?????文件?????????267??2017-04-17?13:03??shipinceshi\3\stdafx.h
?????文件?????????236??2017-04-17?11:31??shipinceshi\3\targetver.h
?????目錄???????????0??2017-06-11?01:26??shipinceshi\3\x64\
?????目錄???????????0??2017-06-11?01:37??shipinceshi\3\x64\Debug\
?????文件????????1634??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.log
?????文件??????907008??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.obj
?????文件?????3997696??2017-06-11?01:34??shipinceshi\3\x64\Debug\3.pch
?????目錄???????????0??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\
?????文件?????????151??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\3.lastbuildstate
?????文件???????67642??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\CL.read.1.tlog
?????文件????????2048??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\CL.write.1.tlog
?????文件????????6188??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\cl.command.1.tlog
?????文件???????12592??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\link.command.1.tlog
?????文件???????14966??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\link.read.1.tlog
?????文件????????1106??2017-06-11?01:37??shipinceshi\3\x64\Debug\3.tlog\link.write.1.tlog
?????文件???????10084??2017-06-11?01:34??shipinceshi\3\x64\Debug\stdafx.obj
?????文件?????1035264??2017-06-11?01:37??shipinceshi\3\x64\Debug\vc120.idb
?????文件?????1863680??2017-06-11?01:37??shipinceshi\3\x64\Debug\vc120.pdb
?????文件????16973824??2017-06-11?01:40??shipinceshi\3.sdf
?????文件????????1143??2017-04-17?12:34??shipinceshi\3.sln
............此處省略10個(gè)文件信息

評論

共有 條評論

相關(guān)資源