matlab中的writeVideo错误

时间:2013-08-02 20:06:28

标签: matlab video image-processing frame video-processing

我有图像,我将某些曲目叠加到电影上,然后变成电影,但我收到了这个错误(关于我所拥有的代码最后的行)。

??? Undefined function or method 'writeVideo' for
input arguments of type 'uint8'.

错误发生在这段代码的最后一行:

% add this frame to movie file
    %mov = addframe(mov,gcf);
    renderer = get(hnd,'renderer');
    if strcmp(renderer,'painters')
        renderer = 'opengl';
    end
    set(hnd, 'Units', 'pixels');
    pixelsperinch = get(0,'screenpixelsperInch');

    frame = hardcopy(hnd, ['-d' renderer], ['-r' num2str(round(pixelsperinch))]);
    writeVideo('mov',frame); %error appears here

1 个答案:

答案 0 :(得分:0)

跟进Acoustic77的评论,看起来你的VideoWriter对象是mov,但你将字符串'mov'而不是对象mov传递给writeVideo。

% demo using random data and surface plot

mov = VideoWriter('demo.avi');
mov.open;

figure;
for x = 1:10
    data = rand(25,25);
    surf(data);

    renderer = get(gcf,'renderer');
    if strcmp(renderer,'painters')
        renderer = 'opengl';
    end
    frame = hardcopy(gcf, ['-d' renderer], ['-r' num2str(round(300))]);

    writeVideo(mov, frame);

end

mov.close;
mov.delete;