Mercurial > hg > nsaunier > traffic-intelligence
comparison c/feature-based-tracking.cpp @ 532:018653d1db3c
corrected bug with empty frames (the program will stop cleanly and store features
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Sun, 29 Jun 2014 14:18:17 -0400 |
| parents | 935430b1d408 |
| children | e37f38274d4f |
comparison
equal
deleted
inserted
replaced
| 531:f012a8ad7a0e | 532:018653d1db3c |
|---|---|
| 157 lastFrameNum = MIN(params.frame1+static_cast<unsigned int>(params.nFrames), nFrames); | 157 lastFrameNum = MIN(params.frame1+static_cast<unsigned int>(params.nFrames), nFrames); |
| 158 | 158 |
| 159 capture->setFrameNumber(params.frame1); | 159 capture->setFrameNumber(params.frame1); |
| 160 for (unsigned int frameNum = params.frame1; (frameNum < lastFrameNum) && !::interruptionKey(key); frameNum++) { | 160 for (unsigned int frameNum = params.frame1; (frameNum < lastFrameNum) && !::interruptionKey(key); frameNum++) { |
| 161 bool success = capture->getNextFrame(frame); | 161 bool success = capture->getNextFrame(frame); |
| 162 if (!success || frame.empty() || frame.size() != videoSize) { | |
| 163 cout << "Empty frame " << frameNum << ", breaking (" << success << " " << frame.empty() << " " << frame.size() << ")" << endl; | |
| 164 break; | |
| 165 } else if (frameNum%50 ==0) | |
| 166 cout << "frame " << frameNum << endl; | |
| 167 | |
| 162 if (params.undistort) { | 168 if (params.undistort) { |
| 163 remap(frame, undistortedFrame, map1, map2, interpolationMethod, BORDER_CONSTANT, 0.); | 169 remap(frame, undistortedFrame, map1, map2, interpolationMethod, BORDER_CONSTANT, 0.); |
| 164 frame = undistortedFrame; | 170 frame = undistortedFrame; |
| 165 } | 171 } |
| 166 //if (!success || frame.empty() || frame.size() != videoSize) | 172 |
| 167 //break; | |
| 168 | |
| 169 if (frameNum%50 ==0) | |
| 170 cout << "frame " << frameNum << endl; | |
| 171 | 173 |
| 172 cvtColor(frame, currentFrameBW, CV_RGB2GRAY); | 174 cvtColor(frame, currentFrameBW, CV_RGB2GRAY); |
| 173 | 175 |
| 174 if (!prevPts.empty()) { | 176 if (!prevPts.empty()) { |
| 175 currPts.clear(); | 177 currPts.clear(); |
