Capturing high-resolution snapshots from a webcam, in Java

Does anyone know a Java library that can be used to capture high resolution image snapshots from a webcam?

More precisely: - Detection of available webcams (laptops can have built-in and external, connected via USB-connection) - Select a webcam to work. - Detect available resolutions for image capture (for example: up to 1280x1024 for a webcam with a 1.3 megapixel sensor). They are usually much larger than for capturing VIDEO (for example: up to 640x480 for the same webcam). - Select the resolution to work. - Upon request (call the API function), take a picture from the selected camera with the selected resolution.

I tried: - JMF: sucks, does not support automatic detection of connected webcams. - FMJ: uses LTI-CIVIL to support webcams. - LTI-CIVIL: only supports VIDEO capture. The code is also very old (2007, if I remember correctly). Uses proprietary libraries written in C ++ to access webcams. DirectX for Windows and Video4Linux for (obviously) Linux. But while looking at the C ++ code, it becomes obvious that it focuses on streaming video, which is not my goal (as reflected in the description of what I need)

I would appreciate if someone could point me to a Java library that matches the profile I need.

Thanks.

+4
source share
4 answers

openCV is a popular library of computer vision in C ++. However, they are also tied to Java. http://code.google.com/p/javacv/

OpenCV allows you to access image and video processing and capture image and video from multiple webcams.

+2
source

This Java API should do the job: http://webcam-capture.sarxos.pl/ The following code takes a snapshot and saves it as a .png file in the project workspace folder. Be sure to check out the creators of other examples on their website.

import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import com.github.sarxos.webcam.Webcam; public class TakePictureExample { public static void main(String[] args) throws IOException { // get default webcam and open it Webcam webcam = Webcam.getDefault(); webcam.open(); // get image BufferedImage image = webcam.getImage(); // save image to PNG file ImageIO.write(image, "PNG", new File("test.png")); } } 
+1
source

The next open source webcam project, http://code.google.com/p/webcamstudio/, did an excellent job using Java to support the webcam. Perhaps take some ideas from there.

0
source

You can use JMyron , the library here and you can see how this works with this example.

0
source

All Articles