Reputation: 10698
I'm trying to perform a camera calibration with a grid of circles. I've been unsuccessful because findCirclesGrid
always returns false even with a file that is nothing but a grid of circles. I've boiled it down to this simple program:
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
using namespace std;
using namespace cv;
int main(int argc, char *argv[]) {
Mat image;
// read an image
if (argc < 2)
image = imread("circleGridSmall.jpg");
else
image = imread(argv[1]);
if (!image.data) {
cout << "Image file not found\n";
return 1;
}
imshow("image", image);
waitKey(0);
bool found;
vector<Point2f> pointbuf;
found = findCirclesGrid( image, Size(8, 12), pointbuf);
printf("found: %d\n", found);
return 0;
}
And this simple image:
Even with this, findCirclesGrid
returns false. What am I missing?
Upvotes: 2
Views: 10970
Reputation: 1457
If it works at one size and not at another, then your size filtering on the blobs is tripping you up. You need to create a custom blob detector, which you tweak with min size, max size, circularity etc.. (although size is probably the one affecting you), then pass the custom blob detector as an optional parameter into your findCirclesGrid() function.
Anther thing I have found useful is to experiment with opencv and its python bindings. Turnaround time is a lot quicker than recompiling each time while you experiment with such things, then when you have it sussed out, you solidify the design into c++ code.
Upvotes: 2
Reputation: 3849
You have inverted the points_per_row
and points_per_colum
in Size() function.
According to the documentation of function findCirclesGrid(), 2nd parameter patternSize
is
Size(points_per_row, points_per_colum)
Theferore:
// not
found = findCirclesGrid( image, Size(8, 12), pointbuf);
// but
found = findCirclesGrid( image, Size(12, 8), pointbuf);
Upvotes: 3