Ask Your Question
0

"flow" in "calcOpticalFlowFarneback(...)

asked 2016-04-04 01:02:19 -0600

Prakhar Mohan gravatar image

updated 2016-04-04 02:36:39 -0600

berak gravatar image

what does the "flow" variable in "calcOpticalFlowFarneback(...)" contains after the function is executed?

In farneback dense optical flow of opencv, the inputOutput array flow is of type 32FC2 (i.e. 32bit float type having 2 channels).

What does this flow variable contain in its two channels after the execution of the function calcOpticalFlowFarneback(....).

I went through the opencv source code of this function but got too much confused after reading it, please help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-04-04 03:40:25 -0600

berak gravatar image

updated 2016-04-04 03:43:39 -0600

the flow matrix contains the gradient of the movement between 2 frames. for each pixel location in the original frame, the channels contain dx and dy, so that prev_x + dx = cur_x, and prev_y + dy = cur_y.

here is a sample with visualization code

(note, that the LK method writes absolute new position into the flow vector, while the farneback one writes differences)

edit flag offensive delete link more

Comments

So , how can someone use LK to create a Mat flow similar to Farneback ? Simply by substructing the position coordinates ?

Giorgos_ts gravatar imageGiorgos_ts ( 2016-04-04 06:18:41 -0600 )edit
1

LK does not have a same-size Mat as your image, but a vector of (say, gftt) points. farneback is dense, LK is sparse.

berak gravatar imageberak ( 2016-04-04 06:32:12 -0600 )edit

So if I want to use k means to detect moving objects do i just give the vector (e.g. points ) as input ?

Giorgos_ts gravatar imageGiorgos_ts ( 2016-04-04 07:29:07 -0600 )edit
1

maybe. (idk, if kmeans is adequate here, since it requires prior knowledge of K, also you probaly need to cluster for direction and position (e.g., to seperate cars on different lanes), not only for direction)

(if your camera is fixed, consider using Background Subtraction

berak gravatar imageberak ( 2016-04-04 07:32:56 -0600 )edit

Actually I will just try for K=2 ( a kind of background substraction ) . Thanks i will try it .

Giorgos_ts gravatar imageGiorgos_ts ( 2016-04-04 07:37:23 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-04-04 01:02:19 -0600

Seen: 1,467 times

Last updated: Apr 04 '16