在MATLAB中读取视频文件的有效方式(意思是使用较少的循环和较短的运行时间)是什么意思,例如:vid1.wmv,例如具有此规格(长度:5分钟,帧宽度:640,帧高度:480,帧速率:30帧/秒)并且提取所有像素具有相同颜色(例如:黑色)并具有容差的帧的时间戳。 以下是我的代码,非常耗时。每个框架大约需要三分钟!如何在MATLAB中以相同颜色有效找到所有像素的视频帧?
clear
close all
clc
videoObject = VideoReader('vid1.wmv');
numFrames = get(videoObject, 'NumberOfFrames');
all_same_color_frame=[];
for i=1:numFrames
frame = read(videoObject,i); % reading the 10th frame
W = get(videoObject, 'Width');
H = get(videoObject, 'Height');
q=1;
for j=1:H
for k=1:W
rgb(q).pixl(i).frm = impixel(frame,j,k);
q=q+1;
end
end
Q=1;
for x=1:q-1
if std(rgb(x).pixl(i).frm)==0 % strict criterion on standard deviation
Q=Q+1;
end
end
if Q>0.9*q % if more than 90 percent of all frames had the same color
all_same_color_frame = [all_same_color_frame i];
end
end
在此先感谢
你问的是如何有效地找到它们或者只是如何找到它们?你目前的代码或方法是什么样的? –
什么是“高效”?什么是“最简单”?没有适当的语境,这些话就没有任何意义 – Piglet
我加了我的解决方案,但速度太慢了! – Remy