Java Face Pad Example

Java PadRGB Example

Initialize pad RGB model

import org.sertiscorp.oneml.face.*;
FacePad padRgb = new FacePad(PadType.Rgb);

Initialize face detector model with licensing

import org.sertiscorp.oneml.face.*;
LicenseManager licenseManager = new LicenseManager();
licenseManager.setKey("LICENSE_KEY_VALUE_HERE");
licenseManager.activateKey();
FacePad padRgb = new FacePad(PadType.Rgb, 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 = ImageIO.read(imagePath);
ImageBatch batch1 = new ImageBatch().add(img1).add(img1);

Read input as oneML’s Image

Image img1 = utils.readImageCV(filePath1);

Run the model

FacePadResultList rgbResults = padRgb.classify(batch1);

or

FacePadResult rgbResult = padRgb.classify(img1);

And get the output

float spoofProb = output.getSpoofProb();
boolean isSpoof = output.isSpoof();
int status = output.getReturnStatus();

Cleanup

padRgb.delete();
utils.delete();

Java PadPaper Example

Initialize pad paper model

import org.sertiscorp.oneml.face.*;
FacePad padPaper = new FacePad(PadType.Paper);

Initialize pad paper model with licensing

import org.sertiscorp.oneml.face.*;
LicenseManager licenseManager = new LicenseManager();
licenseManager.setKey("LICENSE_KEY_VALUE_HERE");
licenseManager.activateKey();
FacePad padPaper = new FacePad(PadType.Paper, 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 img2 = ImageIO.read(imagePath);
ImageBatch batch2 = new ImageBatch().add(img2);

Read input as oneML’s Image

Image img2 = utils.readImageCV(filePath2);

Run the model

FacePadResultList paperResults = padPaper.classify(batch2);

or

FacePadResult paperResult = padPaper.classify(img2);

And get the output

float spoofProb = output.getSpoofProb();
boolean isSpoof = output.isSpoof();
int status = output.getReturnStatus();

Cleanup

padPaper.delete();
utils.delete();