Mercurial Hosting > traffic-intelligence
changeset 278:f21ef87f98f1
resolved issue 2 and problem with negative nframes parameter
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 14 Dec 2012 01:01:55 -0500 |
parents | 21f14fadd098 |
children | 3af4c267a7bf |
files | c/Parameters.cpp c/feature-based-tracking.cpp include/Parameters.hpp |
diffstat | 3 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Parameters.cpp Fri Dec 14 01:01:26 2012 -0500 +++ b/c/Parameters.cpp Fri Dec 14 01:01:55 2012 -0500 @@ -34,7 +34,7 @@ ("display", po::value<bool>(&display), "display trajectories on the video") ("video-fps", po::value<float>(&videoFPS), "original video frame rate") ("frame1", po::value<unsigned int>(&frame1), "first frame to process") - ("nframes", po::value<unsigned int>(&nFrames), "number of frame to process") + ("nframes", po::value<int>(&nFrames), "number of frame to process") // feature tracking ("max-nfeatures", po::value<int>(&maxNFeatures), "maximum number of features added at each frame") ("feature-quality", po::value<float>(&featureQuality), "quality level of the good features to track")
--- a/c/feature-based-tracking.cpp Fri Dec 14 01:01:26 2012 -0500 +++ b/c/feature-based-tracking.cpp Fri Dec 14 01:01:55 2012 -0500 @@ -125,17 +125,22 @@ int key = '?'; unsigned int savedFeatureId=0; - Mat frame, currentFrameBW, previousFrameBW; + Mat frame = Mat::zeros(1, 1, CV_8UC1), currentFrameBW, previousFrameBW; - unsigned int lastFrameNum = params.frame1+nFrames; + unsigned int lastFrameNum = nFrames; if (params.nFrames > 0) - lastFrameNum = MIN(params.frame1+params.nFrames, nFrames); + lastFrameNum = MIN(params.frame1+static_cast<unsigned int>(params.nFrames), nFrames); - capture.set(CV_CAP_PROP_POS_FRAMES, params.frame1); + //capture.set(CV_CAP_PROP_POS_FRAMES, params.frame1); for (unsigned int frameNum = params.frame1; (frameNum < lastFrameNum) && !::interruptionKey(key); frameNum++) { capture >> frame; + + if (frame.empty() || frame.size() != videoSize) + break; + if (frameNum%50 ==0) cout << "frame " << frameNum << endl; + //capture.get(CV_CAP_PROP_POS_FRAMES) << " " << prevPts.size() << endl; // int emptyFrameNum = 0;
--- a/include/Parameters.hpp Fri Dec 14 01:01:26 2012 -0500 +++ b/include/Parameters.hpp Fri Dec 14 01:01:55 2012 -0500 @@ -25,7 +25,7 @@ float videoFPS; // int measurementPrecision; unsigned int frame1; - unsigned int nFrames; + int nFrames; // feature tracking int maxNFeatures; float featureQuality;