Luxand FaceSDK – Mask-on Face Detection
To detect faces covered by masks, you need to adjust the settings of several parameters. You also
need to download a model file trained specifically on masked faces (for visual face detection) and put it into the working
directory of your application:
https://luxand.com/download/fd_masks1.bin
If you are using FSDK_DetectFace or FSDK_DetectMultipleFaces to detect faces (i.e. you don't use Tracker API), use the following code to set the recommended face detection parameters and use the latest model file:
int err = 0;
FSDK_SetFaceDetectionParameters(true, false, 1024);
FSDK_SetFaceDetectionThreshold(5);
if (FSDKE_OK !=
FSDK_SetParameters("FaceDetectionModel=fd_masks1.bin;TrimFacesWithUncertainFacialFeatures=false",
&err))
{
fprintf(stderr, "Error loading face detection model!\n");
exit(3);
}
Alternatively, if you are using Tracker API, use the following calls:
int err = 0;
FSDK_SetTrackerMultipleParameters(tracker, "RecognizeFaces=false; HandleArbitraryRotations=true;
DetermineFaceRotationAngle=false; InternalResizeWidth=1024; FaceDetectionThreshold=5;", &err);
if (FSDKE_OK != FSDK_SetTrackerMultipleParameters(tracker,
"FaceDetectionModel=fd_masks1.bin;TrimFacesWithUncertainFacialFeatures=false",
&err))
{
fprintf(stderr, "Error loading face detection model!\n");
exit(3);
}
In the code above, the TrimFacesWithUncertainFacialFeatures parameter is set to false. When it is
set to true, faces with uncertain facial features are removed from the detection result. As
masks may cover many facial features, this setting was preventing such faces from being
detected. You can learn more about this parameter here:
https://www.luxand.com/facesdk/documentation/configuration.php
We don't recommend that you use face matching when this parameter is set to false, since it will give a higher amount of false acceptances. We plan to update our face recognition models so they support mask-on face matching soon.
We recommend setting the InternalResizeWidth parameter to 1024 so the faces that are far from the camera are detected. If you don't expect your faces to be that far, you can lower the parameter value to 512 or 256 to increase the speed of detection.