| class info |
| com.huawei.hms.mlsdk.document.MLDocumentAnalyzer |
文档检测器:通过调用云端API接口检测文档图像中的文档信息(MLDocument)。 创建设备端图像检测器有两种方式: 1、默认方式:MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer(),默认情况下系统自动识别语种,不校验证书指纹。 2、自定义方式:MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer( MLDocumentSetting setting),用户可设置检测语种和是否校验证书指纹。 |
- // 创建使用默认配置的图像文档分析器
- MLDocumentAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer();
- // 通过Bitmap创建MLFrame
- MLFrame frame = MLFrame.fromBitmap(bitmap);
- // 创建文档检测任务
- Task<MLDocument> task = analyzer.asyncAnalyseFrame(frame);
- task.addOnSuccessListener(new OnSuccessListener<MLDocument>() {
- public void onSuccess(MLDocument document) {
- // 检测成功
- }
- }).addOnFailureListener(new OnFailureListener() {
- public void onFailure(Exception e) {
- // 检测失败
- }
- });
| 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) |
| 从输入的图像中检测文档信息。 |
Parameters
| Parameter name | Parameter desc |
| frame | 待检测图像。 |
Return
| Type | desc |
| com.huawei.hmf.tasks.Task<MLDocument> | 返回封装了检测结果的异步任务。 |
| Method |
| public void close() throws IOException |
| 释放资源,包括释放输入输出流等资源。 |
Throws
| Exception name | Exception desc |
| IOException | 释放资源过程中产生的输入流、输出流异常。 |
| Method |
| public void stop() throws IOException |
| 释放资源,包括释放输入输出流等资源。 |
Throws
| Exception name | Exception desc |
| IOException | 释放资源过程中产生的输入流、输出流异常。 |