ml5js / ml5-next-gen

Repo for next generation of ml5.js: friendly machine learning for the web! 🤖
https://ml5js.org/
Other
94 stars 23 forks source link

HandPose Connections #224

Closed shiffman closed 3 weeks ago

shiffman commented 1 month ago

Picking up on #231, I would like to propose adding getConnections() to ml5.handPose(). According to the official diagram, these are the connections. (I made this manually and the order is somewhat arbitrary. Is there an official standard?)

let connections = [
  [0, 1],
  [1, 2],
  [2, 3],
  [3, 4],
  [0, 5],
  [5, 6],
  [6, 7],
  [7, 8],
  [9, 10],
  [10, 11],
  [11, 12],
  [13, 14],
  [14, 15],
  [15, 16],
  [0, 17],
  [17, 18],
  [18, 19],
  [19, 20],
  [5, 9],
  [9, 13],
  [13, 17],
];
Screenshot 2024-10-23 at 3 35 51 PM
ziyuan-linn commented 1 month ago

This looks great! I also think it is a good idea to add connections for handPose.

Looks like the official standards are defined in constants.ts. I think we can import it with import { MEDIAPIPE_CONNECTED_KEYPOINTS_PAIRS } from "@tensorflow-models/hand-pose-detection/dist/constants";.

Going back to the previous discussion, perhaps we can also add bodyPose.getConnections as an alias for bodyPose.getSkeleton and eventually deprecate the latter?

ziyuan-linn commented 4 weeks ago

@shiffman I just made a PR to add the getConnections function.

I noticed that there is a small difference between the official connections array and the diagram. This is from the connections array: hand skeletal connections drawn from official connections array

Which of the two connection schemes do you think we should use?

shiffman commented 4 weeks ago

Oh interesting! I think it probably makes sense to follow the official ones! It's just strange that the official connections don't match the diagram? It's not so many keypoints that someone couldn't easily build their own list if they prefer a different visual. Maybe @MOQN has a preference?

image

(Just linking this to #227 for reference also)

MOQN commented 3 weeks ago

@shiffman Thank you for looping me in!

I really don’t have any preference, but I’m leaning toward following the official version, like the one in @ziyuan-linn’s screenshot. I just searched for the actual hand skeleton, and it’s similar to the official connections, haha 😂. (I do feel the same though, about the diagram in their documentation.)

(Just a random thought: if we don't follow the official connections, we could consider connecting the points 1 and 5, instead of 0 and 5.)

had