C# Face Id Example

Initialize faceID model

using OneML.Face;

FaceEmbedder embedder = new FaceEmbedder();
FaceId faceId = new FaceId(embedder);

Initialize faceID model with licensing

using OneML.Face;
LicenseManager licenseManager = new LicenseManager();
licenseManager.SetKey("LICENSE_KEY_VALUE_HERE");
licenseManager.ActivateKey();
FaceEmbedder embedder = new FaceEmbedder(licenseManager);
FaceId faceId = new FaceId(embedder, licenseManager);

Initialize oneML’s Utils

Utils utils = new Utils();

Initialize oneML’s Utils with licensing

Utils utils = new Utils(licenseManager);

Read input as oneML’s Image

Image img1 = utils.ReadImageCV(path1);
Image img2 = utils.ReadImageCV(path2);

Run the model for verification

bool same1 = faceId.IsTheSamePerson(img1, img2);

Run the model for identification

FaceIdResult result = faceId.Predict(img);

And get the output

int status = result.GetReturnStatus();
bool isIdentifiable = result.IsIdentifiable();
String id = result.GetId();
float nearestDistance = result.GetNearestNodeDistance();
float combinedDistance = result.GetCombinedDistance();

Cleanup

embedder.Dispose();
faceId.Dispose();
utils.Dispose();

or wrap the application with

using (FaceEmbedder embedder = new FaceEmbedder())
using (FaceId faceId = new FaceId())
using (Utils utils = new Utils())
{
// use embedder, faceId, utils here
}