edu.berkeley.guir.ptk.abstraction
Class MotionAbstractor

java.lang.Object
  extended byedu.berkeley.guir.ptk.PTK
      extended byedu.berkeley.guir.ptk.abstraction.Abstractor
          extended byedu.berkeley.guir.ptk.abstraction.MotionAbstractor

public class MotionAbstractor
extends Abstractor

Performs abstraction of PlanarImages from input.CamperInput to determine if there is motion and how much motion has occurred in pixels. In an IMAGE event, replaces the image object (DataObject) with three pieces of data: a boolean MOTION that is true if there is motion; the AMOUNT_OF_MOTION, which can be either MOTION_NONE, MOTION_LO, MOTION_MED, MOTION_HI; and the AMOUNT_OF_MOTION_PIXELS, which is the number of pixels that have changed since the last image (more precisely quantifies how much motion has occured). The first of these data is saved as a DataSwitch, the last two of these data are saved as DataNumber objects.


Field Summary
protected  int amount_of_motion
           
static int B
           
 boolean debug_feedback
          If true, the motion abstractor will show feedback on what it is doing: differenced images taken by the camera will be displayed.
static int G
           
 int motion_lo_pixels
          Set this to customize the number of pixels below which the motion dector will to set the AMOUNT_OF_MOTION to MOTION_LO.
 int motion_med_pixels
          Set this to customize the number of pixels below which the motion dector will to set the AMOUNT_OF_MOTION to MOTION_MED and above which the motion detector will set it to MOTION_HI.
 int motion_none_pixels
          Set this to customize the number of pixels below which the motion dector will to set the AMOUNT_OF_MOTION to MOTION_NONE.
protected static javax.media.jai.PlanarImage prevImage
           
static int R
           
protected static javax.media.jai.widget.ScrollingImagePanel sip
           
protected static javax.swing.JFrame systemDisplayFrame
           
 
Fields inherited from class edu.berkeley.guir.ptk.abstraction.Abstractor
data_ids_I_want, replace_data
 
Fields inherited from class edu.berkeley.guir.ptk.PTK
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG
 
Constructor Summary
MotionAbstractor()
           
 
Method Summary
protected  int addMotionPixels(javax.media.jai.PlanarImage image)
          Count all the non-black pixels in the image.
protected  javax.media.jai.PlanarImage convertToTiled(java.lang.Object dataSample)
          Converts a Java image to a TiledImage, which is more memory efficient and allows random access to image pixels.
 void displayFeedback(javax.media.jai.widget.ScrollingImagePanel i)
           
 boolean doAbstract(Event e, History h)
          Performs the abstraction of the event e as specified by the class that implements this interface.
protected  boolean isCloseToBlack(float[] pix)
           
 boolean isThereMotion(java.lang.Object dataSample)
           
 
Methods inherited from class edu.berkeley.guir.ptk.abstraction.Abstractor
addMetadataIWant, canIAbstract, getAllMetadata, getFirstMetadata
 
Methods inherited from class edu.berkeley.guir.ptk.PTK
getMAX, getMED, getMIN, getNO, printDebug, printDebug, printError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

R

public static final int R
See Also:
Constant Field Values

G

public static final int G
See Also:
Constant Field Values

B

public static final int B
See Also:
Constant Field Values

systemDisplayFrame

protected static final javax.swing.JFrame systemDisplayFrame

sip

protected static javax.media.jai.widget.ScrollingImagePanel sip

prevImage

protected static javax.media.jai.PlanarImage prevImage

amount_of_motion

protected int amount_of_motion

debug_feedback

public boolean debug_feedback
If true, the motion abstractor will show feedback on what it is doing: differenced images taken by the camera will be displayed. This flag should only be true when you are debugging. Set this flag to false when running the application.


motion_none_pixels

public int motion_none_pixels
Set this to customize the number of pixels below which the motion dector will to set the AMOUNT_OF_MOTION to MOTION_NONE.


motion_lo_pixels

public int motion_lo_pixels
Set this to customize the number of pixels below which the motion dector will to set the AMOUNT_OF_MOTION to MOTION_LO.


motion_med_pixels

public int motion_med_pixels
Set this to customize the number of pixels below which the motion dector will to set the AMOUNT_OF_MOTION to MOTION_MED and above which the motion detector will set it to MOTION_HI.

Constructor Detail

MotionAbstractor

public MotionAbstractor()
Method Detail

doAbstract

public boolean doAbstract(Event e,
                          History h)
Description copied from class: Abstractor
Performs the abstraction of the event e as specified by the class that implements this interface. Returns true if the abstraction was successful and false otherwise.

Specified by:
doAbstract in class Abstractor
Parameters:
e -
h -
Returns:
boolean

isThereMotion

public boolean isThereMotion(java.lang.Object dataSample)

addMotionPixels

protected int addMotionPixels(javax.media.jai.PlanarImage image)
Count all the non-black pixels in the image. This is the amount the image has changed, which indicates motion.


isCloseToBlack

protected boolean isCloseToBlack(float[] pix)

convertToTiled

protected javax.media.jai.PlanarImage convertToTiled(java.lang.Object dataSample)
Converts a Java image to a TiledImage, which is more memory efficient and allows random access to image pixels.


displayFeedback

public void displayFeedback(javax.media.jai.widget.ScrollingImagePanel i)