I made an Unity plugin for Android that uses MLKit. Everything works fine untill the MLKit pose detector is analyzing the image:
Task<Pose> result =
_pd.process(image)
.addOnSuccessListener(
new OnSuccessListener<Pose>() {
@Override
public void onSuccess(Pose pose) {
Log.i("MyComppany", "trig OnSuccessListener!");
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.i("MyComppany", "trig OnFailureListener!");
Log.i("MyComppany", String.valueOf(e));
}
});
after which I get this error:
03-30 12:16:47.318 13171 13171 I MyCompany : com.google.mlkit.common.MlKitException: Mediapipe failed with message: internal: Graph has errors:
03-30 12:16:47.318 13171 13171 I MyCompany : Calculator::Open() for node "posetrackingsubgraph__posedetectionsubgraph__TfLiteInferenceCalculator" failed: RET_CHECK failure (third_party/mediapipe/util/tflite/tflite_model_loader.cc:70) model Failed to load model from path mlkit_pose/pose_person_detector_f16.tflite
This suggests that the tfile was lost when building the plugin but I am not sure how to debug this further. Any insight is appreciated.
This was happening because I literally didn't have the specified model file. Since I was using an AAR plugin, I had to download all the underlying dependencies into Unity's Assets/Plugins/Android using unity-jar-resolver. After I did so, I was experiencing a dependency collision, which forced me to delete that dependency ("com.google.mlkit:pose-detection:17.0.1-beta3"). In the end, it turned out that I had only a reference of "com.google.mlkit:pose-detection:17.0.1-beta3" in the Unity Plugin, not the whole contents.
As a workaround, I exported my project into Android Studio and added "com.google.mlkit:pose-detection:17.0.1-beta3" into Gradle. Everything works now.