奥比中光相机基于opencv进行Eye_to_hand手眼标定

  奥比中光相机基于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,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值