Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding of joint positions causing pose search to fail #9

Open
shiukaheng opened this issue Nov 16, 2021 · 0 comments
Open

Rounding of joint positions causing pose search to fail #9

shiukaheng opened this issue Nov 16, 2021 · 0 comments

Comments

@shiukaheng
Copy link

shiukaheng commented Nov 16, 2021

@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:

handy.js/src/Handy.js

Lines 772 to 774 in 85f22ad

hand.livePoseData.jointPositions[ 0 ][ 0 ] === 0 &&
hand.livePoseData.jointPositions[ 0 ][ 1 ] === 0 &&
hand.livePoseData.jointPositions[ 0 ][ 2 ] === 0

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:

handy.js/src/Handy.js

Lines 522 to 524 in 85f22ad

Math.round( jointMatrix.elements[ 12 ] * 1000 ),
Math.round( jointMatrix.elements[ 13 ] * 1000 ),
Math.round( jointMatrix.elements[ 14 ] * 1000 )

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant