some samples updated according to new CommandLineParser class
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* Author: Liu Liu
|
||||
* liuliu.1987+opencv@gmail.com
|
||||
*/
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/objdetect/objdetect.hpp>
|
||||
#include <opencv2/features2d/features2d.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
@@ -14,16 +15,17 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
void help()
|
||||
{
|
||||
printf(
|
||||
"This program demonstrated the use of the SURF Detector and Descriptor using\n"
|
||||
"either FLANN (fast approx nearst neighbor classification) or brute force matching\n"
|
||||
"on planar objects.\n"
|
||||
"Call:\n"
|
||||
"./find_obj [<object_filename default box.png> <scene_filename default box_in_scene.png>]\n\n"
|
||||
);
|
||||
|
||||
printf( "This program demonstrated the use of the SURF Detector and Descriptor using\n"
|
||||
"either FLANN (fast approx nearst neighbor classification) or brute force matching\n"
|
||||
"on planar objects.\n"
|
||||
"Call:\n"
|
||||
"./find_obj [--object_filename]=<object_filename, box.png as default> \n"
|
||||
"[--scene_filename]=<scene_filename box_in_scene.png as default>]\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
// define whether to use approximate nearest-neighbor search
|
||||
@@ -209,13 +211,16 @@ locatePlanarObject( const CvSeq* objectKeypoints, const CvSeq* objectDescriptors
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
const char* object_filename = argc == 3 ? argv[1] : "box.png";
|
||||
const char* scene_filename = argc == 3 ? argv[2] : "box_in_scene.png";
|
||||
help();
|
||||
|
||||
CommandLineParser parser(argc, argv);
|
||||
|
||||
string objectFileName = parser.get<string>("object_filename", "box.png");
|
||||
string sceneFileName = parser.get<string>("scene_filename", "box_in_scene.png");
|
||||
|
||||
CvMemStorage* storage = cvCreateMemStorage(0);
|
||||
help();
|
||||
cvNamedWindow("Object", 1);
|
||||
cvNamedWindow("Object Correspond", 1);
|
||||
|
||||
@@ -232,13 +237,11 @@ int main(int argc, char** argv)
|
||||
{{255,255,255}}
|
||||
};
|
||||
|
||||
IplImage* object = cvLoadImage( object_filename, CV_LOAD_IMAGE_GRAYSCALE );
|
||||
IplImage* image = cvLoadImage( scene_filename, CV_LOAD_IMAGE_GRAYSCALE );
|
||||
IplImage* object = cvLoadImage( objectFileName.c_str(), CV_LOAD_IMAGE_GRAYSCALE );
|
||||
IplImage* image = cvLoadImage( sceneFileName.c_str(), CV_LOAD_IMAGE_GRAYSCALE );
|
||||
if( !object || !image )
|
||||
{
|
||||
fprintf( stderr, "Can not load %s and/or %s\n"
|
||||
"Usage: find_obj [<object_filename> <scene_filename>]\n",
|
||||
object_filename, scene_filename );
|
||||
fprintf( stderr, "Can not load %s and/or %s\n", objectFileName.c_str(), sceneFileName.c_str() );
|
||||
exit(-1);
|
||||
}
|
||||
IplImage* object_color = cvCreateImage(cvGetSize(object), 8, 3);
|
||||
|
Reference in New Issue
Block a user