C# Face Detector Example¶
Initialize face detector model
using OneML.Face;
FaceDetector detector = new FaceDetector();
Initialize face detector model with licensing
using OneML.Face;
LicenseManager licenseManager = new LicenseManager();
licenseManager.SetKey("LICENSE_KEY_VALUE_HERE");
licenseManager.ActivateKey();
FaceDetector detector = new FaceDetector(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 img = utils.ReadImageCV(filePath);
Run the model
FaceDetectorResultList results = detector.Detect(batch);
or
FaceDetectorResult result = detector.Detect(img);
And get the output
FloatList scores = output.GetScores();
BBoxList bboxes = output.GetBBoxes();
Landmark5List landmarks = output.GetLandmarks();
FacePoseList poses = output.GetPoses();
int size = output.GetSize();
StatusCodeList statuses = output.GetReturnStatus();
Cleanup
detector.Dispose();
utils.Dispose();
or wrap the application with
using (FaceDetector detector = new FaceDetector())
{
// use detector here
}