OpenCv相机标定——圆形标定板标定

提取角点时与黑白棋盘格差别

主要在于寻找角点的函数,只需将第一章内第二段代码

ret, corners1 = cv.findChessboardCorners(img_gray, (w, h)) # 寻找内角点改为

ret, corners1 = cv.findCirclesGrid(img_gray, (w, h)) # 寻找内角点,更详细的内容参考第一章代码段内注释。

收集源图集

先各种姿势拍照:

vdma0.writechannel.stop()
vdma0.writechannel.start()
vdma0.readchannel.stop()
vdma1.readchannel.stop()
vdma0.readchannel.start()
vdma1.readchannel.start()

rgb_frame1=vdma0.readchannel.readframe()
rgb_frame2=vdma1.readchannel.readframe()

vdma0.writechannel.writeframe(frame_out)
plt.imshow(rgb_frame1)
plt.imshow(rgb_frame2)

cv2.imwrite('./L'+str(i)+'.bmp',rgb_frame1)
cv2.imwrite('./R'+str(i)+'.bmp',rgb_frame2)
i=i+1
i=0

rgb_frame1=vdma0.readchannel.readframe()
rgb_frame2=vdma1.readchannel.readframe()
frame_out[:,0:320,:]=rgb_frame1[:,0:320,:]
frame_out[:,320:640,:]=rgb_frame2[:,0:320,:]
vdma0.writechannel.writeframe(frame_out)
cv2.waitKey(10)

输入参数

square_size半圆心距(即每一行相邻两个圆心的圆心距的一半)= 13/2 = 6.5

BoardSize_Width 和Height都是10

注意事项

我所使用的标定程序是在opencv sample文件夹下自带的calibration.cpp文件的基础上进行修改的。

一共主要有三个部分需要进行修改(其余细节可能需要稍微修改)

1、设置棋盘格参数改为设置非对称圆图案标定板参数:

标定程序中标定板的尺寸只需要行列信息半圆心距信息,如下:

float square_size = 17.2525;

Size board_size = Size(4, 11); /* 标定板上每行、列的角点数 */

2、提取角点部分

将标定代码中的提取棋盘格角点的代码部分改为使用opencv的findCirclesGrid()函数提取标定图片中的圆心坐标,代码如下:

/* 提取角点 */
if (false == findCirclesGrid(imageInput, board_size, image_points_buf, CALIB_CB_ASYMMETRIC_GRID))
{
    cout << filename << endl;  // 找不到角点
    std::system("pause");
    continue;
}

3、初始化标定板上角点的三维坐标部分

注释部分为原棋盘格的设置,修改为非对称圆图案标定板,第18行其实就是画出4x11非对称圆图案的圆心的过程,稍加思考即可理解!

/* 初始化标定板上角点的三维坐标 */

/* 初始化标定板上角点的三维坐标 */
int i, j, t;
for (t = 0; t < image_count; t++)
{
    vector<Point3f> tempPointSet;
    for (i = 0; i < board_size.height; i++)
    {
        for (j = 0; j < board_size.width; j++)
        {
            Point3f realPoint;
            /* 假设标定板放在世界坐标系中z=0的平面上 */
            /*
            realPoint.x = i * square_size.width;
            realPoint.y = j * square_size.height;
            realPoint.z = 0;
            */
            
            tempPointSet.push_back(Point3f((float)((2 * j + i % 2)*square_size), i*square_size, 0));
 
            //    tempPointSet.push_back(realPoint);
        }
    }
    object_points.push_back(tempPointSet);
}

————————————————

https://blog.csdn.net/weixin_43526787/article/details/88736980

https://blog.csdn.net/Ketal_N/article/details/88829741

https://blog.csdn.net/weixin_51229250/article/details/120009716

https://eason.blog.csdn.net/article/details/52045531

https://blog.csdn.net/Ketal_N/article/details/88829741

https://blog.csdn.net/u012348774/article/details/108607390

猜你喜欢

转载自blog.csdn.net/qq_42672770/article/details/128640381