Java Face Landmark Example

Initialize face landmark model

import org.sertiscorp.oneml.face.*;
FaceLandmarkDetector landmarkDetector = new FaceLandmarkDetector();

Initialize face landmark model with licensing

import org.sertiscorp.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 BufferedImage

BufferedImage img = ImageIO.read(file);
List<BufferedImage> imgs = Arrays.asList(img);
ImageBatch batch = new ImageBatch().add(imgs);

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.delete();
utils.delete();