gpt4 book ai didi

python-2.7 - Python 2.7:cv2.stereoCalibrate()中的错误。找不到必需的参数 'distCoeffs1'(pos 5)

转载 作者:行者123 更新时间:2023-12-02 17:40:09 28 4
gpt4 key购买 nike

我正在使用Python 2.7和OpenCV 3.3进行立体摄像机校准。我使用的代码是(我从Stereo Calibration Opencv Python and Disparity Map获得):

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*7,3), np.float32)
objp[:,:2] = np.mgrid[0:7,0:6].T.reshape(-1,2)

# Arrays to store object points and image points from all the images.
objpointsL = [] # 3d point in real world space
imgpointsL = [] # 2d points in image plane.
objpointsR = []
imgpointsR = []

images = glob.glob('left*.jpg')

for fname in images:
img = cv2.imread(fname)
grayL = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# Find the chess board corners
ret, cornersL = cv2.findChessboardCorners(grayL, (7,6),None)
# If found, add object points, image points (after refining them)
if ret == True:
objpointsL.append(objp)

cv2.cornerSubPix(grayL,cornersL,(11,11),(-1,-1),criteria)
imgpointsL.append(cornersL)

images = glob.glob('right*.jpg')

for fname in images:
img = cv2.imread(fname)
grayR = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# Find the chess board corners
ret, cornersR = cv2.findChessboardCorners(grayR, (7,6),None)

# If found, add object points, image points (after refining them)
if ret == True:
objpointsR.append(objp)

cv2.cornerSubPix(grayR,cornersR,(11,11),(-1,-1),criteria)
imgpointsR.append(cornersR)


retval,cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F = cv2.stereoCalibrate(objpointsL, imgpointsL, imgpointsR, (640,480))

但是我遇到了类似的错误:
retval,cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F = cv2.stereoCalibrate(objpointsL, imgpointsL, imgpointsR, (640,480))
TypeError: Required argument 'distCoeffs1' (pos 5) not found

我的代码,左图和右图都在同一文件夹中。我读过其他类似的答案,但他们没有收到此错误。 ( Stereo Calibration Opencv Python and Disparity Map)。我想知道为什么会出现此错误以及如何解决?

谢谢。

最佳答案

尝试将代码的最后几行更改为

cameraMatrix1 = None
distCoeffs1 = None
cameraMatrix2 = None
distCoeffs2 = None
R = None
T = None
E = None
F = None
retval, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F = cv2.stereoCalibrate(objpointsL, imgpointsL, imgpointsR, (640,480), flags=cv2.cv.CV_CALIB_FIX_INTRINSIC)

关于python-2.7 - Python 2.7:cv2.stereoCalibrate()中的错误。找不到必需的参数 'distCoeffs1'(pos 5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46018458/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com