diff --git a/webcam-capture-examples/pom.xml b/webcam-capture-examples/pom.xml index dc1abf65..835dca0a 100644 --- a/webcam-capture-examples/pom.xml +++ b/webcam-capture-examples/pom.xml @@ -26,6 +26,7 @@ webcam-capture-qrcode webcam-capture-swt-awt webcam-capture-video-recording + webcam-capture-onejar diff --git a/webcam-capture-examples/webcam-capture-onejar/.classpath b/webcam-capture-examples/webcam-capture-onejar/.classpath new file mode 100644 index 00000000..534b5e52 --- /dev/null +++ b/webcam-capture-examples/webcam-capture-onejar/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webcam-capture-examples/webcam-capture-onejar/.project b/webcam-capture-examples/webcam-capture-onejar/.project new file mode 100644 index 00000000..911fe230 --- /dev/null +++ b/webcam-capture-examples/webcam-capture-onejar/.project @@ -0,0 +1,23 @@ + + + webcam-capture-example-onejar + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/webcam-capture-examples/webcam-capture-onejar/pom.xml b/webcam-capture-examples/webcam-capture-onejar/pom.xml new file mode 100644 index 00000000..60a547ac --- /dev/null +++ b/webcam-capture-examples/webcam-capture-onejar/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + + com.github.sarxos + webcam-capture-examples + 0.3.10-SNAPSHOT + + + webcam-capture-example-onejar + + + + com.github.sarxos + webcam-capture + 0.3.10-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.1 + + + package + + shade + + + + + GetBitmapFromCamera + + + + + + + + + + \ No newline at end of file diff --git a/webcam-capture-examples/webcam-capture-onejar/src/main/java/GetBitmapFromCamera.java b/webcam-capture-examples/webcam-capture-onejar/src/main/java/GetBitmapFromCamera.java new file mode 100644 index 00000000..d436a63f --- /dev/null +++ b/webcam-capture-examples/webcam-capture-onejar/src/main/java/GetBitmapFromCamera.java @@ -0,0 +1,17 @@ +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import com.github.sarxos.webcam.Webcam; + + +public class GetBitmapFromCamera { + + public static void main(String[] args) throws IOException { + Webcam webcam = Webcam.getDefault(); + webcam.open(); + ImageIO.write(webcam.getImage(), "JPG", new File(System.currentTimeMillis() + ".jpg")); + webcam.close(); + } +} diff --git a/webcam-capture/src/example/java/PureDeviceTest.java b/webcam-capture/src/example/java/PureDeviceTest.java new file mode 100644 index 00000000..eca199c7 --- /dev/null +++ b/webcam-capture/src/example/java/PureDeviceTest.java @@ -0,0 +1,38 @@ +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.List; + +import javax.imageio.ImageIO; + +import com.github.sarxos.webcam.WebcamDevice; +import com.github.sarxos.webcam.ds.buildin.WebcamDefaultDriver; + + +public class PureDeviceTest { + + public static void main(String[] args) { + + WebcamDefaultDriver driver = new WebcamDefaultDriver(); + List devices = driver.getDevices(); + + for (WebcamDevice d : devices) { + System.out.println(d.getName()); + try { + d.open(); + BufferedImage image = d.getImage(); + ImageIO.write(image, "jpg", new File(System.currentTimeMillis() + ".jpg")); + } catch (IOException e) { + e.printStackTrace(); + } finally { + d.close(); + } + } + + // finally at the end, don't forget to dispose + for (WebcamDevice d : devices) { + d.dispose(); + } + } + +}