comparison c/feature-based-tracking.cpp @ 679:576d9ea4b41a

small update to deal with videos where the number of frames cannot be read
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 04 Jun 2015 16:04:58 +0200
parents 39fa1c998b29
children 70a3cdf0dbb3
comparison
equal deleted inserted replaced
677:ae07c7b4cf87 679:576d9ea4b41a
19 #include <iostream> 19 #include <iostream>
20 #include <vector> 20 #include <vector>
21 #include <ctime> 21 #include <ctime>
22 #include <cmath> 22 #include <cmath>
23 #include <memory> 23 #include <memory>
24 #include <limits>
24 25
25 using namespace std; 26 using namespace std;
26 using namespace cv; 27 using namespace cv;
27 28
28 void drawMatchesRelative(const vector<KeyPoint>& train, const vector<KeyPoint>& query, std::vector<cv::DMatch>& matches, Mat& img) { 29 void drawMatchesRelative(const vector<KeyPoint>& train, const vector<KeyPoint>& query, std::vector<cv::DMatch>& matches, Mat& img) {
99 exit(0); 100 exit(0);
100 } 101 }
101 102
102 Size videoSize = Size(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT)); 103 Size videoSize = Size(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT));
103 unsigned int nFrames = capture.get(CV_CAP_PROP_FRAME_COUNT); 104 unsigned int nFrames = capture.get(CV_CAP_PROP_FRAME_COUNT);
105 if (nFrames <= 0) {
106 cout << "Guessing that the number of frames could not be read: " << nFrames << endl;
107 nFrames = numeric_limits<int>::max();
108 cout << "Setting arbitrarily high number for testing: " << nFrames << endl;
109 }
110
104 cout << "Video " << params.videoFilename << 111 cout << "Video " << params.videoFilename <<
105 ": width=" << videoSize.width << 112 ": width=" << videoSize.width <<
106 ", height=" << videoSize.height << 113 ", height=" << videoSize.height <<
107 ", nframes=" << nFrames << endl; 114 ", nframes=" << nFrames << endl;
108 115