本帖最后由 山水21 于 2020-3-25 02:52 编辑
错误使用 *
MTIMES 不完全支持整数类。至少有一个输入必须为标量。
要按元素进行 TIMES 计算,请改用 TIMES (.*)。
出错 rgb2gray (line 60)
I= X * coef';
出错 mixture_of_gaussians (line 20)
fr_bw = rgb2gray(fr);
clear all
% source = aviread('C:\Video\Source\traffic\san_fran_traffic_30sec_QVGA');
obj = VideoReader('SampleVideo.avi');
numFrames = obj.NumberOfFrames;
% ----------------------- frame size variables -----------------------
for i = 1 : numFrames
mov(i).cdata=read(obj,i);
frame = mov(i).cdata;
imshow(frame);%显示每一帧
imwrite(frame,strcat(num2str(i),'.jpg'),'jpg');% 保存每一帧
end
fr = mov(1).cdata; % read in 1st frame as background frame
fr_bw = rgb2gray(fr); % convert background to greyscale
fr_size = size(fr);
width = fr_size(2);
height = fr_size(1);
fg = zeros(height, width);
bg_bw = zeros(height, width);
% --------------------- mog variables -----------------------------------
C = 3; % number of gaussian components (typically 3-5)
M = 3; % number of background components
D = 2.5; % positive deviation threshold
alpha = 0.01;