Save screenshot each 10 seconds
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello everyone. I need help. I am a new matlab user. I am taking screenshot of PC desktop each 10 seconds and how screenshots could be saved in one folder for further processing.Thank you in advance
while 1
robot = java.awt.Robot();
pos = [529 132 313 555]; % [left top width height]
rect = java.awt.Rectangle(pos(1),pos(2),pos(3),pos(4));
cap = robot.createScreenCapture(rect);
rgb = typecast(cap.getRGB(0,0,cap.getWidth,cap.getHeight,[],0,cap.getWidth),'uint8');
imgData = zeros(cap.getHeight,cap.getWidth,3,'uint8');
imgData(:,:,1) = reshape(rgb(3:4:end),cap.getWidth,[])';
imgData(:,:,2) = reshape(rgb(2:4:end),cap.getWidth,[])';
imgData(:,:,3) = reshape(rgb(1:4:end),cap.getWidth,[])';
imshow(imgData)
imwrite(imgData,'out.png')
end
댓글 수: 1
Walter Roberson
2019년 4월 3일
See https://www.mathworks.com/matlabcentral/answers/451721-loop-in-realtime-arduino-reading#comment_684969 for discussion of timer objects.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!