matlab VideoReader

博客仅提供了一个参考链接https://blog.csdn.net/shuoshuge/article/details/86131557,未包含其他关键信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ref:https://blog.csdn.net/shuoshuge/article/details/86131557

clc;
clear;

%obj = VideoReader('filename.mp4');
obj = VideoReader('filename.avi'); %读取视频
% obj.CurrentTime = 0.5;
% currAxes = axes;
% while hasFrame(obj)
%     vidFrame = readFrame(obj);
%     image(vidFrame, 'Parent', currAxes);
%     currAxes.Visible = 'off';
%     pause(1/obj.FrameRate);
% end

                                     %读取第几帧
frame1 = readFrame(obj);             %读取第x帧
frame2 = readFrame(obj);             %读取下一帧
a=frame2-frame1;                     %帧差图
a1=rgb2gray(a);                              %把帧差图变为灰度图像     
flow=estimateFlow(opticalFlowHS,a1);         %此处使用Horn-Schunck光流法
flow1=estimateFlow(opticalFlowLK,a1);        %此处使用LK光流法
 
%画图。
figure(1)
subplot(1,2,1),imshow(frame1);     
subplot(1,2,2),imshow(frame2);     
figure(2)
imshow(a);                         
figure(3)
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',20);view(0,270);
title('HS法 5*5');
figure(4)
plot(flow,'DecimationFactor',[8 8],'ScaleFactor',20);view(0,270);
title('HS法 8*8');
figure(5)
plot(flow1,'DecimationFactor',[5 5],'ScaleFactor',6);view(0,270);
title('LK法 5*5');
figure(6)
plot(flow1,'DecimationFactor',[8 8],'ScaleFactor',6);view(0,270);
title('LK法 8*8');

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值