s373.flob
Class Flob

java.lang.Object
  extended by s373.flob.Flob

public class Flob
extends java.lang.Object

flob is a flood-fill multi-blob detector,
tracks blobs in image streams,their centroids and bounding boxes

Author:
andre sier
url: http://s373.net/code/flob
version 0.0.1m


Field Summary
 int[] backgroundPixels
           
 int blobpixmax
           
 int blobpixmin
           
static int BLUE
           
 java.lang.String bluestr
           
 int blur
           
 int colormode
           
static int CONTINUOUS_DIFFERENCE
           
 boolean coordsmode
           
static int GREEN
           
 java.lang.String greenstr
           
 ImageBlobs imageblobs
           
static int LUMA601
           
 java.lang.String luma601str
           
static int LUMA709
           
 java.lang.String luma709str
           
static int LUMAUSER
           
 float[] lumausercoefs
           
 java.lang.String lumausrstr
           
 boolean mirrorX
           
 boolean mirrorY
           
 int numPixels
           
 int om
           
 int presence
           
 int pvideotexmode
           
static int RED
           
 java.lang.String redstr
           
static int STATIC_DIFFERENCE
           
 boolean[] trackfeatures
           
 java.lang.String VERSION
           
 int videofade
           
 processing.core.PImage videoimg
           
 int videoresh
           
 int videoresw
           
 processing.core.PImage videotex
           
 processing.core.PImage videotexbin
           
 boolean videotexchange
           
 processing.core.PImage videoteximgmotion
           
 int videotexmode
           
 processing.core.PImage videotexmotion
           
 int videothresh
           
 int worldheight
           
 int worldwidth
           
 
Constructor Summary
Flob(processing.core.PApplet theParent)
           
Flob(processing.core.PApplet theParent, processing.core.PImage video)
          calling the constructor with a PApplet, PImage parameters inits the image vars
Flob(processing.core.PApplet theParent, processing.core.PImage video, int w, int h)
          calling the constructor with a PApplet, PImage, yourWidth, yourHeight parameters inits the image vars yourWidth will be default coords return on flob for each blob's x pos, the same for height
 
Method Summary
 processing.core.PImage binarize(processing.core.PImage video)
          first pass of the flob engine.
revised in version 001l to allow different color channel tracking.
transforms the input image in a black and white only image (binary image).
optionally insert a fastblur in the image.
 java.util.ArrayList<ABlob> calc(processing.core.PImage img)
          calcs with current PImage.
 java.util.ArrayList<trackedBlob> calcsimple(processing.core.PImage img)
          calcsimple is naive tracking.
 processing.core.PImage fastblur(processing.core.PImage img, int radius)
          PImage img = fastblur(PImage img, int radius); Super Fast Blur v1.1 by Mario Klingemann http://incubator.quasimondo.com
 ABlob getABlob(int i)
          getABlob returns the nth calc'ed blob of the tracker
returns one ABlob element

 boolean getAnyFeatureActive()
          getAnyFeatureActive true if any feature points on
 int[] getBackground()
          gets the background image
 int getBlur()
          get the blur amount on the image.
 int[] getBox(int i)
          getBox int i.
 float[] getCentroid(int i)
          getCentroid int i.
 float[] getCentroidPixelcount(int i)
          getCentroidPixelcount int i.
 float[] getCentroids()
          getCentroids.
 java.lang.String getColorMode()
          get selected colormode
 boolean getCoordsMode()
          get the coords mode for the blobs returns.
 float[] getDim(int i)
          getDim int i.
 int getFade(int t)
          get the fade value to continuos_difference mode
 processing.core.PImage getImage()
          getImage gets the current video image worked inside flob
 float[] getLumaUserCoefs()
          get lumausercoefs
 int getMaxNumPixels()
          get max numpixels to be considered a blob
 int getMinNumPixels()
          get min numpixels to be considered a blob
 boolean[] getMirror()
          get mirror in XY axis
 int getNumBlobs()
          getNumBlobs.
 int getNumTrackedBlobs()
           
 int getNumTrackedSimpleBlobs()
           
 int getOm()
          get the om either CONTINUOUS_DIFFERENCE (1) or STATIC_DIFFERENCE (0)
 int getPresence()
          getPresence.
 float getPresencef()
          getPresencef.
 ABlob getPreviousABlob(int i)
          getPreviousABlob returns the nth calc'ed previous blob of the tracker
returns one ABlob element

 float[] getPreviousCentroids()
           
 float[] getPreviousCurrentCentroid(int i)
          getPreviousCurrentCentroid int i.
 float[] getPreviousCurrentCentroidMass(int i)
          getPreviousCurrentCentroidMass int i.
 trackedBlob getPreviousTrackedBlob(int i)
          getPreviousTrackedBlob returns the nth tracked previous blob of the tracker
returns one trackedBlob element

 float getSmooth()
          get smooth of blob speeds
 processing.core.PImage getSrcImage()
          returns the updated videotex (in case it needs updating)
 int getThresh()
          get the threshold value to the image binarization
 trackedBlob getTrackedBlob(int i)
          getTrackedBlob returns the nth tracked blob of the tracker
returns the arraylist of trackedBlob elements

a tracked blob holds:

// pos & vel & dim results are local world coords

// int tb.id;
// float tb.cx;
// float tb.cy;
// float tb.velx;
// float tb.vely;
// float tb.prevelx;
// float tb.prevely;
// int tb.presencetime;
// float tb.dimx;
// float tb.dimy;
// int tb.birthtime;
 float[] getTrackedBlobf(int i)
          getTrackedBlobf returns the data of the nth tracked blob of the tracker as float[] returns the arraylist of trackedBlob elements
 float[] getTrackedSimpleBlob(int i)
           
 boolean[] getTrackFeatures()
          getTrackFeatures gets the boolean array with on/off's for searching feature points: armleft, armright, head, bottom for each blob
 float getTrackingMinDist()
          get tracking min dist to be the same blob
 void mirrorX(boolean m)
          mirror video data along X axis
 void mirrorY(boolean m)
          mirror video data along Y axis
 void setBackground(processing.core.PImage video)
          sets the background to compare to to this PImage
 void setBlur(int blur)
          set the blur amount on the image.
 void setColorMode(int t)
          set the colormode for the binarization stage.
 void setCoordsMode(boolean t)
          set the coords mode for the blobs returns.
 void setFade(int t)
          set the fade value to continuos_difference mode
 void setImage(int t)
          setImage sets the videotex returned by flob.videotex or flob.getSrcImage
 void setLumaUserCoefs(float[] data)
          set lumausercoefs
 void setMaxNumPixels(int t)
          set max numpixels to be considered a blob
 void setMinNumPixels(int t)
          set min numpixels to be considered a blob
 void setMirror(boolean m0, boolean m1)
          set mirror in XY axis with two booleans
 void setOm(int t)
          set the om either CONTINUOUS_DIFFERENCE (1) or STATIC_DIFFERENCE (0)
 void setSmooth(float s)
          set smooth of blob speeds
 void setSrcImage(int t)
          setSrcImage sets the videotex returned by flob.videotex or flob.getSrcImage
 void setThresh(int t)
          set the threshold value to the image binarization
 void setTrackFeatures(boolean[] tf)
          setTrackFeatures turns on/off searching for feature points: armleft, armright, head, bottom for each blob
 void setTrackingMinDist(float s)
          set tracking min dist to be the same blob
 void setTresh(int t)
          set the threshold value to the image binarization.
 void setVideoTex(int t)
          set the videotex returned by flob.videotex
case 0: videotex = videoimg; break;
case 1: videotex = videotexbin; break;
case 2: videotex = videotexmotion; break;
case 3: videotex = videoteximgmotion; break;
 boolean testPos(float x, float y)
          testPos float x, float y.
 boolean testPos(int x, int y)
          testPos int x, int y.
 java.util.ArrayList<trackedBlob> track(processing.core.PImage img)
          calcs with current PImage.
 java.util.ArrayList<trackedBlob> tracksimple(processing.core.PImage img)
          tracksimple is good tracking code, maintains id's, speed's, presencetime for each trackedBlob returns the arraylist of trackedBlob elements
 processing.core.PImage updateVideoTex()
           
 java.lang.String version()
          return the version of the library.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imageblobs

public ImageBlobs imageblobs

videoimg

public processing.core.PImage videoimg

videotex

public processing.core.PImage videotex

videotexmotion

public processing.core.PImage videotexmotion

videotexbin

public processing.core.PImage videotexbin

videoteximgmotion

public processing.core.PImage videoteximgmotion

backgroundPixels

public int[] backgroundPixels

numPixels

public int numPixels

videoresw

public int videoresw

videoresh

public int videoresh

presence

public int presence

videotexmode

public int videotexmode

pvideotexmode

public int pvideotexmode

videotexchange

public boolean videotexchange

videothresh

public int videothresh

videofade

public int videofade

mirrorX

public boolean mirrorX

mirrorY

public boolean mirrorY

worldwidth

public int worldwidth

worldheight

public int worldheight

coordsmode

public boolean coordsmode

blur

public int blur

trackfeatures

public boolean[] trackfeatures

om

public int om

STATIC_DIFFERENCE

public static final int STATIC_DIFFERENCE
See Also:
Constant Field Values

CONTINUOUS_DIFFERENCE

public static final int CONTINUOUS_DIFFERENCE
See Also:
Constant Field Values

colormode

public int colormode

RED

public static final int RED
See Also:
Constant Field Values

GREEN

public static final int GREEN
See Also:
Constant Field Values

BLUE

public static final int BLUE
See Also:
Constant Field Values

LUMA601

public static final int LUMA601
See Also:
Constant Field Values

LUMA709

public static final int LUMA709
See Also:
Constant Field Values

LUMAUSER

public static final int LUMAUSER
See Also:
Constant Field Values

lumausercoefs

public float[] lumausercoefs

blobpixmin

public int blobpixmin

blobpixmax

public int blobpixmax

redstr

public java.lang.String redstr

greenstr

public java.lang.String greenstr

bluestr

public java.lang.String bluestr

luma601str

public java.lang.String luma601str

luma709str

public java.lang.String luma709str

lumausrstr

public java.lang.String lumausrstr

VERSION

public java.lang.String VERSION
Constructor Detail

Flob

public Flob(processing.core.PApplet theParent)

Flob

public Flob(processing.core.PApplet theParent,
            processing.core.PImage video)
calling the constructor with a PApplet, PImage parameters inits the image vars

Parameters:
PApplet, - PImage

Flob

public Flob(processing.core.PApplet theParent,
            processing.core.PImage video,
            int w,
            int h)
calling the constructor with a PApplet, PImage, yourWidth, yourHeight parameters inits the image vars yourWidth will be default coords return on flob for each blob's x pos, the same for height

Parameters:
PApplet, - PImage
Method Detail

binarize

public processing.core.PImage binarize(processing.core.PImage video)
first pass of the flob engine.
revised in version 001l to allow different color channel tracking.
transforms the input image in a black and white only image (binary image).
optionally insert a fastblur in the image. (if setBlur > 0, blur has that radius)
// nice fastblur insertion, thanks to fausto fonseca for showing the code,
// and to eduardo pinto for pissing me about it. it's fast and great!
// fast blur code by Mario Klingemann
returns a binary image suitable for the calc engine.

built in fastblur filter if blurRadius > 0.

Returns:
PImage

getSrcImage

public processing.core.PImage getSrcImage()
returns the updated videotex (in case it needs updating)

Returns:
PImage

updateVideoTex

public processing.core.PImage updateVideoTex()

setVideoTex

public void setVideoTex(int t)
set the videotex returned by flob.videotex
case 0: videotex = videoimg; break;
case 1: videotex = videotexbin; break;
case 2: videotex = videotexmotion; break;
case 3: videotex = videoteximgmotion; break;


setImage

public void setImage(int t)
setImage sets the videotex returned by flob.videotex or flob.getSrcImage


getImage

public processing.core.PImage getImage()
getImage gets the current video image worked inside flob

Returns:
void

setSrcImage

public void setSrcImage(int t)
setSrcImage sets the videotex returned by flob.videotex or flob.getSrcImage


setTrackFeatures

public void setTrackFeatures(boolean[] tf)
setTrackFeatures turns on/off searching for feature points: armleft, armright, head, bottom for each blob


getTrackFeatures

public boolean[] getTrackFeatures()
getTrackFeatures gets the boolean array with on/off's for searching feature points: armleft, armright, head, bottom for each blob

Returns:
boolean[]

getAnyFeatureActive

public boolean getAnyFeatureActive()
getAnyFeatureActive true if any feature points on

Returns:
boolean

setOm

public void setOm(int t)
set the om either CONTINUOUS_DIFFERENCE (1) or STATIC_DIFFERENCE (0)


getOm

public int getOm()
get the om either CONTINUOUS_DIFFERENCE (1) or STATIC_DIFFERENCE (0)

Returns:
int

setCoordsMode

public void setCoordsMode(boolean t)
set the coords mode for the blobs returns. if true, will scale to global world coordinates, if false, each blob returns normalized coordinates


getCoordsMode

public boolean getCoordsMode()
get the coords mode for the blobs returns. if true, will scale to global world coordinates, if false, each blob returns normalized coordinates

Returns:
boolean

setColorMode

public void setColorMode(int t)
set the colormode for the binarization stage. how to consider a diff pix from background on which channel. red, green, blue, luma


getColorMode

public java.lang.String getColorMode()
get selected colormode

Returns:
int

setLumaUserCoefs

public void setLumaUserCoefs(float[] data)
set lumausercoefs


getLumaUserCoefs

public float[] getLumaUserCoefs()
get lumausercoefs

Returns:
float[]

setBackground

public void setBackground(processing.core.PImage video)
sets the background to compare to to this PImage


getBackground

public int[] getBackground()
gets the background image

Returns:
int[]

setTresh

public void setTresh(int t)
set the threshold value to the image binarization. missing h for backwards compatibility


setThresh

public void setThresh(int t)
set the threshold value to the image binarization


getThresh

public int getThresh()
get the threshold value to the image binarization

Returns:
int

setFade

public void setFade(int t)
set the fade value to continuos_difference mode


getFade

public int getFade(int t)
get the fade value to continuos_difference mode

Returns:
int

mirrorX

public void mirrorX(boolean m)
mirror video data along X axis


mirrorY

public void mirrorY(boolean m)
mirror video data along Y axis


setMirror

public void setMirror(boolean m0,
                      boolean m1)
set mirror in XY axis with two booleans


getMirror

public boolean[] getMirror()
get mirror in XY axis

Returns:
boolean[]

setMinNumPixels

public void setMinNumPixels(int t)
set min numpixels to be considered a blob


setMaxNumPixels

public void setMaxNumPixels(int t)
set max numpixels to be considered a blob


getMinNumPixels

public int getMinNumPixels()
get min numpixels to be considered a blob

Returns:
int

getMaxNumPixels

public int getMaxNumPixels()
get max numpixels to be considered a blob

Returns:
int

setTrackingMinDist

public void setTrackingMinDist(float s)
set tracking min dist to be the same blob


getTrackingMinDist

public float getTrackingMinDist()
get tracking min dist to be the same blob

Returns:
float

setSmooth

public void setSmooth(float s)
set smooth of blob speeds


getSmooth

public float getSmooth()
get smooth of blob speeds

Returns:
float

setBlur

public void setBlur(int blur)
set the blur amount on the image. 0 = off, > 5 high blur


getBlur

public int getBlur()
get the blur amount on the image. 0 = off, > 5 high blur

Returns:
int

calc

public java.util.ArrayList<ABlob> calc(processing.core.PImage img)
calcs with current PImage. PImage must be binary image by this stage. returns the arraylist of the blobs

Returns:
ArrayList

track

public java.util.ArrayList<trackedBlob> track(processing.core.PImage img)
calcs with current PImage. PImage must be binary image by this stage. returns the arraylist of trackedBlob elements

Returns:
ArrayList

tracksimple

public java.util.ArrayList<trackedBlob> tracksimple(processing.core.PImage img)
tracksimple is good tracking code, maintains id's, speed's, presencetime for each trackedBlob returns the arraylist of trackedBlob elements

Returns:
ArrayList

calcsimple

public java.util.ArrayList<trackedBlob> calcsimple(processing.core.PImage img)
calcsimple is naive tracking. works good in stable configs. returns the arraylist of trackedBlob elements

Returns:
ArrayList

getTrackedBlob

public trackedBlob getTrackedBlob(int i)
getTrackedBlob returns the nth tracked blob of the tracker
returns the arraylist of trackedBlob elements

a tracked blob holds:

// pos & vel & dim results are local world coords

// int tb.id;
// float tb.cx;
// float tb.cy;
// float tb.velx;
// float tb.vely;
// float tb.prevelx;
// float tb.prevely;
// int tb.presencetime;
// float tb.dimx;
// float tb.dimy;
// int tb.birthtime;

Returns:
trackedBlob

getPreviousTrackedBlob

public trackedBlob getPreviousTrackedBlob(int i)
getPreviousTrackedBlob returns the nth tracked previous blob of the tracker
returns one trackedBlob element


getABlob

public ABlob getABlob(int i)
getABlob returns the nth calc'ed blob of the tracker
returns one ABlob element

Returns:
ABlob

getPreviousABlob

public ABlob getPreviousABlob(int i)
getPreviousABlob returns the nth calc'ed previous blob of the tracker
returns one ABlob element

Returns:
ABlob

getTrackedSimpleBlob

public float[] getTrackedSimpleBlob(int i)

getNumBlobs

public int getNumBlobs()
getNumBlobs. should be called after calc.

Returns:
int

getNumTrackedBlobs

public int getNumTrackedBlobs()

getNumTrackedSimpleBlobs

public int getNumTrackedSimpleBlobs()

getTrackedBlobf

public float[] getTrackedBlobf(int i)
getTrackedBlobf returns the data of the nth tracked blob of the tracker as float[] returns the arraylist of trackedBlob elements

Returns:
float[12]

getPresence

public int getPresence()
getPresence. returns the number of active pixels

Returns:
int

getPresencef

public float getPresencef()
getPresencef. returns the normalized number of active pixels

Returns:
float

getCentroids

public float[] getCentroids()
getCentroids. returns all coordinates as normalized floats

Returns:
float[]

getPreviousCentroids

public float[] getPreviousCentroids()

getCentroid

public float[] getCentroid(int i)
getCentroid int i. returns coordinates of this centroid as float[2]

Returns:
float[]

getCentroidPixelcount

public float[] getCentroidPixelcount(int i)
getCentroidPixelcount int i. returns coordinates of this centroid + pixelcount as float[3]

Returns:
float[]

getPreviousCurrentCentroid

public float[] getPreviousCurrentCentroid(int i)
getPreviousCurrentCentroid int i. returns previous and current coordinates of this centroid as normalized float[4]

Returns:
float[]

getPreviousCurrentCentroidMass

public float[] getPreviousCurrentCentroidMass(int i)
getPreviousCurrentCentroidMass int i. returns previous and current coordinates of this centroid as normalized float[4]

Returns:
float[]

getDim

public float[] getDim(int i)
getDim int i. returns dimensions of the bounding box of this centroid as normalized float[2]

Returns:
float[]

getBox

public int[] getBox(int i)
getBox int i. returns coordinates of this centroid's box as int[4] box min x + box min y + box max x + box max y

Returns:
int[]

testPos

public boolean testPos(int x,
                       int y)
testPos int x, int y. tests a point coords x + y in the image map returns true if on a blob, false if not on a blob x and y should be constrained to src video dimensions

Returns:
boolean

testPos

public boolean testPos(float x,
                       float y)
testPos float x, float y. tests a point normalized coords x + y in the image map returns true if on a blob, false if not on a blob

Returns:
boolean

fastblur

public processing.core.PImage fastblur(processing.core.PImage img,
                                       int radius)
PImage img = fastblur(PImage img, int radius); Super Fast Blur v1.1 by Mario Klingemann http://incubator.quasimondo.com

Returns:
PImage

version

public java.lang.String version()
return the version of the library.

Returns:
String


processing library flob by AndrŽ Sier. (c) 2008/2009