Mercurial Hosting > traffic-intelligence
comparison c/feature-based-tracking.cpp @ 145:7bf8084e720f
removed bug with loadMat and added diagnosis code for empty frames
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 29 Aug 2011 19:20:37 -0400 |
parents | b32947b002da |
children | 7150427c665e |
comparison
equal
deleted
inserted
replaced
144:b32947b002da | 145:7bf8084e720f |
---|---|
102 // } | 102 // } |
103 | 103 |
104 capture.open(params.videoFilename); | 104 capture.open(params.videoFilename); |
105 if(capture.isOpened()) { | 105 if(capture.isOpened()) { |
106 videoSize = Size(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT)); | 106 videoSize = Size(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT)); |
107 cout << "Video " << argv[1] << | 107 cout << "Video " << params.videoFilename << |
108 ": width=" << videoSize.width << | 108 ": width=" << videoSize.width << |
109 ", height=" << videoSize.height << | 109 ", height=" << videoSize.height << |
110 ", nframes=" << capture.get(CV_CAP_PROP_FRAME_COUNT) << endl; | 110 ", nframes=" << capture.get(CV_CAP_PROP_FRAME_COUNT) << endl; |
111 } else { | 111 } else { |
112 cout << "Video filename " << params.videoFilename << " could not be opened. Exiting." << endl; | 112 cout << "Video filename " << params.videoFilename << " could not be opened. Exiting." << endl; |
139 int key = '?'; | 139 int key = '?'; |
140 unsigned int savedFeatureId=0; | 140 unsigned int savedFeatureId=0; |
141 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)) && !::interruptionKey(key); frameNum++) { | 141 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)) && !::interruptionKey(key); frameNum++) { |
142 capture >> frame; | 142 capture >> frame; |
143 cout << frameNum << " " << capture.get(CV_CAP_PROP_POS_FRAMES) << " " << prevPts.size() << endl; | 143 cout << frameNum << " " << capture.get(CV_CAP_PROP_POS_FRAMES) << " " << prevPts.size() << endl; |
144 while (frame.empty()) | 144 int emptyFrameNum = 0; |
145 while (frame.empty()) { | |
146 cerr << "empty frame " << emptyFrameNum << " " << capture.get(CV_CAP_PROP_POS_FRAMES)<< endl; | |
145 capture >> frame;//break; | 147 capture >> frame;//break; |
148 emptyFrameNum++; | |
149 if (emptyFrameNum>=3000) | |
150 exit(0); | |
151 } | |
146 | 152 |
147 cvtColor(frame, currentFrameBW, CV_RGB2GRAY); | 153 cvtColor(frame, currentFrameBW, CV_RGB2GRAY); |
148 | 154 |
149 // "normal" feature detectors: detect features here | 155 // "normal" feature detectors: detect features here |
150 // detector.detect(currentFrameBW, currKpts); // see video_homography c++ sample | 156 // detector.detect(currentFrameBW, currKpts); // see video_homography c++ sample |