Borrar filtros
Borrar filtros

how to capture certain area of screen

12 visualizaciones (últimos 30 días)
sandeep
sandeep el 26 de Nov. de 2014
Comentada: Image Analyst el 26 de Nov. de 2014
This is a matlab screen capture program that captures whole screen every one second and saves capture screen to a folder. I need to modify it to capture certain rectangular area of screen instead of all screen. Also i need to apply image processing on captured frames in real time i.e. immediately after they are captured. Please help.
%press (ctrl+break) to stop your program from capturing screen
i=1;
while true
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', i));
javax.imageio.ImageIO.write(image,'jpg',filehandle);
pause(300) %# Wait for 5 min
i = i + 1;
end

Respuestas (3)

Sean de Wolski
Sean de Wolski el 26 de Nov. de 2014

sandeep
sandeep el 26 de Nov. de 2014
The code you are referring to takes only one screen shot. I need a code that can capture certain area of screen continuously lets say fro one mniute and then stop.
  4 comentarios
Sean de Wolski
Sean de Wolski el 26 de Nov. de 2014
doc timer
Set the timerfcn up to call screencapture and do whatever processing needs to be done.
sandeep
sandeep el 26 de Nov. de 2014
Can u edit the code that i posted above so that it captures a certain area.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 26 de Nov. de 2014
Don't use image as the name of your variable since it's the name of a built-in function. Try this
screenImage = robo.createScreenCapture(rectangle);
subImage = screenImage(row1:row2, col1:col2,:); % Crop it.
Then do your save on subImage.
  2 comentarios
Image Analyst
Image Analyst el 26 de Nov. de 2014
sandeep's reply moved here since it's not an answer to the original question, but a reply to me:
@ Image analyst, I get the meaning of first line in your code. But what kind of cropping will be done by second line. The code i posted captures full screen every 300 seconds and saves capture screen to a folder. I need to modify it to capture certain rectangular area on screen.... and then send the captures frames to image processing algorithm. Please help me here.
Image Analyst
Image Analyst el 26 de Nov. de 2014
The second line of code takes a 3D image - a color image - and extracts out a sub image (that is also color) into its own variable called subImage. The rest of your code with looping and saving can stay the same, except for the write line where you want to write this subImage to disk, instead of the whole screen image.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by