-
-
Notifications
You must be signed in to change notification settings - Fork 793
Face detection
This library support face detection using camera1 api and camera2. This methods can be used on preview and streaming. If you call it beofre start preview, it will take no effect.
The limitation of this feature could change depend of device. Few devices only support 1 face limit or directly no support for it.
Also, eyes and mouth points are no parsed because most of device don't support it.
If your device support it you can get point provided by camera1 and camera2 api using faces provided by onGetFaces callback and parse it yourself.
To start face detection you use this method:
rtmpCamera1.enableFaceDetection(new Camera1ApiManager.FaceDetectorCallback() {
@Override
public void onGetFaces(Camera.Face[] faces, Rect scaleSensor, int sensorOrientation) {
// provide native info from camera1 face detection api. From faces objects you can obtain, mouth, eyes, bounds and score.
}
});
To stop face detection:
rtmpCamera1.disableFaceDetection();
If you want parse faces result to a valid scale and position for real time filters you can use this:
FaceParsed faceParsed = FaceDetectorUtil.camera1Parse(face, scaleSensor, sensorOrientation,
CameraHelper.getCameraOrientation(context), rtmpCamera1.getCameraFacing());
To start face detection you use this method:
rtmpCamera2.enableFaceDetection(new Camera2ApiManager.FaceDetectorCallback() {
@Override
public void onGetFaces(Face[] faces, Rect scaleSensor, int sensorOrientation) {
// provide native info from camera2 face detection api. From faces objects you can obtain, mouth, eyes, bounds and score.
}
});
To stop face detection:
rtmpCamera2.disableFaceDetection();
If you want parse faces result to a valid scale and position for real time filters you can use this:
FaceParsed faceParsed = FaceDetectorUtil.camera2Parse(face, scaleSensor, sensorOrientation,
CameraHelper.getCameraOrientation(context), rtmpCamera2.getCameraFacing());