How to Implement Data Capture with User Interface

 Note: Before you begin, see Build your application with the library for Android.

Below you can find description of a basic data capture scenario with user interface components.

  1. Before you start, add the CaptureView class to the XML layout of your Activity or Fragment with default parameters. If you are implementing a non-English app, you can override the string resources of the user interface, using the attributes' IDs (see CaptureView attributes for details).
     Note: Please make sure, that you are using the Theme.AppCompat theme. Data capture scenario requires this theme for user interface implementation.
  2. Receive the CaptureView class object from your layout inside the onCreate Activity or onViewCreated Fragment.
  3. Override the onResume and onPause methods, embedding the UI components methods:
  4. Call the Engine.load method on the UI thread to create an engine object, required for all recognition mechanisms to work. This object should be reused for every new operation and should not be created again in the same application.
  5. Create the DataCaptureScenario object, passing the created Engine object to its constructor, to connect the user interface and recognition parts. Configure the capture scenario using the DataCaptureScenario object methods. I.e., you can enable or disable buttons visibility, localize source strings, etc.
  6. Configure capture process, using ImageCaptureSettings and DataCaptureSettings interface objects.
    • Create the ImageCaptureSettings object and configure the capture of an image. I.e. you can set a document size and a minimum document to view ratio.
    • Create the DataCaptureSettings object to configure the data capture process.
      • To use predefined recognition settings call the setProfile method and pass a profile name as a parameter to set the scenario type. See the list of the settings, influenced by the profile, in the Profile Presets section.
        The parameter is case sensitive.
      • Tune necessary data capture settings using methods of the DataCaptureSettings object. I.e., you can set recognition languages and an area of interest. All settings are optional.
      • Call the checkAndApply method of the DataCaptureSettings object to checks consistence of the properties' value and apply the settings to a capture scenario.
  7. Implement the Callback interface. Create the Callback object and set it to the scenario with the DataCaptureScenario.setCallback method. The methods of the callback will be used to get the result and monitor errors. Here are brief recommendations on what the methods should do:
    • the onDataCaptured method returns the Result object, providing access to a captured image with detected document boundary on it, to the recognized data and to additional information about the data;
    • the onError method is for handling processing errors.
  8. Use the CaptureView.setCaptureScenario method to set the capture scenario.
  9. The scenario will start automatically. If you want to delay the start, call the stop method. The start method of the DataCaptureScenario object will resume the scenario
  10. Wait for the response or an error in the callback.

See the description of classes and methods in the User Interface API Reference section.

02.03.2022 12:59:15

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.