Development Guide
This page contains the information of Usage, Configuration, Result of OkayDoc for Android and iOS
Usage
For Android, a valid license key is required to start the process.
Configuration
Build the configuration object with the following Config properties listed below:
Config
Possible Input Range
Default
path
String
null
faceThreshold
between 0.0 and 1.0
0.9
eyeThreshold
between 0.0 and 1.0
0.5
Config config = new Config.Builder()
                .setImagePath(imagePath)
                .setFaceThreshold(0.9f)
                .setEyeThreshold(0.5f)
                .build();SDK Initialization
 Start the process by calling startDetection on FaceDetectorSDK as shown below. You must also pass a valid license string and a config into it.
FaceDetectorSDK.startDetection(this, licenseKey, config, new FaceDetectorResultListener() {
    @Override
    public void onResultReceived(boolean successful, int errorCode, FaceAttr result) {
        if (successful) {
            // handle result
        }
        else {
            // handle error
        }
    }
});Result
Name
Description
getFaceImage
face image
isFaceDetected
returns true if face detected
isEye1Detected
returns true if first eye is detected
isEye2Detected
return true if second eye is detected
Error Code
 errorCode is an int which can have the following values:
Error Code
Constant Name
Description
-1
FaceError.NO_ERROR
Face is successfully detected
1
FaceError.ERROR_INVALID_LICENSE_KEY
The license is invalid
2
FaceError.ERROR_PERMISSION_DENIED
The user did not grant the permission to access camera
3
FaceError.ERROR_USER_CANCEL_ACTION
The user canceled during the scanning process
4
FaceError.ERROR_TIME_OUT
10 seconds timer is triggered when face is detected
Usage
Start by adding the NSCameraUsageDescription to your info.plist.
import FaceDetector module into your swift file.
import FaceDetectorConfiguration
Build the configuration object with the following Config properties listed below:
Config
Possible Input Range
Default
path
String
nil
faceThreshold
between 0.0 and 1.0
0.9
eyeThreshold
between 0.0 and 1.0
0.5
let config = Config.Builder()
        .setPath(imagePath)
        .setFaceThreshold(0.9)
        .setEyeThreshold(0.5)
        .build()SDK Initialization
Start the process by calling startDetection on FaceDetectorSDK as shown below. You must also pass a valid license string and a reference to your view controller. self refers to the current view controller in this example below:
FaceDetectorSDK.startDetection(
    viewController: self,
    license: license,
    config: config
)
{ success, errorCode, result in
    if(success) {
        // handle success
    } else {
        // handle error
    }
}Result
Name
Description
faceImage
face image
faceDetected
returns true if face detected
eye1Detected
returns true if first eye is detected
eye2Detected
return true if second eye is detected
Error Handling
The error received in the completion handler is of the type FaceError:
public enum FaceError: Error {
    // Error due to invalid parameter value in config object.
    case invalidConfig(_ msg: String)
    
    // Any other errors.
    case miscellaneous(_ msg: String)
    
    // Error due to user clicking cancel and going back.
    case userCancelled
    
    // Error due to invalid license usage.
    case invalidLicense
    
    // No error at all.
    case noError
    
    // Error due to camera permission denied by user.
    case cameraPermission
    
    // image file not found
    case invalidImage
    
    // Timeout error
    case timeout
}Usage
Import plugin by using the code below:
import { detectFaceWithImage, detectFaceWithVideo } from 'react-native-innov8tif-face-detector';Configurations
license
license key
empty
base64
return base64 string as image ouput
false
path
image file path
nil
faceThreshold
face threshold
0.9
eyeThreshold
eye threshold
0.5
Code Implementation
Detect face with video processing
detectFaceWithVideo({
    license: licenseKey,
    base64: true,
    faceThreshold: 0.5,
    eyeThreshold: 0.5
})
    .then(result => {
        console.log(result)
    })
    .catch(error => {
        console.log(error)
    })Detect face with image processing
detectFaceWithImage({
    license: licenseKey,
    base64: true,
    path: <imagePath>
    faceThreshold: 0.5,
    eyeThreshold: 0.5
})
    .then(result => {
        console.log(result)
    })
    .catch(error => {
        console.log(error)
    })Result
faceImage
face image output
isFaceDetected
return true if face is detected
isEye1Detected
return true if eye 1 is detected
isEye2Detected
return true if eye 2 is detected
Error Codes
invalid license
The license is invalid
camera permission denied
The user did not grant the permission to access camera
cancel
The user canceled during the scanning process
timeout
Timeout due to face not detected within preset timer
Last updated
Was this helpful?
