資源簡(jiǎn)介
opencv2.4.9+vs2013,行人檢測(cè)代碼,針對(duì)視頻檢測(cè),若想測(cè)圖片只需將讀入視頻部分轉(zhuǎn)為讀入圖片,且需要對(duì)視頻進(jìn)行壓縮(如格式工廠等,或在opencv內(nèi)部實(shí)現(xiàn)),太大的、清晰度高視頻速度較慢。

代碼片段和文件信息
#include?“opencv2/imgproc/imgproc.hpp“??
#include?“opencv2/objdetect/objdetect.hpp“??
#include?“opencv2/highgui/highgui.hpp“??
#include?“cv.h“
#include???
#include???
#include???
using?namespace?cv;
using?namespace?std;
void?dealMat(Mat?img)?{
namedWindow(“people?detector“);
HOGDescriptor?hog;
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
fflush(stdout);
vector?found?found_filtered;
double?t?=?(double)getTickCount();
//?run?the?detector?with?default?parameters.?to?get?a?higher?hit-rate??
//?(and?more?false?alarms?respectively)?decrease?the?hitThreshold?and??
//?groupThreshold?(set?groupThreshold?to?0?to?turn?off?the?grouping?completely).??
hog.detectMultiScale(img?found?0?Size(8?8)?Size(32?32)?1.05?2);
t?=?(double)getTickCount()?-?t;
printf(“tdetection?time?=?%gms\n“?t*1000.?/?cv::getTickFrequency());
size_t?i?j;
for?(i?=?0;?i? Rect?r?=?found[i];
for?(j?=?0;?j? if?(j?!=?i?&&?(r?&?found[j])?==?r)
break;
if?(j?==?found.size())
found_filtered.push_back(r);
}
for?(i?=?0;?i? Rect?r?=?found_filtered[i];
//?the?HOG?detector?returns?slightly?larger?rectangles?than?the?real?objects.??
//?so?we?slightly?shrink?the?rectangles?to?get?a?nicer?output.??
r.x?+=?cvRound(r.width*0.1);
r.width?=?cvRound(r.width*0.8);
r.y?+=?cvRound(r.height*0.07);
r.height?=?cvRound(r.height*0.8);
rectangle(img?r.tl()?r.br()?cv::Scalar(0?255?0)?3);
}
imshow(“people?detector“?img);
waitKey(20);
}
int?main(int?argc?char**?argv)?{
VideoCapture?capture(“D:\\1_1.mpg“);
Mat?img;
while?(capture.read(img))?{
dealMat(img);
}
return?0;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
????I.A....???1115520??2016-07-14?09:48??check\check\1_1.mpg
?????文件???????4227??2016-07-27?10:21??check\check\check.vcxproj
????I.A....???????961??2016-07-27?10:21??check\check\check.vcxproj.filters
????I.A....??????1780??2016-07-27?09:22??check\check\checkmain.cpp
????I.A....??????1920??2016-07-27?10:21??check\check\Debug\check.log
????I.A....???????155??2016-07-27?10:21??check\check\Debug\check.tlog\check.lastbuildstate
????I.A....???????658??2016-07-27?10:21??check\check\Debug\check.tlog\cl.command.1.tlog
????I.A....?????17864??2016-07-27?10:21??check\check\Debug\check.tlog\CL.read.1.tlog
????I.A....???????368??2016-07-27?10:21??check\check\Debug\check.tlog\CL.write.1.tlog
????I.A....??????1876??2016-07-27?10:21??check\check\Debug\check.tlog\li
????I.A....??????5404??2016-07-27?10:21??check\check\Debug\check.tlog\li
????I.A....???????336??2016-07-27?10:21??check\check\Debug\check.tlog\li
????I.A....????306843??2016-07-27?10:21??check\check\Debug\checkmain.obj
????I.A....????625664??2016-07-27?10:21??check\check\Debug\vc120.idb
????I.A....???1257472??2016-07-27?10:21??check\check\Debug\vc120.pdb
????I.A....??15138816??2016-07-27?10:22??check\check.sdf
????I.A....???????961??2016-07-27?10:20??check\check.sln
????I.A..H.?????19456??2016-07-27?10:22??check\check.v12.suo
????I.A....?????91648??2016-07-27?10:21??check\Debug\check.exe
????I.A....????489768??2016-07-27?10:21??check\Debug\check.ilk
????I.A....???1708032??2016-07-27?10:21??check\Debug\check.pdb
????I..D...?????????0??2016-07-27?10:21??check\check\Debug\check.tlog
????I..D...?????????0??2016-07-27?10:21??check\check\Debug
????I..D...?????????0??2016-07-28?11:40??check\check
????I..D...?????????0??2016-07-27?10:21??check\Debug
????I..D...?????????0??2016-07-28?11:40??check
-----------?---------??----------?-----??----
?????????????20789729????????????????????26
評(píng)論
共有 條評(píng)論