智能客服
你问我答,随时在线为你解决问题
日落公告:HMS Toolkit服务当前已不再进行版本更新。中国区域的服务将在2026-11-30日落下线,日落后将不再提供服务。
您若需要应用支持ML Kit,必须完成接入准备,请参见开发准备。
Google API | To HMS API |
|---|---|
FirebaseVision.getInstance(com.google.firebase.FirebaseApp app) | com.huawei.hms.mlsdk.MLAnalyzerFactory.getInstance (com.huawei.hms.mlsdk.common.MLApplication app) 参数app需手动添加代码创建,对应原参数com.google.firebase.FirebaseApp的创建方法FirebaseApp.getInstance()获取默认FirebaseApp实例或使用FirebaseApp.getInstance(String appName)根据App名称获取FirebaseApp实例,可使用MLApplication.getInstance()获取默认MLApplication实例。 |
To HMS API代码示例:
- com.huawei.hms.mlsdk.common.MLApplication app = com.huawei.hms.mlsdk.common.MLApplication.getInstance("appName");
- com.huawei.hms.mlsdk.MLAnalyzerFactory factory = com.huawei.hms.mlsdk.MLAnalyzerFactory.getInstance(app);
Google API | To HMS API |
|---|---|
com.google.android.gms.vision.face.FaceDetector.finalize() | com.huawei.hms.mlsdk.face.MLFaceAnalyzer.stop() MLFaceAnalyzer不支持重写finalize方法,可以调用stop方法释放资源。 |
Google API | Add HMS API | To HMS API |
|---|---|---|
com.google.firebase.ml.vision.face.FirebaseVisionFace.INVALID_ID | 不提供 | 不提供 |
com.google.firebase.ml.vision.label.FirebaseVisionImageLabeler.ON_DEVICE_AUTOML | 不提供 | 不提供 |
如果在Google API代码中使用了switch-case语句,在Add HMS API场景下,需要将其转换为if-else语句,示例如下。
Google API代码:
- int rotation;//rotation值由您自己设置
- int rotationDegree = 0;
- switch (rotation) {
- case FirebaseVisionImageMetadata.ROTATION_90:
- rotationDegree = 90;
- break;
- case FirebaseVisionImageMetadata.ROTATION_180:
- rotationDegree = 180;
- break;
- case FirebaseVisionImageMetadata.ROTATION_270:
- rotationDegree = 270;
- break;
- default:
- break;
- }
- int rotation;//rotation值由您自己设置
- int rotationDegree = 0;
- if (rotation == ExtensionVisionImageMetadata.getROTATION_90()) {
- rotationDegree = 90;
- } else if (rotation == ExtensionVisionImageMetadata.getROTATION_180()) {
- rotationDegree = 180;
- } else if (rotation == ExtensionVisionImageMetadata.getROTATION_270()) {
- rotationDegree = 270;
- } else {
- Log.i("rotation Degree","Unknown rotation");
- }