com.github.sarxos.webcam.WebcamUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webcam-capture Show documentation
Show all versions of webcam-capture Show documentation
This library allows you to use your PC webcam, IP or network cameras directly from Java. It's compatible with most operating systems (Windows, Linux, MacOS).
package com.github.sarxos.webcam;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class WebcamUtils {
public static final void capture(Webcam webcam, String filename) {
try {
ImageIO.write(webcam.getImage(), "PNG", new File(filename + ".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
}