OpenCV手眼标定
一、标定函数
利用opencv中的calibrateHandEye()函数进行标定,函数包含多个参数如下所示。其中gripper就是end,target就是board。
cv2.calibrateHandEye(R_gripper2base: Any,
t_gripper2base: Any,
R_target2cam: Any,
t_target2cam: Any,
R_cam2gripper: Any = None,
t_cam2gripper: Any = None,
method: Any = None)
二、眼在手上
相机安装在机械臂末端时,camera_to_end是一个定值(待求值),函数参数对应关系如下。
"""
R_gripper2base : R_end_to_base
T_gripper2base : T_end_to_base
R_target2camera : R_board_to_camera
T_target2camera : T_board_to_camera
R_cam2gripper : R_camera_to_end
T_cam2gripper : T_camera_to_end
"""
三、眼在手外
相机固定安装在外部时,camera_to_base是一个定值(待求值),函数参数对应关系如下。
"""
R_gripper2base : R_base_to_end
T_gripper2base : T_base_to_end
R_target2camera : R_board_to_camera
T_target2camera : T_board_to_camera
R_cam2gripper : R_camera_to_base
T_cam2gripper : T_camera_to_base
"""
四、眼在手外示例代码
通过虚拟的数据进行标定,其中M_target_to_camera需要通过solvepnp获得旋转平移矩阵,本示例省略该部分。详细内容看我的另一篇《相机标定》。
import cv2
import numpy as np
R_gripper2base = [np.mat([[0.6392664, -0.7427392, 0.1991911],
[0.761848, 0.6469268, -0.0327619],
[-0.1045285, 0.1726969, 0.9794129]]),
np.mat([[0.8571714, -0.4691177, 0.2125697],
[0.4948881, 0.8645198, -0.0877003],
[-0.1426289, 0.1803724, 0.9732023]]),
np.mat([[0.7621228, -0.6455822, -0.0489121],
[0.639497, 0.7388382, 0.2125128],
[-0.1010563