问题描述
好吧,OpenCv在C ++中带有其功能findCheckerboardCorners()
Well, OpenCv comes with its function findCheckerboardCorners() in C++ which goes like
bool findChessboardCorners(InputArray image, Size patternSize,
OutputArray corners,
int flags=CALIB_CB_ADAPTIVE_THRESH+CALIB_CB_NORMALIZE_IMAGE )
使用此功能一段时间后,我了解的一件事是图案大小必须在很大程度上符合图像,否则该算法将拒绝完全检测任何Chessboard.我想知道是否有棋盘的随机图像,此功能将失败,因为输入patternSize的精确值是不切实际的.有没有办法,可以从提供的图像中获得此功能的patternSize.任何帮助,将不胜感激.谢谢.
After using this function for a while, one thing that i understood was that the pattern size must comply with the image to a very good extent, else the algorithm refuses to detect any Chessboard altogether. I was wondering if there were any random image of a chessboard, this function would fail as it is impractical to enter the precise values of the patternSize. Is there a way, the patternSize for this function could be obtained from the image provided. Any help would be appreciated. Thanks.
推荐答案
简短的回答:不能.
OpenCV棋盘检测代码假定图案是均匀的(所有正方形具有相同的大小),因此,为了唯一地定位其在图像中的位置,必须满足以下两个条件:
The OpenCV checkerboard detection code assumes that the pattern is uniform (all squares have the same size) and therefore, in order to uniquely locate its position in the image, the following two conditions must be true:
- 该图案完全可见.
- 该模式具有已知的行数和列数.
如果违反了1或2,则无法知道哪个角是左上角".
If either 1 or 2 is violated there is no way to know which corner is, say, the "top left" one.
对于更一般的情况,尤其是如果您预期图案可能会被部分遮挡,则必须使用其他算法和非均匀图案,这样才能唯一地识别拐角.
For a more general case, and in particular if you anticipate that the pattern may be partially occluded, you must use a different algorithm and a non-uniform pattern, upon which corners can be uniquely identified.
有多种方法可以做到这一点.我最喜欢的模式是Matsunaga和Kanatani的"2D条码",它使用具有独特交叉比例的正方形长度序列.请参见论文此处一个>.为了匹配它,将角点分类到网格中后,您可以使用简单的多数投票算法:
There are various way to do that. My favorite pattern is Matsunaga and Kanatani's "2D barcode" one, which uses sequences of square lengths with unique crossratios. See the paper here. In order to match it, once you have sorted the corners into a grid, you can use a simple majority voting algorithm:
- 在水平和垂直方向上预先计算出图案的所有连续四元组角的交叉比例.
- 对网格中检测到的角执行上述操作.
- 对于每个可能的水平移动
- 每一行
- 积累在阈值内达成共识的交叉比率的数量
- Precompute the crossratios of all the pattern's consecutive 4-tuples of corners, in both the horizontal and vertical directions.
- Do the above for the detected corners in the grid.
- For every possible horizontal shift
- Over every row
- Accumulate the number of crossratios that agree within a threshold
将检测到的角放置在网格中可以通过多种方式实现.有一个经常被发现的算法,它使用拓扑接近性.这个想法是首先将每个角与该角的一个小窗口内的所有正方形相关联,从而构建一个角->正方形表,然后将其遍历为图形以构建每个角之间的偏移量的全局表.
Placing the detected corners in a grid can be achieved in various ways. There is an often-rediscovered algorithm that uses topological proximity. The idea is to first associate each corner to all the squares within a small window of it, thus building a corner->squares table, and then traverse it as a graph to build a global table of the offsets of each corner from one another.
这篇关于在opencv中为任何随机ChessBoard查找CheckerBoard点(图案大小未知)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- Over every row
- 每一行