Face Detection not working in Portrait Mode
Hi, I'm using Samsung Galaxy j5 (2016) model. On this face detection is not working in portrait mode but working fine in landscape only.
I've tested on Nexus 5, Galaxy TAB A and LG G Pro devices and on all these devices your library is working perfectly for both orientations. Can you help me please?
fetching same issue !
I find the resolution of this Issue:
fdet.findFaces(bmp, fullResults);
We should ensure the width and height of bitmap are even. It works for me.
`gray8toRGB32(grayBuff, previewWidth, previewHeight, rgbs); Bitmap bitmap = Bitmap.createBitmap(rgbs, previewWidth, previewHeight, Bitmap.Config.RGB_565);
if (w % 2 == 1) {
w -= 1;
}
if (h % 2 == 1) {
h -= 1;
}//here
Bitmap bmp = Bitmap.createScaledBitmap(bitmap, w, h, false);
float xScale = (float) previewWidth / (float) prevSettingWidth;
float yScale = (float) previewHeight / (float) h;
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int rotate = mDisplayOrientation;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT && mDisplayRotation % 180 == 0) {
if (rotate + 180 > 360) {
rotate = rotate - 180;
} else {
rotate = rotate + 180;
}
}
switch (rotate) {
case 90:
bmp = ImageUtils.rotate(bmp, 90);
xScale = (float) previewHeight / bmp.getWidth();
yScale = (float) previewWidth / bmp.getHeight();
break;
case 180:
bmp = ImageUtils.rotate(bmp, 180);
break;
case 270:
bmp = ImageUtils.rotate(bmp, 270);
xScale = (float) previewHeight / (float) h;
yScale = (float) previewWidth / (float) prevSettingWidth;
break;
default:
break;
}
fdet = new FaceDetector(bmp.getWidth(), bmp.getHeight(), MAX_FACE);
FaceDetector.Face[] fullResults = new FaceDetector.Face[MAX_FACE];
fdet.findFaces(bmp, fullResults);`
Tysm for helping ..
But I find this project cost too much CPU resources (15~20% CPU), I'm trying to find a high performance method to detect faces。