Java Challenge Response ExampleΒΆ

Initialize Challenge Response module

import org.sertiscorp.oneml.face.*;
ChallengeResponse challenge = new ChallengeResponse();

Initialize Challenge Response module from existing FaceDetector and FaceLandmarkDetector

import org.sertiscorp.oneml.face.*;
FaceDetector faceDetector = new FaceDetector();
FaceLandmarkDetector faceLandmark = new FaceLandmarkDetector();
ChallengeResponse challenge = new ChallengeResponse(faceDetector, faceLandmark);

Initialize Challenge Response module with licensing

import org.sertiscorp.oneml.face.*;
LicenseManager licenseManager = new LicenseManager();
licenseManager.setKey("LICENSE_KEY_VALUE_HERE");
licenseManager.activateKey();
ChallengeResponse challenge = new ChallengeResponse(licenseManager);

Initialize Challenge Response module with licensing from existing FaceDetector and FaceLandmarkDetector

import org.sertiscorp.oneml.face.*;
LicenseManager licenseManager = new LicenseManager();
licenseManager.setKey("LICENSE_KEY_VALUE_HERE");
licenseManager.activateKey();

FaceDetector faceDetector = new FaceDetector(licenseManager);
FaceLandmarkDetector faceLandmark = new FaceLandmarkDetector(licenseManager);
ChallengeResponse challenge = new ChallengeResponse(faceDetector, faceLandmark, licenseManager);

Run the module from videos

String vidPath = "path/to/video.mp4";
ChallengeResponseOps ops = new ChallengeResponseOps(true);
ChallengeResponseResult result = challenge.run(vidPath, ops);

Run the module from stream of images (can be used with opencv VideoCapture)

# if we can still read frame from image stream
ChallengeResponseOps ops = new ChallengeResponseOps(true);
while (can_read_frame):
    # use any function to get each frame from image stream
    Image frame = getOneFrame()
    ChallengeResponseResult result = challenge.run(frame, ops)
challenge.reset()

Run the module with ImageBatch

// create ImageBatch
Utils utils = new Utils();

String vidPath = "path/to/video.mp4";
ImageBatch images = utils.videoToImages(vidPath);
ChallengeResponseOps ops = new ChallengeResponseOps(true);

// run ChallengeResponse with ImageBatch
ChallengeResponseResult result = challenge.run(images, ops);

Get result

System.out.println("status: " + result.getReturnStatus());
System.out.println("is_blink: " + result.isBlink());
System.out.println("number of blinks: " + result.getNumBlinks());
System.out.println("liveness_score: " + result.getLivenessScore());
Image bestFrame = result.getBestFrame();

Cleanup

faceDetector.delete();
faceLandmark.delete();
challenge.delete();