-
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.
Example for WebcamPanel Painter which flips image, refs #581
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
webcam-capture/src/example/java/WebcamPanelFlippingExample.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,45 @@ | ||
import java.awt.FlowLayout; | ||
import java.awt.event.ActionEvent; | ||
|
||
import javax.swing.AbstractAction; | ||
import javax.swing.JCheckBox; | ||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
import com.github.sarxos.webcam.WebcamPanel; | ||
import com.github.sarxos.webcam.WebcamResolution; | ||
|
||
|
||
@SuppressWarnings("serial") | ||
public class WebcamPanelFlippingExample { | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
|
||
final Webcam webcam = Webcam.getDefault(); | ||
webcam.setViewSize(WebcamResolution.QVGA.getSize()); | ||
|
||
final WebcamPanel panel = new WebcamPanel(webcam); | ||
panel.setFPSDisplayed(true); | ||
panel.setImageSizeDisplayed(true); | ||
panel.setMirrored(true); | ||
|
||
final JCheckBox flip = new JCheckBox(); | ||
flip.setSelected(true); | ||
flip.setAction(new AbstractAction("Flip") { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
panel.setMirrored(flip.isSelected()); | ||
} | ||
}); | ||
|
||
JFrame window = new JFrame("Test webcam panel"); | ||
window.setLayout(new FlowLayout()); | ||
window.add(panel); | ||
window.add(flip); | ||
window.setResizable(true); | ||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
window.pack(); | ||
window.setVisible(true); | ||
} | ||
} |