我正在尝试使用mmreader将视频上传到MATLAB中。我试图按照文档中的示例进行操作,但是在
行mov(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),'colormap',[]);
我收到以下错误:
??? The following error occurred converting from struct to mmreader: Error using ==> which Argument must contain a string.
Error in ==> VIDEO2 at 16 mov(1:nFrames) = struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),'colormap',[]);
任何想法可能有什么不对?这是我写的代码:
xyloObj = mmreader('xylophone.mpg');
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
%// Preallocate movie structure.
mov(1:nFrames) = struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'), ...
'colormap', []);
%// Read one frame at a time.
for k = 1 : nFrames
mov(k).cdata = read(xyloObj, k);
end
%// Size a figure based on the video's width and height.
hf = figure;
set(hf, 'position', [150 150 vidWidth vidHeight])
%// Play back the movie once at the video's frame rate.
movie(hf, mov, 1, xyloObj.FrameRate);