【发布时间】:2021-10-03 01:55:04
【问题描述】:
我正在使用OpenCV 进行相机校准并设法获取所有相机参数,但现在我不确定我是否正确执行了所有操作。
这是我使用的图像
我在图像上使用了 6 个点(4 个球场角,两个在网与球场线接触的中间)imgPts = [[577, 303], [1333, 303], [495, 517], [1422, 517], [366, 857], [1562, 857]]
假设左上角是原点,我构建了以米为单位的相应世界坐标( 23.77mx 10.97m): objPts = [[0, 0, 0], [10.97, 0, 0], [0, 11.8, 0], [10.97, 11.8, 0], [0, 23.77, 0], [10.97, 23.77, 0]]
以下是我获取camera_matrix、旋转平移向量的代码:
objPts = np.array(objPts)
objPts = objPts.astype('float32')
imgPts = np.array(imgPts)
imgPts = imgPts.astype('float32')
w = frame.shape[1]
h = frame.shape[0]
size = (w,h)
camera_matrix = cv2.initCameraMatrix2D([objPts],[imgPts], size)
rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera([objPts], [imgPts], size, None, None)
print(rms)
2.2659039195846487
print(camera_matrix)
[[7.29904054e+04 0.00000000e+00 7.70590422e+02]
[0.00000000e+00 3.27820311e+03 1.05708724e+02]
[0.00000000e+00 0.00000000e+00 1.00000000e+00]]
print(dist_coefs)
[[-4.60113019e+00 1.52353355e+03 -1.11809613e+00 7.20674734e-02
-2.28959021e+04]]
print(rvecs[0])
[[ 0.48261931]
[-4.87671221]
[ 0.28501516]]
print(tvecs[0])
[[ -0.69935398]
[ 15.30349325]
[189.46509398]]
如何检查这些值/矩阵/向量是否正确?
【问题讨论】:
标签: python opencv camera-calibration