Closed hohoaisan closed 8 months ago
When you want to send a message from the main thread to the worker, make sure that worker thread has finished any existing task and is idle before actually sending the message. Judging from your code, you are sending a message to worker unconditionally at a constant 24 fps (cameras fps), but there is no guarantee that the worker thread can process the holistic processing within one frame.
Thanks! I was able to resolve the delayed message of the worker by introducing running state. Now the framerate is better.
But it still drops frequently cuz Holistic take from 80ms to 120ms to inference (8 - 12 FPS), which feels very laggy when the Live2D move its head/body. While the 3D Model of XR Animator feels very smooth with the same inference frame rate. Any idea of overcome this issue?
What is the spec of your PC? Holistic should run above 15fps on an average PC.
XR Animator does frame interpolation, so even if the detection fps is just 10fps, the actual animation will still look smooth. You can use the detection fps to determine how much you should interpolate the animation frames.
Mine is i5-7300HQ 2.5GHz (4CPUs) with Intel HD Graphic 630 and Nvidia Mobile GTX 1050, MoCap holistic seems to run only on Intel GPU.
My Live2D playground was deployed here https://live2d-playground-git-feature-holistic-worker-hohoaisan.vercel.app/
Is there any direction about frame interpolation? Thank you!
Unfortunately you can't decide which GPU Holitsic (or any WebGL app in general) uses in normal web browser.
Let's say Holitsic runs at 10fps and animation runs at 60fps. In between the animation frame, you interpolate frame data (be it a float value, vector position or quaternion rotation) between the previous one and the current one, by using lerp function.
I have tried using Kalidokit's lerp and not much improved result. So I decided to give up Holistic and use Facemesh + Movenet combined, pretty good inference time!
Currently I'm making a simple Live2D Mocap tool that runs only on web.
I was able to make the Mocap feature works just fine, but it is blocking main thread, so whenever Motion tracking feature is enabled, the UI was very laggy
I have followed this discussion and able to move the holistic code to worker thread, FPS on main thread now fully 60 https://github.com/google/mediapipe/issues/2506
Below is my simple implementation: (Full draft code)
But I came with another issue, the Mocap in worker thread is quite slow compared to what I was build on main, while debugging what is slowing the code
I saw messaging delay between main and worker gradually increase overtime
Although I have tried to reduce frame rate (which is bad), and trying to decrease videoElement width/height, model complexity to lite, the delay is still very noticeable.
However, XR_Animator using Holistic Legacy does not have this issue, and the time between message transfering is quite fast (less than 100ms), I have looked into
SA_system_emulation.min.js
and it does use the samecreateImageBitmap
which I was using above, even keep original resolution 1280x720.Is there any step that I was wrong with my simple implementation above? I even copied the same holistic model that XRAnimator is using.