ICvBasepublic interface ITextDetector extends ICvBase
Text can be extracted from screenshots with simple or complex backgrounds, from in-focus shots on documents, and from lighting shots on billboards, road signs, product packaging, and more.
Currently, the maximum width and height of a screenshot that can be captured by OCR are 2200 px and 15210 px, respectively. If the image size is out of range, the error code 200 is returned.
Currently, screenshot OCR can recognize text only in Chinese and English.
The recommended resolution for snapshots is greater than 720 px, and the recommended length-to-width ratio is less than 2:1. If an input image is not of the recommended size, text recognition may not be as accurate as expected.
This interface provides two process modes. The MODE_IN mode indicates that the SDK directly invokes
the OCR function in the caller process. The MODE_OUT mode indicates that the SDK functions as a client
to send a calling request to the HUAWEI HiAI Engine, which performs OCR and returns the result to the caller.
This interface also provides two block modes. In synchronous mode, the calling is blocked in the
detect method until the OCR processing is complete. In asynchronous mode, the detect method is
returned immediately, and the OCR processing result is returned to the caller in callback mode.
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
detect(VisionImage image,
Text result,
VisionCallback<Text> visionCallBack) |
Performs general text recognition on a given image and returns the result code.
|
void |
setVisionConfiguration(TextConfiguration textConfiguration) |
Sets parameters for general text recognition.
|
getAvailability, loadPlugin, prepare, releaseint detect(VisionImage image, Text result, VisionCallback<Text> visionCallBack)
Currently, the maximum width and height allowed for a screenshot are 2200 px and 15210 px, respectively. The recommended resolution for snapshots is greater than 720 px, and the recommended length-to-width ratio is less than 2:1.
image - Indicates an input image.result - Indicates the text result after OCR in synchronous mode.visionCallBack - Indicates the callback class to use.
detect is called synchronously, and the text after OCR
is output from the result parameter.detect is called asynchronously, and the result
parameter should be null. When the asynchronous call is successful, the text after OCR can be
obtained from onResult, or an error code is passed from onError.HwHiAIResultCode.AIRESULT_SUCCESS if the synchronous call is successful;
returns an error code otherwise.
Returns HwHiAIResultCode.AIRESULT_ASYNC_MODE if the asynchronous call is successful;
returns an error code if any input parameter is invalid.
For more information, see HwHiAIResultCode.
void setVisionConfiguration(TextConfiguration textConfiguration)
textConfiguration - Indicates the parameters to set, including region of interest (ROI),
text level to return, and OCR engine type.