Read 2 frames simultaneously from same video
27 views (last 30 days)
Show older comments
Lukas Wyon
on 16 Oct 2019
Answered: Walter Roberson
on 16 Oct 2019
I want to do some video processing, and i need two frames contiously. the two frames need be right after each other, so i am able to compare them, either being subtracting or else.
clc; clear all;
Video = VideoReader('VID_1.mp4','CurrentTime',11);
opticFlow = opticalFlowLK('NoiseThreshold',0.009);
h = figure;
movegui(h);
hViewPanel = uipanel(h,'Position',[0 0 1 1],'Title','Plot of Optical Flow Vectors');
hPlot = axes(hViewPanel);
while hasFrame(Video)
frameRGB = readFrame(Video);
frameGray = rgb2gray(frameRGB);
frameRGB2 = readFrame(Video,CurrentTime+1); % I need help here...
flow = estimateFlow(opticFlow,frameGray);
imshow(frameRGB2)
hold on
plot(points.selectStrongest(50));
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',100,'Parent',hPlot);
hold off
pause(10^-3)
end
0 Comments
Accepted Answer
Walter Roberson
on 16 Oct 2019
frameRGB = readFrame(Video);
while hasFrame(Video)
frameRGB2 = readFrame(Video);
%now process like you did
frameRGB = frameRGB2; %make current frame the previous frame
end
0 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!