Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to convert detected mouth region in gray-scale and binary in android ?

Here is my code, i am not able to covert the mouth region into grayscale please help me...i have tried everything available on internet

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.width * 2 / 7), r.y
                + (r.height * 2 / 3), r.width / 2, r.height / 4); // /
                                                                    // extract
                                                                    // mouth
        Mat innerWindow = mRgba.submat(moutharea);
                    Imgproc.cvtColor(innerWindow,innerWindow, Imgproc.COLOR_RGB2GRAY);
Imgproc.threshold(innerWindow, innerWindow, 100, 255,Imgproc.THRESH_BINARY);

How to convert detected mouth region in gray-scale and binary in android ?

Here is my code, i am not able to covert the mouth region into grayscale please help me...i have tried everything available on internet

public Mat onCameraFrame(CvCameraViewFrame inputFrame) { // Rotating the input frame mRgba = inputFrame.rgba(); mGray = inputFrame.gray();

    if (mAbsoluteFaceSize == 0) {
        int height = mGray.rows();
        if (Math.round(height * mRelativeFaceSize) > 0) {
            mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
        }
        mNativeDetector.setMinFaceSize(mAbsoluteFaceSize);
    }
    // Detecting face in the frame
    MatOfRect faces = new MatOfRect();

    if (mDetectorType == JAVA_DETECTOR) {
        if (mJavaDetector != null)
            mJavaDetector.detectMultiScale(mGray, faces, 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, faces);
    } else {
        Log.e(TAG, "Detection method is not selected!");
    }

    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.width * 2 / 7), r.y
                + (r.height * 2 / 3), r.width / 2, r.height / 4); // /
                                                                    // extract
                                                                    // mouth
        Mat innerWindow = mRgba.submat(moutharea);
                    Imgproc.cvtColor(innerWindow,innerWindow, Imgproc.COLOR_RGB2GRAY);
Imgproc.threshold(innerWindow, Imgproc.cvtColor(innerWindow, innerWindow,Imgproc.COLOR_RGB2GRAY);      
Imgproc.threshold( innerWindow, 100,  innerWindow,70, 255,Imgproc.THRESH_BINARY);

    }

    return mRgba;
}

How to convert detected mouth region in gray-scale and binary in android ?

Here is my code, i am not able to covert the mouth region into grayscale please help me...i have tried everything available on internet

 public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
 // Rotating the input frame
 mRgba = inputFrame.rgba();
 mGray = inputFrame.gray();

inputFrame.gray();
 if (mAbsoluteFaceSize == 0) {
int height = mGray.rows();
if (Math.round(height * mRelativeFaceSize) > 0) {
mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
}
mNativeDetector.setMinFaceSize(mAbsoluteFaceSize);
}
// Detecting face in the frame
MatOfRect faces = new MatOfRect();
if (mDetectorType == JAVA_DETECTOR) {
if (mJavaDetector != null)
mJavaDetector.detectMultiScale(mGray, faces, 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, faces);
} else {
Log.e(TAG, "Detection method is not selected!");
}
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.width * 2 / 7), r.y
+ (r.height * 2 / 3), r.width / 2, r.height / 4); // /
// extract
// mouth
Mat innerWindow = mRgba.submat(moutharea);
Imgproc.cvtColor(innerWindow, innerWindow,Imgproc.COLOR_RGB2GRAY);
Imgproc.threshold( innerWindow, innerWindow,70, 255,Imgproc.THRESH_BINARY);
}
return mRgba;
}

How to convert detected mouth region in gray-scale and binary in android ?

Here is my code, i am not able to covert the mouth region into grayscale please help me...i have tried everything available on internet

 public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    // Rotating the input frame
    mRgba = inputFrame.rgba();
    mGray = inputFrame.gray();

    if (mAbsoluteFaceSize == 0) {
        int height = mGray.rows();
        if (Math.round(height * mRelativeFaceSize) > 0) {
            mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
        }
        mNativeDetector.setMinFaceSize(mAbsoluteFaceSize);
    }
    // Detecting face in the frame
    MatOfRect faces = new MatOfRect();

    if (mDetectorType == JAVA_DETECTOR) {
        if (mJavaDetector != null)
            mJavaDetector.detectMultiScale(mGray, faces, 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, faces);
    } else {
        Log.e(TAG, "Detection method is not selected!");
    }

    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.width * 2 / 7), r.y
                + (r.height * 2 / 3), r.width / 2, r.height / 4); // /
                                                                    // extract
                                                                    // mouth
        Mat innerWindow = mRgba.submat(moutharea);
Imgproc.cvtColor(innerWindow, innerWindow,Imgproc.COLOR_RGB2GRAY);      
Imgproc.threshold( innerWindow,  innerWindow,70, 255,Imgproc.THRESH_BINARY);

    }

    return mRgba;
}