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

  • 大小: 35.11MB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-07-05
  • 語言: Matlab
  • 標(biāo)簽: HOG??SVM??行人檢測(cè)??

資源簡(jiǎn)介

基于HOG和SVM的行人檢測(cè) matlab平臺(tái)

資源截圖

代碼片段和文件信息

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

using?namespace?std;
using?namespace?cv;

#define?PosSamNO?2400??//正樣本個(gè)數(shù)
#define?NegSamNO?12000????//負(fù)樣本個(gè)數(shù)

#define?TRAIN?false???//是否進(jìn)行訓(xùn)練true表示重新訓(xùn)練,false表示讀取xml文件中的SVM模型
#define?CENTRAL_CROP?true???//true:訓(xùn)練時(shí),對(duì)96*160的INRIA正樣本圖片剪裁出中間的64*128大小人體

//HardExample:負(fù)樣本個(gè)數(shù)。如果HardExampleNO大于0,表示處理完初始負(fù)樣本集后,繼續(xù)處理HardExample負(fù)樣本集。
//不使用HardExample時(shí)必須設(shè)置為0,因?yàn)樘卣飨蛄烤仃嚭吞卣黝悇e矩陣的維數(shù)初始化時(shí)用到這個(gè)值
#define?HardExampleNO?0??


//繼承自CvSVM的類,因?yàn)樯蓅etSVMDetector()中用到的檢測(cè)子參數(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()
{
//檢測(cè)窗口(64128)塊尺寸(1616)塊步長(zhǎng)(88)cell尺寸(88)直方圖bin個(gè)數(shù)9
HOGDescriptor?hog(Size(64128)Size(1616)Size(88)Size(88)9);//HOG檢測(cè)器,用來計(jì)算HOG描述子的
int?DescriptorDim;//HOG描述子的維數(shù),由圖片大小、檢測(cè)窗口大小、塊大小、細(xì)胞單元中直方圖bin個(gè)數(shù)決定
MySVM?svm;//SVM分類器

//若TRAIN為true,重新訓(xùn)練分類器
if(TRAIN)
{
string?ImgName;//圖片名(絕對(duì)路徑)
ifstream?finPos(“INRIAPerson96X160PosList.txt“);//正樣本圖片的文件名列表
//ifstream?finPos(“PersonFromVOC2012List.txt“);//正樣本圖片的文件名列表
ifstream?finNeg(“NoPersonFromINRIAList.txt“);//負(fù)樣本圖片的文件名列表

Mat?sampleFeatureMat;//所有訓(xùn)練樣本的特征向量組成的矩陣,行數(shù)等于所有樣本的個(gè)數(shù),列數(shù)等于HOG描述子維數(shù)
Mat?sampleLabelMat;//訓(xùn)練樣本的類別向量,行數(shù)等于所有樣本的個(gè)數(shù),列數(shù)等于1;1表示有人,-1表示無人


//依次讀取正樣本圖片,生成HOG描述子
for(int?num=0;?num {
cout<<“處理:“< //ImgName?=?“D:\\DataSet\\PersonFromVOC2012\\“?+?ImgName;//加上正樣本的路徑名
ImgName?=?“E:\\運(yùn)動(dòng)目標(biāo)檢測(cè)\\INRIAPerson\\96X160H96\\Train\\pos\\“?+?ImgName;//加上正樣本的路徑名
Mat?src?=?imread(ImgName);//讀取圖片
if(CENTRAL_CROP)
src?=?src(Rect(161664128));//將96*160的INRIA正樣本圖片剪裁為64*128,即剪去上下左右各16個(gè)像素
//resize(srcsrcSize(64128));

vector?descriptors;//HOG描述子向量
hog.compute(srcdescriptorsSize(88));//計(jì)算HOG描述子,檢測(cè)窗口移動(dòng)步長(zhǎng)(88)
//
cout<<“描述子維數(shù):“<riptors.size()<
//處理第一個(gè)樣本時(shí)初始化特征向量矩陣和類別矩陣,因?yàn)橹挥兄懒颂卣飨蛄康木S數(shù)才能初始化特征向量矩陣
if(?0?==?num?)
{
DescriptorDim?=?descriptors.size();//HOG描述子的維數(shù)
//初始化所有訓(xùn)練樣本的特征向量組成的矩陣,行數(shù)等于所有樣本的個(gè)數(shù),列數(shù)等于HOG描述子維數(shù)sampleFeatureMat
sampleFeatureMat?=?Mat::zeros(PosSamNO+NegSamNO+HardExampleNO?DescriptorDim?CV_32FC1);
//初始化訓(xùn)練樣本的類別向量,行數(shù)等于所有樣本的個(gè)數(shù),列數(shù)等于1;1表示有人,0表示無人
sampleLabelMat?=?Mat::zeros(PosSamNO+NegSamNO+HardExampleNO?1?CV_32FC1);
}

//將計(jì)算好的HOG描述子復(fù)制到樣本特征矩陣sampleFeatureMat
for(int?i=0;?iriptorDim;?i++)
sampleFeatureMat.at(numi)?=?descriptors[i];//第num個(gè)樣本的特征向量中的第i個(gè)元素
sampleLabelMat.at(num0)?=?

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-06-30?15:36??SVM_Train_Predict_HOG2\
?????目錄???????????0??2015-06-30?15:36??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\
?????目錄???????????0??2015-06-30?15:36??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\Debug\
?????文件??????144896??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.exe
?????文件?????1115176??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.ilk
?????文件?????1960960??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.pdb
?????目錄???????????0??2015-06-30?15:36??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\
?????文件??????174277??2013-10-22?16:53??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\00000.jpg
?????文件??????788547??2013-10-21?21:44??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\1.png
?????文件??????813015??2013-10-21?21:47??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\2.png
?????文件???????90689??2007-01-10?01:37??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\2007_000423.jpg
?????文件??????818604??2013-10-21?21:48??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\3.png
?????文件?????1610478??2013-10-21?21:48??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\4.png
?????文件??????911894??2013-10-21?21:49??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\5.png
?????目錄???????????0??2015-06-30?15:36??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\
?????文件???????27996??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\CL.read.1.tlog
?????文件?????????968??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\CL.write.1.tlog
?????文件?????????406??2013-11-07?15:55??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.exe.embed.manifest
?????文件?????????472??2014-11-24?11:22??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.exe.embed.manifest.res
?????文件?????????381??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.exe.intermediate.manifest
?????文件??????????78??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.lastbuildstate
?????文件????????3508??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.log
?????文件??????477476??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.obj
?????文件?????????707??2014-11-24?12:42??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.vcxprojResolveAssemblyReference.cache
?????文件???????????0??2014-11-24?11:22??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.write.1.tlog
?????文件?????????232??2013-11-07?15:55??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG_manifest.rc
?????文件????????1542??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\cl.command.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link-cvtres.read.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link-cvtres.write.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10128-cvtres.read.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG2\SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10128-cvtres.write.1.tlog
............此處省略120個(gè)文件信息

評(píng)論

共有 條評(píng)論