Python - OpenCV stereoCalibrate()太manu值来解压缩

时间:2017-03-17 19:41:48

标签: python opencv computer-vision stereo-3d

我正在使用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,函数cv2.stereoCalibrate()应在flags=cv2.CALIB_FIX_INTRINSIC时返回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修复cameraMatrix?和distCoeffs?所以只估算R,T,E和F矩阵。

PS:我发现了这个answer,但它不适用于cv2

1 个答案:

答案 0 :(得分:0)

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