| class info |
| com.huawei.hms.mlsdk.document.MLDocumentAnalyzer |
Represents the document analyzer, which detects document information (MLDocument) in images of documents by calling the cloud API. An on-device document analyzer can be created in either of the following ways: 1. Default mode: MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer(). The system automatically identifies languages without verifying the certificate fingerprint. 2. Customized mode: MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer(MLDocumentSetting setting).You can set the languages to be detected and whether to enable certificate fingerprint verification. |
- // Create a document recognizer that uses the default configuration.
- MLDocumentAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer();
- Create an MLFra**MLFrame**sing the bitmap.
- MLFrame frame = MLFrame.fromBitmap(bitmap);
- // Create a document detection task.
- Task<MLDocument> task = analyzer.asyncAnalyseFrame(frame);
- task.addOnSuccessListener(new OnSuccessListener<MLDocument>() {
- public void onSuccess(MLDocument document) {
- // Detection success.
- }
- }).addOnFailureListener(new OnFailureListener() {
- public void onFailure(Exception e) {
- // Detection failure.
- }
- });
| Return type | Method name |
| com.huawei.hmf.tasks.Task<MLDocument> | asyncAnalyseFrame(MLFrame frame) |
| void | close()throws IOException |
| void | stop()throws IOException |
| Method |
| public com.huawei.hmf.tasks.Task<MLDocument> asyncAnalyseFrame(MLFrame frame) |
| Detects document information in an input image. |
Parameters
| Parameter name | Parameter desc |
| frame | Image to be detected. |
Return
| Type | desc |
| com.huawei.hmf.tasks.Task<MLDocument> | Returns the asynchronous task that encapsulates the detection result. |
| Method |
| public void close() throws IOException |
| Releases resources, including input and output streams. |
Throws
| Exception name | Exception desc |
| IOException | Exception that occurs in the input and output streams during resource release. |
| Method |
| public void stop() throws IOException |
| Releases resources, including input and output streams. |
Throws
| Exception name | Exception desc |
| IOException | Exception that occurs in the input and output streams during resource release. |