speed detection using optical flow

1 回表示 (過去 30 日間)
Nachiket Patki
Nachiket Patki 2018 年 5 月 5 日
編集済み: Nachiket Patki 2018 年 5 月 5 日
I was referring to this mathwork's site...
for finding the speed of objects from a video file I have. But the code didn't say anything about how to find a speed. Also when I run the code I could see no optical flow thing...can anyone help me...I must be doing something wrong. Here is the code (the main code is same as that shown in link, just a little addition of reading video file from the disk):
nFrames=0;
opticFlow = opticalFlowHS;
v = VideoReader('Activity1.avi');
while hasFrame(v) % Process for the first 100 frames.
% Acquire single frame from imaging device.
frameRGB = readFrame(v);
% Compute the optical flow for that particular frame.
flow = estimateFlow(opticFlow,rgb2gray(frameRGB));
imshow(frameRGB)
hold on
drawnow
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',25)
hold off
% Increment frame count
nFrames = nFrames + 1;
end
I tried 'drawnow' command as suggested here Only I could see the video but not the optical flow...
I couldn't attach the .avi file here otherwise I would have.
  1 件のコメント
Nachiket Patki
Nachiket Patki 2018 年 5 月 5 日
編集済み: Nachiket Patki 2018 年 5 月 5 日
Ok I could solve the problem... I use
frameWithFlow = getframe(gca);
imshow(frameWithFlow.cdata)
now I am getting the optical flow over each frame.
But still, there is one problem the video gets very slow how can I make it run with normal video speed? (or at least faster than the current one)

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by