不同颜色棋盘的 OpenCV 相机标定

标签 opencv camera camera-calibration

今天早上我想到了一个疑问:findChessboardCorners OpenCV 函数是否适用于不同颜色(例如蓝色)的棋盘? 如果不是这种情况,您认为非常简单的阈值设置是否可以解决问题?

最佳答案

您不能将彩色图像传递给 findChessboardCorners,因为正如 @api55 在他的评论中指出的那样,它只需要一张灰度图像。

您可能值得看一下提供的棋盘代码 here

// does a fast check if a chessboard is in the input image. This is a workaround to
// a problem of cvFindChessboardCorners being slow on images with no chessboard
// - src: input binary image
// - size: chessboard size
// Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
// 0 if there is no chessboard, -1 in case of error
int checkChessboardBinary(const cv::Mat & img, const cv::Size & size)
{
    CV_Assert(img.channels() == 1 && img.depth() == CV_8U);

    Mat white = img.clone();
    Mat black = img.clone();

    int result = 0;
    for ( int erosion_count = 0; erosion_count <= 3; erosion_count++ )
    {
        if ( 1 == result )
            break;

        if ( 0 != erosion_count ) // first iteration keeps original images
        {
            erode(white, white, Mat(), Point(-1, -1), 1);
            dilate(black, black, Mat(), Point(-1, -1), 1);
        }

        vector<pair<float, int> > quads;
        fillQuads(white, black, 128, 128, quads);
        if (checkQuads(quads, size))
            result = 1;
    }
    return result;
}

主循环是:

CV_IMPL
int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
                             CvPoint2D32f* out_corners, int* out_corner_count,
                             int flags )

是这个方法的主要实现。他们在这里

  1. 使用cvCheckChessboard判断图像中是否有棋盘
  2. 转换为二进制 (B&W) 并膨胀以将角分开 使用
  3. icvGenerateQuads 找到正方形。

因此,在回答您的问题时,只要您的图像在将其转换为灰度后有足够的对比度,它就可能会起作用,我想灰度蓝白图像就足够了,如果它是光的话水绿色或黄色或其他你可能不经过更多处理就难以处理的东西

关于不同颜色棋盘的 OpenCV 相机标定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48316923/

相关文章:

opencv - OpenCV 中基本矩阵的基本矩阵

C++/OpenCV 在图像上查找对象

python - 查找具有轮廓的对象的旋转

opencv - python cv2.calibrateCamera 的输入参数

c++ - libv4l2 错误 : No space left on device

ios - 如何使用 `AVFoundation` 检测相机是否存在?

c++ - 来自 Tsai 校准参数的 3x3 单应矩阵

Python:如何从图像中切出具有特定颜色的区域(OpenCV、Numpy)

c++ - OpenCV:cv::mat 是否像 shared_ptr?

java - 如何在android studio中不使用 Intent 的情况下从相机拍照