How to Implement One-Page 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.
- 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).
- Receive the CaptureView class object from your layout inside the onCreate Activity or onViewCreated Fragment.
- Override the onResume and onPause methods, embedding the UI components methods:
- add startCamera method to the onResume method;
- add stopCamera method to the onPause method.
- 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 activity.
- Create the ImageCaptureScenario object, passing the created Engine object to its constructor, to connect the user interface and recognition parts.
- Implement the Callback interface. Create the Callback object with the ImageCaptureScenario.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 onImageCaptured method returns the image as a Result object;
- the onError method is for handling processing errors.
- Use the CaptureView.setCaptureScenario method to set the capture scenario.
Note: Currently only Mobile Imaging scenario is supported. - Start performing the scenario with the start method of the ImageCaptureScenario object.
- Wait for the response or an error in the callback.
See the description of classes and methods in the User Interface API Reference section.
3/2/2022 12:59:15 PM