Save screenshot each 10 seconds
12 views (last 30 days)
Show older comments
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 Comment
Walter Roberson
on 3 Apr 2019
See https://www.mathworks.com/matlabcentral/answers/451721-loop-in-realtime-arduino-reading#comment_684969 for discussion of timer objects.
Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!