Mercurial Hosting > traffic-intelligence
changeset 193:a728fce85881
simple test of adding and using default HoG pedestrian detector
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 12 Dec 2011 15:44:54 -0500 |
parents | 38974d27dd2d |
children | 09c7881073f3 |
files | c/Makefile c/feature-based-tracking.cpp |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Makefile Mon Dec 12 02:05:26 2011 -0500 +++ b/c/Makefile Mon Dec 12 15:44:54 2011 -0500 @@ -20,7 +20,7 @@ ifneq ($(OPENCV), 0) CFLAGS += -DUSE_OPENCV - LDFLAGS += -lopencv_highgui -lopencv_core -lopencv_video -lopencv_ml -lopencv_features2d -lopencv_imgproc + LDFLAGS += -lopencv_highgui -lopencv_core -lopencv_video -lopencv_ml -lopencv_features2d -lopencv_imgproc -lopencv_objdetect endif ifeq ($(UNAME), Linux)
--- a/c/feature-based-tracking.cpp Mon Dec 12 02:05:26 2011 -0500 +++ b/c/feature-based-tracking.cpp Mon Dec 12 15:44:54 2011 -0500 @@ -12,6 +12,7 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/features2d/features2d.hpp" #include "opencv2/highgui/highgui.hpp" +#include "opencv2/objdetect/objdetect.hpp" #include <boost/shared_ptr.hpp> #include <boost/foreach.hpp> @@ -138,6 +139,9 @@ vector<FeatureTrajectoryPtr> lostFeatures; vector<FeaturePointMatch> featurePointMatches; + HOGDescriptor hog; + hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); + int key = '?'; unsigned int savedFeatureId=0; Mat frame, currentFrameBW, previousFrameBW; @@ -199,6 +203,11 @@ if (params.display) { BOOST_FOREACH(FeaturePointMatch fp, featurePointMatches) fp.feature->draw(frame, invHomography, Colors::red()); + // object detection + // vector<Rect> locations; + // hog.detectMultiScale(frame, locations, 0, Size(8,8), Size(32,32), 1.05, 2); + // BOOST_FOREACH(Rect r, locations) + // rectangle(frame, r.tl(), r.br(), cv::Scalar(0,255,0), 3); } //drawOpticalFlow(prevPts, currPts, status, frame);