简体   繁体   English

python中的openCV光流

[英]openCV optical flow in python

I am writing image analysis program in python and am trying to use the cv.CalcOpticalFlowFarneback .我正在用 python 编写图像分析程序,并尝试使用cv.CalcOpticalFlowFarneback I figured out most of the things and the analysis works, however, I would like to play a little with flags parameter.我弄清楚了大部分事情并且分析有效,但是,我想玩一点flags参数。 In cv documentation it says that flags is an integer and the description is the following:在 cv 文档中,它说标志是一个整数,描述如下:

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.制作标志的常用方法是对每个标志使用不同的 2 次幂。 For instance, if OPTFLOW_USE_INITIAL_FLOW is 2 and OPTFLOW_FARNEBACK_GAUSSIAN is 8 then their combination is 1010 in binary.例如,如果OPTFLOW_USE_INITIAL_FLOW是 2 并且OPTFLOW_FARNEBACK_GAUSSIAN是 8,那么它们的组合是二进制的 1010。

Their actual values can be seen in the documentation :它们的实际值可以在文档中看到:

OPTFLOW_USE_INITIAL_FLOW = 4
OPTFLOW_FARNEBACK_GAUSSIAN = 256

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM