目录

华为机器学习服务提供的最新SDK版本参见:ML Kit最新版本,该版本优化了各个服务的使用体验。

1.0.0.xxx升级到2.0.0.xxx

  1. dependencies{
  2.    implementation 'com.huawei.hms:ml-computer-vision-cloud:2.0.0.300'
  3. }

如果您只使用了云端图片分类、地标识别,您只需将集成的SDK基础依赖(com.huawei.hms:ml-computer-vision)修改为:

  1. dependencies{
  2.    implementation 'com.huawei.hms:ml-computer-vision-cloud:1.0.4.300'
  3. }

  1. dependencies{
  2.    // 如果集成多个模块,可以将各个模块一起添加。
  3.    implementation 'com.huawei.hms:ml-computer-vision-ocr:2.0.0.300'
  4.    implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
  5.    implementation 'com.huawei.hms:ml-computer-vision-object:1.0.4.300'
  6.    implementation 'com.huawei.hms:ml-computer-vision-face:1.0.4.300'
  7. }

第二步,如果您使用Full SDK方式集成了人脸检测服务,首先,需要将集成的能力包删除(com.huawei.hms:ml-computer-vision-face-recognition-model),然后,参考如下说明进行升级:

1. 如果您的应用使用了人脸检测服务的如下接口:

getEmotions()

您可以引入表情检测能力包:

  1. dependencies{
  2.    // 引入表情检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-emotion-model:1.0.4.300'
  4. }

2. 如果您的应用使用了人脸检测服务的如下接口:

getFeatures()

您可以引入特征检测能力包:

  1. dependencies{
  2.    // 引入特征检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-feature-model:1.0.4.300'
  4. }

3. 如果您的应用使用了人脸检测服务的如下接口:

getAllPoints()

getFaceKeyPoint(int keyPointType)

getFaceKeyPoints()

getFaceShape(int shapeType)

getFaceShapeList()

getRotationAngleX()

getRotationAngleY()

getRotationAngleZ()

您可以引入轮廓+关键点检测能力包:

  1. dependencies{
  2.    // 引入人脸轮廓+关键点检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-shape-point-model:1.0.4.300'
  4. }

4. 下述四个接口为基础接口,只要引入上述任一个或多个包即可支持。

getBorder()

getCoordinatePoint()

getHeight()

getWidth()

1.0.2.xxx升级到2.0.0.xxx

  1. dependencies{
  2.    implementation 'com.huawei.hms:ml-computer-vision-cloud:2.0.0.300'
  3. }
  1. dependencies{
  2.    implementation 'com.huawei.hms:ml-computer-vision-cloud:1.0.4.300'
  3. }
  1. dependencies{
  2.    // 如果集成多个模块,可以将各个模块一起添加。
  3.    implementation 'com.huawei.hms:ml-computer-vision-ocr:2.0.0.300'
  4.    implementation 'com.huawei.hms:ml-computer-vision-icr:1.0.4.300'
  5.    implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
  6.    implementation 'com.huawei.hms:ml-computer-vision-object:1.0.4.300'
  7.    implementation 'com.huawei.hms:ml-computer-vision-face:1.0.4.300'
  8.    implementation 'com.huawei.hms:ml-computer-vision-segmentation:1.0.4.301'
  9. }

第二步,

1. 如果您使用Full SDK方式集成了人脸检测服务,首先,需要将集成的能力包删除(com.huawei.hms:ml-computer-vision-face-recognition-model),然后,参考如下说明进行升级:

a. 如果您的应用使用了人脸检测服务的如下接口:

getEmotions()

您可以引入表情检测能力包:

  1. dependencies{
  2.    // 引入表情检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-emotion-model:1.0.4.300'
  4. }

b. 如果您的应用使用了人脸检测服务的如下接口:

getFeatures()

您可以引入特征检测能力包:

  1. dependencies{
  2.    // 引入特征检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-feature-model:1.0.4.300'
  4. }

c. 如果您的应用使用了人脸检测服务的如下接口:

getAllPoints()

getFaceKeyPoint(int keyPointType)

getFaceKeyPoints()

getFaceShape(int shapeType)

getFaceShapeList()

getRotationAngleX()

getRotationAngleY()

getRotationAngleZ()

您可以引入轮廓+关键点检测能力包:

  1. dependencies{
  2.    // 引入人脸轮廓+关键点检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-shape-point-model:1.0.4.300'
  4. }

d. 下述四个接口为基础接口,只要引入上述任一个或多个包即可支持。

getBorder()

getCoordinatePoint()

getHeight()

getWidth()

2. 如果您集成了身份证识别服务,您可以参考如下说明进行升级。

a. 如果您的应用使用了身份证识别服务的如下接口:

getIcrAnalyzer()

getIcrAnalyzer(MLIcrAnalyzerSetting setting)

MLIcrAnalyzerSetting

MLIcrAnalyzerSetting.Factory

MLIcrAnalyzer

您可以将集成的SDK基础依赖(com.huawei.hms:ml-computer-vision-icr)升级到最新版本,若集成了身份证识别能力包,需要将能力包升级到最新版本。

  1. dependencies{
  2.    // 引入基础SDK
  3.    implementation 'com.huawei.hms:ml-computer-vision-icr:1.0.4.300'
  4.    // 引入身份证识别能力包
  5.    implementation 'com.huawei.hms:ml-computer-card-icr-cn-model:1.0.4.300'
  6. }

说明:
推荐您集成身份证识别服务插件,插件提供图片质量较验、相机封装功能以及部分UI,可以助力您的应用便捷、高效、准确的识别身份证信息,集成可参见:集成身份证识别服务,客户端开发可参见:身份证识别服务客户端开发。

b. 如果您的应用使用了身份证识别服务的如下接口:

getRemoteIcrAnalyzer()

getRemoteIcrAnalyzer(MLRemoteIcrAnalyzerSetting setting)

MLRemoteIcrAnalyzer

MLRemoteIcrAnalyzerSetting

MLRemoteIcrAnalyzerSetting.Factory

您可以将集成的SDK基础依赖(com.huawei.hms:ml-computer-vision-cloud或com.huawei.hms:ml-computer-vision-icr)升级到最新版本:

  1. dependencies{
  2.    // 引入基础SDK
  3.    implementation 'com.huawei.hms:ml-computer-vision-cloud:1.0.4.300'
  4. }
说明:
推荐您集成身份证识别服务插件,插件提供图片质量较验、相机封装功能以及部分UI,可以助力您的应用便捷、高效、准确的识别身份证信息,集成可参见:集成身份证识别服务,客户端开发可参见:身份证识别服务客户端开发。

c. 如果您的应用使用了身份证识别服务的如下接口:

MLCnIcrCapture

MLCnIcrCapture.CallBack

MLCnIcrCaptureConfig

MLCnIcrCaptureConfig.Factory

MLCnIcrCaptureFactory

MLCnIcrCaptureResult

您可以删除集成的SDK基础依赖(com.huawei.hms:ml-computer-vision-cloud或com.huawei.hms:ml-computer-vision-icr)和质量检测插件(com.huawei.hms:ml-computer-card-qa-plugin),同时把身份证识别服务插件更新到最新版本,若您集成了身份证识别能力包,需要将能力包升级到最新版本。

  1. dependencies{
  2.    // 引入身份证识别plugin包
  3.    implementation ('com.huawei.hms:ml-computer-card-icr-cn-plugin:1.0.4.300') {
  4.        // 使用端侧能力时,可以排除云侧相关依赖,降低生成的APK包大小。如果您使用的是云端身份证识别能力,需要删除下面两行配置
  5.        exclude group: 'com.huawei.hms', module: 'ml-computer-net'
  6.        exclude group: 'com.huawei.hms', module: 'ml-computer-card-qa-plugin'
  7.        }
  8.    // 引入身份证识别能力包
  9.    implementation 'com.huawei.hms:ml-computer-card-icr-cn-model:1.0.4.300'
  10. }

1.0.3.xxx升级到2.0.0.xxx

如果您使用Full SDK方式集成了人脸检测服务,首先,需要将集成的能力包删除(com.huawei.hms:ml-computer-vision-face-recognition-model),然后,参考如下说明进行升级:

1. 如果您的应用使用了人脸检测服务的如下接口:

getEmotions()

您可以引入表情检测能力包:

  1. dependencies{
  2.    // 引入表情检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-emotion-model:1.0.4.300'
  4. }

2. 如果您的应用使用了人脸检测服务的如下接口:

getFeatures()

您可以引入特征检测能力包:

  1. dependencies{
  2.    // 引入特征检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-feature-model:1.0.4.300'
  4. }

3. 如果您的应用使用了人脸检测服务的如下接口:

getAllPoints()

getFaceKeyPoint(int keyPointType)

getFaceKeyPoints()

getFaceShape(int shapeType)

getFaceShapeList()

getRotationAngleX()

getRotationAngleY()

getRotationAngleZ()

您可以引入轮廓+关键点检测能力包:

  1. dependencies{
  2.    // 引入人脸轮廓+关键点检测能力包。
  3.    implementation 'com.huawei.hms:ml-computer-vision-face-shape-point-model:1.0.4.300'
  4. }

4. 下述四个接口为基础接口,只要引入上述任一个或多个包即可支持。

getBorder()

getCoordinatePoint()

getHeight()

getWidth()

如果您集成了身份证识别服务,您可以参考如下说明进行升级。

1. 如果您的应用使用了身份证识别服务的如下接口:

getIcrAnalyzer()

getIcrAnalyzer(MLIcrAnalyzerSetting setting)

MLIcrAnalyzerSetting

MLIcrAnalyzerSetting.Factory

MLIcrAnalyzer

您可以将集成的SDK基础依赖(com.huawei.hms:ml-computer-vision-icr)升级到最新版本,若集成了身份证识别能力包,需要将能力包升级到最新版本。

  1. dependencies{
  2.    // 引入基础SDK
  3.    implementation 'com.huawei.hms:ml-computer-vision-icr:1.0.4.300'
  4.    // 引入身份证识别能力包
  5.    implementation 'com.huawei.hms:ml-computer-card-icr-cn-model:1.0.4.300'
  6. }
说明:
推荐您集成身份证识别服务插件,插件提供图片质量较验、相机封装功能以及部分UI,可以助力您的应用便捷、高效、准确的识别身份证信息,集成可参见:集成身份证识别服务,客户端开发可参见:身份证识别服务客户端开发。

2. 如果您的应用使用了身份证识别服务的如下接口:

getRemoteIcrAnalyzer()

getRemoteIcrAnalyzer(MLRemoteIcrAnalyzerSetting setting)

MLRemoteIcrAnalyzer

MLRemoteIcrAnalyzerSetting

MLRemoteIcrAnalyzerSetting.Factory

您可以将集成的SDK基础依赖(com.huawei.hms:ml-computer-vision-cloud或com.huawei.hms:ml-computer-vision-icr)升级到最新版本:

  1. dependencies{
  2.    // 引入基础SDK
  3.    implementation 'com.huawei.hms:ml-computer-vision-cloud:1.0.4.300'
  4. }
说明:
推荐您集成身份证识别服务插件,插件提供图片质量较验、相机封装功能以及部分UI,可以助力您的应用便捷、高效、准确的识别身份证信息,集成可参见:集成身份证识别服务,客户端开发可参见:身份证识别服务客户端开发。

3. 如果您的应用使用了身份证识别服务的如下接口:

MLCnIcrCapture

MLCnIcrCapture.CallBack

MLCnIcrCaptureConfig

MLCnIcrCaptureConfig.Factory

MLCnIcrCaptureFactory

MLCnIcrCaptureResult

您可以删除集成的SDK基础依赖(com.huawei.hms:ml-computer-vision-cloud或com.huawei.hms:ml-computer-vision-icr)和质量检测插件(com.huawei.hms:ml-computer-card-qa-plugin),同时把身份证识别服务插件更新到最新版本,若您集成了身份证识别能力包,需要将能力包升级到最新版本。

  1. dependencies{
  2.    // 引入身份证识别plugin包
  3.    implementation ('com.huawei.hms:ml-computer-card-icr-cn-plugin:1.0.4.300') {
  4.        // 使用端侧能力时,可以排除云侧相关依赖,降低生成的APK包大小。如果您使用的是云端身份证识别能力,需要删除下面两行配置
  5.        exclude group: 'com.huawei.hms', module: 'ml-computer-net'
  6.        exclude group: 'com.huawei.hms', module: 'ml-computer-card-qa-plugin'
  7.    }
  8.    // 引入身份证识别能力包
  9.    implementation 'com.huawei.hms:ml-computer-card-icr-cn-model:1.0.4.300'
  10. }

如果您集成了银行卡识别服务,您需要把银行卡识别服务插件更新到最新版本,若您集成了银行卡识别能力包,需要将能力包升级到最新版本。

  1. dependencies{
  2.    // 引入银行卡识别plugin包
  3.    implementation 'com.huawei.hms:ml-computer-card-bcr-plugin:2.0.0.300'
  4.    // 引入银行卡识别能力包
  5.    implementation 'com.huawei.hms:ml-computer-card-bcr-model:2.0.0.300'
  6. }

若集成了其他服务的能力包,将能力包版本号按照ML Kit最新版本进行升级即可。

1.0.4.xxx升级到2.0.0.xxx

  1. dependencies{
  2.    // 引入语音合成服务SDK
  3.    implementation 'com.huawei.hms:ml-computer-voice-tts:2.0.0.401'
  4. }

同时,需要在语音合成回调中(MLTtsCallback callback = new MLTtsCallback()),增加onAudioAvailable方法:

  1. MLTtsCallback callback = new MLTtsCallback() {  
  2.    @Override
  3.    public void onAudioAvailable(String taskId, MLTtsAudioFragment audioFragment, int offset, Pair<Integer, Integer> range,
  4.        Bundle bundle){
  5.        // 音频流处理逻辑。
  6.    }
  7. }

此方法用于将合成的音频流返回到您的App,使用此方法,您可以自行处理语音合成服务生成的音频流,具体使用方法请参见:语音合成(开发步骤)。