0

I am trying to use createOptFlow_DualTVL1 from OpenCV for Python. I am using this book (Page 120) as a reference( https://books.google.de/books?id=TrZTDwAAQBAJ&pg=PA119&lpg=PA119&dq=cv2.createOptFlow_DualTVL1()+parameters+python&source=bl&ots=3sQlqNwhDX&sig=h7Ve4FzpsVJKkjrNXpy8t_Arpvw&hl=en&sa=X&ved=0ahUKEwicu6_EveTbAhUDb1AKHQp1Bq8Q6AEIUDAD#v=onepage&q=cv2.createOptFlow_DualTVL1()%20parameters%20python&f=false).

According to the book, I need to create an instance of cv2.DualTVL1OpticalFlow class by calling the cv2.createOptFlow_DualTVL1 function. Then the optical flow can be calculated by calling the calc function of the created instance. This function takes the previous frame, the current frame and the optical flow initialisations as arguments. The book also says that other algorithm parameters can be set by using set. But I am unable to pass any other parameter as argument in Python. Is there a way to set additional algorithm parameters? Below is a snippet of what I have until now.

optical_flow = cv2.createOptFlow_DualTVL1() flow = optical_flow.calc(new_prvs, new_nxt, None)

Silver moon
  • 229
  • 3
  • 15

1 Answers1

0

I found the solution: here

For cv2 version "'4.1.0'":

replace:

optical_flow = cv2.createOptFlow_DualTVL1()
flow = optical_flow.calc(new_prvs, new_nxt, None)

with:

optical_flow = cv2.optflow.DualTVL1OpticalFlow_create()
flow = optical_flow.calc(prvs, next, None)

The parameter descriptions can be found here: http://docs.opencv.org/3.3.0/dc/d47/classcv_1_1DualTVL1OpticalFlow.html

sjcoding
  • 864
  • 6
  • 6