How to extract real-world velocities values from MATLAB's estimateFlow()?

조회 수: 3 (최근 30일)
Alex
Alex 2021년 7월 14일
편집: Prabhan Purwar 2021년 7월 28일
Hello
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
i=1;
while(~isDone(videoReader))
vidFrame = step(videoReader);
flowField = estimateFlow(of,vidFrame);
plot(flowField,'DecimationFactor',[1,1],'ScaleFactor',1);
flowFieldSimp.Vx = flowField.Vx; %flowFieldSimp is my own object to store the flowField objects information
Vx(:,:,i) = flowFieldSimp.Vx;
i=i+1;
end
%Output: A 3d matrix of x direction velocity values from the estimate flow
%function.
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.
Thanks,
Alex

답변 (1개)

Prabhan Purwar
Prabhan Purwar 2021년 7월 28일
편집: Prabhan Purwar 2021년 7월 28일
Hi Alex,
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!!
Thanks

카테고리

Help CenterFile Exchange에서 Optics에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by