comparison c/feature-based-tracking.cpp @ 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 0e60a306d324
children 09c7881073f3
comparison
equal deleted inserted replaced
192:38974d27dd2d 193:a728fce85881
10 #include "opencv2/core/core.hpp" 10 #include "opencv2/core/core.hpp"
11 #include "opencv2/imgproc/imgproc.hpp" 11 #include "opencv2/imgproc/imgproc.hpp"
12 #include "opencv2/video/tracking.hpp" 12 #include "opencv2/video/tracking.hpp"
13 #include "opencv2/features2d/features2d.hpp" 13 #include "opencv2/features2d/features2d.hpp"
14 #include "opencv2/highgui/highgui.hpp" 14 #include "opencv2/highgui/highgui.hpp"
15 #include "opencv2/objdetect/objdetect.hpp"
15 16
16 #include <boost/shared_ptr.hpp> 17 #include <boost/shared_ptr.hpp>
17 #include <boost/foreach.hpp> 18 #include <boost/foreach.hpp>
18 19
19 #include <iostream> 20 #include <iostream>
136 Mat prevDesc, currDesc; 137 Mat prevDesc, currDesc;
137 138
138 vector<FeatureTrajectoryPtr> lostFeatures; 139 vector<FeatureTrajectoryPtr> lostFeatures;
139 vector<FeaturePointMatch> featurePointMatches; 140 vector<FeaturePointMatch> featurePointMatches;
140 141
142 HOGDescriptor hog;
143 hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
144
141 int key = '?'; 145 int key = '?';
142 unsigned int savedFeatureId=0; 146 unsigned int savedFeatureId=0;
143 Mat frame, currentFrameBW, previousFrameBW; 147 Mat frame, currentFrameBW, previousFrameBW;
144 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)) && !::interruptionKey(key); frameNum++) { 148 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)) && !::interruptionKey(key); frameNum++) {
145 capture >> frame; 149 capture >> frame;
197 saveFeatures(lostFeatures, *trajectoryDB, "positions", "velocities"); 201 saveFeatures(lostFeatures, *trajectoryDB, "positions", "velocities");
198 202
199 if (params.display) { 203 if (params.display) {
200 BOOST_FOREACH(FeaturePointMatch fp, featurePointMatches) 204 BOOST_FOREACH(FeaturePointMatch fp, featurePointMatches)
201 fp.feature->draw(frame, invHomography, Colors::red()); 205 fp.feature->draw(frame, invHomography, Colors::red());
206 // object detection
207 // vector<Rect> locations;
208 // hog.detectMultiScale(frame, locations, 0, Size(8,8), Size(32,32), 1.05, 2);
209 // BOOST_FOREACH(Rect r, locations)
210 // rectangle(frame, r.tl(), r.br(), cv::Scalar(0,255,0), 3);
202 } 211 }
203 //drawOpticalFlow(prevPts, currPts, status, frame); 212 //drawOpticalFlow(prevPts, currPts, status, frame);
204 213
205 // cout << matches.size() << " matches" << endl; 214 // cout << matches.size() << " matches" << endl;
206 // descMatcher.match(currDesc, prevDesc, matches); 215 // descMatcher.match(currDesc, prevDesc, matches);