How to Implement Multipage Image 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 image 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. Multipage image 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 a Builder class object. Via this object the MultiPageImageCaptureScenario object will be created on the next step. Pass to the Builder the created Engine object and Context. Passing Context to the constructor will set a default internal path for image files storage.
  6. The Builder class object provides various methods for flexible tuning of your application. I.e., depending on your application goal you can tune the presets of the scenario user interface and image count requirements:
    • use the setRequiredPageCount method of the Builder object for fixing an exact number of images to be captured or allow unlimited image capture;
    • to customize interface string resources, do the following:
  7. When the Builder class object is tuned, create the MultiPageImageCaptureScenario object via the build method.
  8. Implement the Callback interface. 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 onFinished method returns Result object, which methods for provide access to the captured images and corresponding metadata;
    • the onClose method is for capture scenario should be stopped by user;
    • the onError method is for handling errors.
  9. Use the CaptureView.setCaptureScenario method to set the image capture scenario.
  10. The scenario is started automatically by default. You may delay it with stop method and then start it with start method. If you want to delay the start, use the MultiPageImageCaptureScenario.stop method to stop the automatically started scenario and then start it with MultiPageImageCaptureScenario.start method.
  11. Wait for the response or an error in the callback. If scenario is stopped by user on tapping "Cancel", onClose method will be called. If "Done" button was tapped, onFinished method will be called.

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.