文档管理中心

此版本文档已归档不再维护,推荐您使用最新版本

API参考机器学习服务mlsdk.cardmlplugin.card.gcrMLGcrCapture

MLGcrCapture

class info
com.huawei.hms.mlplugin.card.gcr.MLGcrCapture
通用卡证识别处理类。

Public Method Summary

Public Methods

Method
public void captureImage(android.graphics.Bitmap bitmap, Object object, MLGcrCapture.Callback callback)
启用通用卡证静态图片识别插件。

Parameters

Parameter nameParameter desc
bitmap静态图片。
object用户传递的保留字段。
callback识别结果回调。

Sample Code

  1. // 创建通用卡证识别配置器。
  2. MLGcrCaptureConfig config = new MLGcrCaptureConfig.Factory().create();
  3. MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(config);
  4. ocrManager.captureImage(bitmap, object, callback);
Method
public void capturePhoto(android.content.Context context, Object object, MLGcrCapture.Callback callback)
启用通用卡证拍照识别插件。

Parameters

Parameter nameParameter desc
contextActivity或Application上下文。
object用户传递的保留字段。
callback识别结果回调。

Sample Code

  1. // 创建通用卡证识别配置器。
  2. MLGcrCaptureConfig cardConfig = new MLGcrCaptureConfig.Factory().create();
  3. // 创建通用卡证识别界面配置器。
  4. MLGcrCaptureUIConfig uiConfig = new MLGcrCaptureUIConfig.Factory()
  5.     // 设置扫描框颜色。
  6.     .setScanBoxCornerColor(Color.GREEN)
  7.     // 设置扫描框中的提示文字,建议少于30个字符。
  8.     .setTipText("Recognizing, align edges")
  9.     // 设置界面横竖屏,支持三种模式:
  10.     // MLGcrCaptureUIConfig.ORIENTATION_AUTO:自动模式,由物理感应器决定显示方向。
  11.     // MLGcrCaptureUIConfig.ORIENTATION_LANDSCAPE:横屏模式,显示时屏幕宽度大于高度。
  12.     // MLGcrCaptureUIConfig.ORIENTATION_PORTRAIT:竖屏模式,显示时屏幕高度大于宽度。
  13.     .setOrientation(MLGcrCaptureUIConfig.ORIENTATION_AUTO)
  14.     .create();
  15. // 方式一:根据自定义的卡证识别界面配置器,创建通用卡证识别处理器。
  16. MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig, uiConfig);
  17. // 方式二:使用默认界面,创建通用卡证识别处理器。
  18. MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig);
  19. // 绑定通用卡证识别器和识别结果回调方法。
  20. ocrManager.capturePhoto(this, object, callback);
Method
public void capturePreview(android.content.Context context, Object object, MLGcrCapture.Callback callback)
启用通用卡证视频帧识别插件。

Parameters

Parameter nameParameter desc
contextActivity或Application上下文。
object用户传递的保留字段。
callback识别结果回调。

Sample Code

  1. // 创建通用卡证识别配置器。
  2. MLGcrCaptureConfig cardConfig = new MLGcrCaptureConfig.Factory().create();
  3. // 创建通用卡证识别界面配置器。
  4. MLGcrCaptureUIConfig uiConfig = new MLGcrCaptureUIConfig.Factory()
  5.     // 设置扫描框颜色。
  6.     .setScanBoxCornerColor(Color.GREEN)
  7.     // 设置扫描框中的提示文字,建议少于30个字符。
  8.     .setTipText("Recognizing, align edges")
  9.     // 设置界面横竖屏,支持三种模式:
  10.     // MLGcrCaptureUIConfig.ORIENTATION_AUTO:自动模式,由物理感应器决定显示方向。
  11.     // MLGcrCaptureUIConfig.ORIENTATION_LANDSCAPE:横屏模式,显示时屏幕宽度大于高度。
  12.     // MLGcrCaptureUIConfig.ORIENTATION_PORTRAIT:竖屏模式,显示时屏幕高度大于宽度。
  13.     .setOrientation(MLGcrCaptureUIConfig.ORIENTATION_AUTO)
  14.     .create();
  15. // 方式一:根据自定义的卡证识别界面配置,创建通用卡证识别器。
  16. MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig, uiConfig);
  17. // 方式二:使用默认界面,创建通用卡证识别器。
  18. MLGcrCapture ocrManager = MLGcrCaptureFactory.getInstance().getGcrCapture(cardConfig);
  19. // 绑定通用卡证识别器和识别结果回调方法。
  20. ocrManager.capturePreview(this, object, callback);


本页面可能包含由第三方许可的内容,请参考具体描述
在 API参考 中进行搜索
请输入您想要搜索的关键词