OpenCv 3.4 .... cv2.StereoCalibrate()...未找到必需参数distcoeff1(pos5)

时间:2018-03-09 10:04:35

标签: python python-3.x opencv stereo-3d

我们正在尝试立体声校准并使用以下代码来完成任务。

    import numpy as np
    import cv2
    import glob

    # termination criteria
    criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

    # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
    objp = np.zeros((6*9,3), np.float32)
    objp[:,:2] = np.mgrid[0:9,0:6].T.reshape(-1,2)

    # Arrays to store object points and image points from all the images.
    objpoints = {} # 3d point in real world space
    imgpoints = {} # 2d points in image plane.

    # calibrate stereo
    for side in ['Left', 'Right']:
    counter = 0
    images = glob.glob('E:\Calibration\%s*.jpg' %side)
objpoints[side] = [];
imgpoints[side] = [];
for fname in images:
    img = cv2.imread(fname)
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

    # Find the chess board corners
    ret, corners = cv2.findChessboardCorners(gray, (9,6),None)
    # If found, add object points, image points (after refining them)
    if ret == True:
        objpoints[side].append(objp)

        cv2.cornerSubPix(gray,corners,(11,11),(-1,-1),criteria)
        imgpoints[side].append(corners)
        counter += 1

assert counter == len(images), "missed chessboard!!"


stereocalib_criteria = (cv2.TERM_CRITERIA_MAX_ITER + cv2.TERM_CRITERIA_EPS, 100, 1e-5)
stereocalib_flags = cv2.CALIB_FIX_ASPECT_RATIO | cv2.CALIB_ZERO_TANGENT_DIST |   cv2.CALIB_SAME_FOCAL_LENGTH | cv2.CALIB_RATIONAL_MODEL | cv2.CALIB_FIX_K3 | 
cv2.CALIB_FIX_K4 | cv2.CALIB_FIX_K5
retval,cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F = 
cv2.stereoCalibrate(objpoints['Left'], imgpoints['Left'], imgpoints['Right'], (640, 480), criteria = stereocalib_criteria, flags = stereocalib_flags)`

我们在使用cv2.stereoCalibrate

时遇到以下错误

获取错误:

  

文件" C:\ Users \ Shehroz   伊克巴尔\应用程序数据\本地\程序\的Python \ Python36 \ Calib_Stereo_Try2.py&#34 ;,   第41行,在       retval,cameraMatrix1,distCoeffs1,cameraMatrix2,distCoeffs2,R,T,E,F = cv2.stereoCalibrate(objpoints [' Left'],imgpoints [' Left'],   imgpoints [' Right'],(640,480),criteria = stereocalib_criteria,flags   = stereocalib_flags)TypeError:必需参数' distCoeffs1' (pos 5)not foundTraceback(最近一次调用最后一次):

0 个答案:

没有答案