目录

class info
com.huawei.hms.mlsdk.document.MLDocumentAnalyzer

文档检测器:通过调用云端API接口检测文档图像中的文档信息(MLDocument)。 创建设备端图像检测器有两种方式:

1、默认方式:MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer(),默认情况下系统自动识别语种,不校验证书指纹。

2、自定义方式:MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer( MLDocumentSetting setting),用户可设置检测语种和是否校验证书指纹。

Sample Code

  1. // 创建使用默认配置的图像文档分析器
  2. MLDocumentAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer();
  3. // 通过Bitmap创建MLFrame
  4. MLFrame frame = MLFrame.fromBitmap(bitmap);
  5. // 创建文档检测任务
  6. Task<MLDocument> task = analyzer.asyncAnalyseFrame(frame);
  7. task.addOnSuccessListener(new OnSuccessListener<MLDocument>() {
  8.    public void onSuccess(MLDocument document) {
  9.        // 检测成功
  10.    }
  11. }).addOnFailureListener(new OnFailureListener() {
  12.    public void onFailure(Exception e) {
  13.        // 检测失败
  14.    }
  15. });

Public Method Summary

Return typeMethod name
com.huawei.hmf.tasks.Task<MLDocument>asyncAnalyseFrame(MLFrame frame)
voidclose()throws IOException
voidstop() throws IOException

Public Methods

Method
public com.huawei.hmf.tasks.Task<MLDocument> asyncAnalyseFrame(MLFrame frame)
从输入的图像中检测文档信息。

Parameters

Parameter nameParameter desc
frame待检测图像。

Return

Typedesc
com.huawei.hmf.tasks.Task<MLDocument>返回封装了检测结果的异步任务。
Method
public void close() throws IOException
释放资源,包括释放输入输出流等资源。

Throws

Exception nameException desc
IOException释放资源过程中产生的输入流、输出流异常。
Method
public void stop() throws IOException
释放资源,包括释放输入输出流等资源。

Throws

Exception nameException desc
IOException释放资源过程中产生的输入流、输出流异常。