Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setROI() #107

Open
isemechkov opened this issue Feb 26, 2018 · 0 comments
Open

setROI() #107

isemechkov opened this issue Feb 26, 2018 · 0 comments

Comments

@isemechkov
Copy link

Hi, please, i need help. At me it is impossible to understand from functions setROI(). It is necessary to look for eyes in a face, I send parameters of the person to function opencv_eyes.setROI(face_x, face_y, face_width,face_height), and eyes are not on a face (pic "ROI apply.png"). If I comment on a line "opencv_eyes.setROI(face_x, face_y, face_width,face_height);", all ok (pic "ROI coment.png").

What do I do not so?
With respect for Strunkin Stepan.

roi apply
default

roi coment
default

sketch_to_Greg.zip

sketch:
//-----------------------------------------------------------------------------------------------------------------------------
import processing.video.;
import gab.opencv.;
import java.awt.Rectangle;

OpenCV opencv_face, opencv_eyes;
Rectangle[] faces, eyes;

int face_x, face_y, face_width, face_height;

Capture webcam;

void setup() {
size(320, 240);

String[] webcameras = Capture.list();

if (webcameras.length == 0) {
println("There are no webcameras available for capture.");
exit();
} else {
println("Available webcameras:");
for (int i = 0; i < webcameras.length; i++) {
println(webcameras[i]);
}

// The webcamera can be initialized directly using an
// element from the array returned by list():
webcam = new Capture(this, webcameras[4]); // 32024030
webcam.start();

opencv_face = new OpenCV(this, width, height);
opencv_eyes = new OpenCV(this, width, height);

opencv_face.loadCascade(OpenCV.CASCADE_FRONTALFACE);
opencv_eyes.loadCascade(OpenCV.CASCADE_EYE);

};
}

void draw() {
if (webcam.available() == true) {
webcam.read();
opencv_face.loadImage(webcam);
opencv_eyes.loadImage(webcam);
image(opencv_eyes.getInput()/webcam/, 0, 0);

faces = opencv_face.detect(1.2, 3, 0, 80, 250);   
    
noFill();
stroke(0, 255, 0);
strokeWeight(2);
for (int i = 0; i < faces.length; i++) {  
  face_x = faces[i].x;
  face_y = faces[i].y;
  face_width = faces[i].width;
  face_height = faces[i].height;
  rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);           
}
 
 opencv_eyes.setROI(face_x, face_y, face_width,face_height);
 eyes = opencv_eyes.detect(1.2, 3, 0, 20, 100);
 
 for( int j=0; j<eyes.length; j++ ) {
   rect( eyes[j].x, eyes[j].y, eyes[j].width, eyes[j].height );
 }

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant