Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use detectMultiScale detector for ROI in Face detection. Please help me in this code.

i am modifying this link text

code for my android application. I have change the code for mouth detection instead of eyes detection.

After detecting the face i am getting MOUTH region from FACE. but when i pass the argument "moutharea" to "detectmultiscale "

it is showing me this error "The method detectMultiScale(Mat, MatOfRect, double, int, int, Size, Size) in the type CascadeClassifier is not applicable for the arguments (Rect, MatOfRect, double, int, int, Size, Size)"

    Rect[] facesArray = faces.toArray();
    for (int i = 0; i < facesArray.length; i++)

    {

        Imgproc.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);

        Rect r = facesArray[i]; ////// for each detected face
        Rect moutharea = new Rect (r.x , r.y+(r.height * 2/3), r.width,r.height/3 ); ////// for extracting lower portion of mouth

        MatOfRect mouth = new MatOfRect();

        if (mDetectorType == JAVA_DETECTOR) {
            if (mJavaDetectorMouth != null)
                mJavaDetectorMouth.detectMultiScale(motharea, mouth, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE
                        new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
        }
        else if (mDetectorType == NATIVE_DETECTOR) {
            if (mNativeDetector != null)
                mNativeDetector.detect(mGray, mouth);
        }
        else {
            Log.e(TAG, "Detection method is not selected!");
        }

        Rect[] mouthArray = mouth.toArray();

        for (int j = 0; j < mouthArray.length; j++){
        Imgproc.rectangle(mRgba, mouthArray[j].tl(), mouthArray[j].br(),new Scalar(255, 0, 0, 255), 2);
        }

       Imgproc.rectangle(mRgba, moutharea.tl(), moutharea.br(),new Scalar(255, 0, 0, 255), 2);

    }

    return mRgba;
}

How to use detectMultiScale detector for ROI in Face detection. Please help me in this code.

i am modifying using this link textopen cv 3.0 sample project of face detection.

i am writing code for my android application. I have change the code for mouth detection instead of eyes detection.on face.

After detecting the face i am getting MOUTH region from FACE. but when i pass the argument "moutharea" to "detectmultiscale "

it is showing me this error "The method detectMultiScale(Mat, MatOfRect, double, int, int, Size, Size) in the type CascadeClassifier is not applicable for the arguments (Rect, MatOfRect, double, int, int, Size, Size)"

    Rect[] facesArray = faces.toArray();
    for (int i = 0; i < facesArray.length; i++)

    {

        Imgproc.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);

        Rect r = facesArray[i]; ////// for each detected face
        Rect moutharea = new Rect (r.x , r.y+(r.height * 2/3), r.width,r.height/3 ); ////// for extracting lower portion of mouth

        MatOfRect mouth = new MatOfRect();

        if (mDetectorType == JAVA_DETECTOR) {
            if (mJavaDetectorMouth != null)
                mJavaDetectorMouth.detectMultiScale(motharea, mouth, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE
                        new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
        }
        else if (mDetectorType == NATIVE_DETECTOR) {
            if (mNativeDetector != null)
                mNativeDetector.detect(mGray, mouth);
        }
        else {
            Log.e(TAG, "Detection method is not selected!");
        }

        Rect[] mouthArray = mouth.toArray();

        for (int j = 0; j < mouthArray.length; j++){
        Imgproc.rectangle(mRgba, mouthArray[j].tl(), mouthArray[j].br(),new Scalar(255, 0, 0, 255), 2);
        }

       Imgproc.rectangle(mRgba, moutharea.tl(), moutharea.br(),new Scalar(255, 0, 0, 255), 2);

    }

    return mRgba;
}