【问题标题】:OpenCV's findCirclesGrid isn't finding a grid of circlesOpenCV 的 findCirclesGrid 没有找到圆圈网格
【发布时间】:2016-10-02 20:59:37
【问题描述】:

我正在尝试使用圆形网格执行相机校准。我一直没有成功,因为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。我错过了什么?

【问题讨论】:

    标签: c++ opencv


    【解决方案1】:

    您已在 Size() 函数中反转了 points_per_rowpoints_per_colum
    根据函数findCirclesGrid()的文档,2nd参数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); 
    

    【讨论】:

    • 这就是这张图片的原因,但不幸的是,这不是唯一的问题。我的原始图像是 3264 x 2448。我为这篇文章缩小了它。 findCirclesGrid 在全尺寸图片中找不到圆圈。因此,作为测试,我在照片上将它们减少了 75% 后调用了findCirclesGrid,它找到了圆圈。所以显然有一些未记录的最大尺寸图像可以使用,或者它只是一个错误。
    • 我做了一些测试,一旦图像达到 2448 x 1836 findCirclesGrid 找不到任何圈子。
    【解决方案2】:

    如果它适用于一种尺寸而不适用于另一种尺寸,那么您对 ​​blob 的尺寸过滤会让您失望。您需要创建一个自定义 blob 检测器,您可以使用最小尺寸、最大尺寸、圆形度等进行调整。(尽管尺寸可能是影响您的因素),然后将自定义 blob 检测器作为可选参数传递给您的 findCirclesGrid() 函数.

    我发现有用的另一件事是尝试使用 opencv 及其 python 绑定。周转时间比每次尝试这些东西时都重新编译要快得多,然后当你搞定它时,你将设计固化成 c++ 代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-08
      • 1970-01-01
      • 1970-01-01
      • 2021-11-17
      • 2020-06-24
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多