arrow-left

All pages
gitbookPowered by GitBook
1 of 3

Loading...

Loading...

Loading...

Android

hashtag

Interactions with the Oz API Server

hashtag
Retrofit API

SDK contains IOzForensicsAPI interface describing APO net calls that can be used to create a Retrofit instance.

This interface uses a gson-converter and operates classes from the com.ozforensics.liveness.sdk.api.model pack.

Apart from this, the interface specifies a static method for creating a default Retrofit instance (without logging, interceptors and with 15-second timeouts). This instance will look for the server at the specified address:

hashtag
OzForensicsService Class

SDK includes the OzForensicsService class that uses a Retrofit instance from OzForensicsAPI.create(). This class wraps in net calls from the Retrofit interface and checks the presence of a token. When an auth request is performed, the token is stored automatically for internal goals. Also, the required metadata is added where necessary when performing the net requests (creating a folder, uploading media data to be analyzed). The method calls of this class are asynchronous (the StatusListener<> interface is used). You can obtain an instance of this class as follows:

If the TOKEN parameter value is set to null, authorization is required before performing any API call (except auth):

After a successful request, onSuccessCallback is performed so that the access token can be transferred with AuthResponse.

OzForensicsAPI apiService = OzForensicsAPI.Factory.create(BASE_URL);
OzForensicsService service = OzForensicsService(BASE_URL, ACCESS_TOKEN);
service.auth(EMAIL, PASSWORD, listener);
val apiService = OzForensicsAPI.create(BASE_URL)
val service = OzForensicsService(BASE_URL, ACCESS_TOKEN)
service.auth(EMAIL, PASSWORD, listener)

Uploading and Analyzing Media

hashtag
Server-Based Analyzes

Data to be uploaded and analyzed is stored in object sdkMediaResult, obtained after capturing and recording video. Upload it to the server and initiate required analyses via Oz API.

A simple scenario of interaction with Oz API can be implemented with theuploadMediaAndAnalyze method as described below.

val statusListener = object: StatusListener<List<OzAnalysisResult>> {

hashtag
On-Device Analyzes

To run the on-device analyses instead of server-based, use the following methods:

override fun onStatusChanged(status: String?) { /*your code for showing status message*/ }
override fun onSuccess(result:List <OzAnalysisResult>) { /*your code to handle analysis result*/ }
override fun onError(error: OzException) { /*your code to handle analysis error*/ }
}
val analysisCancelable = OzLivenessSDK.uploadMediaAndAnalyze(
mediaList,
listOf(OzAnalysis.QUALITY, OzAnalysis.BIOMETRY),
statusListener
)
StatusListener<List<OzAnalysisResult>> statusListener = new StatusListener<List<OzAnalysisResult>>() {
            @Override public void onStatusChanged(@Nullable String s) { /*your code for showing status message*/
            @Override public void onSuccess(List<OzAnalysisResult> result) { /* your code to handle analysis result 
            @Override public void onError(@NonNull OzException e) { /* your code to handle analysis error */
        };
        Cancelable analysisCancelable = OzLivenessSDK.INSTANCE.uploadMediaAndAnalyze(
            mediaList,
            Arrays.asList(OzAnalysis.QUALITY, OzAnalysis.BIOMETRY),
            statusListener
        );
OzLivenessSDK.runOnDeviceLivenessAnalysis(mediaList)
OzLivenessSDK.runOnDeviceBiometryAnalysis(mediaList)
OzLivenessSDK.INSTANCE.runOnDeviceLivenessAnalysis(mediaList);
OzLivenessSDK.INSTANCE.runOnDeviceBiometryAnalysis(mediaList);
}
*/
}
}