We are about to switch to a new forum software. Until then we have removed the registration on this forum.
im using an example of FaceDetection in openCV library. i want to retain the face image within green rectangle and change the rest background to white. ideally, fill another picture into background.
but what is wrong with my code? it didnt change the background when i run it. who can help me?
import gab.opencv.*;
import java.awt.Rectangle;
OpenCV opencv;
Rectangle[] faces;
Rectangle[] blank;
void setup() {
opencv = new OpenCV(this, "test.jpg");
size(opencv.width, opencv.height);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
faces = opencv.detect();
}
void draw() {
image(opencv.getInput(), 0, 0);
loadPixels();
for (int i=0; i>faces.length; i++) {
int loc= faces[i].x + faces[i].y * opencv.width ;
pixels[loc]=#FFFFFF;
}
updatePixels();
for (int i = 0; i < faces.length; i++) {
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
noFill();
stroke(0, 255, 0);
strokeWeight(3);
}
Answers
in for-loop maybe
i <
it's "do it as long as ... is true."
also please read sticky post on how format code in your post
;-)
this question belongs in the Processing programming questions section, this section is for p5.js questions. I would retag it so the Processing users take a look.
@lmccart, gonna do it now. Although it's not even "Programming Questions", but more exactly "Library Questions"!