views:

866

answers:

2

Hello,

I want to take a snapshot with my webcam using java and save it to a jpg file. What are the steps needed to do so? A tutorial would be greatly appreciated.

Greetings,
Burkhard

+1  A: 

Hi,

what you are looking for might be the Java Media Framework (JMF). See the Sun Tutorial. I hope that helps.

moxn
+1  A: 

the JMF (Java Media Framework) is a good starting point. However, I did not succeed with it.

I finally found the solution here.

The important part being:

Buffer buf = frameGrabber.grabFrame();
// Convert frame to an buffered image so it can be processed and saved
Image img = (new BufferToImage((VideoFormat) buf.getFormat()).createImage(buf));
buffImg = new BufferedImage(img.getWidth(this), img.getHeight(this), BufferedImage.TYPE_INT_RGB);
//TODO saving the buffImg
Burkhard