运行前需要获得point3s、point2s对应的数值,明确坐标系(这里,前X右Y)
import cv2
import numpy as np
import math
#######################################外参标定#################################
point3s=np.array(([0,6,0],[0,10.5,0],[0,15,0],[-3,6,0],[3,6,0]),dtype=np.double)
point2s=np.array(([1036,976],[1040,715],[1043,596],[198,961],[1880,922]),dtype=np.double)
camera=np.array(([2141.1,0,981],[ 0,2145,519.2],[0,0,1]),dtype=np.double)
dist=np.array(([-0.4937,0.2642,0,0,0]),dtype=np.double)
found,rvec,tvec=cv2.solvePnP(point3s,point2s,camera,dist)
print("*"*20,"rvec","*"*20)
print(rvec)
print("*"*20,"tvec","*"*20)
print(tvec)
#rvec = np.array([[ 1.67371645],[ 0.00353279],[-0.04648109]])
#tvec = np.array([[0.00817186],[2.11977887],[0.8784217]])
#camera=np.array(([ 2141.1,0,981],[ 0,2145,519.2],[0,0,1]),dtype=np.double)
###################################外参标定验证###############
|