dLife Home Page

dlife.vision.filter
Class Filter

java.lang.Object
  extended by java.util.Observable
      extended by dlife.vision.filter.Filter
Direct Known Subclasses:
AprilTagFilter, BlobFilter, ConvolutionFilter, MatchFilter, RGBtoGrayFilter

public abstract class Filter
extends Observable

Abstract base class for all filters that can be used for image processing. Processing performed by filters includes color matching, blobification, smoothing, etc... A chain of filters can be applied to the raw camera image. Each filter will be able to be turned on or off. A filter that is on will have its filter() method invoked on the camera image. A filter that is not on will not affect the camera image.

This Abstract class provides functionality that is common to all Filters. In particular:

All Filter subclasses must implement:

Filters may also receive notification of click/drag events on either the raw or filtered video windows (or both). In order to do so the Filter subclass must also implement the FilterMouseHandler interface.

Version:
Jul 7, 2008
Author:
Grant Braught, Dickinson College

Constructor Summary
Filter()
          Constructor for a new Filter.
 
Method Summary
protected abstract  FilterGUI createGUIObject()
          Build the GUI for this Filter and return a reference to it.
abstract  BufferedImage filter(BufferedImage frame)
          Filter the image contained in the provided BufferedImage.
abstract  String getCode(String name)
          Get a String containing the Java code that would be necessary to create this Filter in its current state and add it to the specified VisionClient.
 FilterGUI getGUI()
          Get a GUI that allows the user to control the parameters of this Filter.
 int getID()
          Get the ID number of this filter.
 boolean isOn()
          Return true if this Filter is on (i.e.
 void turnOn(boolean on)
          Turn this Filter on or off.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Filter

public Filter()
Constructor for a new Filter. Sets the Filter to be on.

Method Detail

getID

public int getID()
Get the ID number of this filter. Every filter is assigned a unique ID number. This number is typically used in the getCode method to ensure non-conflicting variable names.

Returns:
the ID number assigned to this filter.

isOn

public boolean isOn()
Return true if this Filter is on (i.e. currently being applied to the camera image.

Returns:
true if this filter is on and false if it is not.

turnOn

public void turnOn(boolean on)
Turn this Filter on or off.

Parameters:
on - true to turn this Filter on, false to turn it off.

createGUIObject

protected abstract FilterGUI createGUIObject()
Build the GUI for this Filter and return a reference to it.

Returns:
a reference to the GUI for this Filter.

getGUI

public FilterGUI getGUI()
Get a GUI that allows the user to control the parameters of this Filter. This GUI should also display the filter parameters when they are set programmatically (e.g. by a Controller).

If the GUI for the filter has not yet been created, this method invokes the createGUIObject method to create the GUI and a reference to the GUI is returned. If the GUI has already been created then this method simply returns a reference to the GUI.

Returns:
a reference to the GUI for this Filter.

getCode

public abstract String getCode(String name)
Get a String containing the Java code that would be necessary to create this Filter in its current state and add it to the specified VisionClient. The code generated should use the ID of this filter as part of any variable name to ensure that its variables have a unique identifier.

Parameters:
name - the name of the Camera device to which the generated code should add the Filter.
Returns:
the Java code to create this Filter.

filter

public abstract BufferedImage filter(BufferedImage frame)
Filter the image contained in the provided BufferedImage. The VisionPipeline ensures that this method is invoked for each active Filter in the VisionFilterList If a Filter in the list is not turned on (i.e. not active), its filter() method will not be invoked.

Parameters:
frame - the BufferedImage to be filtered.
Returns:
the image after filtering.

dLife Home Page