I am writing image analysis program in python and am trying to use the cv.CalcOpticalFlowFarneback
. I figured out most of the things and the analysis works, however, I would like to play a little with flags
parameter. In cv documentation it says that flags is an integer and the description is the following:
flags –
Operation flags that can be a combination of the following:
OPTFLOW_USE_INITIAL_FLOW Use the input flow as an initial flow approximation.
OPTFLOW_FARNEBACK_GAUSSIAN ...
The question is how do I set flag to use either one of the options or both of them?
Try:
flags = OPTFLOW_USE_INITIAL_FLOW | OPTFLOW_FARNEBACK_GAUSSIAN
The |
(pipe) character is a bitwise or. A common way of doing flags is to use different powers of 2 for each flag. For instance, if OPTFLOW_USE_INITIAL_FLOW
is 2 and OPTFLOW_FARNEBACK_GAUSSIAN
is 8 then their combination is 1010 in binary.
Their actual values can be seen in the documentation:
OPTFLOW_USE_INITIAL_FLOW = 4
OPTFLOW_FARNEBACK_GAUSSIAN = 256