edu.berkeley.guir.ptk.abstraction
Class PeopleCountAbstractor

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

public class PeopleCountAbstractor
extends Abstractor

Performs abstraction of PlanarImages from input.CamperInput to determine how many people are in the image. The algorithm used is approximate: it looks for skin-colored blobs (tested mainly with light- and tan-colored skin), determines the size of the blobs (in number of pixels), and counts the blobs that are larger than some threshold as people. This assumes that faces will be the biggest blobs (i.e., that people will not be wearing sleevless shirts or shorts).

In an IMAGE event, adds the number of people counted in the image frame, which is saved as a DataNumber object. Can remove and replace the image data if you set replace_data to true.

This abstractor is much more accurate with high quality digital images. Inexpensive webcams can be used, but the count will be less accurate due to noise in the camera and poor color quality (which is required for recognizing skin colors). To tweak the skin color ranges the abstractor will find, modify valies in the isSkin or isSkinHighQualityImage (the former is used for inexpensive webcams and the latter is for high quality camera images).

The image processing performed in this class require a large amount of memory and processor time. It is preferable that it be run on a machine that is not being used for other processing purposes (e.g., do not run it on the user's machine). Set the input's time between event dispatch to a high number to reduce the amount of processing required for this class.


Nested Class Summary
 class PeopleCountAbstractor.ConnectedComponent
          Inner class for encapsulating connected component information.
 
Field Summary
static int B
           
 boolean debug_feedback
          If true, the people counter abstractor will show feedback on what it is doing: skin blobs counted as people will be colored in the images taken by the camera and displayed.
static int G
           
static int R
           
static int skin_blob_size
          Set this to customize the size of skin blobs (in number of pixels) the abstractor will count as people.
 
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
PeopleCountAbstractor()
           
 
Method Summary
 javax.media.jai.PlanarImage checkSkinColor(javax.media.jai.PlanarImage pi)
          Uses common skin colors to detect skin.
 void displayFeedback(javax.media.jai.PlanarImage pi)
           
 boolean doAbstract(Event e, History h)
          Performs the abstraction of the event e as specified by the class that implements this interface.
 int getNumPeople(javax.media.jai.PlanarImage img)
           
 PeopleCountAbstractor.ConnectedComponent[] labelConnectedComponents(javax.media.jai.PlanarImage marked, int[][] label_matrix)
          Checks each pixel of an image and if it is not black, adds it to some ConnectedComponent.
 
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

debug_feedback

public boolean debug_feedback
If true, the people counter abstractor will show feedback on what it is doing: skin blobs counted as people will be colored in the images taken by the camera and displayed. This flag should only be true when you are debugging. Set this flag to false when running the application.


skin_blob_size

public static final int skin_blob_size
Set this to customize the size of skin blobs (in number of pixels) the abstractor will count as people. This number largely depends on where you place your camera and how many pixels are in an image it takes.

See Also:
Constant Field Values
Constructor Detail

PeopleCountAbstractor

public PeopleCountAbstractor()
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

getNumPeople

public int getNumPeople(javax.media.jai.PlanarImage img)

displayFeedback

public void displayFeedback(javax.media.jai.PlanarImage pi)

checkSkinColor

public javax.media.jai.PlanarImage checkSkinColor(javax.media.jai.PlanarImage pi)
Uses common skin colors to detect skin. Sets all non-skin pixels to black. This method doesn't work very well since it only takes a range of colors into consideration. It think many things are skin, like hair, wood, bright water, etc.


labelConnectedComponents

public PeopleCountAbstractor.ConnectedComponent[] labelConnectedComponents(javax.media.jai.PlanarImage marked,
                                                                           int[][] label_matrix)
Checks each pixel of an image and if it is not black, adds it to some ConnectedComponent. At the end, returns an array of ConnectedComponents with their areas computed.