Handpose is a machine-learning model that allows for palm detection and hand-skeleton finger tracking in the browser. It can detect a maximum of one hand at a time and provides 21 3D hand keypoints that describe important locations on the palm and fingers.
Quickstart :
let predictions = [];
const video = document.getElementById('video');
// Create a new handpose method
const handpose = ml5.handpose(video, modelLoaded);
// When the model is loaded
function modelLoaded() {
console.log('Model Loaded!');
}
// Listen to new 'hand' events
handpose.on('hand', results => {
predictions = results;
});
Usage :
Initialize
You can initialize ml5.handpose with an optional video, configuration options object, or a callback function.
const handpose = ml5.handpose(?video, ?options, ?callback);
Parameters :
* video : OPTIONAL. Optional HTMLVideoElement input to run predictions on.
* options : OPTIONAL. A object that contains properties that effect the Handpose model accuracy, results, etc. See documentation on the available options in TensorFlow's Handpose documentation.
const options = {
flipHorizontal: false, // boolean value for if the video should be flipped, defaults to false
maxContinuousChecks: Infinity, // How many frames to go without running the bounding box detector. Defaults to infinity, but try a lower value if the detector is consistently producing bad predictions.
detectionConfidence: 0.8, // Threshold for discarding a prediction. Defaults to 0.8.
scoreThreshold: 0.75, // A threshold for removing multiple (likely duplicate) detections based on a "non-maximum suppression" algorithm. Defaults to 0.75
iouThreshold: 0.3, // A float representing the threshold for deciding whether boxes overlap too much in non-maximum suppression. Must be between [0, 1]. Defaults to 0.3.
}
* callback : OPTIONAL. A function that is called once the model has loaded.