如何在实时预览、人脸检测中检测人脸方向变化 android
How to detect face orientation changes on live preview ,face detection android
我正在开发一个使用google-人脸检测的应用程序API,我已经使用了示例项目,我需要的是,我想添加基于人脸的叠加图像(遮罩)方向改变,例如:如果面部旋转到右侧或左侧我想通过坐标 values.How 来更新叠加图像来做到这一点?任何人都可以提前 help.Thanks 吗?
我已经通过检测到的欧拉 Z 值解决了这个问题 face.I 我正在发布我的代码:
当方向改变时,我旋转了检测到的面部上的矩形和遮罩位图;
RectF dest = new RectF((int) left, (int) top, (int) right, (int) bottom);
Matrix m = new Matrix();
m.setRotate(face.getEulerZ(),dest.centerX(),dest.centerY());
m.mapRect(dest);
旋转位图。
public Bitmap rotate_bitmap(Bitmap bmp,float degree){
Matrix matrix = new Matrix();
matrix.postRotate(degree);
return Bitmap.createBitmap(bmp , 0, 0, bmp .getWidth(), bmp .getHeight(), matrix, true);
}
正在 canvas 上绘制旋转蒙版。
canvas.drawBitmap(rotate_bitmap(faceTrackerActivity.getBitmapItem("face"),face.getEulerZ()), null, dest, null);
此外,将快速模式设置为人脸检测器。
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.setMode(FaceDetector.FAST_MODE)
.build();`
我正在开发一个使用google-人脸检测的应用程序API,我已经使用了示例项目,我需要的是,我想添加基于人脸的叠加图像(遮罩)方向改变,例如:如果面部旋转到右侧或左侧我想通过坐标 values.How 来更新叠加图像来做到这一点?任何人都可以提前 help.Thanks 吗?
我已经通过检测到的欧拉 Z 值解决了这个问题 face.I 我正在发布我的代码:
当方向改变时,我旋转了检测到的面部上的矩形和遮罩位图;
RectF dest = new RectF((int) left, (int) top, (int) right, (int) bottom);
Matrix m = new Matrix();
m.setRotate(face.getEulerZ(),dest.centerX(),dest.centerY());
m.mapRect(dest);
旋转位图。
public Bitmap rotate_bitmap(Bitmap bmp,float degree){
Matrix matrix = new Matrix();
matrix.postRotate(degree);
return Bitmap.createBitmap(bmp , 0, 0, bmp .getWidth(), bmp .getHeight(), matrix, true);
}
正在 canvas 上绘制旋转蒙版。
canvas.drawBitmap(rotate_bitmap(faceTrackerActivity.getBitmapItem("face"),face.getEulerZ()), null, dest, null);
此外,将快速模式设置为人脸检测器。
FaceDetector detector = new FaceDetector.Builder(context)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.setMode(FaceDetector.FAST_MODE)
.build();`