Smile detection using opencv on android

0

Hello, I'm having a hard time doing smilie detection using opencv on android. I can do the detection of faces and eyes very well using haar cascade but only the detection of smiles is not working using this method.

private Mat image, originalImage, imgGray;
private CascadeClassifier face;
private CascadeClassifier eye; //atributos
private CascadeClassifier smile;
private Size dsize = new Size(480, 640);
private MatOfRect faceDetections;
private MatOfRect eyeDetections;
private MatOfRect smileDetections;
private boolean center;

public FaceDetection(Mat imagem, Mat imgCinza) {
    //load the haarcascade's archives to detect faces, eyes and smiles.

    this.face = new CascadeClassifier("/storage/emulated/0/data/haarcascade_frontalface_alt.xml");
    this.face.load("/storage/emulated/0/data/haarcascade_frontalface_alt.xml");
    this.eye = new CascadeClassifier("/storage/emulated/0/data/haarcascade_eye_tree_eyeglasses.xml");
    this.eye.load("/storage/emulated/0/data/haarcascade_eye_tree_eyeglasses.xml");
    this.smile = new CascadeClassifier("/storage/emulated/0/data/haarcascade_myhaar.xml");
    this.smile.load("/storage/emulated/0/data/haarcascade_myhaar.xml");
    this.originalImage = imagem;
    this.imgGray = new Mat();
    this.image = new Mat();
    Imgproc.resize(imgCinza, this.imgGray, dsize);
    Imgproc.resize(this.originalImage, this.image, dsize);
    this.faceDetections = new MatOfRect();
    this.eyeDetections = new MatOfRect();
    this.smileDetections = new MatOfRect();
}

public void detectate() {
    eye.detectMultiScale(imgGray, eyeDetections);
    smile.detectMultiScale(imgGray, smileDetections);
    face.detectMultiScale(imgGray, faceDetections);
    faceDetect();
    System.out.println("Funcionou");
}

As shown in the code, I'm loading the cascades by passing the path of the haarcascades xml files. My question is because only the detection of faces and eyes works, and I'm using a haarcascade from opencv itself to detect smiles and it just does not work. I hope I have made my difficulty clearer.

    
asked by anonymous 31.10.2017 / 19:47

0 answers