How to Implement Text Capture with User Interface
Note: Before you begin, see How to Add the Library to Your Xcode Project.
- Add the NSCameraUsageDescription and NSPhotoLibraryUsageDescription keys into the info.plist file for requesting access to the device’s camera and to the user’s photo library.
- Create an instance of the AUICaptureController interface for managing user interface and starting capture scenario. On this step you can use the properties of this interface to tune the user interface appearance and the settings of the camera.
- To get access to the processing mechanisms for the chosen scenario create an RTREngine object using the sharedEngineWithLicenseData: method. The method requires an NSData object containing your license data. For example, you can use dataWithContentsOfFile: to create a data object, then pass this object to the sharedEngineWithLicenseData: method.
- Create an instance of an interface inherited from the AUICaptureScenario for managing the capture scenario. Choose the inherited interface for the data capture scenario: AUIDataCaptureScenario interface. Pass the previously created RTREngine object as an input parameter to the constructor.
- Configure capture process, using the AUIImageCaptureSettings protocol and the AUIDataCaptureSettings interface. These objects are read-only, so you should change necessary settings via the dataCaptureSettings and the imageCaptureSettings properties of the AUIDataCaptureScenario interface.
- Configure the capture of an image via the imageCaptureSettings property. I.e. you can set a document size and a minimum document to view ratio.
- Configure the data capture via the dataCaptureSettings property. Set the profile property to a "Text" NSString value to set the scenario type. The parameter is case sensitive.
Tune scenario settings using properties of the AUIDataCaptureSettings interface if necessary. I.e., you can set recognition languages and an area of interest. All settings are optional.
Call the checkAndApply: method to check the properties consistence and apply the settings to the data capture scenario. - Implement the delegate interface, corresponding to the scenario object, and its methods. I.e. for AUIDataCaptureScenarioDelegate interface you should implement these methods:
- The dataCaptureScenario:didFinishWithResult: method returns the recognized result as an AUIDataCaptureScenarioResult object
- The dataCaptureScenario:didFailWithError: method delivers error messages
- The dataCaptureScenarioDidCancel: method notifies that the scenario was canceled.
- Add the instance of the interface as a delegate property of the AUIDataCaptureScenario object.
- Set the created scenario object as a captureScenario property of the AUICaptureController object. Scenario will start immediately at the camera start.
- If any error occurs while processing, the capture scenario becomes temporary passive and the paused property of the AUICaptureController object is set to true.
- Process the messages sent by scenario to the delegate object. The result will be delivered as an AUIDataCaptureScenarioDelegate object, storing the AUIDataCaptureScenarioResult object.
02.03.2022 12:59:15