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:
AndrŽ Sier
url: http://s373.net/code/flob
version 0.0.1s


Field Summary
 int[] backgroundPixels
           
 int blobpixmax
           
 int blobpixmin
           
static int BLUE
           
static java.lang.String bluestr
           
 int blur
           
 int colormode
           
static int CONTINUOUS_DIFFERENCE
           
 float continuous_ease
           
static int CONTINUOUS_EASE_DIFFERENCE
           
 boolean coordsmode
           
static int GREEN
           
static java.lang.String greenstr
           
 ImageBlobs imageblobs
           
static int LUMA601
           
static java.lang.String luma601str
           
static int LUMA709
           
static java.lang.String luma709str
           
static int LUMAUSER
           
 float[] lumausercoefs
           
static java.lang.String lumausrstr
           
 boolean mirrorX
           
 boolean mirrorY
           
 int numPixels
           
 int om
           
 int presence
           
 int pvideotexmode
           
static int RED
           
static java.lang.String redstr
           
static int STATIC_DIFFERENCE
           
static int trackedBlobLifeTime
           
 boolean[] trackfeatures
           
static 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(int srcW, int srcH, int dstW, int dstH)
          calling the constructor with a PApplet, srcWidth, srcHeight, dstWidth, dstHeight parameters inits the image vars yourWidth will be default coords return on flob for each blob's x pos, the same for height
Flob(processing.core.PApplet theParent)
           
Flob(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
Flob(processing.core.PImage video, processing.core.PApplet theParent)
          calling the constructor with a PApplet, PImage parameters inits the image vars
 
Method Summary
 processing.core.PImage binarize(int[] pix)
           
 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<quadBlob> calcQuad(processing.core.PImage img)
          calcs with current PImage.
 java.util.ArrayList<trackedBlob> calcsimple(processing.core.PImage img)
          calcsimple is naive tracking.
 Flob easeBackground(processing.core.PImage video)
          ease the background to compare to to this PImage
 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()
          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 getNumQuadBlobs()
           
 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

 quadBlob getQuadBlob(int i)
           
 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
 int gettrackedBlobLifeTime()
          get the max lifetime for a trackedblob
 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
 Flob mirrorX(boolean m)
          mirror video data along X axis
 Flob mirrorY(boolean m)
          mirror video data along Y axis
 Flob setBackground(processing.core.PImage video)
          sets the background to compare to to this PImage
 Flob setBlur(int blur)
          set the blur amount on the image.
 Flob setColorMode(int t)
          set the colormode for the binarization stage.
 Flob setCoordsMode(boolean t)
          set the coords mode for the blobs returns.
 Flob setFade(int t)
          set the fade value to continuos_difference mode
 Flob setImage(int t)
          setImage sets the videotex returned by flob.videotex or flob.getSrcImage
 Flob setLumaUserCoefs(float[] data)
          set lumausercoefs
 Flob setMaxNumPixels(int t)
          set max numpixels to be considered a blob
 Flob setMinNumPixels(int t)
          set min numpixels to be considered a blob
 Flob setMirror(boolean m0, boolean m1)
          set mirror in XY axis with two booleans
 Flob setOm(int t)
          set the om either CONTINUOUS_DIFFERENCE (1) or STATIC_DIFFERENCE (0)
 Flob setSmooth(float s)
          set smooth of blob speeds
 Flob setSrcImage(int t)
          setSrcImage sets the videotex returned by flob.videotex or flob.getSrcImage
 Flob setThresh(int t)
          set the threshold value to the image binarization
 Flob settrackedBlobLifeTime(int t)
          set the max lifetime for a trackedblob
 Flob setTrackFeatures(boolean[] tf)
          setTrackFeatures turns on/off searching for feature points: armleft, armright, head, bottom for each blob
 Flob setTrackingMinDist(float s)
          set tracking min dist to be the same blob
 Flob setTresh(int t)
          set the threshold value to the image binarization.
 Flob 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

CONTINUOUS_EASE_DIFFERENCE

public static final int CONTINUOUS_EASE_DIFFERENCE
See Also:
Constant Field Values

continuous_ease

public float continuous_ease

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 static java.lang.String redstr

greenstr

public static java.lang.String greenstr

bluestr

public static java.lang.String bluestr

luma601str

public static java.lang.String luma601str

luma709str

public static java.lang.String luma709str

lumausrstr

public static java.lang.String lumausrstr

trackedBlobLifeTime

public static int trackedBlobLifeTime

VERSION

public static java.lang.String VERSION
Constructor Detail

Flob

public Flob(processing.core.PApplet theParent)

Flob

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

Parameters:
PApplet - , PImage

Flob

public Flob(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:
PImage - , width, height

Flob

public Flob(int srcW,
            int srcH,
            int dstW,
            int dstH)
calling the constructor with a PApplet, srcWidth, srcHeight, dstWidth, dstHeight parameters inits the image vars yourWidth will be default coords return on flob for each blob's x pos, the same for height

Parameters:
srcWidth - , srcHeight, dstWidth, dstHeight
Method Detail

binarize

public processing.core.PImage binarize(int[] pix)

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 Flob 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;

Returns:
void

setImage

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

Returns:
void

getImage

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

Returns:
void

setSrcImage

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

Returns:
void

setTrackFeatures

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

Returns:
void

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 Flob setOm(int t)
set the om either CONTINUOUS_DIFFERENCE (1) or STATIC_DIFFERENCE (0)

Returns:
this

getOm

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

Returns:
int

settrackedBlobLifeTime

public Flob settrackedBlobLifeTime(int t)
set the max lifetime for a trackedblob

Returns:
void

gettrackedBlobLifeTime

public int gettrackedBlobLifeTime()
get the max lifetime for a trackedblob

Returns:
int

setCoordsMode

public Flob 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

Returns:
this

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 Flob 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

Returns:
this

getColorMode

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

Returns:
int

setLumaUserCoefs

public Flob setLumaUserCoefs(float[] data)
set lumausercoefs

Returns:
this

getLumaUserCoefs

public float[] getLumaUserCoefs()
get lumausercoefs

Returns:
float[]

setBackground

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

Returns:
this

easeBackground

public Flob easeBackground(processing.core.PImage video)
ease the background to compare to to this PImage

Returns:
this

getBackground

public int[] getBackground()
gets the background image

Returns:
int[]

setTresh

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

Returns:
this

setThresh

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

Returns:
this

getThresh

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

Returns:
int

setFade

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

Returns:
this

getFade

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

Returns:
int

mirrorX

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

Returns:
this

mirrorY

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

Returns:
this

setMirror

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

Returns:
this

getMirror

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

Returns:
boolean[]

setMinNumPixels

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

Returns:
this

setMaxNumPixels

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

Returns:
this

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 Flob setTrackingMinDist(float s)
set tracking min dist to be the same blob

Returns:
this

getTrackingMinDist

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

Returns:
float

setSmooth

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

Returns:
this

getSmooth

public float getSmooth()
get smooth of blob speeds

Returns:
float

setBlur

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

Returns:
void

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

calcQuad

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

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

getQuadBlob

public quadBlob getQuadBlob(int i)

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

getNumQuadBlobs

public int getNumQuadBlobs()

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