Read 2 frames simultaneously from same video

27 views (last 30 days)
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

Accepted Answer

Walter Roberson
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

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!