small fixes for features2d tutorials

This commit is contained in:
berak 2015-05-10 13:44:49 +02:00
parent a69b435c92
commit 3fe69f4e67
4 changed files with 12 additions and 11 deletions

View File

@ -49,13 +49,13 @@ int main( int argc, char** argv )
int minHessian = 400; int minHessian = 400;
Ptr<SURF> detector = SURF::create(); Ptr<SURF> detector = SURF::create();
detector->setMinHessian(minHessian); detector->setHessianThreshold(minHessian);
std::vector<KeyPoint> keypoints_1, keypoints_2; std::vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2; Mat descriptors_1, descriptors_2;
detector->detectAndCompute( img_1, keypoints_1, descriptors_1 ); detector->detectAndCompute( img_1, Mat(), keypoints_1, descriptors_1 );
detector->detectAndCompute( img_2, keypoints_2, descriptors_2 ); detector->detectAndCompute( img_2, Mat(), keypoints_2, descriptors_2 );
//-- Step 2: Matching descriptor vectors with a brute force matcher //-- Step 2: Matching descriptor vectors with a brute force matcher
BFMatcher matcher(NORM_L2); BFMatcher matcher(NORM_L2);

View File

@ -58,13 +58,13 @@ int main( int argc, char** argv )
int minHessian = 400; int minHessian = 400;
Ptr<SURF> detector = SURF::create(); Ptr<SURF> detector = SURF::create();
detector->setMinHessian(minHessian); detector->setHessianThreshold(minHessian);
std::vector<KeyPoint> keypoints_1, keypoints_2; std::vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2; Mat descriptors_1, descriptors_2;
detector->detectAndCompute( img_1, keypoints_1, descriptors_1 ); detector->detectAndCompute( img_1, Mat(), keypoints_1, descriptors_1 );
detector->detectAndCompute( img_2, keypoints_2, descriptors_2 ); detector->detectAndCompute( img_2, Mat(), keypoints_2, descriptors_2 );
//-- Step 2: Matching descriptor vectors using FLANN matcher //-- Step 2: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher; FlannBasedMatcher matcher;

View File

@ -20,6 +20,7 @@ This tutorial code's is shown lines below.
#include <stdio.h> #include <stdio.h>
#include <iostream> #include <iostream>
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp" #include "opencv2/features2d.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp" #include "opencv2/calib3d.hpp"
@ -50,8 +51,8 @@ int main( int argc, char** argv )
std::vector<KeyPoint> keypoints_object, keypoints_scene; std::vector<KeyPoint> keypoints_object, keypoints_scene;
Mat descriptors_object, descriptors_scene; Mat descriptors_object, descriptors_scene;
detector->detectAndCompute( img_object, keypoints_object, descriptors_object ); detector->detectAndCompute( img_object, Mat(), keypoints_object, descriptors_object );
detector->detectAndCompute( img_scene, keypoints_scene, descriptors_scene ); detector->detectAndCompute( img_scene, Mat(), keypoints_scene, descriptors_scene );
//-- Step 2: Matching descriptor vectors using FLANN matcher //-- Step 2: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher; FlannBasedMatcher matcher;
@ -81,13 +82,13 @@ int main( int argc, char** argv )
Mat img_matches; Mat img_matches;
drawMatches( img_object, keypoints_object, img_scene, keypoints_scene, drawMatches( img_object, keypoints_object, img_scene, keypoints_scene,
good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS ); std::vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Localize the object //-- Localize the object
std::vector<Point2f> obj; std::vector<Point2f> obj;
std::vector<Point2f> scene; std::vector<Point2f> scene;
for( int i = 0; i < good_matches.size(); i++ ) for( size_t i = 0; i < good_matches.size(); i++ )
{ {
//-- Get the keypoints from the good matches //-- Get the keypoints from the good matches
obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt ); obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );

View File

@ -96,7 +96,7 @@ void goodFeaturesToTrack_Demo( int, void* )
/// Draw corners detected /// Draw corners detected
cout<<"** Number of corners detected: "<<corners.size()<<endl; cout<<"** Number of corners detected: "<<corners.size()<<endl;
int r = 4; int r = 4;
for( int i = 0; i < corners.size(); i++ ) for( size_t i = 0; i < corners.size(); i++ )
{ circle( copy, corners[i], r, Scalar(rng.uniform(0,255), rng.uniform(0,255), { circle( copy, corners[i], r, Scalar(rng.uniform(0,255), rng.uniform(0,255),
rng.uniform(0,255)), -1, 8, 0 ); } rng.uniform(0,255)), -1, 8, 0 ); }