Refer to Latest version of ML Kit. This version optimizes all services provided by ML Kit to deliver better user experience.
If you are integrating ML Kit for the first time, use the SDK of the latest version. For details, please refer to Integrating the HMS SDK.
If you have integrated an earlier version of the HMS Core ML SDK, you need to upgrade it to the latest version. In the new version, the SDK name and capability package integration method are optimized. Therefore, you are advised to complete the following preparations before the upgrade:
If you use only the on-cloud capabilities provided by ML Kit, including on-cloud text recognition and document recognition, you only need to modify the integrated SDK's basic dependencies (com.huawei.hms:ml-computer-vision) as follows:
- dependencies{
- implementation 'com.huawei.hms:ml-computer-vision-cloud:2.0.0.300'
- }
If you use on-cloud image classification and landmark recognition, modify the integrated SDK's basic dependencies (com.huawei.hms:ml-computer-vision) as follows:
- dependencies{
- implementation 'com.huawei.hms:ml-computer-vision-cloud:1.0.4.300'
- }
If you use ML Kit capabilities on the device, first modify the integrated SDK's basic dependencies (com.huawei.hms:ml-computer-vision) as follows:
- dependencies{
- // To integrate multiple services, you can add them together.
- implementation 'com.huawei.hms:ml-computer-vision-ocr:2.0.0.300'
- implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
- implementation 'com.huawei.hms:ml-computer-vision-object:1.0.4.300'
- implementation 'com.huawei.hms:ml-computer-vision-face:1.0.4.300'
- }
Then, if you use the Full SDK mode to integrate the face detection service, delete com.huawei.hms:ml-computer-vision-face-recognition-model from the integrated capability package and perform the upgrade as follows:
1. If your app uses the following API of face detection:
You can import the facial expression detection capability package.
- dependencies{
- // Import the facial expression detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-emotion-model:1.0.4.300'
- }
2. If your app uses the following API of face detection:
You can import the feature detection capability package.
- dependencies{
- // Import the feature detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-feature-model:1.0.4.300'
- }
3. If your app uses the following APIs of face detection:
getFaceKeyPoint(int keyPointType)
You can import the contour and key point detection capability package.
- dependencies{
- // Import the contour and key point detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-shape-point-model:1.0.4.300'
- }
4. The following four APIs are basic APIs and can be supported as long as one or more of the preceding packages are imported:
If the capability packages of other services are integrated, upgrade the capability package version to the latest version of ML Kit.
If you use only the on-cloud capabilities provided by ML Kit, including on-cloud text recognition, document recognition, and product visual search, you only need to modify the integrated SDK's basic dependencies (com.huawei.hms:ml-computer-vision) as follows:
- dependencies{
- implementation 'com.huawei.hms:ml-computer-vision-cloud:2.0.0.300'
- }
If you use on-cloud , text translation, language detection, image classification, and landmark recognition, modify the integrated SDK's basic dependencies (com.huawei.hms:ml-computer-vision) as follows:
- dependencies{
- implementation 'com.huawei.hms:ml-computer-vision-cloud:1.0.4.300'
- }
If you use ML Kit capabilities on the device, first, modify the integrated SDK's basic dependencies (com.huawei.hms:ml-computer-vision) as follows:
- dependencies{
- // To integrate multiple services, you can add them together.
- implementation 'com.huawei.hms:ml-computer-vision-ocr:2.0.0.300'
- implementation 'com.huawei.hms:ml-computer-vision-icr:1.0.4.300'
- implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
- implementation 'com.huawei.hms:ml-computer-vision-object:1.0.4.300'
- implementation 'com.huawei.hms:ml-computer-vision-face:1.0.4.300'
- implementation 'com.huawei.hms:ml-computer-vision-segmentation:1.0.4.301'
- }
Then, perform the following steps:
1. If you use the Full SDK mode to integrate the face detection service, delete com.huawei.hms:ml-computer-vision-face-recognition-model from the integrated capability package and perform the upgrade as follows:
If your app uses the following API of face detection:
You can import the facial expression detection capability package.
- dependencies{
- // Import the facial expression detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-emotion-model:1.0.4.300'
- }
If your app uses the following API of face detection:
You can import the feature detection capability package.
- dependencies{
- // Import the feature detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-feature-model:1.0.4.300'
- }
If your app uses the following APIs of face detection:
getFaceKeyPoint(int keyPointType)
You can import the contour and key point detection capability package.
- dependencies{
- // Import the contour and key point detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-shape-point-model:1.0.4.300'
- }
The following four APIs are basic APIs and can be supported as long as one or more of the preceding packages are imported:
If the capability packages of other services are integrated, upgrade the capability package version to the latest version of ML Kit.
If you use the Full SDK mode to integrate the face detection service, delete com.huawei.hms:ml-computer-vision-face-recognition-model from the integrated capability package and perform the upgrade as follows
1. If your app uses the following API of face detection:
You can import the facial expression detection capability package.
- dependencies{
- // Import the facial expression detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-emotion-model:1.0.4.300'
- }
2. If your app uses the following API of face detection:
You can import the feature detection capability package.
- dependencies{
- // Import the feature detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-feature-model:1.0.4.300'
- }
3. If your app uses the following APIs of face detection:
getFaceKeyPoint(int keyPointType)
You can import the contour and key point detection capability package.
- dependencies{
- // Import the contour and key point detection capability package.
- implementation 'com.huawei.hms:ml-computer-vision-face-shape-point-model:1.0.4.300'
- }
4. The following four APIs are basic APIs and can be supported as long as one or more of the preceding packages are imported:
If you have integrated bank card recognition, you need to upgrade the bank card recognition plug-in to the latest version. If you have integrated the bank card recognition capability package, upgrade it to the latest version.
- dependencies{
- // Import the bank card recognition plug-in package.
- implementation 'com.huawei.hms:ml-computer-card-bcr-plugin:2.0.0.300'
- // Import the bank card recognition capability package.
- implementation 'com.huawei.hms:ml-computer-card-bcr-model:2.0.0.300'
- }
If the capability packages of other services are integrated, upgrade the capability package version to the latest version of ML Kit.
If you have integrated TTS, you need to upgrade the SDK version as follows:
- dependencies{
- // Import the TTS SDK.
- implementation 'com.huawei.hms:ml-computer-voice-tts:2.0.0.401'
- }
Add the onAudioAvailable method to the TTS callback (MLTtsCallback callback = new MLTtsCallback()).
- MLTtsCallback callback = new MLTtsCallback() {
- @Override
- public void onAudioAvailable(String taskId, MLTtsAudioFragment audioFragment, int offset, Pair<Integer, Integer> range,
- Bundle bundle){
- // Audio stream processing logic.
- }
- }
This method is used to return the synthesized audio stream to your app. You can use this method to process the audio stream generated by TTS. For details, please refer to Development Process of TTS.
If the capability packages of other services are integrated, upgrade the capability package version to the latest version of ML Kit.