- https://www.mathworks.com/discovery/optical-flow.html (Optical Flow)
- https://www.mathworks.com/help/vision/ug/tracking-cars-using-optical-flow.html (Tracking car using Optical Flow)
How to extract real-world velocities values from MATLAB's estimateFlow()?
20 views (last 30 days)
I am working on writing a bit of code to determine the velocity of an object moving in front of a camera. I am wondering if anyone of you has experience determining the real world velocity of something that you captured with a camera. I have information about the conversion between pixels and real world length, as well as the time between frames. Unfortunately, I don't know what role the optical flow values play in this, and how they can be converted to a real world velocity. That's my main question.
Here is the code that I am working with
%Input: video file
videoReader = vision.VideoFileReader('VideoInCurrentDirectory.mp4','ImageColorSpace','Intensity');
of = opticalFlowHS; %Create optical flow object using the Horn Schunk Method.
Vx = zeros(250,400,100); %100 is number of frames
vidFrame = step(videoReader);
flowField = estimateFlow(of,vidFrame);
flowFieldSimp.Vx = flowField.Vx; %flowFieldSimp is my own object to store the flowField objects information
Vx(:,:,i) = flowFieldSimp.Vx;
%Output: A 3d matrix of x direction velocity values from the estimate flow
I can then see the optical flow x direction velocities for each frame in the Vx matrix. But I don't know what to do with those values.
So if any of you can offer help or point to any resources that deal with optical flow and real world velocities, that would be a big help. I have looked at other answers about the units of optical flow from MATLAB, but the answers weren't very clear.
Prabhan Purwar on 28 Jul 2021
Edited: Prabhan Purwar on 28 Jul 2021
As you mentioned, estimating optical flow between the adjacent frames is used to measure the velocity of the objects. Intuitively it calculates the movement/change in the position of the object with reference to the previous frame.
Kindly have a look at the following example and document for further insights:
If camera position and camera intrinsics are available then that could be used to refine the overall estimated vehicle position and velocity.
Kindly refer to the following example:
Hope it helps!!