please format code with </> button * homework policy * asking questions
Hello, I am trying to put an image instead of a square in the face detector code and on a video and it gives me error the image is too big, it does not only occupy the face
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
Capture cam;
OpenCV opencv;
Movie film;
PImage cara;
void settings() {
size(640, 480);
}
void setup() {
cara= loadImage("cara.jpg");
colorMode(HSB, 256, 256, 256);
film= new Movie(this, "Secuencia 01_2.mp4");
cam = new Capture(this, width, height);
opencv = new OpenCV(this, width, height);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
cam.start();
film.loop();
noFill();
stroke(0, 255, 0);
strokeWeight(3);
}
void draw() {
background(250, 150, 0);
//scale(2);
opencv.loadImage(cam);
//video.loadPixels();
image(film, 0, 0);
loadPixels();
Rectangle[] faces = opencv.detect();
if (frameCount%15==0) println(faces.length);
for (int x = 0; x < film.width; x++) {
for (int y = 0; y < film.height; y++) {
// Calculate the 1D location from a 2D grid
int loc = x + y * film.width;
float h= hue(film.pixels[loc]);
float s= saturation(film.pixels[loc]);
float br= brightness(film.pixels[loc]);
for (int i = 0; i < faces.length; i++) {
//println(faces[i].x + "," + faces[i].y);
float d = dist(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
float adjustbrightness = map(d, 50, 200, 0, 255);
color c = color(h, s, br);
}
}
}
updatePixels();
for (int i = 0; i < faces.length; i++) {
//println(faces[i].x + "," + faces[i].y);
float d = dist(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
image(cara,faces[i].width, faces[i].height);
if (frameCount%15==0) println(faces[i].x, faces[i].y, d);
}
}
void captureEvent(Capture video) {
video.read();
}
void movieEvent(Movie m) {
m.read();
}