openCV Python:cv2.calibrateCamera:错误返回无异常

时间:2015-04-13 15:06:31

标签: python opencv camera-calibration

我正在使用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,并尝试了各种标志设置都没有成功。我希望任何人都知道我的错误在哪里或什么。我会很高兴得到所有帮助,因为我一直坚持这一点。

问候毛利人

1 个答案:

答案 0 :(得分:0)

查看函数原型:

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

你错过了rvecs,tvecs在旗帜之前。