This example shows how to train and use a planar object detector
#include <iostream>
#include <highgui.h>
using namespace std;
int main(
int argc,
char *argv[])
{
if (argc<2) {
cerr << "Usage: " << argv[0]
<< " [-m <model image>] <image> [<image> ...]\n";
return -1;
}
for (int i=1; i<argc-1; i++) {
if (strcmp(argv[i], "-m") ==0) {
modelFile = argv[i+1];
break;
}
}
string(modelFile),
400,
32,
3,
16,
3
))
{
cerr << modelFile << ": Error while loading model image or classifier!\n";
return -2;
}
for (int i=1; i<argc; ++i) {
if (argv[i][0] == '-') { ++i; continue; }
IplImage *im = cvLoadImage(argv[i],0);
if (!im) {
cerr << argv[i] << ": unable to load image.\n";
continue;
}
cout << argv[i] << ": detection succeeded!\n";
char fn[512]; sprintf(fn,"result_%s", argv[i]);
cvSaveImage(fn, result);
cvReleaseImage(&result);
} else {
cout << argv[i] << ": detection failed.\n";
}
}
return 0;
}