Srđan Rašić
Srđan Rašić

Reputation: 1787

Lucas Kanade dense optical flow

Can OpenCV be used to calculate dense optical flow using Lucas Kanade method? I am aware of function in gpu/ocl module that can do that (gpu::PyrLKOpticalFlow::dense), but is there non-gpu equivalent of that function?

I'm also aware of Farneback and TV L1, but I need LK / pyramidal LK for my research.

Upvotes: 1

Views: 6769

Answers (2)

Matteo Ragni
Matteo Ragni

Reputation: 2956

No. Actually there is no good dense optical flow extraction method. I'm facing the same problem (particle advection on optical flow, right?)

There is a function that evaluates optical flow with Farneback method [1], but it gives me bad results. It does not use ocl nor gpu.

You may try with phaseCorrelate to extract it with a shift based algorithm. I've used this method. When I will upload it to github I'll give you the link.

[EDIT]

Here is the code. I've decided to separate the phase correlation algorithm from the whole project, to make it more simple to understand: https://github.com/MatteoRagni/OpticalFlow Please star it, if you intend to use it.

Upvotes: 3

alrikai
alrikai

Reputation: 4194

You can find the OpenCV non-gpu video analysis functionality documentation here

There is an implementation of the sparse iterative Lucas-Kanade method with pyramids (specifically from this paper). The function is called calcOpticalFlowPyrLK, and you build the associated pyramid(s) via buildOpticalFlowPyramid. Note however that it does specify that it's for sparse feature sets, so I don't know how much of a difference that'll make for you if you need dense optical flow.

Upvotes: 2

Related Questions