FindChessboardCorners 无法通过长焦距镜头在超大图像上检测棋盘 [英] FindChessboardCorners cannot detect chessboard on very large images by long focal length lens

查看:27
本文介绍了FindChessboardCorners 无法通过长焦距镜头在超大图像上检测棋盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将 FindChessboardCorners 函数用于小于 15 兆像素的图像,例如 2k x 1.5k.但是,当我在 DSLR 的图像上使用它时,分辨率为 3700x5300,它不起作用.

I can use FindChessboardCorners functions for images that less than 15 Mega pixel such like 2k x 1.5k. however when I use it on the image from DSLR, the resolution at 3700x5300, it doesn't work.

我尝试使用resize()直接缩小图片大小,然后就可以了.

I tried to use resize() to reduce the image size directly, then it works.

显然 OpenCV 源代码中存在一些硬编码或错误.

Obviously there's some hard coded or bug in the OpenCV source code.

你能帮我弄清楚吗,或者给我一个补丁?

Could you help me to figure it out, or point me to a patch for this ?

我发现有人在 2006 年发布了类似的问题,这里,所以看起来问题仍然存在.

I found someone posted a similar issue in 2006, here, so it looks like the problem still remains.

我使用的代码是这样的

found = findChessboardCorners( viewGray, boardSize, ptvec,
                                CV_CALIB_CB_ADAPTIVE_THRESH + CV_CALIB_CB_FILTER_QUADS + CV_CALIB_CB_NORMALIZE_IMAGE + CV_CALIB_CB_FAST_CHECK);

更新

只是在这里澄清一下.我认为该算法适用于大图像分辨率,但当棋​​盘占据图像的较大比例时它会失败.例如,当我在同一相机位置使用 50mm 固定镜头时,FindChessboardCorners 永远不会失败.在我将其更改为 100mm 固定镜头后,该功能开始停止检测图案.我认为这与比例或焦距有关.

Just here to clarify. I think the algorithm works on large image resolution, but it fails when the chessboard occupy larger proportion of the image. For example, when I use a 50mm fixed lens on the same camera position, FindChessboardCorners never fails. After I change it to 100mm fixed lens, the function starts to stop detecting the pattern. I think it relates to the proportion or the focal length.

下图是100mm镜头的效果.

The image below is the 100mm lens result.

更新 2

我为大图像添加了锐化滤镜,它开始解决问题.

I added a sharpen filter to the large image, and it starts to fix the problem.

首先我使用了

//do a sharpen filter for the large resolution image
if (viewGray.cols > 1500)
{
  Mat temp ;
  GaussianBlur(viewGray,temp, Size(0,0), 105) ; //hardcoded filter size, to be tested on 50 mm lens
  addWeighted(viewGray, 1.8, temp, -0.8,0,viewGray) ; //hardcoded weight, to be tested.
//imwrite("test"+ imageList[k][i], viewGray) ;

}

found = findChessboardCorners( viewGray, boardSize, ptvec,
CV_CALIB_CB_ADAPTIVE_THRESH + CV_CALIB_CB_FILTER_QUADS + CV_CALIB_CB_NORMALIZE_IMAGE + CV_CALIB_CB_FAST_CHECK);

上传图片:

原始分辨率为 3744 x 5616 的 jpg 图片,如果本站强制转换,请确保您使用的是正确的分辨率.

A jpg image at original resolution 3744 x 5616, if this site force convert, then make sure you are using at the correct resolution.

推荐答案

几点.

  1. 如您所见,缩小尺寸有助于检测器.这是因为 OpenCV 中用于查找角点的角点检测过滤器具有固定大小,并且卷积掩码的大小可能太小而无法检测到角点 - 在该比例下,全尺寸图像实际上可能看起来平滑",特别是稍微模糊的地方.但是,缩小比例会降低角点位置的准确性.
  2. 出于同样的原因,锐化也有帮助.然而,它也违背了准确性,因为它会增加角落的子像素位置的偏差——即使在没有噪声的理想情况下也是如此.为了让自己相信这种情况,请考虑 1D 模拟:拐角处的图像强度(在 1D 中,清晰的黑白过渡)在理想情况下看起来像 sigmoid 曲线(具有平滑拐角的斜坡),并且您想要找到其拐点的位置.锐化使曲线更陡峭,这通常会移动该点的位置.考虑到锐化通常会放大噪点,情况会变得更糟.
  3. 可能的正确方法是从较低的分辨率开始(即缩小尺寸),然后放大由此找到的角的位置,并将它们用作在全分辨率下运行 cvFindCornersSubpix 的初始估计值.

这篇关于FindChessboardCorners 无法通过长焦距镜头在超大图像上检测棋盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆