Java Face Detector Example

Initialize face detector model

import org.sertiscorp.oneml.face.*;
FaceDetector detector = new FaceDetector();

Initialize face detector model with licensing

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

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