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() method.
Core.flip(mRgba, mRgba, 1);
Still do not recognize face.
How to detect face by portrait mode?
Thank you.
Set the portrait mode in android's manifest first.
Flip the colored and gray image(Mat) clockwise for face/feature detection to work in portrait mode. At the end of feature detection Logic, you flip counter clockwise the colored image(mRgba Mat) . As illustrated.
After that the camera will show face detection in landscape orientation to fix this you rotate the canvas clockwise by 90 in opencv's CameraBridgeViewBase main class or hack it.(Note this reduces FPS but face detection is still fast)
}
(Using OpenCV 2.4.9)
you need to do transpose and then flip: