Read 2 frames simultaneously from same video
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2019-10-16
frameRGB = readFrame(Video);
while hasFrame(Video)
frameRGB2 = readFrame(Video);
%now process like you did
frameRGB = frameRGB2; %make current frame the previous frame
end
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!