Java Face Id Example¶
Initialize faceID model
import org.sertiscorp.oneml.face.*;
FaceEmbedder embedder = new FaceEmbedder();
FaceId faceId = new FaceId(embedder);
Initialize faceID model with licensing
import org.sertiscorp.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 BufferedImage
BufferedImage img1 = getImage(path1);
BufferedImage img2 = getImage(path2);
Read input as oneML’s Image
Image img1 = utils.readImageCV(path1);
Image img2 = utils.readImageCV(path2);
Run the model for verification
boolean same1 = faceId.isTheSamePerson(img1, img2);
Run the model for identification
FaceIdResult result = faceId.predict(img);
And get the output
int status = result.getReturnStatus();
boolean isIdentifiable = result.isIdentifiable();
String id = result.getId();
float nearestDistance = result.getNearestNodeDistance();
float combinedDistance = result.getCombinedDistance();
Cleanup
embedder.delete();
faceId.delete();
utils.delete();