-
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 image transformation feature, closes #73
- Loading branch information
Showing
4 changed files
with
171 additions
and
65 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...am-capture/src/example/java/com/github/sarxos/webcam/example/ImageTransformerExample.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,46 @@ | ||
package com.github.sarxos.webcam.example; | ||
|
||
import java.awt.image.BufferedImage; | ||
|
||
import javax.swing.JFrame; | ||
|
||
import com.github.sarxos.webcam.Webcam; | ||
import com.github.sarxos.webcam.WebcamImageTransformer; | ||
import com.github.sarxos.webcam.WebcamPanel; | ||
import com.github.sarxos.webcam.WebcamResolution; | ||
import com.github.sarxos.webcam.util.jh.JHGrayFilter; | ||
|
||
|
||
public class ImageTransformerExample implements WebcamImageTransformer { | ||
|
||
private static final JHGrayFilter GRAY = new JHGrayFilter(); | ||
|
||
@Override | ||
public BufferedImage transform(BufferedImage image) { | ||
return GRAY.filter(image, null); | ||
} | ||
|
||
public ImageTransformerExample() { | ||
|
||
Webcam webcam = Webcam.getDefault(); | ||
webcam.setViewSize(WebcamResolution.VGA.getSize()); | ||
webcam.setImageTransformer(this); | ||
webcam.open(); | ||
|
||
JFrame window = new JFrame("Test Transformer"); | ||
|
||
WebcamPanel panel = new WebcamPanel(webcam); | ||
panel.setFPSDisplayed(true); | ||
panel.setFillArea(true); | ||
|
||
window.add(panel); | ||
window.pack(); | ||
window.setVisible(true); | ||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
} | ||
|
||
public static void main(String[] args) { | ||
new ImageTransformerExample(); | ||
} | ||
|
||
} |
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
10 changes: 10 additions & 0 deletions
10
webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamImageTransformer.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,10 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import java.awt.image.BufferedImage; | ||
|
||
|
||
public interface WebcamImageTransformer { | ||
|
||
BufferedImage transform(BufferedImage image); | ||
|
||
} |
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