|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectBlobscanner.Detector
public class Detector
The Detector class
Constructor Summary | |
---|---|
Detector(processing.core.PApplet p5,
int sx,
int sy,
int w,
int h,
int threshold)
Detector class constructor. |
Method Summary | |
---|---|
void |
drawBlobContour(int blobnumber,
int contourColor,
float thickness)
Draws the blob contour for the blob specified by blobnumber parameter value. |
void |
drawBox(int boxColor,
float thickness)
Draws the blob bounding box. |
void |
drawContours(int contoursColor,
float thickness)
Draws the edge of each blob. |
void |
drawSelectBox(int minimumWeight,
int boxColor,
float thickness)
Draws the blob's bounding box only for blobs which weight is bigger than or equals to minimumWeight parameter value. |
void |
drawSelectContours(int minimumWeight,
int contoursColor,
float thickness)
Draws the contour only for blobs which weight is bigger than or equals to minimumWeight parameter value. |
void |
findBlobs(int[] pix_array,
int trueWidth,
int trueHeight)
Finds all the blob pixels and saves them into the pixel group buffer MyGroup . |
void |
findCentroids(boolean printLocation,
boolean drawCentroids)
Calculates the blob centroids. |
processing.core.PVector[] |
getA()
Returns an array of PVectors which contains all the left upper corners of the blobs bounding boxes. |
processing.core.PVector[] |
getB()
Returns an array of PVectors which contains all the right upper corners of the blobs bounding boxes. |
int |
getBlobHeight(int blobnumber)
Returns the blob height. |
int |
getBlobNumberAt(int x,
int y)
Returns the blob number at the x y coordinates. |
processing.core.PVector[] |
getBlobPixelsLocation(int blobnumber)
Computes and returns the coordinates of all the pixels in the specified blob. |
int |
getBlobsNumber()
The total number of blobs in the current frame or image. |
int |
getBlobWeight(int blobNum)
Returns the weight of the blob specified. |
int |
getBlobWeightLabel(int label)
Returns the weight of the blob with the specified label. |
int |
getBlobWidth(int blobnumber)
Returns the blob width. |
float |
getBoxCentX(int blobnumber)
Returns the x coordinates of the bounding box center. |
float |
getBoxCentY(int blobnumber)
Returns the y coordinates of the bounding box center. |
processing.core.PVector[] |
getC()
Returns an array of PVectors which contains all the left lower corners of the blobs bounding boxes. |
float |
getCentroidX(int blobnumber)
Returns the blob centroid x coordinate. |
float |
getCentroidY(int blobnumber)
Returns the blob centroid y coordinate. |
processing.core.PVector |
getCrossPoints(int blobnumber,
int pointVector,
boolean draw_them)
Finds the coordinates of the middle point of the blob's bounding box side. |
processing.core.PVector[] |
getD()
Returns an array of PVectors which contains all the right lower corners of the blobs bounding boxes. |
processing.core.PVector[] |
getEdgePoints(int blobnumber)
Computes the coordinates of the edge's pixels for the specified blob. |
int |
getEdgeSize(int blobnumber)
Computes the number of edge pixels for the specified blob. |
int |
getEdgeX(int blobnumber,
int index)
Deprecated. |
processing.core.PVector[] |
getEdgeXY()
Deprecated. |
int |
getEdgeY(int blobnumber,
int index)
Deprecated. |
int |
getGlobalWeight()
Get the total weight for all the blobs in the current frame or image. |
int |
getLabel(int blobnumber)
Returns the label of the blob indicated by the blobnumber parameter. |
int |
getLabel(int x,
int y)
Returns the blob label at x, y screen coordinates. |
void |
imageFindBlobs(processing.core.PImage img)
Like findBlobs(int[],int,int)
but to be used with a PImage object. |
boolean |
isBlob(int x,
int y)
Returns true if at x y location finds a blob pixel. |
boolean |
isEdge(int x,
int y)
Returns true if the pixel at x y coordinates is a blob edge pixel. |
boolean |
isMatch(int x,
int y,
int blobToMatch)
Returns true only if the pixel at the coordinates x y is inside the blob represented by the parameter blobToMatch . |
void |
loadBlobsFeatures()
findBlobs() or imageFindBlobs(PImage)
methods must be called before to call this method. |
void |
weightBlobs(boolean printConsoleIfNoBlobs)
Calculates the total blob weight (mass) for each frame or image. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Detector(processing.core.PApplet p5, int sx, int sy, int w, int h, int threshold)
Detector
class constructor.
p5
- Reference to register with the host PApplet.sx
- The x coordinate of the top left corner of the rectangular area scanned for blobs.sy
- The y coordinate of the top left corner of the rectangular area scanned for blobs.w
- The width of the rectangular area scanned for blobs.h
- The height of the rectangular area scanned for blobs.threshold
- Blobscanner will search for blobs which brightness is equals to this
parameter's value.Method Detail |
---|
public void findBlobs(int[] pix_array, int trueWidth, int trueHeight)
MyGroup
.
pix_array
- The screen buffer to scan for blobs.trueWidth
- The width of the image or video to search for blobs.trueHeight
- The height of the image or video to search for blobs.public void imageFindBlobs(processing.core.PImage img)
findBlobs(int[],int,int)
but to be used with a PImage object.
img
- PImage to scan for blobs.public void weightBlobs(boolean printConsoleIfNoBlobs)
getBlobWeight(int blobNum)
,
getBlobWeightLabel(int label)
,
drawSelectBox(int minimumWeight,int boxColor,float thickness)
,
drawSelectContours(int minimumWeight,int contourColor,float thickness)
and
findCentroids(boolean, boolean)
methods.
findBlobs()
or imageFindBlobs(PImage)
must be called first to call this method.
printConsoleIfNoBlobs
- If true,
the method
prints a message to the console if
zero blobs have been found.public void drawContours(int contoursColor, float thickness)
contoursColor
- The edges color. Here can be passed color( r, g, b)
Processing method.
This parameter is passed to the stroke
Processing method.thickness
- The edges thickness. This parameter is passed
to strokeWeight(int)
Processing method.
findBlobs()
or imageFindBlobs(PImage)
must be called first to call this method.public void drawSelectContours(int minimumWeight, int contoursColor, float thickness)
minimumWeight
parameter value.
findBlobs()
or imageFindBlobs(PImage)
,
weightBlobs(boolean)
and loadBlobsFeatures()
methods must be called
before to call this method.
minimumWeight
- The minimum weight of the blobs for which
the contour is drawncontoursColor
- The pixel edge color. Here it can be passed color( r, g, b)
Processing method.thickness
- The edge thickness. This parameter is passed
to strokeWeight(int)
Processing method.loadBlobsFeatures()
,
weightBlobs(boolean)
public void drawBlobContour(int blobnumber, int contourColor, float thickness)
blobnumber
parameter value.
findBlobs()
or imageFindBlobs(PImage)
and loadBlobsFeatures()
methods must be called
before to call this method.
blobnumber
- The blob which contours are drawncontourColor
- The contour color. Here it can be passed color( r, g, b)
Processing method.thickness
- The contour thickness. This parameter is passed
to strokeWeight
Processing method.loadBlobsFeatures()
public void drawBox(int boxColor, float thickness)
boxColor
- The bounding box color. Here it can be passed color( r, g, b)
Processing function.
This parameter is passed to stroke
Processing method.
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
methods must be called
before to call this method.thickness
- The bounding box thickness. This parameter is passed
to strokeWeight
Processing method.public void drawSelectBox(int minimumWeight, int boxColor, float thickness)
minimumWeight
parameter value.
imageFindBlobs(PImage)
,findBlobs()
or
weightBlobs(boolean)
,
loadBlobsFeatures()
methods must be called
before to call this method.
minimumWeight
- The minimum weight of the blob for which
the bounding box is drawnboxColor
- The bounding box color. Here it can be passed color( r, g, b)
Processing function.thickness
- The edges thickness. This parameter is passed
to strokeWeight
Processing function.loadBlobsFeatures()
,
weightBlobs(boolean)
public boolean isBlob(int x, int y)
findBlobs()
or imageFindBlobs(PImage)
methods must be called before to call this method.
x
- The x location of the pixel to check.y
- The y location of the pixel to check.
public boolean isEdge(int x, int y)
findBlobs()
or imageFindBlobs(PImage)
must be called first to call this method.
x
- The screen x coordinate to check.y
- The screen y coordinate to check.
public boolean isMatch(int x, int y, int blobToMatch)
blobToMatch
.
findBlobs()
or imageFindBlobs(PImage)
must be called first to call this method.
x
- The X coordinate of the pixel to test.y
- The Y coordinate of the pixel to test.blobToMatch
- The blob to match
blobToMatch
.public void loadBlobsFeatures()
findBlobs()
or imageFindBlobs(PImage)
methods must be called before to call this method.
This method must be called before any call to one of the followings methods :
getA, getB, getC, getD, getBlobWidth, getBlobHeight, getBoxCentX, getBoxCentY,
getCentroidX, getCentroidY, getcrossPoints, getEdgeX, getEdgeY, getEdgeXY,
findCentroids.
getA()
,
getB()
,
getC()
,
getD()
,
getBoxCentX(int)
,
getBoxCentY(int)
,
getBlobWidth(int)
,
getBlobHeight(int)
,
findCentroids(boolean, boolean)
,
getCentroidX(int)
,
getCentroidY(int)
,
getEdgeX(int, int)
,
getEdgeY(int, int)
,
#getEdgeXY(int)
,
getCrossPoints(int, int, boolean)
public void findCentroids(boolean printLocation, boolean drawCentroids)
findBlobs()
or imageFindBlobs(PImage)
,
weightBlobs(boolean)
and loadBlobsFeatures()
methods
must be called first to call this method. Also this method must be called
always before callinggetCentroidX(int)<,/code> and
getCentroidY(int)
methods.
- Parameters:
printLocation
- If true prints to the console
the blob's centroid coordinate x y.drawCentroids
- If true draws a point at the centroid
coordinates.- See Also:
getCentroidX(int)
,
getCentroidY(int)
,
weightBlobs(boolean)
,
loadBlobsFeatures()
public float getCentroidX(int blobnumber)
findBlobs()
or imageFindBlobs(PImage)
,
weightBlobs(boolean)
, findCentroids(boolean, boolean)
and loadBlobsFeatures()
methods
must be called before to call this method.
blobnumber
- The blob for which the centroid is returned.
findCentroids(boolean,boolean)
public float getCentroidY(int blobnumber)
findBlobs()
or imageFindBlobs(PImage)
,
weightBlobs(boolean)
, findCentroids(boolean, boolean)
and loadBlobsFeatures()
methods
must be called first to call this method.
blobnumber
- The blob for which the centroid is returned.
findCentroids(boolean,boolean)
public int getBlobWidth(int blobnumber)
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
methods must be called
before to call this method.
blobnumber
-
loadBlobsFeatures()
public int getBlobHeight(int blobnumber)
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
methods must be called
before to call this method.
blobnumber
-
loadBlobsFeatures()
public int getBlobsNumber()
findBlobs()
or imageFindBlobs(PImage)
methods
must be called first to call this method.
public int getGlobalWeight()
findBlobs()
or imageFindBlobs(PImage)
methods
must be called first to call this method.
public int getBlobWeight(int blobNum)
findBlobs()
or imageFindBlobs(PImage)
,
weightBlobs(boolean)
,
methods must be called first to call this method.
blobNum
- The number of the blob for which the weight
is returned. The first blob is numbered with 0.
public int getBlobWeightLabel(int label)
getLabel(int blobnumber)
or
getLabel(int x, int y)
to find the a blob label number to pass to this method.
findBlobs()
or imageFindBlobs(PImage)
,
weightBlobs(boolean)
,
and loadBlobsFeatures()
methods
must be called before to call this method.
label
- The label of the blob for which
the weight is returned.
The labels start from 1, not 0.
label
.weightBlobs(boolean)
,
getLabel(int)
,
getLabel(int, int)
public processing.core.PVector[] getA()
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
methods
must be called first to call this method.
public processing.core.PVector[] getB()
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
methods
must be called first to call this method.
public processing.core.PVector[] getC()
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
methods
must be called first to call this method.
public processing.core.PVector[] getD()
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
methods
must be called first to call this method.
public int getBlobNumberAt(int x, int y)
findBlobs()
or imageFindBlobs(PImage)
must be called first to call this method.
x
- The X coordinate to check for blob presence.y
- The Y coordinate to check for blob presence.
public int getLabel(int x, int y)
x, y
screen coordinates.
If at that location there is no blob
returns 0.
findBlobs()
or imageFindBlobs(PImage)
must be called first to call this method.
x
- The x screen coordinates.y
- The y screen coordinates.
public int getLabel(int blobnumber)
blobnumber
parameter.
blobnumber
can be from 0 to getBlobsNumber()
If there are 5 blobs, blobnumber
= 4 returns
the label of the 5th blob in the image counting from top left.
findBlobs()
or imageFindBlobs(PImage)
must be called first to call this method.
blobnumber
- The blob for which the label is returned.
@Deprecated public int getEdgeX(int blobnumber, int index)
@Deprecated public int getEdgeY(int blobnumber, int index)
@Deprecated public processing.core.PVector[] getEdgeXY()
public processing.core.PVector[] getEdgePoints(int blobnumber)
findBlobs(int[], int, int)
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
must be called first to call this method.
blobnumber
- The blob for which the edge's pixels coordinates are computed
public int getEdgeSize(int blobnumber)
findBlobs(int[], int, int)
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
must be called first to call this method.
blobnumber
- The blob for which the number of edge pixels is computed.
public processing.core.PVector[] getBlobPixelsLocation(int blobnumber)
findBlobs()
or imageFindBlobs(PImage)
,
weightBlobs(boolean)
,
and loadBlobsFeatures()
methods
must be called before to call this method.
blobnumber
- The blob for which the pixels
coordinates are computed.
public float getBoxCentX(int blobnumber)
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
must be called first to call this method.
blobnumber
- The blob number ( starts from 0 ).
loadBlobsFeatures()
public float getBoxCentY(int blobnumber)
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
must be called first to call this method.
blobnumber
- The blob number ( starts from 0 ).
loadBlobsFeatures()
public processing.core.PVector getCrossPoints(int blobnumber, int pointVector, boolean draw_them)
findBlobs()
or imageFindBlobs(PImage)
,
loadBlobsFeatures()
and
weightBlobs(boolean)
methods must be called before
to call this method.
blobnumber
- The blob you need to compute the points for.pointVector
- The point you need extract( 0 | 1 | 2 | 3 ).
The order of the vectors in the array is : 0 = top, 1 = down, 2 = left, 3 = right.draw_them
- If true draws the four points.
loadBlobsFeatures()
,
weightBlobs(boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |