Ask Your Question

How to provide flag arguments in pthon cv2 module function

asked 2019-07-21 09:23:12 -0500

I am wondering how we would provide the flag arguments for a function in the python cv2 module.

E.g. the cv2.findChessboardCorners() function. How would I provide the additional flags for example for cv2.CALIB_CB_ADAPTIVE_THRESH and cv2.CALIB_CB_FAST_CHECK.

By doing flags= cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FAST_CHECK or by flags= cv2.CALIB_CB_ADAPTIVE_THRESH | cv2.CALIB_CB_FAST_CHECK or something like this?

edit retag flag offensive close merge delete


both of the methods should work, so why do you ask ?

berak gravatar imageberak ( 2019-07-21 12:41:33 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-08-02 19:07:27 -0500

See Python API for cv2.findChessboardCorners using google. You'll get to OpenCV: Camera Calibration and Reconstruction. Note the python parameter description:


retval, corners = cv.findChessboardCorners( image, patternSize[, corners[, flags]]  )

So, you can pass flags and NOT pass corners by calling it like this:

retval, corners = cv.findChessboardCorners(image, patternSize, flags=find_flags)

Note that for bit fields, addition (+) results in the same values as a bitwise OR operation (|), so the choice is arbitrary (I tend to use + in Python, but | in C++).

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-07-21 09:23:12 -0500

Seen: 175 times

Last updated: Aug 02 '19