Mercurial > hg > nsaunier > traffic-intelligence
comparison c/feature-based-tracking.cpp @ 121:c4d4b5b93add
copied the video_homography opencv sample
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 15 Aug 2011 12:53:10 -0400 |
| parents | 45a426552aaa |
| children | 654f1c748644 |
comparison
equal
deleted
inserted
replaced
| 120:46b166523bf8 | 121:c4d4b5b93add |
|---|---|
| 1 #include "../include/Feature.hpp" | 1 #include "../include/Feature.hpp" |
| 2 | |
| 3 #include "opencv2/highgui/highgui.hpp" | |
| 4 //#include "opencv2/imgproc/imgproc.hpp" | |
| 5 #include "opencv2/features2d/features2d.hpp" | |
| 6 | |
| 7 #include <iostream> | |
| 8 //#include <list> | |
| 9 #include <vector> | |
| 10 | |
| 11 using namespace std; | |
| 12 using namespace cv; | |
| 2 | 13 |
| 3 //#include "cv.h" | 14 //#include "cv.h" |
| 4 | 15 |
| 5 using namespace std; | 16 using namespace std; |
| 6 | 17 |
| 7 int main(int argc, char *argv[]) { | 18 int main(int argc, char *argv[]) { |
| 8 | 19 |
| 20 BriefDescriptorExtractor brief(32); | |
| 21 | |
| 22 VideoCapture capture; | |
| 23 capture.open(atoi(argv[1])); | |
| 24 if (!capture.isOpened()) | |
| 25 { | |
| 26 //help(argv); | |
| 27 cout << "capture device " << atoi(argv[1]) << " failed to open!" << endl; | |
| 28 return 1; | |
| 29 } | |
| 30 | |
| 31 Mat frame; | |
| 32 | |
| 33 vector<DMatch> matches; | |
| 34 | |
| 35 BruteForceMatcher<Hamming> desc_matcher; | |
| 36 | |
| 37 vector<Point2f> train_pts, query_pts; | |
| 38 vector<KeyPoint> train_kpts, query_kpts; | |
| 39 vector<unsigned char> match_mask; | |
| 40 | |
| 41 Mat gray; | |
| 42 | |
| 43 Mat train_desc, query_desc; | |
| 44 const int DESIRED_FTRS = 500; | |
| 45 GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4); | |
| 46 | |
| 47 for (;;) | |
| 48 { | |
| 49 capture >> frame; | |
| 50 if (frame.empty()) | |
| 51 break; | |
| 52 | |
| 53 cvtColor(frame, gray, CV_RGB2GRAY); | |
| 54 | |
| 55 detector.detect(gray, query_kpts); //Find interest points | |
| 56 | |
| 57 brief.compute(gray, query_kpts, query_desc); //Compute brief descriptors at each keypoint location | |
| 58 | |
| 59 // find how keypoints descriptions are matched to previous ones (in train kpts probably) | |
| 60 | |
| 61 imshow("frame", frame); | |
| 62 char key = (char)waitKey(2); | |
| 63 } | |
| 64 | |
| 9 Feature f; | 65 Feature f; |
| 10 | 66 |
| 11 return 0; | 67 return 0; |
| 12 } | 68 } |
| 13 | 69 |
