python 奥比中光相机基于opencv进行Eye - array([[579
奥比中光相机基于opencv进行眼在手外标定,在标定前首先要理解经典方程组AX=XB原理,弄清楚机器人基座,法兰,标定板,相机之间坐标转换关系,并且注意易错点单位要统一。
import cv2
import numpy as np
import glob
from math import *
import pandas as pd
import os
from scipy.spatial.transform import Rotation as R
#奥比中光相机内参
K=np.array([[579.446, 0, 318.1348],
[0, 579.1467, 239.8945],
[0, 0, 1]], dtype=np.float64)#奥比中光相机内参
imgpoints = []
objpoint2 =[]
chess_board_x_num=4#棋盘格x方向格子数
chess_board_y_num=5#棋盘格y方向格子数
chess_board_len=40#单位棋盘格长度,mm 拼多多帮助力入口
objp = np.zeros((chess_board_x_num * chess_board_y_num, 3), np.float32)
objp[:, :2] = np.mgrid[0:chess_board_x_num, 0:chess_board_y_num].T.reshape(-1, 2) * chess_board_len
#用于根据欧拉角计算旋转矩阵
def myRPY2R_robot(x, y, z):
Rx = np.array([[1, 0, 0], [0, cos(x), -sin(x)], [0, sin(x), cos(x)]])
Ry = np.array([[cos(y), 0, sin(y)], [0, 1, 0], [-sin(y), 0, cos(y)]])
Rz = np.array([[cos(z), -sin(z), 0], [sin(z), cos(z), 0], [0, 0, 1]])
R = Rz@Ry@Rx
return R
#用于根据四元数计算旋转矩阵
def quaternion2rot(x):
quaternion = [x[3], x[4], x[5], x[6]]
r = R.from_quat(quaternion)
rot = r.as_matrix()
t = np.array([[x[0]], [x[1]], [x[2]]])
RT1 = np.column_stack([rot, t]) # 列合并
RT1 = np.row_stack((RT1, np.array([0, 0,
好文链接