how to detect the mouth region in java?

asked 2014-07-30 02:27:48 -0500

mockingjay05 gravatar image

hi im new to opencv and now im working for face detection im successful in working with the face detection, but when i try to detect the mouth region it generate an output of 5 or 6,,, i dont know how to fix it please help me here is the source code

package com.shekhar.facedetection;

import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.core.MatOfRect; import org.opencv.core.Point; import org.opencv.core.Rect; import org.opencv.core.Scalar; import org.opencv.highgui.Highgui; import org.opencv.objdetect.CascadeClassifier;

public class FaceDetector {

public static void main(String[] args) {

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    System.out.println("\nRunning FaceDetector");

    CascadeClassifier faceDetector = new CascadeClassifier(FaceDetector.class.getResource("haarcascade_mcs_mouth.xml").getPath().substring(1));
    Mat image = Highgui
            .imread(FaceDetector.class.getResource("sarah.jpg").getPath().substring(1));
    MatOfRect faceDetections = new MatOfRect();
    faceDetector.detectMultiScale(image, faceDetections);

    System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));



}

}

edit retag flag offensive close merge delete

Comments

Looking at your other question it seems that you are using JavaCV. If that is the case, and you are not the official Java interface of the OpenCV package, then address your problem to the proper forum which can be found here

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-31 03:12:43 -0500 )edit