-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add few examples, change MJPEG streamer
- Loading branch information
Showing
15 changed files
with
499 additions
and
198 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
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
41 changes: 30 additions & 11 deletions
41
webcam-capture-drivers/webcam-capture-driver-gstreamer/.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 |
---|---|---|
@@ -1,11 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry kind="src" path="src/etc/licenses"/> | ||
<classpathentry kind="src" path="src/example/java"/> | ||
<classpathentry kind="src" path="src/example/resources"/> | ||
<classpathentry kind="src" path="src/etc/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> | ||
<?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" path="src/etc/licenses"/> | ||
<classpathentry kind="src" path="src/example/java"/> | ||
<classpathentry kind="src" path="src/example/resources"/> | ||
<classpathentry kind="src" path="src/etc/resources"/> | ||
<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="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> |
54 changes: 54 additions & 0 deletions
54
...capture-drivers/webcam-capture-driver-gstreamer/src/example/java/TakePictureExample2.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,54 @@ | ||
import java.awt.event.ActionEvent; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import javax.imageio.ImageIO; | ||
import javax.swing.AbstractAction; | ||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
import com.github.sarxos.webcam.ds.gstreamer.GStreamerDriver; | ||
|
||
|
||
/** | ||
* Example of how to take single picture. | ||
* | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class TakePictureExample2 { | ||
|
||
static { | ||
Webcam.setDriver(new GStreamerDriver()); | ||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
final Webcam webcam = Webcam.getDefault(); | ||
webcam.open(); | ||
|
||
JFrame window = new JFrame(); | ||
JButton button = new JButton(new AbstractAction("Take Snapshot Now") { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
try { | ||
String name = String.format("test-%d.jpg", System.currentTimeMillis()); | ||
ImageIO.write(webcam.getImage(), "JPG", new File(name)); | ||
System.out.format("File %s has been saved\n", name); | ||
} catch (IOException t) { | ||
t.printStackTrace(); | ||
} | ||
} | ||
}); | ||
|
||
window.add(button); | ||
|
||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
window.pack(); | ||
window.setVisible(true); | ||
|
||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...apture-driver-openimaj/src/example/java/com/github/sarxos/webcam/TakePictureExample2.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,55 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import javax.imageio.ImageIO; | ||
import javax.swing.AbstractAction; | ||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.ds.openimaj.OpenImajDriver; | ||
|
||
|
||
/** | ||
* Example of how to take single picture. | ||
* | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class TakePictureExample2 { | ||
|
||
static { | ||
Webcam.setDriver(new OpenImajDriver()); | ||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
final Webcam webcam = Webcam.getDefault(); | ||
webcam.open(); | ||
|
||
JFrame window = new JFrame(); | ||
JButton button = new JButton(new AbstractAction("Take Snapshot Now") { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
try { | ||
String name = String.format("test-%d.jpg", System.currentTimeMillis()); | ||
ImageIO.write(webcam.getImage(), "JPG", new File(name)); | ||
System.out.format("File %s has been saved\n", name); | ||
} catch (IOException t) { | ||
t.printStackTrace(); | ||
} | ||
} | ||
}); | ||
|
||
window.add(button); | ||
|
||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
window.pack(); | ||
window.setVisible(true); | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...capture-driver-openimaj/src/example/java/com/github/sarxos/webcam/WebcamPanelExample.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,28 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.ds.openimaj.OpenImajDriver; | ||
|
||
|
||
public class WebcamPanelExample { | ||
|
||
static { | ||
Webcam.setDriver(new OpenImajDriver()); | ||
} | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
|
||
Webcam webcam = Webcam.getDefault(); | ||
|
||
WebcamPanel panel = new WebcamPanel(webcam); | ||
panel.setFPSDisplayed(true); | ||
|
||
JFrame window = new JFrame("Test webcam panel"); | ||
window.add(panel); | ||
window.setResizable(false); | ||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
window.pack(); | ||
window.setVisible(true); | ||
} | ||
} |
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
55 changes: 55 additions & 0 deletions
55
webcam-capture-drivers/webcam-capture-driver-v4l4j/src/example/java/TakePictureExample2.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,55 @@ | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import javax.imageio.ImageIO; | ||
import javax.swing.AbstractAction; | ||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
import com.github.sarxos.webcam.ds.v4l4j.V4l4jDriver; | ||
|
||
|
||
/** | ||
* Example of how to take single picture. | ||
* | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class TakePictureExample2 { | ||
|
||
static { | ||
Webcam.setDriver(new V4l4jDriver()); | ||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
final Webcam webcam = Webcam.getDefault(); | ||
webcam.open(); | ||
|
||
JFrame window = new JFrame(); | ||
JButton button = new JButton(new AbstractAction("Take Snapshot Now") { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
try { | ||
String name = String.format("test-%d.jpg", System.currentTimeMillis()); | ||
ImageIO.write(webcam.getImage(), "JPG", new File(name)); | ||
System.out.format("File %s has been saved\n", name); | ||
} catch (IOException t) { | ||
t.printStackTrace(); | ||
} | ||
} | ||
}); | ||
|
||
window.add(button); | ||
|
||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
window.pack(); | ||
window.setVisible(true); | ||
|
||
} | ||
} |
13 changes: 12 additions & 1 deletion
13
webcam-capture-examples/webcam-capture-live-streaming/.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
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
15 changes: 15 additions & 0 deletions
15
webcam-capture/src/example/java/MjpegStreamingExample.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,15 @@ | ||
import com.github.sarxos.webcam.Webcam; | ||
import com.github.sarxos.webcam.WebcamStreamer; | ||
|
||
|
||
public class MjpegStreamingExample { | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
Webcam w = Webcam.getDefault(); | ||
new WebcamStreamer(8080, w, 0.5, true); | ||
do { | ||
Thread.sleep(5000); | ||
} while (true); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import java.awt.event.ActionEvent; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import javax.imageio.ImageIO; | ||
import javax.swing.AbstractAction; | ||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
|
||
|
||
/** | ||
* Example of how to take single picture on button press. | ||
* | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class TakePictureExample2 { | ||
|
||
public static void main(String[] args) { | ||
|
||
final Webcam webcam = Webcam.getDefault(); | ||
webcam.open(); | ||
|
||
JFrame window = new JFrame(); | ||
JButton button = new JButton(new AbstractAction("Take Snapshot Now") { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
try { | ||
String name = String.format("test-%d.jpg", System.currentTimeMillis()); | ||
ImageIO.write(webcam.getImage(), "JPG", new File(name)); | ||
System.out.format("File %s has been saved\n", name); | ||
} catch (IOException t) { | ||
t.printStackTrace(); | ||
} | ||
} | ||
}); | ||
|
||
window.add(button); | ||
|
||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
window.pack(); | ||
window.setVisible(true); | ||
|
||
} | ||
} |
Oops, something went wrong.