Hi there,
I’m trying to write code that will form a cluster of ellipses in the shape of a person as they approach the screen. I’m okay with the part of motion detection, but I can’t work out how to make the clusters appear and follow the movement. I can only make the ellipses one-by-one in a fixed position on the movement. Any help would be really appreciated
This is the code so far:
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
PImage img1;
int val = 10;
Capture video;
OpenCV opencv;
void setup() {
size(640, 480);
background(0);
video = new Capture(this, 640/2, 480/2);
opencv = new OpenCV(this, 640/2, 480/2);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
img1 = loadImage("Stephen.png");
video.start();
}
void draw() {
scale(2);
opencv.loadImage(video);
image(video, 0, 0 );
fill(255);
stroke(0, 0, 0);
strokeWeight(1);
Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i < faces.length; i++) {
println(faces[i].x + "," + faces[i].y);
ellipse(faces[i].x+5, faces[i].y+0, 5, 5);
ellipse(faces[i].x+10, faces[i].y+0, 5, 5);
ellipse(faces[i].x+15, faces[i].y+0, 5, 5);
ellipse(faces[i].x+33, faces[i].y+0, 5, 5);
//the cluster would go here
}
}
void captureEvent(Capture c) {
c.read();
}