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

  • 大小: 38.44MB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2023-07-17
  • 語言: 其他
  • 標簽: hog??svm??行人檢測??

資源簡介

行人檢測分類器的訓練,訓練完可測試效果如何,注意樣本的路徑問題

資源截圖

代碼片段和文件信息

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

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

#define?PosSamNO?2400??//正樣本個數
#define?NegSamNO?12000????//負樣本個數

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

//HardExample:負樣本個數。如果HardExampleNO大于0,表示處理完初始負樣本集后,繼續處理HardExample負樣本集。
//不使用HardExample時必須設置為0,因為特征向量矩陣和特征類別矩陣的維數初始化時用到這個值
#define?HardExampleNO?0??


//繼承自CvSVM的類,因為生成setSVMDetector()中用到的檢測子參數時,需要用到訓練好的SVM的decision_func參數,
//但通過查看CvSVM源碼可知decision_func參數是protected類型變量,無法直接訪問到,只能繼承之后通過函數訪問
class?MySVM?:?public?CvSVM??
{??
public:??
????//獲得SVM的決策函數中的alpha數組??
????double?*?get_alpha_vector()??
????{??
????????return?this->decision_func->alpha;??
????}??
??
????//獲得SVM的決策函數中的rho參數即偏移量??
????float?get_rho()??
????{??
????????return?this->decision_func->rho;??
????}??
};?



int?main()
{
//檢測窗口(64128)塊尺寸(1616)塊步長(88)cell尺寸(88)直方圖bin個數9
HOGDescriptor?hog(Size(64128)Size(1616)Size(88)Size(88)9);//HOG檢測器,用來計算HOG描述子的
int?DescriptorDim;//HOG描述子的維數,由圖片大小、檢測窗口大小、塊大小、細胞單元中直方圖bin個數決定
MySVM?svm;//SVM分類器

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

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


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

vector?descriptors;//HOG描述子向量
hog.compute(srcdescriptorsSize(88));//計算HOG描述子,檢測窗口移動步長(88)
//
cout<<“描述子維數:“<riptors.size()<
//處理第一個樣本時初始化特征向量矩陣和類別矩陣,因為只有知道了特征向量的維數才能初始化特征向量矩陣
if(?0?==?num?)
{
DescriptorDim?=?descriptors.size();//HOG描述子的維數
//初始化所有訓練樣本的特征向量組成的矩陣,行數等于所有樣本的個數,列數等于HOG描述子維數sampleFeatureMat
sampleFeatureMat?=?Mat::zeros(PosSamNO+NegSamNO+HardExampleNO?DescriptorDim?CV_32FC1);
//初始化訓練樣本的類別向量,行數等于所有樣本的個數,列數等于1;1表示有人,0表示無人
sampleLabelMat?=?Mat::zeros(PosSamNO+NegSamNO+HardExampleNO?1?CV_32FC1);
}

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

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-11-24?17:29??SVM_Train_Predict_HOG\
?????目錄???????????0??2014-11-24?14:45??SVM_Train_Predict_HOG\Debug\
?????文件??????144896??2014-11-24?16:06??SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.exe
?????文件?????1115176??2014-11-24?16:06??SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.ilk
?????文件?????1960960??2014-11-24?16:06??SVM_Train_Predict_HOG\Debug\SVM_Train_Predict_HOG.pdb
?????目錄???????????0??2014-11-24?09:25??SVM_Train_Predict_HOG\ipch\
?????目錄???????????0??2014-11-24?09:27??SVM_Train_Predict_HOG\ipch\svm_train_predict_hog-878bb37b\
?????文件????49741824??2014-11-24?17:25??SVM_Train_Predict_HOG\ipch\svm_train_predict_hog-878bb37b\svm_train_predict_hog-b7ad37e6.ipch
?????目錄???????????0??2014-11-24?13:35??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\
?????文件????13258752??2014-11-24?17:29??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG.sdf
?????文件?????????930??2013-11-07?15:49??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG.sln
?????文件???????16896??2014-11-24?17:29??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG.suo
?????文件??????174277??2013-10-22?16:53??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\00000.jpg
?????文件??????788547??2013-10-21?21:44??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\1.png
?????文件??????813015??2013-10-21?21:47??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\2.png
?????文件???????90689??2007-01-10?01:37??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\2007_000423.jpg
?????文件??????818604??2013-10-21?21:48??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\3.png
?????文件?????1610478??2013-10-21?21:48??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\4.png
?????文件??????911894??2013-10-21?21:49??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\5.png
?????目錄???????????0??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\
?????文件????????1542??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\cl.command.1.tlog
?????文件???????27996??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\CL.read.1.tlog
?????文件?????????968??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\CL.write.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link-cvtres.read.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link-cvtres.write.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10128-cvtres.read.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10128-cvtres.write.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10128.read.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10128.write.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10220-cvtres.read.1.tlog
?????文件???????????2??2014-11-24?16:06??SVM_Train_Predict_HOG\SVM_Train_Predict_HOG\Debug\link.10220-cvtres.write.1.tlog
............此處省略119個文件信息

評論

共有 條評論