I am using the calibrateCamera
function.
How do I use two flags? I want to use the CALIB_USE_INTRINSIC_GUESS
, and CALIB_FIX_PRINCIPAL_POINT
together, but I am not sure of the syntax. When I use just the first flag, the code runs fine, but when I use two flags using the following code:
a,camMatrix, c, rvec, tvec = cv2.calibrateCamera(
[obj_points],
[img_points],
size, camera_matrix,
dist_coefs,
flags=(cv2.CALIB_USE_INTRINSIC_GUESS and cv2.CALIB_FIX_PRINCIPAL_POINT))
I get the error:
OpenCV Error: Bad argument (For non-planar calibration rigs the initial intrinsic matrix must be specified) in cvCalibrateCamera2, file D:\Build\OpenCV\opencv-3.1.0\modules\calib3d\src\calibration.cpp, line 1440 Traceback (most recent call last): File "C:/Bdrive/AlgoSurg intern/DLT/CamCalTrial2.py", line 109, in a,camMatrix, c, rvec, tvec = cv2.calibrateCamera([obj_points], [img_points], size, camera_matrix, dist_coefs, flags=(cv2.CALIB_USE_INTRINSIC_GUESS and cv2.CALIB_FIX_PRINCIPAL_POINT)) cv2.error: D:\Build\OpenCV\opencv-3.1.0\modules\calib3d\src\calibration.cpp:1440: error: (-5) For non-planar calibration rigs the initial intrinsic matrix must be specified in function cvCalibrateCamera2
Either the syntax is wrong, or maybe there is something that I am missing?
You have to do it this way:
a,camMatrix, c, rvec, tvec = cv2.calibrateCamera(
[obj_points],
[img_points],
size, camera_matrix,
dist_coefs,
flags=(cv2.CALIB_USE_INTRINSIC_GUESS + cv2.CALIB_FIX_PRINCIPAL_POINT))
And there is no need for the parenthesis around the flags, so this is acceptable as well:
a,camMatrix, c, rvec, tvec = cv2.calibrateCamera(
[obj_points],
[img_points],
size, camera_matrix,
dist_coefs,
flags=cv2.CALIB_USE_INTRINSIC_GUESS + cv2.CALIB_FIX_PRINCIPAL_POINT)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With