-
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.
Small changes in the examples [ci skip]
- Loading branch information
Showing
4 changed files
with
92 additions
and
53 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
webcam-capture/src/example/java/TakePictureFromTwoCamsExample.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
webcam-capture/src/example/java/TakeSnapshotFromAllWebcamsExample.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,58 @@ | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import javax.imageio.ImageIO; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
|
||
|
||
/** | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class TakeSnapshotFromAllWebcamsExample { | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
List<Webcam> webcams = Webcam.getWebcams(); | ||
|
||
// NOTE! | ||
/* | ||
* Yes, I know we could do this in one loop, but I wanted to prove here | ||
* that it's possible to have many native webcams open in the same time. | ||
* I tested this example with 4 webcams simultaneously connected to the | ||
* USB bus - 1 x PC embedded device, and 3 x UVC devices connected to | ||
* the USB concentration hub, which was connected to the USB 2.0 port. | ||
* It's working like a charm. | ||
*/ | ||
|
||
// USB BANDWIDTH! | ||
/* | ||
* As you probably know the USB has limited bandwidth and therefore it | ||
* may not be possible to transfer images from as many cameras as you | ||
* would like to wish. This example works when I'm using QQVGA (176x144) | ||
* but fails with the error message when I want to fetch VGA (640x480). | ||
*/ | ||
|
||
// open all at once (this is the most time-consuming operation, all | ||
// others are executed instantly) | ||
for (Webcam webcam : webcams) { | ||
System.out.format("Opening %s\n", webcam.getName()); | ||
webcam.open(); | ||
} | ||
|
||
// capture picture from all of them | ||
for (int i = 0; i < webcams.size(); i++) { | ||
Webcam webcam = webcams.get(i); | ||
System.out.format("Capturing %s\n", webcam.getName()); | ||
ImageIO.write(webcam.getImage(), "PNG", new File(String.format("test-%d.png", i))); | ||
} | ||
|
||
// close all | ||
for (Webcam webcam : webcams) { | ||
System.out.format("Closing %s\n", webcam.getName()); | ||
webcam.close(); | ||
} | ||
} | ||
|
||
} |
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
11 changes: 5 additions & 6 deletions
11
webcam-capture/src/example/java/WebcamDiscoveryListenerExample.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
696bf68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Sarxos,
First of all thumbs up to your work !
I am a student working on same thing.
I want to contact to you please provide me your email-address.
Thanks in advance !