目录

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.

Sample Code

  1. // Create a document recognizer that uses the default configuration.
  2.    MLDocumentAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteDocumentAnalyzer();
  3.    Create an MLFra**MLFrame**sing the bitmap.
  4.    MLFrame frame = MLFrame.fromBitmap(bitmap);
  5. // Create a document detection task.
  6.    Task<MLDocument> task = analyzer.asyncAnalyseFrame(frame);
  7.    task.addOnSuccessListener(new OnSuccessListener<MLDocument>() {
  8.    public void onSuccess(MLDocument document) {
  9.      // Detection success.
  10.    }
  11. }).addOnFailureListener(new OnFailureListener() {
  12.    public void onFailure(Exception e) {
  13.      // Detection failure.
  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)
Detects document information in an input image.

Parameters

Parameter nameParameter desc
frameImage to be detected.

Return

Typedesc
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 nameException desc
IOExceptionException 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 nameException desc
IOExceptionException that occurs in the input and output streams during resource release.