ChArUco标定

在这里插入图片描述

相机内外参和畸变参数

ref1 jianshu
ref2 opencv

畸变参数

相机会有径向畸变(Radial distortion)和切向畸变(tangential distortion)。

径向畸变:

在这里插入图片描述

在这里插入图片描述

切向畸变:

在这里插入图片描述
公式怎么来的不晓得,暂时不去管它,写论文的时候才需要去看,做工程用就完了。

失真系数

所以失真系数就是五个参数:
在这里插入图片描述

相机内参(固定不变)

相机坐标系到图像像素坐标系。
在这里插入图片描述
其实就是小孔成像。
f x , f y f_x,f_y fx,fy是焦距, c x , c y c_x,c_y cx,cy是相机的光学中心。
在这里插入图片描述
u,v是图像像素平面坐标,Z是物体上面的点到相机光心的距离。

相机外参

指旋转矩阵和平移矩阵。R&T。
在这里插入图片描述

Chessboard

ref
直接检测corners,进行相机校准。

ArUco

ArUco的每个块就是一个二进制编码。ChArUco的白色块部分用上了二进制编码块。
ArUco可以用来进行位姿估计,也可以用来进行标定,效果不如ChArUco。
ref
ok。

ChArUco

那么ChArUco是什么呢?
opencv的介绍。
Detection of ChArUco Boards
一个ChArUco板就是Chessboard和ArUco的结合。
在这里插入图片描述

Using the ArUco module, calibration can be performed based on ArUco markers corners or ChArUco corners. Calibrating using ArUco is much more versatile than using traditional chessboard patterns, since it allows occlusions or partial views.
As it can be stated, calibration can be done using both, marker corners or ChArUco corners. However, it is highly recommended using the ChArUco corners approach since the provided corners are much more accurate in comparison to the marker corners. Calibration using a standard Board should only be employed in those scenarios where the ChArUco boards cannot be employed because of any kind of restriction.

To calibrate using a ChArUco board, it is necessary to detect the board from different viewpoints, in the same way that the standard calibration does with the traditional chessboard pattern. However, due to the benefits of using ChArUco, occlusions and partial views are allowed, and not all the corners need to be visible in all the viewpoints.
——opencv

黄字部分说明了ChArUco 的优点。opencv建议相机标定优先使用ChArUco 板,只有再无法使用ChArUco 板的时候,才用标准板或者ArUco 板。

Calibration with ChArUco Boards

检测markers

代码参考:
code 主要参考
code 次要参考
版本不高,我的opencv4.8.1比他高,改了几个python 的 api的名字。
可能会经常用到的几个opencv的文档的网页
webpage 1
webpage 2
webpage 3
在这里插入图片描述
不同角度的检测效果,有些检测不足6个格子的我没放上来。貌似最少得6个格子。

corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict, 
                                                      parameters=parameters)

参数参考
在这里插入图片描述
翻译一下就是:

corners:检测到的maker角点的向量,每个maker角点用4个角点表示,4个角点顺序按照顺时针排列。就像这样:
array([[155. , 383. ], [224. , 381. ], [208.58003, 402.61102], [132.88284, 405.2367 ]])
ids:maker的id,数值从0到N,N是makers的总数。顺序和imgPoints array(输入图像)的像素顺序相同。
rejectedImgPoints :貌似是不正确的点。便于debug。

获得corners

detectMarkers得到Markers, ids之后,

retval, charucoCorners, charucoIds = cv2.aruco.interpolateCornersCharuco(corners,ids,gray,board) 

This function receives the detected markers and returns the 2D position of the chessboard corners from a ChArUco board using the detected Aruco markers. If camera parameters are provided, the process is based in an approximated pose estimation, else it is based on local homography. Only visible corners are returned. For each corner, its corresponding identifier is also returned in charucoIds. The function returns the number of interpolated corners.
翻译:此函数接收detectMakers检测到的makers,返回ChArUco 的二维角点坐标。若提供了相机参数,这个函数基于姿态估计去计算,否则基于单应性(local homography)。link

但是这样还是不知道cv2.aruco.interpolateCornersCharuco(corners,ids,gray,board)干了啥。
查看cv2.aruco.interpolateCornersCharuco(corners,ids,gray,board)前后的corners数目,有的变多、有的变少。
在这里插入图片描述

aruco.drawDetectedCornersCharuco

画出DetectedCornersCharuco:
在这里插入图片描述
这样就知道interpolateCornersCharuco检测的就是是角点了。
所以前面以为detectMarkers得到的是corners,不全对,corner是markers的corner,所以是marker_corner
在这里插入图片描述

即detectMarkers得到markers。
interpolateCornersCharuco得到Corners。
细节代码就不看了。(感兴趣了再看)。
老板让我后面可以研究一下格子数目、markers大小和检测到的数目对标定结果的影响。

但是这一部分的的算法原理是怎么做的呢?

以上都是corners检测的部分,后面标定就是根据检测到的corners进行的。

单目标定

calibrateCameraCharuco
ref1:Zhengyou Zhang. A flexible new technique for camera calibration. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 22(11):1330–1334, 2000.
ref2:Jean-Yves Bouguet. Camera calibration tool box for matlab [eb/ol], 2004.

张正友标定法:

论文只有五页,还包括一页参考文献,全是数学公式。
牛逼的文章就是这么吊,不用背景,不用相关技术,不用实验,简简单单几个公式,就可以了。
这里的内容比较多,先留个坑。

猜你喜欢

转载自blog.csdn.net/onlyyoujojo/article/details/135145974
今日推荐