Ask Your Question

mockingjay05's profile - activity

2016-10-13 05:36:24 -0600 received badge  Student (source)
2014-07-30 08:53:33 -0600 asked a question how to detect mouth region using javacv?

hi can you please help me to accurately detect the mouth region using javacv,, i have try to use the haarcascade_mcs_mouth.xml but it gives 4 detections,, please help me thanks in advance

here is the code

package com.shekhar.facedetection;

import com.googlecode.javacv.cpp.opencv_core.IplImage; import static com.googlecode.javacv.cpp.opencv_core.; import static com.googlecode.javacv.cpp.opencv_highgui.; import static com.googlecode.javacv.cpp.opencv_objdetect.*;

public class FaceDetector{ IplImage img; public static final String XML_FILE = "C:\Users\Michelle\workspace\day12-face-detection-master\src\com\shekhar\facedetection\haarcascade_eye.xml";

public static void main(String[] args){

    IplImage img = cvLoadImage("C:\\Users\\Michelle\\workspace\\day12-face-detection-master\\src\\com\\shekhar\\facedetection\\sarah.jpg");     
    detect(img);        
}   

public static void detect(IplImage src){

    CvHaarClassifierCascade cascade = new 
            CvHaarClassifierCascade(cvLoad(XML_FILE));
    CvMemStorage storage = CvMemStorage.create();
    CvSeq sign = cvHaarDetectObjects(
        src,
            cascade,
            storage,
            1.5,
            3,
            CV_HAAR_DO_CANNY_PRUNING);

    cvClearMemStorage(storage);

    int total_Faces = sign.total();     

    for(int i = 0; i < total_Faces; i++){
        CvRect r = new CvRect(cvGetSeqElem(sign, i));
        cvRectangle (
                src,
                cvPoint(r.x(), r.y()),
                cvPoint(r.width() + r.x(), r.height() + r.y()),
                CvScalar.RED,
                2,
                CV_AA,
                0);

    }

    cvShowImage("Result", src);
    cvWaitKey(0);

}

}

2014-07-30 02:32:39 -0600 commented answer Face detection and mouth detection using OpenCV

hi im a newbie in opencv,, im also facing that kind of problem,, but im using java,, how to implement that code in java,, thanks in advance

2014-07-30 02:27:48 -0600 asked a question how to detect the mouth region in java?

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));



}

}