Ask Your Question
0

How to provide flag arguments in pthon cv2 module function

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

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

Comments

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

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

1 answer

Sort by ยป oldest newest most voted
0

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

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

Python:

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

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

find_flags = cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FAST_CHECK
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

Question Tools

1 follower

Stats

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

Seen: 2,496 times

Last updated: Aug 02 '19