Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to set view size + example
- Loading branch information
Showing
4 changed files
with
143 additions
and
8 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/example/java/com/github/sarxos/webcam/TakePictureDifferentSizeExample.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,26 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import java.awt.Dimension; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import javax.imageio.ImageIO; | ||
|
||
|
||
/** | ||
* Set view size before taking picture. It's worth to mention that size has to | ||
* be set before opening camera. | ||
* | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class TakePictureDifferentSizeExample { | ||
|
||
public static void main(String[] args) throws IOException { | ||
Webcam webcam = Webcam.getDefault(); | ||
webcam.setViewSize(new Dimension(176, 144)); | ||
webcam.open(); | ||
ImageIO.write(webcam.getImage(), "PNG", new File("test.png")); | ||
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
29 changes: 29 additions & 0 deletions
29
src/example/java/com/github/sarxos/webcam/TakePictureFromTwoCamsExample.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,29 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import javax.imageio.ImageIO; | ||
|
||
|
||
/** | ||
* @author Bartosz Firyn (SarXos) | ||
*/ | ||
public class TakePictureFromTwoCamsExample { | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
Webcam webcam1 = Webcam.getWebcams().get(0); | ||
Webcam webcam2 = Webcam.getWebcams().get(1); | ||
|
||
webcam1.open(); | ||
webcam2.open(); | ||
|
||
ImageIO.write(webcam1.getImage(), "PNG", new File("test1.png")); | ||
ImageIO.write(webcam2.getImage(), "PNG", new File("test2.png")); | ||
|
||
webcam1.close(); | ||
webcam2.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