-
-
Notifications
You must be signed in to change notification settings - Fork 564
Description
Plugin Version or Commit ID
v0.16.1
Unity Version
6000.0.33f1
Your Host OS
Windows 11 Enterprise
Target Platform
Android
Target Device
Galaxy A53
[Windows Only] Visual Studio C++ and Windows SDK Version
No response
[Linux Only] GCC/G++ and GLIBC Version
No response
[Android Only] Android Build Tools and NDK Version
Build Tools: 34.0.0
NDK: 23.1.7779620
[iOS Only] XCode Version
No response
Build Command
None. I'm using the pre-built/setup "all" project.
Bug Description
Running the Face Landmark Detection sample scene on Android, the face landmark detection is very slow. The on-screen annotation lags behind actual movement by multiple seconds, and the lag increases over time as the app runs. This issue does not occur when running in the Editor on Windows or a built application for Windows. This issue occurs regardless of whether I build with the inference mode set to CPU or GPU.
I added a small timing test to the code based on my understanding of the FaceLandmarkerRunner class: By my understanding, the timestamp sent to the OnFaceLandmarkDetectionOutput function is the same timestamp sent via taskApi.DetectAsync in the Run method. Thus, the difference between the current time within OnFaceLandmarkDetectionOutput and the provided timestamp would give the time (or an approximation of the time) that it took to detect the face landmarks of the image matching that timestamp. Based on this premise, I logged the difference between GetCurrentTimestampMillisec() and timestamp in OnFaceLandmarkDetectionOutput to see what the "processing time" was for each image. Similar to the increasing lag I'm seeing in the built app, the "processing time" increases with each image.
private void OnFaceLandmarkDetectionOutput(FaceLandmarkerResult result, Image image, long timestamp)
{
long timeDiff = GetCurrentTimestampMillisec() - timestamp;
Logger.Log("[TIME TEST] Processing time: " + timeDiff);
_faceLandmarkerResultAnnotationController.DrawLater(result);
}
Please let me know if my understanding of this issue and the timestamp sent to OnFaceLandmarkDetectionOutput is correct. If my simple time test is not a valid way to measure/approximate frame-by-frame processing time, please let me know what would be a good alternative, or at least where I could start looking for a solution. Any help or additional information would be greatly appreciated. Thank you!
Steps to Reproduce the Bug
- Open the MediaPipeUnityPlugin-all project in Unity 6000.0.33
- Add the code change shown above
- Add Android Logcat to the project for Android debugging
- Set the build platform to Android
- Set the default scene (or only scene) to the
Face Landmark Detectionsample scene - Set the build as a Development build
- Build and run the app
- When the scene opens, make sure the camera is set to one pointing at your/a face
- Filter the Android log for "[TIME TEST]" and check the changes in processing time over time.
Log
Screenshot/Video
No response
Additional Context
LOG NOTES
- The time stamps up until 06-26 04:21:20.110 are for the back camera with no face detected. After that, I switched to the front camera where my face was detected.
- At 06-26 04:21:48.580, I started closing the app, which is why the processing times start decreasing after that point.