What is the measurement unit for the optical flow velocity components?
16 views (last 30 days)
Show older comments
Hello! I have a question: I have a matlab based application in which I compute the optical flow and extract the two velocity components Vx and Vy.
The code: img = imread('img_capture'.jpg); img = rgb2gray(img); glob.images(:,:,1) = img; [Vx, Vy] = OpticalFlowMatlab(glob.images, 1, 4); %%images,alpha, iterations
Next I compute the position for the FOE (focus of expansion) and use this FOE to compute the time-to-contact:
ttc = D_foe/sum(Vmag(:));
where D_foe is the distance from a point to the FOE; Vmag is the magnitude of the optical flow.
I would like to know what is the output unit for the velocity components (D_foe is the distance in pixels) and the output unit for the time-to-contact. For example a value for the ttc is 0.0092. Can this be seconds? When I got this value there was no obstacle in front of the camera.
0 Comments
Accepted Answer
David Young
on 21 Feb 2011
The units depend on what the function OpticalFlowMatlab does. I don't know this function, so I can't be sure. Normally, the units would be pixels per frame (where by "frame" I mean the time between image frames in the sequence).
To compute ttc, you divide the image distance from the foe by the flow magnitude. The distance will be measured in pixels, and if the optic flow was in pixels per frame, the ttc will be in frames.
Your expression for the ttc looks wrong, though. You need to divide the distance between the foe and an image point by the magnitude of the flow at that point, and then maybe average over a set of such points. I don't know how Vmag has been computed, but taking its overall sum is most unlikely to be correct. This may account for the unlikely result of 0.0092.
Incidentally, if you're trying to measure ttc, you might do better by getting an overall estimate of the image dilation, using for example http://www.mathworks.com/matlabcentral/fileexchange/27093-affine-optic-flow.
11 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!