C# Face Landmark Example¶
Initialize face landmark model
using OneML.Face;
FaceLandmarkDetector landmarkDetector = new FaceLandmarkDetector();
Initialize face landmark model with licensing
using OneML.Face;
LicenseManager licenseManager = new LicenseManager();
license_manager.SetKey("LICENSE_KEY_VALUE_HERE");
license_manager.ActivateKey();
FaceLandmarkDetector landmarkDetector = new FaceLandmarkDetector(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
// landmarks is Landmark5List, we can get landmarks from FaceDetectorResult
FaceLandmarkResultList results = landmarkDetector.Detect(batch, landmarks, true);
or
// landmark is Landmark5, we can get landmark from FaceDetectorResult
FaceLandmarkResult result = detector.Detect(img, landmark, true);
And get the output
Landmark106 landmarks = output.GetLandmarks();
int status = output.GetReturnStatus();
Cleanup
landmarkDetector.Dispose();
utils.Dispose();
or wrap the application with
using (FaceLandmarkDetector landmarkDetector = new FaceLandmarkDetector())
using (Utils utils = new Utils())
{
// use landmarkDetector, utils here
}