Python - OpenCV stereoCalibrate() 太多值无法解包

Python - OpenCV stereoCalibrate() too manu values to unpack

我正在使用 OpenCV 进行立体校准。我已经对各个相机进行了校准。对于以下代码片段:

ret, rot, trans, ess, fund = cv2.stereoCalibrate(objectPoints=objpoints,
                                                 imagePoints1=imgpoints1,
                                                 imagePoints2=imgpoints2,
                                                 cameraMatrix1=mtx1,
                                                 distCoeffs1=dist1,
                                                 cameraMatrix2=mtx2,
                                                 distCoeffs2=dist2,
                                                 imageSize=gray1.shape[::-1],
                                                 flags=cv2.CALIB_FIX_INTRINSIC)

我收到错误:

Traceback (most recent call last):
   File "stereoCalibration.py", line 94, in <module>
  flags=cv2.CALIB_FIX_INTRINSIC)
ValueError: too many values to unpack (expected 5)

但我已经在左侧有五个变量。根据这个 documentation,当 flags=cv2.CALIB_FIX_INTRINSIC.

时,函数 cv2.stereoCalibrate() 应该 return 5 个值

Python: cv2.stereoCalibrate(objectPoints, imagePoints1, imagePoints2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, imageSize[, R[, T[, E[, F[, flags[, criteria]]]]]]) → retval, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, R, T, E, F

CV_CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E , and F matrices are estimated.

PS: 我找到了这个 answer,但它不适用于 cv2.

如果您将 cv2.stereoCalibrate() 的返回值分配给 list 并检查值的数量,您可以知道它是否确实返回了 5 个值或其他值。这样你就可以修复你的接收变量并相应地调整你的代码。