Hey guys.
Im doing an installation involving 5 robotic arms. I want the arms to point towards audience members in the room, and to do this im planning to use blob detection, from a web cam pointing down from the ceiling.
I've messed with a blob detection library example to make to make it ignore the middle section of the image, so the movement of the arms in the centre of the room wont trigger any blobs.
In the program that controls the arms they currently follow the mouse, I now basically want to switch this so they instead select one of the blobs and follow it for a certain amount of time, before switching to another blob (i.e. another audience member).
I wont post the arm control program because its huge, but can someone show me how to access the location variables of an individual blob in the blob detection patch?
cheers.
import processing.video.*;
import blobDetection.*;
Capture cam;
BlobDetection theBlobDetection;
PImage img;
boolean newFrame = false;
// ==================================================
// setup()
// ==================================================
void setup()
{
// Size of applet
size(640, 480);
// Capture
cam = new Capture(this, 40*4, 30*4, 30);
//cam.start();
// BlobDetection
// img which will be sent to detection (a smaller copy of the cam frame);
img = new PImage(80, 60);
theBlobDetection = new BlobDetection(img.width, img.height);
theBlobDetection.setPosDiscrimination(true); //this decides whether to blob light or dark areas
theBlobDetection.setThreshold(0.2f); // will detect bright areas whose luminosity > 0.2f;
}
// ==================================================
// captureEvent()
// ==================================================
void captureEvent(Capture cam)
{
cam.read();
newFrame = true;
}
// ==================================================
// draw()
// ==================================================
void draw()
{
if (newFrame)
{
newFrame = false;
image( cam, 0, 0, width, height );
img.copy( cam, 0, 0, cam.width, cam.height,
0, 0, img.width, img.height );
theBlobDetection.computeBlobs( img.pixels );
drawBlobsAndEdges( true, true );
}
}
// ==================================================
// drawBlobsAndEdges()
// ==================================================
void drawBlobsAndEdges( boolean drawBlobs, boolean drawEdges )
{
noFill();
Blob b;
EdgeVertex eA, eB;
for ( int n = 0 ; n<theBlobDetection.getBlobNb() ; n++ )
{
b=theBlobDetection.getBlob( n );
if ( b != null ) {
if (( b.xMin*width<160 ) || ( b.xMin*width>490 ) || ( b.yMin*height<160 ) || ( b.yMin*height>320 )) {
float audienceX = b.xMin * width;
float audienceY = b.yMin * height;
rect( audienceX, audienceY, b.w*width, b.h*height );
}
}
}
}
1