Skip to content

regulaforensics/DocumentReader-web-java-client

Repository files navigation

Regula Document Reader java client compatible with jvm and android

maven OpenAPI documentation live

Documents recognition as easy as reading two bytes.

If you have any problems with or questions about this client, please contact us through a GitHub issue. You are invited to contribute new features, fixes, or updates, large or small; We are always thrilled to receive pull requests, and do our best to process them as fast as we can. See dev guide

Install package

Add Regula Forensics, Inc. maven repository to repositories section in your build.gradle, and declare client as regular dependency.

repositories {
    maven {
        url = uri("https://maven.regulaforensics.com/RegulaDocumentReaderWebClient")
    }
}

dependencies {
    implementation("com.regula.documentreader:webclient:5.+")
}

Example

Performing request:

byte[] imageBytes = readFile("australia_passport.jpg");
var image = new ProcessRequestImage(imageBytes, Light.WHITE);

var requestParams = new RecognitionParams()
        .withScenario(Scenario.FULL_PROCESS)
        .withResultTypeOutput(Result.STATUS, Result.TEXT, Result.IMAGES);

RecognitionRequest request = new RecognitionRequest(requestParams, List.of(image));

var api = new DocumentReaderApi();
RecognitionResponse response = api.process(request);

Parsing results:

var status = response.status();
var docOverallStatus = status.getComplete() == CheckResult.OK ? "valid" : "not valid";
var docOpticalTextStatus = status.getDetailsOptical().getText();

var docNumberField = response.text().getField(DOCUMENT_NUMBER);
var docNumberMrz = docNumberField.getValue(Source.MRZ);
var docNumberMrzValidity = docNumberField.sourceValidity(Source.MRZ);
var docNumberMrzVisualMatching = docNumberField.crossSourceComparison(Source.MRZ, Source.VISUAL);

You can find a more detailed example in example folder.