changeset 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 46b166523bf8
children 654f1c748644
files c/Makefile c/feature-based-tracking.cpp
diffstat 2 files changed, 57 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/c/Makefile	Mon Aug 15 11:56:34 2011 -0400
+++ b/c/Makefile	Mon Aug 15 12:53:10 2011 -0400
@@ -17,7 +17,7 @@
 
 ifneq ($(OPENCV), 0)
 	CFLAGS += -DUSE_OPENCV
-	LDFLAGS += -lopencv_highgui -lopencv_core -lopencv_video -lopencv_ml
+	LDFLAGS += -lopencv_highgui -lopencv_core -lopencv_video -lopencv_ml -lopencv_features2d
 endif
 
 ifeq ($(UNAME), Linux)
--- a/c/feature-based-tracking.cpp	Mon Aug 15 11:56:34 2011 -0400
+++ b/c/feature-based-tracking.cpp	Mon Aug 15 12:53:10 2011 -0400
@@ -1,11 +1,67 @@
 #include "../include/Feature.hpp"
 
+#include "opencv2/highgui/highgui.hpp"
+//#include "opencv2/imgproc/imgproc.hpp"
+#include "opencv2/features2d/features2d.hpp"
+
+#include <iostream>
+//#include <list>
+#include <vector>
+
+using namespace std;
+using namespace cv;
+
 //#include "cv.h"
 
 using namespace std;
 
 int main(int argc, char *argv[]) {
 
+  BriefDescriptorExtractor brief(32);
+  
+  VideoCapture capture;
+  capture.open(atoi(argv[1]));
+  if (!capture.isOpened())
+    {
+      //help(argv);
+      cout << "capture device " << atoi(argv[1]) << " failed to open!" << endl;
+      return 1;
+    }
+  
+  Mat frame;
+
+  vector<DMatch> matches;
+  
+  BruteForceMatcher<Hamming> desc_matcher;
+  
+  vector<Point2f> train_pts, query_pts;
+  vector<KeyPoint> train_kpts, query_kpts;
+  vector<unsigned char> match_mask;
+  
+  Mat gray;
+  
+  Mat train_desc, query_desc;
+  const int DESIRED_FTRS = 500;
+  GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4);
+  
+  for (;;)
+    {
+      capture >> frame;
+      if (frame.empty())
+	break;
+      
+      cvtColor(frame, gray, CV_RGB2GRAY);
+      
+      detector.detect(gray, query_kpts); //Find interest points
+      
+      brief.compute(gray, query_kpts, query_desc); //Compute brief descriptors at each keypoint location
+      
+      // find how keypoints descriptions are matched to previous ones (in train kpts probably)
+      
+      imshow("frame", frame);
+      char key = (char)waitKey(2);
+    }  
+  
   Feature f;
 
   return 0;