0
votes

I'm using openCV 2.4.10 and want to calibrate a camera. if I use cv2.calibrateCamera with flag=0 everything is fine. the named error occur if I try to set some flags and provide initial cameraMatrix and distCoeffs as input. below you find part of my code.

# 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)

I used different versions for creating cameraMatrix and distCoeffs and also tried various flag settings all without success. I hope anybody has an idea where or what my error is. I would be glad for all help, because I'm stuck on this along time.

Greetings Maori

1
for testing and reproduce the error you could simply copy and paste my code in the calibrate.py sample from openCV. (C:\opencv\sources\samples\python2\calibrate.py)Maori
see the function prototype: cv2.calibrateCamera(objectPoints, imagePoints, imageSize[, cameraMatrix[, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]]]) you missed rvecs, tvecs before flagslanpa
thanks a lot. it was really a beginner mistake but now it runs without errors. I'm grateful for your help. maybe you could mark your comment as an answer, then I could accept it and close the question.Maori
glad that helps. I copied my comment as answer.lanpa

1 Answers

0
votes

see the function prototype:

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

you missed rvecs, tvecs before flags.