Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speeding up optical flow (createOptFlow_DualTVL1)

I am using createOptFlow_DualTVL1() to calculate optical flow which is giving me exactly what I want but it is very slow. Is there any way I can speed it up a little bit or is there any other optical flow function which will give me the same result with less processing time? I have used calcOpticalFlowFarneback(), cvGoodFeaturesToTrack() but the quality is not good. please help.

Thank you in advance Below is how I apply createOptFlow_DualTVL1()

Ptr<DenseOpticalFlow> tvl1 = createOptFlow_DualTVL1();
tvl1->calc(Previous_Gray_Frame, Current_Gray_Frame, Optical_Flow);
like image 948
Dave Avatar asked Oct 11 '13 03:10

Dave


People also ask

What is Farneback optical flow?

Description. opticFlow = opticalFlowFarneback returns an optical flow object that you can use to estimate the direction and speed of the moving objects in a video. The optical flow is estimated using the Farneback method.

What is sparse optical flow?

Sparse optical flow selects a sparse feature set of pixels (e.g. interesting features such as edges and corners) to track its velocity vectors (motion). The extracted features are passed in the optical flow function from frame to frame to ensure that the same points are being tracked.

What is optical flow Opencv?

Optical flow is the pattern of apparent motion of image objects between two consecutive frames caused by the movement of object or camera. It is 2D vector field where each vector is a displacement vector showing the movement of points from first frame to second.

What is optical flow vector?

Optical flow is a vector field between two images, showing how the pixels of an object in the first image can be moved to form the same object in the second image . It is a kind of correspondence learning, because if the corresponding pixels of an object are known, the optical flow field can be calculated.


1 Answers

In order to speed up the computation, you need to reduce the total count of computations performed each time. This seems obvious, but the huge number of strategies to achieve that goal can be confusing. So, here are some proposals:

  1. Reduce the size of your images (input data). In particular, you should try to divide their size by 2 along each dimension, compute the flow, then compute a full size flow with linear interpolation. Unless your application requires a very high accuracy, this solution should be acceptable and will give you a huge speedup.

  2. Reduce the number of warps (parameter: warps) per scale. This will harm a little the accuracy, but unless you have very difficult motion patterns (e.g., when all the image pixels are moving in different directions, or when you have a very fast motion inside the image) the result should still be acceptable. The algorithms runs the minimization procedure warps times per level in the image pyramid, so even a small change in warps will give you a noticeable speedup.

  3. Reduce the number of levels in the image pyramid (parameter: scales). This can have an important impact on the accuracy though, so be careful and experiment a lot with it. It has been found in the literature that a good (for accuracy) scale factor between levels is 0.8, so you should compute your number of levels accordingly. Before 0.8, the standard in experimenting with optical flow was a scale factor of 0.5, so you can try to go down until this value.

  4. Convergence speed: the inner procedure for L1 minimization is stable for time steps (parameter: tau) up to 1/8 (0.125) in theory, but in practice values of 1/4 (0.25) are known to still work.

like image 122
sansuiso Avatar answered Sep 22 '22 18:09

sansuiso