Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@145a5
sortmodified
showSpacefalse
reversetrue
typepage
cqllabel = "kb-how-to-article" and type = "page" and space = "TSD"
labelskb-how-to-article

Excerpt

To launch the Gini Capture SDK, do the following:

  1. Request camera access.

  2. Configure a new instance of GiniCapture.

  3. Launch CameraActivity.

  4. Handle the extraction results.

  5. Clean up the SDK by calling GiniCapture.cleanup() while also providing the required extraction feedback to improve future extraction accuracy.

The diagram below shows the interaction between your app and the SDK:

Drawio
mVer2
zoom1
simple0
inComment0
pageId2949214
custContentId2884089
lbox1
diagramDisplayNameUntitled Diagram-1675761818164.drawio
contentVer2
revision2
baseUrlhttps://gini.atlassian.net/wiki
diagramNameUntitled Diagram-1675761818164.drawio
pCenter0
width862
links
tbstyle
height380.5
Info

Check out the example app to see how an integration could look like.

The CameraActivity can return with the following result codes:

  • Activity.RESULT_OK

    Document was analyzed and the extractions are available in the EXTRA_OUT_EXTRACTIONS result extra. It contains a Bundle with the extraction labels as keys and GiniCaptureSpecificExtraction parcelables as values.

  • Activity.RESULT_CANCELED

    User has canceled Gini Capture SDK.

  • CameraActivity.RESULT_ERROR

    An error occured and the details are available in the EXTRA_OUT_ERROR result extra. It contains a parcelable extra of type GiniCaptureError detailing what went wrong.

  • CameraActivity.RESULT_ENTER_MANUALLY

    The document analysis finished with no results or an error and the user clicked the “Enter manually” button.

In the following example, you can see how to launch Gini Capture SDK and how to handle the results:

Code Block
languagekotlin
void launchGiniCapture() {
    // Make sure camera permission has been already granted at this point.

    // Check that the device fulfills the requirements.
    RequirementsReport report = GiniCaptureRequirements.checkRequirements((Context) this);
    if (!report.isFulfilled()) {
        handleUnfulfilledRequirements(report);
        return;
    }

    // Instantiate the networking implementations.
    GiniCaptureNetworkService networkService = ...

    // Configure GiniCapture and create a new singleton instance.
    GiniCapture.newInstance()
            .setGiniCaptureNetworkService(networkService)
            ...
            .build();

    // Launch the CameraActivity and wait for the result.
    Intent intent = new Intent(this, CameraActivity.class);
    startActivityForResult(intent, GINI_CAPTURE_REQUEST);
}

@Override
protected void onActivityResult(final int requestCode, final int resultCode,
        final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GINI_CAPTURE_REQUEST) {
        switch (resultCode) {
            case Activity.RESULT_CANCELED:
                GiniCapture.cleanup(this, "", "",
                            "", "","", Amount.EMPTY);
                break;

            case Activity.RESULT_OK:
                // Retrieve the extractions
                Bundle extractionsBundle = data.getBundleExtra(
                        CameraActivity.EXTRA_OUT_EXTRACTIONS);

                // Retrieve the extractions from the extractionsBundle
                Map<String, GiniCaptureSpecificExtraction> extractions = new HashMap<>();
                for (String extractionLabel : extractionsBundle.keySet()) {
                    GiniCaptureSpecificExtraction extraction = extractionsBundle.getParcelable(extractionLabel);
                    extractions.put(extractionLabel, extraction);
                }
                handleExtractions(extractions);

                break;

            case CameraActivity.RESULT_ERROR:
                // Something went wrong, retrieve and handle the error
                final GiniCaptureError error = data.getParcelableExtra(
                        CameraActivity.EXTRA_OUT_ERROR);
                if (error != null) {
                    handleError(error);
                }
                GiniCapture.cleanup(this, "", "",
                        "", "","", Amount.EMPTY);
                break;

            case CameraActivity.RESULT_ENTER_MANUALLY:
                handleEnterManually();
                GiniCapture.cleanup(this, "", "",
                        "", "","", Amount.EMPTY);
                break;
        }
    }
}

void stopGiniCaptureSDK() {
    // After the user has seen and potentially corrected the extractions
    // cleanup the SDK while passing in the final extraction values
    // which will be used as feedback to improve the future extraction accuracy:
    GiniCapture.cleanup((Context) this,
            paymentRecipient,
            paymentReference,
            paymentPurpose,
            iban,
            bic,
            amount
        )
}