Slides: https://docs.google.com/presentation/d/15bwDZquwddGGuSol8JGsd22IePLhdX324xOZdU0dEjs/edit?usp=sharing
Program code:
// – Super Fast Blur v1.1 by Mario Klingemann <http://incubator.quasimondo.com>
// – BlobDetection library
// – BlobDetection library
import processing.video.*;
import blobDetection.*;
import blobDetection.*;
Capture cam;
BlobDetection theBlobDetection;
PImage img;
boolean newFrame=false;
BlobDetection theBlobDetection;
PImage img;
boolean newFrame=false;
ArrayList shapes;
ArrayList shape;
ArrayList
// ==================================================
// setup()
// ==================================================
void setup()
{
// Size of applet
size(640, 480, P2D);
// Capture
cam = new Capture(this, 640/2, 480/2);
// Comment the following line if you use Processing 1.5
cam.start();
// setup()
// ==================================================
void setup()
{
// Size of applet
size(640, 480, P2D);
// Capture
cam = new Capture(this, 640/2, 480/2);
// Comment the following line if you use Processing 1.5
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);
theBlobDetection.setThreshold(0.3f); // will detect bright areas whose luminosity > 0.2f;
// 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);
theBlobDetection.setThreshold(0.3f); // will detect bright areas whose luminosity > 0.2f;
shapes = new ArrayList();
}
}
// ==================================================
// captureEvent()
// ==================================================
void captureEvent(Capture cam)
{
cam.read();
newFrame = true;
}
// 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);
//fastblur(img, 2);
theBlobDetection.computeBlobs(img.pixels);
drawShapes();
}
if(shapes.size()>=5hapes.remove(0);
if(shapes.size()>=200
for (int i = 0; i<=5; i++) shapes.remove(i);
}
}
// 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);
//fastblur(img, 2);
theBlobDetection.computeBlobs(img.pixels);
drawShapes();
}
if(shapes.size()>=5hapes.remove(0);
if(shapes.size()>=200
for (int i = 0; i<=5; i++) shapes.remove(i);
}
}
// ==================================================
// drawBlobsAndEdges()
// ==================================================
void drawShapes()
{
Blob b;
EdgeVertex eA,eB;
PShape s;
for (int n=0 ; n{
s = createShape();
s.beginShape();
s.fill(255,0,0);
s.noStroke();
b=theBlobDetection.getBlob(n);
if (b!=null)
{
for (int m=0;m{
eA = b.getEdgeVertexA(m);
if (eA != null)
s.vertex(eA.x*width, eA.y*height);
}
}
s.endShape(CLOSE);
shapes.add(s);
}
for (int o=0; o<shapes.size(); o++){
PShape shape = shapes.get(o);
shape(shape, 0, 0);
}
print(shapes.size(), ” “);
}
// drawBlobsAndEdges()
// ==================================================
void drawShapes()
{
Blob b;
EdgeVertex eA,eB;
PShape s;
for (int n=0 ; n
s = createShape();
s.beginShape();
s.fill(255,0,0);
s.noStroke();
b=theBlobDetection.getBlob(n);
if (b!=null)
{
for (int m=0;m{
eA = b.getEdgeVertexA(m);
if (eA != null)
s.vertex(eA.x*width, eA.y*height);
}
}
s.endShape(CLOSE);
shapes.add(s);
}
for (int o=0; o<shapes.size(); o++){
PShape shape = shapes.get(o);
shape(shape, 0, 0);
}
print(shapes.size(), ” “);
}
No comments:
Post a Comment