Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grabber initialization failure in multithreaded environment
fixes #4 a
- Loading branch information
Showing
22 changed files
with
616 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
webcam-capture-examples/webcam-capture-executable/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src/main/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
23 changes: 23 additions & 0 deletions
23
webcam-capture-examples/webcam-capture-executable/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>webcam-capture-example-executable</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
131 changes: 131 additions & 0 deletions
131
webcam-capture-examples/webcam-capture-executable/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<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"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.github.sarxos</groupId> | ||
<artifactId>webcam-capture-examples</artifactId> | ||
<version>0.3.5</version> | ||
</parent> | ||
|
||
<artifactId>webcam-capture-example-executable</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.sarxos</groupId> | ||
<artifactId>webcam-capture</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jclarion</groupId> | ||
<artifactId>image4j</artifactId> | ||
<version>0.7</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>2.5.1</version> | ||
<executions> | ||
<execution> | ||
<id>copy-libs</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.directory}/libs</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.akathist.maven.plugins.launch4j</groupId> | ||
<artifactId>launch4j-maven-plugin</artifactId> | ||
<version>1.5.1</version> | ||
<executions> | ||
<execution> | ||
<id>l4j-gui</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>launch4j</goal> | ||
</goals> | ||
<configuration> | ||
<headerType>gui</headerType> | ||
<outfile>${project.build.directory}/capture.exe</outfile> | ||
<jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar> | ||
<errTitle>Error</errTitle> | ||
<icon>src/main/resources/Security-Camera.ico</icon> | ||
<classPath> | ||
<mainClass>com.github.sarxos.webcam.WebcamExecutableExample</mainClass> | ||
<addDependencies>true</addDependencies> | ||
<jarLocation>libs</jarLocation> | ||
</classPath> | ||
<jre> | ||
<minVersion>1.5.0</minVersion> | ||
<maxVersion>1.6.0</maxVersion> | ||
</jre> | ||
<singleInstance> | ||
<mutexName>WebcamCapture</mutexName> | ||
<windowTitle>${project.name}</windowTitle> | ||
</singleInstance> | ||
<versionInfo> | ||
<fileVersion>1.2.3.4</fileVersion> | ||
<txtFileVersion>v1.2.3.4</txtFileVersion> | ||
<fileDescription>${project.name}</fileDescription> | ||
<copyright>Bartosz Firyn</copyright> | ||
<productVersion>1.2.3.4</productVersion> | ||
<txtProductVersion>v1.2.3.4</txtProductVersion> | ||
<productName>${project.name}</productName> | ||
<internalName>${project.name}</internalName> | ||
<originalFilename>capture.exe</originalFilename> | ||
</versionInfo> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.m2e</groupId> | ||
<artifactId>lifecycle-mapping</artifactId> | ||
<version>1.0.0</version> | ||
<configuration> | ||
<lifecycleMappingMetadata> | ||
<pluginExecutions> | ||
<pluginExecution> | ||
<pluginExecutionFilter> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<versionRange>[2.5.1,)</versionRange> | ||
<goals> | ||
<goal> | ||
copy-dependencies | ||
</goal> | ||
</goals> | ||
</pluginExecutionFilter> | ||
<action> | ||
<ignore/> | ||
</action> | ||
</pluginExecution> | ||
</pluginExecutions> | ||
</lifecycleMappingMetadata> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
85 changes: 85 additions & 0 deletions
85
...am-capture-executable/src/main/java/com/github/sarxos/webcam/WebcamExecutableExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import java.awt.Color; | ||
import java.awt.FlowLayout; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.awt.image.BufferedImage; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import javax.swing.ImageIcon; | ||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
|
||
import net.sf.image4j.codec.ico.ICODecoder; | ||
|
||
|
||
public class WebcamExecutableExample extends JFrame implements ActionListener { | ||
|
||
private static final long serialVersionUID = -1368783325310232511L; | ||
|
||
private Executor executor = Executors.newSingleThreadExecutor(); | ||
private AtomicBoolean initialized = new AtomicBoolean(false); | ||
private Webcam webcam = null; | ||
private WebcamPanel panel = null; | ||
private JButton button = null; | ||
|
||
public WebcamExecutableExample() { | ||
super(); | ||
|
||
setTitle("Webcam Executable Example"); | ||
setLayout(new FlowLayout(FlowLayout.CENTER)); | ||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
webcam = Webcam.getDefault(); | ||
webcam.setViewSize(webcam.getViewSizes()[0]); | ||
|
||
panel = new WebcamPanel(webcam, false); | ||
panel.setPreferredSize(webcam.getViewSize()); | ||
panel.setOpaque(true); | ||
panel.setBackground(Color.BLACK); | ||
|
||
ImageIcon icon = null; | ||
try { | ||
List<BufferedImage> icons = ICODecoder.read(getClass().getResourceAsStream("/Security-Camera.ico")); | ||
icon = new ImageIcon(icons.get(1)); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
button = new JButton(icon); | ||
button.addActionListener(this); | ||
button.setFocusable(false); | ||
button.setPreferredSize(webcam.getViewSize()); | ||
|
||
add(panel); | ||
add(button); | ||
|
||
pack(); | ||
setVisible(true); | ||
} | ||
|
||
boolean running = false; | ||
|
||
public static void main(String[] args) throws IOException { | ||
new WebcamExecutableExample(); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
if (initialized.compareAndSet(false, true)) { | ||
executor.execute(new Runnable() { | ||
|
||
@Override | ||
public void run() { | ||
panel.start(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
} |
Binary file added
BIN
+422 KB
webcam-capture-examples/webcam-capture-executable/src/main/resources/Security-Camera.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
webcam-capture-examples/webcam-capture-executable/src/main/resources/Security-Camera.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Icon from http://www.iconarchive.com/show/vista-hardware-devices-icons-by-icons-land/Security-Camera-icon.html | ||
|
||
Artist: Icons-Land (Available for custom work) | ||
Iconset: Vista Hardware Devices Icons (28 icons) | ||
License: Free for non-commercial use. | ||
Commercial usage: Not allowed |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.