Matlab while循环截图重新加载

时间:2014-09-07 14:05:07

标签: matlab loops while-loop screenshot

我想每秒拍摄一次屏幕截图,然后保存。 我想用它来玩游戏,那里有一个柜台。我认为一个while循环会不断刷新imshow(截图)但是,它没有。这是我的代码:

 i = 1;    
 while i > 0 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Screenshot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    imshow(screenshot)
    robo = java.awt.Robot;
    t = java.awt.Toolkit.getDefaultToolkit();

    %# Set the capture area as the size for the screen
    rectangle = java.awt.Rectangle(t.getScreenSize());

    %# Get the capture
    image = robo.createScreenCapture(rectangle);

    %# Save it to file
    filehandle = java.io.File(sprintf('capture%d.jpg', 1));
    javax.imageio.ImageIO.write(image,'jpg',filehandle);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Load screen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

    screenshot = imread('capture1.jpg'); % is using as a test        
    screenshot = imcrop(screenshot,[360 205 520 423]);                
 end

1 个答案:

答案 0 :(得分:0)

您是否尝试使用 drawow 更新当前数字:http://www.mathworks.com/help/matlab/ref/drawnow.html?refresh=true