i am using java application . in this application capture image from webcam using jmf and java after capture 4 or 5 images its goes to video mode. i cant to capture image again at that time showing some error "heap error out of memory exceptions" please any one tell me idea. Advance in thanks
First check if you are calling dispose()
on Graphics2D
created via BufferedImage.createGraphics()
, then check if you are calling flush()
method on BufferedImage
you have created when you do not want to use this image any more. If this won't help, you can try to use ready solution, e.g. utilize this project:
https://github.com/sarxos/webcam-capture
Code example (take picture from webcam and save in test.png file):
Webcam webcam = Webcam.getDefault();
BufferedImage image = webcam.getImage();
ImageIO.write(image, "PNG", new File("test.png"));
With this library you don't need to dispose graphics nor flush buffered image after it is not used any more - underlying driver will do it for you.
i am using java application . in this application capture image from webcam using jmf and java after capture 4 or 5 images its goes to video mode. i cant to capture image again at that time showing some error "heap error out of memory exceptions" please any one tell me idea. Advance in thanks
First check if you are calling dispose()
on Graphics2D
created via BufferedImage.createGraphics()
, then check if you are calling flush()
method on BufferedImage
you have created when you do not want to use this image any more. If this won't help, you can try to use ready solution, e.g. utilize this project:
https://github.com/sarxos/webcam-capture
Code example (take picture from webcam and save in test.png file):
Webcam webcam = Webcam.getDefault();
BufferedImage image = webcam.getImage();
ImageIO.write(image, "PNG", new File("test.png"));
With this library you don't need to dispose graphics nor flush buffered image after it is not used any more - underlying driver will do it for you.
0 commentaires:
Enregistrer un commentaire