Face detector¶
To detect faces on an image the IDLive Face uses custom face detector. This detector can be used directly with the DetectEngine
class:
auto config = facesdk::InitConfig::createConfig(IDLIVEFACE_HOME + "/data/detection/ssd/ssd_new.conf");
auto image = facesdk::Image::createImage(IDLIVEFACE_HOME + "/examples/images/real_face.jpg");
facesdk::DetectEnginePtr detector = facesdk::FaceSDK::getDetectEngine("BaseNnetDetector", config);
facesdk::DetectionResult result = detector->detect(image);
std::cout << "Image orientation: " << result.orientation << " degrees" << std::endl;
for (auto& face : result.faces) {
std::cout << "Face characteristics: " << face << std::endl;
}
config = sdk.InitConfig.createConfig(os.path.join(IDLIVEFACE_HOME, "data/detection/ssd/ssd_new.conf"))
image = sdk.Image.createImage(os.path.join(IDLIVEFACE_HOME, "examples/images/real_face.jpg"))
detector = sdk.FaceSDK.getDetectEngine("BaseNnetDetector", config)
result = detector.detect(image)
print(f"Image orientation: {result.orientation} degrees")
for face in result.get_faces():
print(f"Face characteristics: {face}")
try (
InitConfig config = new InitConfig(IDLIVEFACE_HOME + "/data/detection/ssd/ssd_new.conf");
Image image = new Image(IDLIVEFACE_HOME + "/examples/images/real_face.jpg");
DetectEngine detector = new DetectEngine("BaseNnetDetector", config);
) {
DetectionResult result = detector.detect(image);
System.out.println("Image orientation: " + result.getOrientation() + " degrees");
for (FaceParameters face : result.getFaces()) {
System.out.println("Face characteristics: " + face);
}
}
var config = new InitConfig(Path.Combine(IDLIVEFACE_HOME, "data/detection/ssd/ssd_new.conf"));
var image = new Image(Path.Combine(IDLIVEFACE_HOME, "examples/images/real_face.jpg"));
var detector = new DetectEngine("BaseNnetDetector", config);
var result = detector.Detect(image);
Console.WriteLine($"Image orientation: {result.Orientation} degrees");
foreach (var face in result.Faces)
{
Console.WriteLine($"Face characteristics: {face}");
}
For every found face the detector collects the following characteristics:
- Bounding box with top-left and bottom-right points in pixels.
- Head pose with pitch, yaw and roll angles in degrees.
- Interpupillary distance in pixels.
- Face occlusion probability, ranging from 0 (not occluded) to 1 (occluded).
- Coordinates of 68 facial landmarks.