我正在尝试使用棋盘校准一对立体网络摄像头。为此,我修复了2个摄像机的相对位置并制作了一张棋盘照片,以便findChessboardCorners
功能检测到两个图像上的角落 - ' left.png'和' right.png'。我的代码如下:
import cv2
import numpy as np
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
lf = 'left.png'
rf = 'right.png'
lim = cv2.imread(lf, 0)
rim = cv2.imread(rf, 0)
nrows = 9
ncols = 6
objp = np.zeros((nrows * ncols, 3), np.float32)
objp[:, :2] = np.mgrid[0:nrows, 0:ncols].T.reshape(-1, 2)
objpoints=[objp]
lret, lcorners = cv2.findChessboardCorners(limg, (nrows, ncols), None)
rret, rcorners =.findChessboardCorners(rimg, (nrows, ncols), None)
cv2.cornerSubPix(limg, lcorners, (11, 11), (-1, -1), criteria)
cv2.cornerSubPix(rimg, rcorners, (11, 11), (-1, -1), criteria)
limgpoints = [lcorners]
rimgpoints = [rcorners]
retval, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F = cv2.stereoCalibrate(objpoints,limgpoints, rimgpoints, None, None,None,None, limg.shape[::-1],flags = cv2.CALIB_RATIONAL_MODEL ,criteria=criteria)
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, limgpoints, limg.shape[::-1], None, None)
我希望数组dist和ditsCoeffs1重合,因为它们是左相机的内在参数。但是,distCoeffs1中的值的顺序为e-1 - e+1
,而dist~ e-0 - e-2
的值。这有什么不对?
答案 0 :(得分:0)
答案很简单 - stereoCalibrate函数的flags参数应该设置为0.