在视频.avi文件上使用欧拉放大代码时,帧索引号出错

问题描述

对于一组特定的视频,我在matlab代码中遇到错误,它对一个视频有效,而对其他视频则无效。我正在使用Matlab R2020a版本。

“帧索引必须是一个大于零且小于或等于文件中帧数的数值。”

一行错误==> video1 = read(v,ii);

enter code here


clearvars;
clc;
myDir = pwd; %gets directory
myFiles = dir(fullfile(myDir,'onlybreathing.avi')); %gets all txt files in struct
for vid_num=1:length(myFiles)
v = VideoReader(eval(sprintf('''onlybreathing.avi''',vid_num)));
%FFT length.
fft_len = 512;
%Video rate is 30 frames per second.
vid_rate = 30;
%Get number of frames in the video file.
vid_len = v.NumberOfFrames;
%Generate arrays of zeros.
aa = zeros(1,fft_len+1);
ab = zeros(1,fft_len);
%Loop through every frame and calculate a sum for each frame.
for ii = 1:fft_len+1
**video1 = read(v,ii);**
video1bw = rgb2gray(video1);
%frame_val = sum(sum(video1bw));
frame_val = sum(video1bw(:) > 200);
aa(ii) = frame_val;
end

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)