opencv自带标定算法解析

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lxy_2011/article/details/67637186
                                        <div class="markdown_views prism-atom-one-dark">
                        <!-- flowchart 箭头图标 勿删 -->
                        <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path></svg>
                        <h1 id="procedure"><a name="t0"></a>Procedure</h1>

1.Dilation of the white squares by 1 pixel, so that the black squares don’t touch.

2.Thresholding with a value beneath the medium intensity.

3.Contour extraction and approximation to a rectangle. This extract the black squares.

4.Selection of the inner corners by rejecting the points which don’t belong to the two extracted rectangles.

I noticed that this is not working very well for images taken using a camera with a flash, due to non uniform illumination. But i managed to extract the correct corners by running the contour extraction several times, using several different thresholds, even adaptive thresholding, different combinations of Dilate/Erode and rejecting duplicate rectangles prior to step 4.

Loacation of chessboard

整个棋盘定位过程是一个循环过程,先对读入的棋盘图像直方图均衡化,接着自适应(取决于flag参数)二值化,再对二值化后的图像膨胀。为了定位的鲁棒性,自适应二值化和膨胀所采用核的大小不能是唯一的,故不断的循环用不同的参数用对棋盘图像处理,膨胀所采用核的大小逐渐变大。

在每次的循环过程都需要,经过以下步骤。

1、在二值化后图像外围画一白色的矩形框(方便轮廓提取),然后进行轮廓提取cvFindContours。经过膨胀后的二值图像,每个黑色的方格已经被分开,轮廓提取后可以得到每个方格的轮廓,当然还有很多干扰轮廓。对轮廓进行多边形拟合cvApproxPoly,排除不是矩形的轮廓,利用矩形的其他性质,再排除一些干扰轮廓。这些工作主要由icvGenerateQuads函数完成。

2、寻找每个方格的相邻方格,并记相邻方格的个数,连同相邻方格的信息存在相应CvCBQuad结构体中。二值图像在膨胀后原本相邻的方格,分开了,原来相连部分有一个公共点,现在分开变成了两个点。找到相邻的方格之后,计算出原来的公共点,用公共点替代膨胀后分开的点。这主要由icvFindQuadNeighborhors函数完成。

3、对所有“方格”(包括被误判的)分类,分类的原则是类内所有方格是相邻的。由icvFindConnectedQuads函数完成。

4、根据已知所求的角点个数,判别每个类中方格是否为所求的棋盘方格,并对棋盘方格排序,即该方格位于哪行那列。在这个过程中,可以添加每类方格总缺少的方格,也可以删除每类方格中多余的方格。icvOrderFoundConnetedQuads函数完成该过程。

扫描二维码关注公众号,回复: 3241767 查看本文章

5、icvCleanFoundConnectedQuads函数、icvCheckQuadGroup函数根据已知棋盘的方格个数(由棋盘的角点数计算出来)确认方格位置及个数是否正确,并确定粗略强角点的位置(两个方格的相连位置)。icvCheckBoardMonotony再次检验棋盘方格是否提取正确。

6、以上如果有一步所有方格都不符合要求,则进入一个新的循环。若循环结束,还尚未找到符合要求的方格,则棋盘定位失败,退出函数。
最后,cvFindCornerSubpix()根据上步的强角点位置,确定强角点的精确位置。



版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lxy_2011/article/details/67637186
                                        <div class="markdown_views prism-atom-one-dark">
                        <!-- flowchart 箭头图标 勿删 -->
                        <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path></svg>
                        <h1 id="procedure"><a name="t0"></a>Procedure</h1>

1.Dilation of the white squares by 1 pixel, so that the black squares don’t touch.

2.Thresholding with a value beneath the medium intensity.

3.Contour extraction and approximation to a rectangle. This extract the black squares.

4.Selection of the inner corners by rejecting the points which don’t belong to the two extracted rectangles.

I noticed that this is not working very well for images taken using a camera with a flash, due to non uniform illumination. But i managed to extract the correct corners by running the contour extraction several times, using several different thresholds, even adaptive thresholding, different combinations of Dilate/Erode and rejecting duplicate rectangles prior to step 4.

Loacation of chessboard

整个棋盘定位过程是一个循环过程,先对读入的棋盘图像直方图均衡化,接着自适应(取决于flag参数)二值化,再对二值化后的图像膨胀。为了定位的鲁棒性,自适应二值化和膨胀所采用核的大小不能是唯一的,故不断的循环用不同的参数用对棋盘图像处理,膨胀所采用核的大小逐渐变大。

在每次的循环过程都需要,经过以下步骤。

1、在二值化后图像外围画一白色的矩形框(方便轮廓提取),然后进行轮廓提取cvFindContours。经过膨胀后的二值图像,每个黑色的方格已经被分开,轮廓提取后可以得到每个方格的轮廓,当然还有很多干扰轮廓。对轮廓进行多边形拟合cvApproxPoly,排除不是矩形的轮廓,利用矩形的其他性质,再排除一些干扰轮廓。这些工作主要由icvGenerateQuads函数完成。

2、寻找每个方格的相邻方格,并记相邻方格的个数,连同相邻方格的信息存在相应CvCBQuad结构体中。二值图像在膨胀后原本相邻的方格,分开了,原来相连部分有一个公共点,现在分开变成了两个点。找到相邻的方格之后,计算出原来的公共点,用公共点替代膨胀后分开的点。这主要由icvFindQuadNeighborhors函数完成。

3、对所有“方格”(包括被误判的)分类,分类的原则是类内所有方格是相邻的。由icvFindConnectedQuads函数完成。

4、根据已知所求的角点个数,判别每个类中方格是否为所求的棋盘方格,并对棋盘方格排序,即该方格位于哪行那列。在这个过程中,可以添加每类方格总缺少的方格,也可以删除每类方格中多余的方格。icvOrderFoundConnetedQuads函数完成该过程。

5、icvCleanFoundConnectedQuads函数、icvCheckQuadGroup函数根据已知棋盘的方格个数(由棋盘的角点数计算出来)确认方格位置及个数是否正确,并确定粗略强角点的位置(两个方格的相连位置)。icvCheckBoardMonotony再次检验棋盘方格是否提取正确。

6、以上如果有一步所有方格都不符合要求,则进入一个新的循环。若循环结束,还尚未找到符合要求的方格,则棋盘定位失败,退出函数。
最后,cvFindCornerSubpix()根据上步的强角点位置,确定强角点的精确位置。

猜你喜欢

转载自blog.csdn.net/monk1992/article/details/82655756