我正在尝试用圆圈网格执行相机校准。我一直不成功,因为findCirclesGrid
始终返回false,即使文件只不过是一个网格。我将其简化为以下简单程序:
#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;
}
这个简单的图像:
即使这样,
findCirclesGrid
仍返回false。我想念什么? 最佳答案
您已经在 Size()函数中反转了points_per_row
和points_per_colum
。
根据函数findCirclesGrid()的文档,第二个参数patternSize
为
Size(points_per_row, points_per_colum)
Theferore:
// not
found = findCirclesGrid( image, Size(8, 12), pointbuf);
// but
found = findCirclesGrid( image, Size(12, 8), pointbuf);
关于c++ - OpenCV的findCirclesGrid找不到圆网格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37603445/