简体   繁体   English

如何为TVL1 Opticalflow算法修复OpenCV导入

[英]How to fix opencv import for TVL1 opticalflow algorithm

I'm asking you a very simple question. 我想问你一个非常简单的问题。 I want to use the TVL1 function for computing opticalflow with openCV (and python). 我想使用TVL1函数通过openCV(和python)计算光流。 But here is what I get : 但是,这就是我得到的:

AttributeError: 'module' object has no attribute 'DualTVL1OpticalFlow_create'

Traceback (most recent call last):

File "opticalFlowModel.py", line 50, in computeOpticalFlow
optical_flow = cv2.DualTVL1OpticalFlow_create()

AttributeError: 'module' object has no attribute 'DualTVL1OpticalFlow_create'

The problem is that in this topic How to compute optical flow using tvl1 opencv function , they seems to use the exact same code. 问题在于,在本主题中, 如何使用tvl1 opencv函数计算光流 ,他们似乎使用了完全相同的代码。 I also try this code : Speed Up Optical Flow algorithm (If applicable) Python OpenCV and have the same result. 我也尝试以下代码: 加快光流算法(如果适用)Python OpenCV,并得到相同的结果。

Here are all my import : 这是我所有的导入:

import cv2
import numpy as np
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import QtCore, QtGui

I'm using OpenCV 4.0.1 我正在使用OpenCV 4.0.1

I found the solution here . 我在这里找到了解决方案。

The way to call the function is different with the latest openCV version. 调用函数的方式与最新的openCV版本不同。 Here is what to do : 这是做什么:

Replace 更换

optical_flow = cv2.DualTVL1OpticalFlow_create()

by 通过

optical_flow = cv2.optflow.DualTVL1OpticalFlow_create()

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

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