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。
ref
用于相机校准。主要是利用标定板获取相机的内外参。
ArUco的每个块就是一个二进制编码。ChArUco的白色块部分用上了二进制编码块。
ArUco的目的是用于相机的姿态估计,也就是给定一个ArUco板子,作为参照物,来估计相机的运动。
ref
ok。
那么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 板。
代码参考:
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。
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大小和检测到的数目对标定结果的影响。