Example for usage of Checkerboard Detector Usage: ExampleCheckerboard <filename> <inner_xCorners> <inner_yCorners>
#include <Base/Common/W32Compat.hh>
#include <math.h>
#include <vector>
#include <string>
#include <iostream>
#include <Base/Debug/Error.hh>
#include <Base/Image/Image.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Common/FileHandling.hh>
#include <FeatureDetector/CheckerboardDetector.hh>
using namespace std;
using namespace BIAS;
int main(int argc, char** argv)
{
string imgFilename(BIAS_TESTS_DATA "chess7x4_002.jpg");
unsigned int xCorners(7), yCorners(4);
if (argc > 1)
imgFilename = argv[1];
if (argc > 2)
xCorners = atoi(argv[2]);
if (argc > 3)
yCorners = atoi(argv[3]);
if (argc < 2)
cout << "Usage: ExampleCheckerboard [<image>] [<corners x>] [<corners y>]"
<< endl << endl
<< "Default: image " << imgFilename << " with 7 x 4 corners"
<< endl << endl;
else
cout << "Detecting " << xCorners << "x " << yCorners << " corners in image "
<< imgFilename << endl << endl;
cout << "Loading image " << imgFilename << endl;
if (ImageIO::Load(imgFilename, img)!=0)
{
cout << "Failed to load image " << imgFilename << "!" << endl;
return -1;
}
vector< pair<float,float> > coords;
int result = CheckerboardDetector::Compute(img, xCorners , yCorners, coords, true);
if (result != 0){
cout << "Failed to detect corners!" << endl;
return -1;
}
cout << "Detected " << coords.size() << " corners : " << endl;
for (unsigned int i = 0; i < coords.size(); i++) {
cout << "[" << (i+1) << "] corner " << coords[i].first << ", " << coords[i].second
<< endl;
}
cout << endl;
return 0;
}