Skip to content

Commit 05a1fa7

Browse files
committed
Add onejar example
1 parent 859273c commit 05a1fa7

File tree

6 files changed

+161
-0
lines changed

6 files changed

+161
-0
lines changed

webcam-capture-examples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<module>webcam-capture-qrcode</module>
2727
<module>webcam-capture-swt-awt</module>
2828
<module>webcam-capture-video-recording</module>
29+
<module>webcam-capture-onejar</module>
2930
</modules>
3031

3132
<build>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="output" path="target/classes"/>
36+
</classpath>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>webcam-capture-example-onejar</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>com.github.sarxos</groupId>
7+
<artifactId>webcam-capture-examples</artifactId>
8+
<version>0.3.10-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>webcam-capture-example-onejar</artifactId>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>com.github.sarxos</groupId>
16+
<artifactId>webcam-capture</artifactId>
17+
<version>0.3.10-SNAPSHOT</version>
18+
</dependency>
19+
</dependencies>
20+
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-shade-plugin</artifactId>
26+
<version>2.1</version>
27+
<executions>
28+
<execution>
29+
<phase>package</phase>
30+
<goals>
31+
<goal>shade</goal>
32+
</goals>
33+
<configuration>
34+
<transformers>
35+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
36+
<mainClass>GetBitmapFromCamera</mainClass>
37+
</transformer>
38+
</transformers>
39+
</configuration>
40+
</execution>
41+
</executions>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
46+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.io.File;
2+
import java.io.IOException;
3+
4+
import javax.imageio.ImageIO;
5+
6+
import com.github.sarxos.webcam.Webcam;
7+
8+
9+
public class GetBitmapFromCamera {
10+
11+
public static void main(String[] args) throws IOException {
12+
Webcam webcam = Webcam.getDefault();
13+
webcam.open();
14+
ImageIO.write(webcam.getImage(), "JPG", new File(System.currentTimeMillis() + ".jpg"));
15+
webcam.close();
16+
}
17+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import java.awt.image.BufferedImage;
2+
import java.io.File;
3+
import java.io.IOException;
4+
import java.util.List;
5+
6+
import javax.imageio.ImageIO;
7+
8+
import com.github.sarxos.webcam.WebcamDevice;
9+
import com.github.sarxos.webcam.ds.buildin.WebcamDefaultDriver;
10+
11+
12+
public class PureDeviceTest {
13+
14+
public static void main(String[] args) {
15+
16+
WebcamDefaultDriver driver = new WebcamDefaultDriver();
17+
List<WebcamDevice> devices = driver.getDevices();
18+
19+
for (WebcamDevice d : devices) {
20+
System.out.println(d.getName());
21+
try {
22+
d.open();
23+
BufferedImage image = d.getImage();
24+
ImageIO.write(image, "jpg", new File(System.currentTimeMillis() + ".jpg"));
25+
} catch (IOException e) {
26+
e.printStackTrace();
27+
} finally {
28+
d.close();
29+
}
30+
}
31+
32+
// finally at the end, don't forget to dispose
33+
for (WebcamDevice d : devices) {
34+
d.dispose();
35+
}
36+
}
37+
38+
}

0 commit comments

Comments
 (0)