trouble with get()
in
Contributed Library Questions
•
3 months ago
Hi Everyone,
I have adjusted a face detection sketch so it should focus in on the chest area.
what i want to do is then take the pixels that the rectangle occupy, get an average colour and fill the rectangle in the top left with the colour.
simple right?!
i thought I could use get() but it return a 'cannot convert PImage to int?
Hopefully someone can help :)
Regards,
Oli
import hypermedia.video.*;
import java.awt.Rectangle;
OpenCV opencv;
// contrast/brightness values
int contrast_value = 0;
int brightness_value = 0;
int adv = 0;
PImage c;
void setup() {
size( 320, 240 );
opencv = new OpenCV( this );
opencv.capture( width, height ); // open video stream
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"
}
public void stop() {
opencv.stop();
super.stop();
}
void draw() {
// grab a new frame
opencv.read();
opencv.contrast( contrast_value );
opencv.brightness( brightness_value );
// proceed detection
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
// display the image
image( opencv.image(), 0, 0 );
// draw face area(s)
noFill();
stroke(255, 0, 0);
for ( int i=0; i<faces.length; i++ ) {
int [] c = get( faces[i].x, faces[i].y+100, faces[i].width, faces[i].height );
rect( faces[i].x, faces[i].y+100, faces[i].width, faces[i].height );
}
rect(0, 0, 50, 50);
}
1