Ask Your Question
0

How to detect face by portrait mode?

asked 2013-10-08 20:49:37 -0500

chungjs gravatar image

Hi, I'm studying OpenCV recently.

OpenCV for Android sample code(2.4.6) is tested.

I have some wonder.

I can detect face by sample code(OpenCV Sample - face-detection). but, can't detect face by portrait mode(vertical mode) on android device.

First, I try set Front-Camera by portrait mode.

//added code in onCameraFrame() Core.flip(mRgba, mRgba, 1);

Still do not recognize face.

How to detect face by portrait mode?

Thank you.

edit retag flag offensive close merge delete

Comments

did u find any solution for the problem ?

bunta gravatar imagebunta ( 2013-10-09 05:01:07 -0500 )edit

not find yet

chungjs gravatar imagechungjs ( 2013-10-09 09:12:19 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-10-09 04:15:06 -0500

simon111 gravatar image

Actually, you need rotate your input video by 90 degree , flip is not enough,

As you noticed, many camera apps in Android devices only support landscape mode, fairly support protraint mode.

First, you can make your activity not to be a fullscreen app, I mean, remain the title bar or status bar. These UI elements will help you to know the real orientation of you activity.

Second, adjust your camera view suit for approperity activity oritentation. If you activity is portrait mode, you should do nothing. If you activity is landscape mode, you should rotate your input video by 90 degree ( transpose+flip ) , so you should detect the faces in portrait oritentaion.

edit flag offensive delete link more

Comments

Thank you . but I have no idea. I'm Android Programming and OpenCV beginner. Please explain more easily by Example Code(OpenCV Sample - face-detection).

chungjs gravatar imagechungjs ( 2013-10-09 09:15:55 -0500 )edit

I tried-

IplImage my_image = (IplImage) grayImage; CvMat mat = my_image.asCvMat();

    int cols = mat.cols();
    int rows = mat.rows();
    IplImage DstImage = cvCreateImage(cvSize(rows, cols), IPL_DEPTH_8U, 1);


   int angle = ((180 / 90) % 4) * 90;

    //0 : flip vertical; 1 flip horizontal
    int flip_horizontal_or_vertical = angle > 0 ? 1 : 0;
    int  number = Math.abs(angle / 90);
    for(int i = 0; i != number; ++i){
        cvTranspose(grayImage, DstImage);        
        cvFlip(grayImage,DstImage,flip_horizontal_or_vertical);
    }

But couldnt get anything

bunta gravatar imagebunta ( 2013-10-09 13:24:38 -0500 )edit

try to
IplImage DstImage0 = cvCreateImage(cvSize(rows, cols), IPL_DEPTH_8U, 1); ... cvTranspose(grayImage, DstImage0);
cvFlip(DstImage0,DstImage,flip_horizontal_or_vertical);

and you should modifiy code, so if you detected face, output some infos to logcat. I think you draw the face rectangle in a internal mat, so you can't see the rectangle in the final output view.

simon111 gravatar imagesimon111 ( 2013-10-09 19:21:20 -0500 )edit

I'm sorry. but I need for android plaform(sample code(OpenCV Sample - face-detection). please answer again. I'm diffcult OpenCV. becasue, I'm beginner for android and OpenCV.

chungjs gravatar imagechungjs ( 2013-10-10 02:58:31 -0500 )edit

if its android use javaCV, and rest of the code will work in android platform

bunta gravatar imagebunta ( 2013-10-10 03:21:01 -0500 )edit

It's not detect face by portrait mode. only detect face by landscape mode.(Original Source :OpenCV Sample - face-detection). I want to detect face by portrait mode.

chungjs gravatar imagechungjs ( 2013-10-10 05:25:20 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-10-08 20:49:37 -0500

Seen: 2,350 times

Last updated: Oct 09 '13