目录

class info
com.huawei.hms.mlsdk.card.icr.cloud.MLRemoteIcrAnalyzer

On-cloud ID card (second-generation ID card of Chinese mainland residents) recognition analyzer, which is used to recognize ID card information in the supplied image, and call the on-cloud API (the detection model runs on the cloud).You can create an on-cloud ID card recognition analyzer in either of the following ways based on the site requirements:  

// Method 1: Use default parameter settings. MLRemoteIcrAnalyzer analyzer = MLCardAnalyzerFactory.getInstance().getRemoteIcrAnalyzer();

// Method 2: Use customized parameter settings. MLRemoteIcrAnalyzer analyzer = MLCardAnalyzerFactory.getInstance().getRemoteIcrAnalyzer(setting);

Sample Code

  1. // Method 1: Use default parameter settings.
  2. MLRemoteIcrAnalyzer analyzer = MLCardAnalyzerFactory.getInstance().getRemoteIcrAnalyzer();
  3. // Method 2: Use customized parameter settings.
  4. // setsetSideTyperont or back side of an ID card.
  5. // MLRMLRemoteIcrAnalyzerSetting.FRONThe value is FROFRONTndicating the front side.
  6. // MLRMLRemoteIcrAnalyzerSetting.BACKhe value is BACBACKndicating the back side.
  7. MLRemoteIcrAnalyzerSetting settings = new MLRemoteIcrAnalyzerSetting.Factory()
  8.   .setSideType(MLRemoteIcrAnalyzerSetting.FRONT)
  9.   .create();
  10. MLRemoteIcrAnalyzer analyzer = MLCardAnalyzerFactory.getInstance().getRemoteIcrAnalyzer(settings);
  11. // Construct MLFMLFrame using the bitmap.It is recommended that the image size be greater than or equal to 512 x 512.
  12. MLFrame mlFrame = new MLFrame.Creator().setBitmap(bitmap).create();
  13. // Recognize information from an ID card.
  14. Tasktask = analyzer.asyncAnalyseFrame(mlFrame);
  15. task.addOnSuccessListener(new OnSuccessListener() {
  16.   public void onSuccess(MLIdCard idCard) {
  17.       // Processing logic for recognition success.
  18. }})
  19. .addOnFailureListener(new OnFailureListener() {
  20.   public void onFailure(Exception e) {
  21.       // Processing logic for failure.
  22. }});

Public Method Summary

Return typeMethod name
com.huawei.hmf.tasks.Task<MLIdCard>asyncAnalyseFrame(final MLFrame frame)
voidstop()
MLRemoteIcrAnalyzercreate(MLApplication app, mlsdk.card.icr.cloud.MLRemoteIcrAnalyzerSetting setting)

Public Methods

Method
public com.huawei.hmf.tasks.Task<MLIdCard> asyncAnalyseFrame(final MLFrame frame)
Recognizes ID card information in a supplied image.

Parameters

Parameter nameParameter desc
frameImage object to be recognized, which can be a bitmap.

Return

Typedesc
com.huawei.hmf.tasks.Task<MLIdCard>Returns the asynchronous task object.
Method
public void stop()
Releases resources, including input and output streams.
Method
 public static synchronized MLRemoteIcrAnalyzer create(MLApplication app, MLRemoteIcrAnalyzerSetting setting)
Creates an on-cloud ID card recognition analyzer object.

Parameters

Parameter nameParameter desc
appMLApplication instance.
settingID card recognition configurator instance.


Return

Typedesc
MLRemoteIcrAnalyzerReturns an on-cloud ID card recognition analyzer object.