why i cant turn background to white? urgent!!!

edited December 2014 in Library Questions

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. QQ截图20141206135645

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

Sign In or Register to comment.