#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
-#include <iostream>
+//#include <iostream>
#include <stdio.h>
#include <ctype.h>
float hranges[] = {0,180};
const float* phranges = hranges;
-// if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
-// cap.open(argc == 2 ? argv[1][0] - '0' : 0);
-// else if( argc == 2 )
-// cap.open(argv[1]);
cap.open(cameraInd);
if( !cap.isOpened() )
{
help();
- cout << "***Could not initialize capturing...***\n";
+ printf("***Could not initialize capturing...***\n");
return 0;
}
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"
-#include <iostream>
+#include <stdio.h>
using namespace cv;
using namespace std;
void help()
{
- cout <<
- "\nThis program demonstrates Chamfer matching -- computing a distance between an \n"
- "edge template and a query edge image.\n"
- "Call:\n"
- "./chamfer [<image edge map> <template edge map>]\n"
- "By default\n"
- "the inputs are ./chamfer logo_in_clutter.png logo.png\n"<< endl;
+ printf("\nThis program demonstrates Chamfer matching -- computing a distance between an \n"
+ "edge template and a query edge image.\n"
+ "Usage:\n"
+ "./chamfer [<image edge map, logo_in_clutter.png as default>\n"
+ "<template edge map, logo.png as default>]\n"
+ "Example: \n"
+ " ./chamfer logo_in_clutter.png logo.png\n");
}
-int main( int argc, char** argv )
+int main( int argc, const char** argv )
{
- if( argc != 1 && argc != 3 )
- {
- help();
- return 0;
- }
- Mat img = imread(argc == 3 ? argv[1] : "logo_in_clutter.png", 0);
+ help();
+
+ CommandLineParser parser(argc, argv);
+
+ string image = parser.get<string>("0","logo_in_clutter.png");
+ string tempLate = parser.get<string>("1","logo.png");
+ Mat img = imread(image,0);
Mat cimg;
cvtColor(img, cimg, CV_GRAY2BGR);
- Mat tpl = imread(argc == 3 ? argv[2] : "logo.png", 0);
+ Mat tpl = imread(tempLate,0);
+
+// Mat img = imread(argc == 3 ? argv[1] : "logo_in_clutter.png", 0);
+// Mat cimg;
+// cvtColor(img, cimg, CV_GRAY2BGR);
+// Mat tpl = imread(argc == 3 ? argv[2] : "logo.png", 0);
+// if( argc != 1 && argc != 3 )
+// {
+// help();
+// return 0;
+// }
+
// if the image and the template are not edge maps but normal grayscale images,
// you might want to uncomment the lines below to produce the maps. You can also
// run Sobel instead of Canny.
int best = chamerMatching( img, tpl, results, costs );
if( best < 0 )
{
- cout << "not found;\n";
+ printf("not found;\n");
return 0;
}