【问题标题】:openCV Python: cv2.calibrateCamera: error return without exceptionopenCV Python:cv2.calibrateCamera:错误返回无异常
【发布时间】:2016-03-07 05:51:47
【问题描述】:

我正在使用 openCV 2.4.10 并且想要校准相机。如果我使用带有 flag=0 的 cv2.calibrateCamera 一切都很好。如果我尝试设置一些标志并提供初始 cameraMatrix 和 distCoeffs 作为输入,则会发生命名错误。您可以在下面找到我的部分代码。

# create initial cameraMatrix and distCoeffs    
cameraMatrix = np.zeros((3,3), dtype=np.float32)
cameraMatrix[0,0] = 1.0

distCoeffs = np.zeros((8,1), np.float32)

flag = 0
flag = flag | cv2.CALIB_USE_INTRINSIC_GUESS

# Find intrinsic and extrinsic camera parameters 
# next line works fine
#rms, cameraMatrix, distCoeffs, rvecs, tvecs = cv2.calibrateCamera(obj_points, img_points, (w,h), 0)

# the following line throw the error
 rms,camera_matrix,dist_coefs,rvecs,tvecs = cv2.calibrateCamera(obj_points, img_points, (w, h),cameraMatrix, distCoeffs, flag)

我使用不同的版本来创建 cameraMatrix 和 distCoeffs,还尝试了各种标志设置,但均未成功。我希望任何人都知道我的错误在哪里或是什么。我会很高兴得到所有帮助,因为我一直坚持这一点。

毛利人问候

【问题讨论】:

  • 为了测试和重现错误,您可以简单地将我的代码复制并粘贴到 openCV 的 calibrate.py 示例中。 (C:\opencv\sources\samples\python2\calibrate.py)
  • 查看函数原型:cv2.calibrateCamera(objectPoints, imagePoints, imageSize[, cameraMatrix[, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]]]) 你错过了@ 987654322@flags之前的@
  • 非常感谢。这确实是一个初学者的错误,但现在它运行没有错误。我很感激你的帮助。也许您可以将您的评论标记为答案,然后我可以接受并关闭问题。
  • 很高兴有帮助。我复制了我的评论作为答案。

标签: python opencv camera-calibration


【解决方案1】:

查看函数原型:

 cv2.calibrateCamera(objectPoints, imagePoints, imageSize[, cameraMatrix[, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]]])  

你错过了 rvecs,flags 之前的 tvecs。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多