victordibia / handtrack.js

A library for prototyping realtime hand detection (bounding box), directly in the browser.
https://victordibia.com/handtrack.js/
MIT License
2.83k stars 250 forks source link

How would I disable Face Tracking? #63

Open AyaanZaveri opened 2 years ago

AyaanZaveri commented 2 years ago

Is there a way I can disable face tracking? All I want is open, closed, pinch, point, point tip, and pinch tip.

vladmandic commented 2 years ago

see my implementation at: https://github.com/vladmandic/human/blob/863850054218cb55598faa08d43a6c1ecb3e96a7/src/hand/handtrack.ts#L97

key part is

[t.rawScores, t.rawBoxes] = await models[0].executeAsync(t.cast, modelOutputNodes) as Tensor[];
  t.boxes = tf.squeeze(t.rawBoxes, [0, 2]);
  t.scores = tf.squeeze(t.rawScores, [0]);
  const classScores: Array<Tensor> = tf.unstack(t.scores, 1); // unstack scores based on classes
  tf.dispose(classScores[faceIndex]);
  classScores.splice(faceIndex, 1); // remove faces
  t.filtered = tf.stack(classScores, 1); // restack
  tf.dispose(classScores);
  t.max = tf.max(t.filtered, 1); // max overall score
  t.nms = await tf.image.nonMaxSuppressionAsync(t.boxes, t.max, config.hand.maxDetected, config.hand.iouThreshold, config.hand.minConfidence);
AyaanZaveri commented 2 years ago

Thanks!

ahmetturk93 commented 2 years ago

How can i do this implementation?