diff --git a/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/JpegDasdingStudioExample.java b/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/JpegDasdingStudioExample.java index bc76fbf1..f560aa90 100644 --- a/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/JpegDasdingStudioExample.java +++ b/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/JpegDasdingStudioExample.java @@ -54,7 +54,7 @@ public static void main(String[] args) throws MalformedURLException { WebcamPanel panel = new WebcamPanel(webcam, new Dimension(256, 144), false); panel.setFillArea(true); panel.setFPSLimited(true); - panel.setFPS(0.2); // 0.2 FPS = 1 frame per 5 seconds + panel.setFPSLimit(0.2); // 0.2 FPS = 1 frame per 5 seconds panel.setBorder(BorderFactory.createEmptyBorder()); f.add(panel); diff --git a/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/MjpegLignanoBeachExample.java b/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/MjpegLignanoBeachExample.java index 477c5757..66fa4db3 100644 --- a/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/MjpegLignanoBeachExample.java +++ b/webcam-capture-drivers/webcam-capture-driver-ipcam/src/examples/java/MjpegLignanoBeachExample.java @@ -31,7 +31,7 @@ public static void main(String[] args) throws MalformedURLException { IpCamDeviceRegistry.register("Lignano", "http://88.37.116.138/mjpg/video.mjpg", IpCamMode.PUSH); WebcamPanel panel = new WebcamPanel(Webcam.getWebcams().get(0)); - panel.setFPS(1); + panel.setFPSLimit(1); JFrame f = new JFrame("Live Views From Lignano Beach"); f.add(panel); diff --git a/webcam-capture-examples/webcam-capture-detect-face/src/main/java/com/github/sarxos/webcam/FacePainterExample.java b/webcam-capture-examples/webcam-capture-detect-face/src/main/java/com/github/sarxos/webcam/FacePainterExample.java index 9ce23350..3c4f44a4 100644 --- a/webcam-capture-examples/webcam-capture-detect-face/src/main/java/com/github/sarxos/webcam/FacePainterExample.java +++ b/webcam-capture-examples/webcam-capture-detect-face/src/main/java/com/github/sarxos/webcam/FacePainterExample.java @@ -53,7 +53,7 @@ public FacePainterExample() throws IOException { panel.setPainter(this); panel.setFPSDisplayed(true); panel.setFPSLimited(true); - panel.setFPS(20); + panel.setFPSLimit(20); panel.setPainter(this); panel.start(); diff --git a/webcam-capture/src/etc/resources/faces.jpg b/webcam-capture/src/etc/resources/faces.jpg new file mode 100644 index 00000000..8d8b4f2b Binary files /dev/null and b/webcam-capture/src/etc/resources/faces.jpg differ diff --git a/webcam-capture/src/etc/resources/painter-crystallize.png b/webcam-capture/src/etc/resources/painter-crystallize.png new file mode 100644 index 00000000..e3ab4c15 Binary files /dev/null and b/webcam-capture/src/etc/resources/painter-crystallize.png differ diff --git a/webcam-capture/src/etc/resources/webcam-capture-handbook.doc b/webcam-capture/src/etc/resources/webcam-capture-handbook.doc index d2e4cb11..79da98c4 100644 Binary files a/webcam-capture/src/etc/resources/webcam-capture-handbook.doc and b/webcam-capture/src/etc/resources/webcam-capture-handbook.doc differ diff --git a/webcam-capture/src/example/java/WebcamPanelExample.java b/webcam-capture/src/example/java/WebcamPanelExample.java index 514325ca..b38de5a2 100644 --- a/webcam-capture/src/example/java/WebcamPanelExample.java +++ b/webcam-capture/src/example/java/WebcamPanelExample.java @@ -8,18 +8,16 @@ public class WebcamPanelExample { public static void main(String[] args) throws InterruptedException { - JFrame window = new JFrame("Test webcam panel"); - Webcam webcam = Webcam.getDefault(); WebcamPanel panel = new WebcamPanel(webcam); - panel.setFPSDisplayed(true); // display FPS on screen - panel.setFPSLimited(false); // no FPS limit - panel.setFillArea(true); // image will be resized with window + 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); - window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } diff --git a/webcam-capture/src/example/java/WebcamPanelFillAreaExample.java b/webcam-capture/src/example/java/WebcamPanelFillAreaExample.java new file mode 100644 index 00000000..e7a8016d --- /dev/null +++ b/webcam-capture/src/example/java/WebcamPanelFillAreaExample.java @@ -0,0 +1,23 @@ +import javax.swing.JFrame; + +import com.github.sarxos.webcam.Webcam; +import com.github.sarxos.webcam.WebcamPanel; + + +public class WebcamPanelFillAreaExample { + + public static void main(String[] args) throws InterruptedException { + + Webcam webcam = Webcam.getDefault(); + + WebcamPanel panel = new WebcamPanel(webcam); + panel.setFPSDisplayed(true); + panel.setFillArea(true); + + JFrame window = new JFrame("Test webcam panel"); + window.add(panel); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.pack(); + window.setVisible(true); + } +} diff --git a/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamPanel.java b/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamPanel.java index 5c912f89..fe63a115 100644 --- a/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamPanel.java +++ b/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamPanel.java @@ -372,13 +372,15 @@ private void update() { */ private AtomicBoolean started = new AtomicBoolean(false); + private Painter defaultPainter = new DefaultPainter(); + /** * Painter used to draw image in panel. * * @see #setPainter(Painter) * @see #getPainter() */ - private Painter painter = new DefaultPainter(); + private Painter painter = defaultPainter; /** * Preferred panel size. @@ -612,7 +614,7 @@ public void setFPSLimited(boolean frequencyLimit) { * * @return Rendering frequency */ - public double getFPS() { + public double getFPSLimit() { return frequency; } @@ -620,16 +622,16 @@ public double getFPS() { * Set rendering frequency (in Hz or FPS). Minimum frequency is 0.016 (1 * frame per minute) and maximum is 25 (25 frames per second). * - * @param frequency the frequency + * @param fps the frequency */ - public void setFPS(double frequency) { - if (frequency > MAX_FREQUENCY) { - frequency = MAX_FREQUENCY; + public void setFPSLimit(double fps) { + if (fps > MAX_FREQUENCY) { + fps = MAX_FREQUENCY; } - if (frequency < MIN_FREQUENCY) { - frequency = MIN_FREQUENCY; + if (fps < MIN_FREQUENCY) { + fps = MIN_FREQUENCY; } - this.frequency = frequency; + this.frequency = fps; } public boolean isFPSDisplayed() { @@ -686,4 +688,8 @@ public void propertyChange(PropertyChangeEvent evt) { rb = WebcamUtils.loadRB(WebcamPanel.class, lc); } } + + public Painter getDefaultPainter() { + return defaultPainter; + } }