Face Capture
Face Capture is a UI module that displays the Camera UI and automatically captures a photo with a person's face on it.
Face Capture comes with a configuration allowing you to change the behavior and appearance of some UI elements. For more UI customization, please check out UI Customization.
Show Face Capture
let configuration = FaceCaptureConfiguration {
$0.cameraPosition = .front
$0.cameraSwitchEnabled = true
$0.rejectMultipleFaces = true
}
FaceSDK.service.presentFaceCaptureViewController(
from: viewController,
animated: true,
configuration: configuration,
onCapture: { response in
// ... check response.image for capture result.
},
completion: nil
)
RFSFaceCaptureConfiguration *configuration = [RFSFaceCaptureConfiguration configurationWithBuilder:^(RFSFaceCaptureConfigurationBuilder * _Nonnull builder) {
builder.cameraPosition = RFSCameraPositionFront;
builder.cameraSwitchEnabled = YES;
builder.rejectMultipleFaces = YES;
}];
[RFSFaceSDK.service presentFaceCaptureViewControllerFrom:viewController
animated:YES
configuration:configuration
onCapture:^(RFSFaceCaptureResponse * _Nonnull response) {
// ... check response.image for capture result.
} completion:nil];
val configuration = FaceCaptureConfiguration.Builder()
.setCameraId(0)
.setCameraSwitchEnabled(true)
.setRejectMultipleFaces(true)
.build()
FaceSDK.Instance().presentFaceCaptureActivity(this@MainActivity, configuration) { response ->
// ... check response.image for capture result.
}
FaceCaptureConfiguration configuration = new FaceCaptureConfiguration.Builder()
.setCameraId(0)
.setCameraSwitchEnabled(true)
.setRejectMultipleFaces(true)
.build();
FaceSDK.Instance().presentFaceCaptureActivity(MainActivity.this, configuration, response -> {
// ... check response.getImage(); for capture result.
});
var response = await FaceSDK.instance.startFaceCapture(
config: FaceCaptureConfig(
cameraPositionAndroid: 0,
cameraPositionIOS: CameraPosition.FRONT,
cameraSwitchEnabled: true,
rejectMultipleFaces: true,
),
);
// ... check response.image.image for capture result.
var response = await FaceSDK.instance.startFaceCapture({
config: new FaceCaptureConfig({
cameraPositionAndroid: 0,
cameraPositionIOS: CameraPosition.FRONT,
cameraSwitchEnabled: true,
rejectMultipleFaces: true,
}),
})
// ... check response.image.image for capture result.
// Android
FaceCaptureConfiguration configuration = new FaceCaptureConfiguration.Builder()
.SetCameraId(0)
.SetCameraSwitchEnabled(true)
.SetRejectMultipleFaces(true)
.Build();
FaceSDK.Instance().PresentFaceCaptureActivity(Platform.AppContext, configuration, this);
// iOS
RFSFaceSDK.Service.PresentFaceCaptureViewControllerFrom(CurrentPresenter, true, RFSFaceCaptureConfiguration.ConfigurationWithBuilder((RFSFaceCaptureConfigurationBuilder builder) =>
{
builder.CameraPosition = RFSCameraPosition.Front;
builder.CameraSwitchButtonEnabled = true;
builder.RejectMultipleFaces = true;
}),
(RFSFaceCaptureResponse response) =>
{
// ... check response.image for capture result.
}, null);
To keep the default configuration, omit the configuration parameter.
Info
For more information on FaceCaptureConfiguration and FaceCaptureResponse, please see SDK Reference.
Reject Multiple Faces
By default, multiple-face detection is disabled for Face Capture. To enable it, set the rejectMultipleFaces parameter to true in the Face Capture configuration, as shown in the examples above.
When enabled, Face SDK Core checks for multiple faces during capture. If multiple faces are detected, the capture process fails and the SDK returns a platform-specific error with the message Processing failed by too many faces.