我正在使用 opencv 3.2 检测打印的 Aruco 标记:
aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs,tvecs);
这将返回标记的平移和旋转向量。我需要的是标记每个角的 3d 坐标。
我知道标记长度,我可以做类似的事情
corner1 = tvecs[0] - markerlength /2;
corner2 = tvecs[0] + markerlength /2;
……
但是有更好的方法吗?还是现有的功能?总结一下,我有:
2d 正方形中心的 3d 点。
该正方形边的长度。
正方形的旋转值。
如何找到角的 3d 坐标?
原文由 anti 发布,翻译遵循 CC BY-SA 4.0 许可协议
首先,假设我们只有一个标记
side = 2 * half_side
。其次,
aruco::detectMarker
返回相机在标记世界中的相对位置。因此,我假设您正在寻找 相机世界 中角落的坐标。然后,在标记的空间:
where the center
O
of the square has coordinatetvec
(in camera’s world) and rotation mat of the markerrot_mat
is computed bycv::Rodrigues(rvec,rot_mat)
.现在,使用针孔 相机模型,cam世界中的点
P
与marker世界的坐标之间的关系是:例如,中心
O
[0,0,0]
即标记世界中的tvec
,在凸轮世界中是 --- 。所以,cam世界中
E
的坐标是:神奇的是,它是
rot_mat
的第一列乘以half_size
和tvec
的总和。 Similarly, the coodinates ofF
isrot_mat
’s second column multiplied byhalf_size
andtvec
.现在,可以计算角点,例如
其中
E-O
正是rot_mat
的第一列乘以half_size
。考虑到所有这些,我们可以编写函数:
注 1:我讨厌 SO 没有 MathJax
注意2:必须有一些我不知道的更快的实现。