Skip to content

Commit

Permalink
Extract WebcamPanel painter interface
Browse files Browse the repository at this point in the history
fixes #5
  • Loading branch information
sarxos committed Nov 23, 2012
1 parent bd932f5 commit 6835fc1
Show file tree
Hide file tree
Showing 20 changed files with 648 additions and 60 deletions.
1 change: 1 addition & 0 deletions webcam-capture-examples/pom.xml
Expand Up @@ -19,6 +19,7 @@
<module>webcam-capture-applet</module>
<module>webcam-capture-executable</module>
<module>webcam-capture-motiondetector</module>
<module>webcam-capture-painter</module>
</modules>

</project>
31 changes: 31 additions & 0 deletions webcam-capture-examples/webcam-capture-painter/.classpath
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions webcam-capture-examples/webcam-capture-painter/.project
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>webcam-capture-example-painter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
73 changes: 73 additions & 0 deletions webcam-capture-examples/webcam-capture-painter/README.md
@@ -0,0 +1,73 @@
# Webcam Capture Custom Painter Example

This simple example show how to create custom painter for `WebcamCapture` Swing
component used to draw images from `Webcam` instance.

## What Is This

This example presents how to use custom painters to alter image displayed in
`WebcamPanel` component. Usually, if user won't change it, `DefaultPainter` is
being used. This painter implements `Painter` interface which consists of two methods:

* `paintPanel(WebcamPanel wp, Graphics2D g2)` which paints panel when image from camera
is not disdplayed, and second one,
* `paintImage(WebcamPanel wp, BufferedImage img, Graphics2D g2)` which pains image from
camera when camera is turned on.

In this example I used filters from awesome image processing library by
_[Jerry Huxtable Labs](http://www.jhlabs.com/)_
which descriptions be found **[here](http://www.jhlabs.com/ip/filters/)** and which can be
[downloaded](http://search.maven.org/#artifactdetails|com.jhlabs|filters|2.0.235|jar) from Maven Central.

[Look and Feel](http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html)
used in all examples can be found in [Insubstantial](https://github.com/Insubstantial/insubstantial) project.
The one I used in this example is `SubstanceTwilightLookAndFeel`. Thank you
_[Kirill](http://www.linkedin.com/in/kirillcool)_ for this awesome Look and Feel stuff!

### Screenshoots:

Capturing is disabled:

![Capturing Disabled](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/not-displayed.png "Capturing Disabled")

Possible filters (only few from whole JS Labs filters set):

![Filters](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/filters.png "Filters")

Crystallize filter:

![Crystallize](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/crystallize.png "Crystallize")

Dither filter:

![Dither](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/dither.png "Dither")

Invert filter:

![Invert](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/invert.png "Invert")

Kaleidoscope filter:

![Kaleidoscope](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/kaleidoscope.png "Kaleidoscope")

Noise filter:

![Noise](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/noise.png "Noise")

Sphere filter:

![Sphere](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/sphere.png "Sphere")

Threshold filter:

![Threshold](https://raw.github.com/sarxos/webcam-capture/master/webcam-capture-examples/webcam-capture-painter/src/etc/resources/threshold.png "Threshold")

## License

Copyright (C) 2012 Bartosz Firyn

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 changes: 36 additions & 0 deletions webcam-capture-examples/webcam-capture-painter/pom.xml
@@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.sarxos</groupId>
<artifactId>webcam-capture-examples</artifactId>
<version>0.3.5</version>
</parent>

<artifactId>webcam-capture-example-painter</artifactId>
<packaging>jar</packaging>

<name>Webcam Capture - Custom Painter Example</name>
<description>Example of how to create custom painter for WebcamPanel component</description>

<dependencies>
<dependency>
<groupId>com.github.sarxos</groupId>
<artifactId>webcam-capture</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.github.insubstantial</groupId>
<artifactId>substance</artifactId>
<version>7.1</version>
</dependency>

<dependency>
<groupId>com.jhlabs</groupId>
<artifactId>filters</artifactId>
<version>2.0.235</version>
</dependency>
</dependencies>

</project>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6835fc1

Please sign in to comment.