handy.js icon indicating copy to clipboard operation
handy.js copied to clipboard

Rounding of joint positions causing pose search to fail

Open shiukaheng opened this issue 2 years ago • 0 comments

@stewdio Heya, I'm using handy.js for a machine learning project and you have saved me a lot of time! Thanks for the amazing library. However I think I might have found a bug but I'm not sure if it's a problem with my code or with the library.

The problem that I encountered was that handy.js was not properly searching up distances to the predefined poses, and I traced the problem to this: https://github.com/stewdio/handy.js/blob/85f22ad21ea57d141b4a5ef11591db779b65b70b/src/Handy.js#L772-L774 where there was an optimization to terminate the search early if the first joint had its coordinates be all zero. I double checked with your live demo but your demo seemed to work fine.

However, when I ran it in my code, even with all the non-essential parts cut out, the first joint position was always at [0, 0 ,0] which causes the pose search to always fail. The other joint positions were however not all 0s, so the termination should not have happened.

If I remove the rounding from here: https://github.com/stewdio/handy.js/blob/85f22ad21ea57d141b4a5ef11591db779b65b70b/src/Handy.js#L522-L524 the first joint position is still some ridiculously small number (e-13!!) so probably its just some numeric errors from the matrix operations, so honestly I'm not sure what I'm doing wrong in my code as in your demo, the first joint does not return a position so close to all zeros.

BUT, upon closer inspection after I removed the rounding from handy.js, the position of the first joint also are quite often in the >0.5 range in your live demo, which perhaps might have cause some skipped searches. While I'm still figuring out why the coordinates of the first joint of my hands are almost all zero, which may as well be specific to my code, perhaps the rounding may also be causing issues for other people?

shiukaheng avatar Nov 16 '21 08:11 shiukaheng