Ask Your Question

Revision history [back]

Face Detection is not working portrait mode in android plateform

Hi, I am creating an application for face recognition using opencv in android.App is working good in landscape mode. I want to use this app in portrait mode for this I added following code in onCameraFrame method :-

    int height = mGray.rows();
    int faceSize = Math.round(height * 0.4f);
    Mat temp = mGray.clone();
    Core.transpose(mGray, temp);
    Core.flip(temp, temp, -1);
    MatOfRect faces = new MatOfRect();
    mJavaDetector.detectMultiScale(mRgba, faces, 1.1, 2, 2, new Size(faceSize, faceSize), new Size());

But its not working in portrait mode.When I am rotating device from portrait to landscape , then camera shows in portrait mode. Please help me to resolve this issue..

Thanks in advance !!

click to hide/show revision 2
retagged

updated 2014-03-18 04:23:51 -0500

berak gravatar image

Face Detection is not working portrait mode in android plateform

Hi, I am creating an application for face recognition using opencv in android.App is working good in landscape mode. I want to use this app in portrait mode for this I added following code in onCameraFrame method :-

    int height = mGray.rows();
    int faceSize = Math.round(height * 0.4f);
    Mat temp = mGray.clone();
    Core.transpose(mGray, temp);
    Core.flip(temp, temp, -1);
    MatOfRect faces = new MatOfRect();
    mJavaDetector.detectMultiScale(mRgba, faces, 1.1, 2, 2, new Size(faceSize, faceSize), new Size());

But its not working in portrait mode.When I am rotating device from portrait to landscape , then camera shows in portrait mode. Please help me to resolve this issue..

Thanks in advance !!

Face Detection is not working portrait mode in android plateform

Hi, I am creating an application for face recognition using opencv in android.App is working good in landscape mode. I want to use this app in portrait mode for this I added following code in onCameraFrame method :-

    int height = mGray.rows();
    int faceSize = Math.round(height * 0.4f);
    Mat temp = mGray.clone();
    Core.transpose(mGray, temp);
    Core.flip(temp, temp, -1);
    MatOfRect faces = new MatOfRect();
    mJavaDetector.detectMultiScale(mRgba, mJavaDetector.detectMultiScale(temp, faces, 1.1, 2, 2, new Size(faceSize, faceSize), new Size());

I also did changes in CameraBridgeViewBase. I following code

canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
                         new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
                         (int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);

with

                     Matrix matrix = new Matrix();
                     matrix.preTranslate( (int)(canvas.getWidth() - mCacheBitmap.getWidth()) / 2,(canvas.getHeight() - mCacheBitmap.getHeight()) / 2);
                     if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
                     matrix.postRotate(270f,( (int)canvas.getWidth()) / 2,(canvas.getHeight()) / 2);
                     canvas.drawBitmap(mCacheBitmap, matrix, new Paint());

But its not working in portrait mode.When I am rotating device from portrait to landscape , then camera shows in portrait mode. working.Face detector mark is not coming exactly surrounding user's face. It is coming slightly down and right side of the face. I have attached screenshot of this.

Screenshot_2014-03-18-15-13-50.png

Please help me to resolve this issue..

problem. Thanks in advance !!

Face Detection is not working portrait mode in android plateform

Hi, I am creating an application for face recognition using opencv in android.App is working good in landscape mode. I want to use this app in portrait mode for this I added following code in onCameraFrame method :-

    int height = mGray.rows();
    int faceSize = Math.round(height * 0.4f);
    Mat temp = mGray.clone();
    Core.transpose(mGray, temp);
    Core.flip(temp, temp, -1);
    MatOfRect faces = new MatOfRect();
    mJavaDetector.detectMultiScale(temp, faces, 1.1, 2, 2, new Size(faceSize, faceSize), new Size());

I also did changes in CameraBridgeViewBase. I CameraBridgeViewBase class, I replace following code

canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
                         new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
                         (int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);

with

                     Matrix matrix = new Matrix();
                     matrix.preTranslate( (int)(canvas.getWidth() - mCacheBitmap.getWidth()) / 2,(canvas.getHeight() - mCacheBitmap.getHeight()) / 2);
                     if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
                     matrix.postRotate(270f,( (int)canvas.getWidth()) / 2,(canvas.getHeight()) / 2);
                     canvas.drawBitmap(mCacheBitmap, matrix, new Paint());

But its not working.Face detector mark is not coming exactly surrounding user's face. It is coming slightly down and right side of the face. I have attached screenshot of this.

Screenshot_2014-03-18-15-13-50.png

Please help me to resolve this problem. Thanks in advance !!

Face Detection is not working portrait mode in android plateform

Hi, I am creating an application for face recognition using opencv in android.App is working good in landscape mode. I want to use this app in portrait mode for this I added following code in onCameraFrame method :-

    int height = mGray.rows();
    int faceSize = Math.round(height * 0.4f);
    Mat temp = mGray.clone();
    Core.transpose(mGray, temp);
    Core.flip(temp, temp, -1);
    MatOfRect faces = new MatOfRect();
    mJavaDetector.detectMultiScale(temp, faces, 1.1, 2, 2, new Size(faceSize, faceSize), new Size());

I also did changes in CameraBridgeViewBase class, I replace replaced following lines of code

canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
                         new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
                         (int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);

with

                     Matrix matrix = new Matrix();
                     matrix.preTranslate( (int)(canvas.getWidth() - mCacheBitmap.getWidth()) / 2,(canvas.getHeight() - mCacheBitmap.getHeight()) / 2);
                     if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
                     matrix.postRotate(270f,( (int)canvas.getWidth()) / 2,(canvas.getHeight()) / 2);
                     canvas.drawBitmap(mCacheBitmap, matrix, new Paint());

But its not working.Face detector mark is not coming exactly surrounding user's face. It is coming slightly down and right side of the face. I have attached screenshot of this.

Screenshot_2014-03-18-15-13-50.png

Please help me to resolve this problem. Thanks in advance !!

Face Detection is not working portrait mode in android plateform

Hi, I am creating an application for face recognition using opencv in android.App is working good in landscape mode. I want to use this app in portrait mode for this I added following code in onCameraFrame method :-

    int height = mGray.rows();
    int faceSize = Math.round(height * 0.4f);
    Mat temp = mGray.clone();
    Core.transpose(mGray, temp);
    Core.flip(temp, temp, -1);
    MatOfRect faces = new MatOfRect();
    mJavaDetector.detectMultiScale(temp, faces, 1.1, 2, 2, new Size(faceSize, faceSize), new Size());

I also did changes in CameraBridgeViewBase class, I replaced following lines of code

canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
                         new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
                         (int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
                         (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);

with

                     Matrix matrix = new Matrix();
                     matrix.preTranslate( (int)(canvas.getWidth() - mCacheBitmap.getWidth()) / 2,(canvas.getHeight() - mCacheBitmap.getHeight()) / 2);
                     if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
                     matrix.postRotate(270f,( (int)canvas.getWidth()) / 2,(canvas.getHeight()) / 2);
                     canvas.drawBitmap(mCacheBitmap, matrix, new Paint());

But its not working.Face detector mark is not coming exactly surrounding user's face. It is coming slightly down and right side of the face. I have attached screenshot of this.

Screenshot_2014-03-18-15-13-50.png

Please help me to resolve this problem. Thanks in advance !!