Hi to whoever is reading this!
I am trying to create an overlay over a webcam feed. I am using the webcam to capture the darkest points in its vision, where it will draw a circle. However, in the end result I don’t want to see the actual webcam live feed. Just a white background, and the circles that are being drawn. Just setting the background to 255 in the setup doesn’t work. So I tried to use a mask with a white background image. But that doesn’t work as well. Obviously I don’t want to put anything in the draw function, because then I would lose the drawed circles. I feel like I am missing a clear solution here! I hope anyone can help me with this.
My code:
import processing.video.*;
import gab.opencv.*;
Capture cam;
OpenCV opencv;
PVector prevLoc;
PImage maskImage;
void setup() {
size(1920, 1080);
background(255); // so this doesn't work lol
maskImage = loadImage("background.png"); //doesn't work as well
noStroke();
opencv = new OpenCV(this, 1920, 1080);
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
cam = new Capture(this, 1920, 1080, cameras[1]);
cam.start();
cam.mask(maskImage); //I put the other line of the mask here, after I called the cam
prevLoc = new PVector(0, width/2);
frameRate(24);
}
}
void captureEvent(Capture cam) {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0);
}
void draw() {
opencv.loadImage(cam);
PVector loc = opencv.min();
ellipse(loc.x, loc.y, 50, 50);
fill(random(255), random(255), random(255));
prevLoc = loc;
}
void keyPressed() {
if (key == ' ') {
background(255);
}
}