Mercurial > hg > nsaunier > traffic-intelligence
comparison c/feature-based-tracking.cpp @ 146:7150427c665e
added loading of mask
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 30 Aug 2011 13:04:36 -0400 |
| parents | 7bf8084e720f |
| children | 0089fb29cd26 |
comparison
equal
deleted
inserted
replaced
| 145:7bf8084e720f | 146:7150427c665e |
|---|---|
| 116 // { | 116 // { |
| 117 // //help(argv); | 117 // //help(argv); |
| 118 // cout << "capture device " << argv[1] << " failed to open!" << endl; | 118 // cout << "capture device " << argv[1] << " failed to open!" << endl; |
| 119 // return 1; | 119 // return 1; |
| 120 // } | 120 // } |
| 121 | |
| 122 // mask | |
| 123 Mat mask = imread(params.maskFilename, 0); | |
| 124 if (mask.empty()) | |
| 125 mask = Mat::ones(videoSize, CV_8UC1); | |
| 121 | 126 |
| 122 // database | 127 // database |
| 123 boost::shared_ptr<TrajectoryDBAccess<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccess<Point2f> >(new TrajectoryDBAccessList<Point2f>()); | 128 boost::shared_ptr<TrajectoryDBAccess<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccess<Point2f> >(new TrajectoryDBAccessList<Point2f>()); |
| 124 //TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>(); | 129 //TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>(); |
| 125 trajectoryDB->connect(params.databaseFilename.c_str()); | 130 trajectoryDB->connect(params.databaseFilename.c_str()); |
| 205 // cout << matches.size() << " matches" << endl; | 210 // cout << matches.size() << " matches" << endl; |
| 206 //drawMatchesRelative(prevKpts, currKpts, matches, frame); | 211 //drawMatchesRelative(prevKpts, currKpts, matches, frame); |
| 207 } | 212 } |
| 208 | 213 |
| 209 // adding new features, using mask around existing feature positions | 214 // adding new features, using mask around existing feature positions |
| 210 Mat featureMask = Mat::ones(videoSize, CV_8UC1); | 215 Mat featureMask = mask.clone(); |
| 211 for (unsigned int n=0;n<currPts.size(); n++) | 216 for (unsigned int n=0;n<currPts.size(); n++) |
| 212 for (int j=MAX(0, currPts[n].x-params.minFeatureDistanceKLT); j<MIN(videoSize.width, currPts[n].x+params.minFeatureDistanceKLT+1); j++) | 217 for (int j=MAX(0, currPts[n].x-params.minFeatureDistanceKLT); j<MIN(videoSize.width, currPts[n].x+params.minFeatureDistanceKLT+1); j++) |
| 213 for (int i=MAX(0, currPts[n].y-params.minFeatureDistanceKLT); i<MIN(videoSize.height, currPts[n].y+params.minFeatureDistanceKLT+1); i++) | 218 for (int i=MAX(0, currPts[n].y-params.minFeatureDistanceKLT); i<MIN(videoSize.height, currPts[n].y+params.minFeatureDistanceKLT+1); i++) |
| 214 featureMask.at<uchar>(i,j)=0; | 219 featureMask.at<uchar>(i,j)=0; |
| 215 goodFeaturesToTrack(currentFrameBW, newPts, params.maxNFeatures, params.featureQuality, params.minFeatureDistanceKLT, featureMask, params.windowSize, params.useHarrisDetector, params.k); | 220 goodFeaturesToTrack(currentFrameBW, newPts, params.maxNFeatures, params.featureQuality, params.minFeatureDistanceKLT, featureMask, params.windowSize, params.useHarrisDetector, params.k); |
