Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Forks of this sketch will become the forks of "ML5NextGen-Handpose".
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
A fork of ML5NextGen-Handpose by Golan Levin
CC Attribution NonCommercial ShareAlike
ml5-handPose-2024
Levin
xxxxxxxxxx
// Copyright (c) 2024 ml5
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
// Requires: https://unpkg.com/ml5@1/dist/ml5.js
// Documentation: https://docs.ml5js.org/#/reference/handpose
let handpose;
let video;
let hands = [];
let options = { maxHands: 2, flipHorizontal: true, runtime: "mediapipe" };
function preload() {
// Load the handPose model.
handpose = ml5.handPose(options);
}
function setup() {
createCanvas(800, 600);
// Create the webcam video and hide it
video = createCapture(VIDEO);
video.size(640, 480);
video.hide();
// start detecting hands from the webcam video
handpose.detectStart(video, gotHands);
}
function draw() {
// Draw the webcam video
background(255);
push();
if (options.flipHorizontal){
translate(width,0);
scale(-1,1);
}
let transparency = 255; // reduce this to make video transparent
tint(255,255,255,transparency);
image(video, 0, 0, width, height);
pop();
push();
// Cope with difference between capture size and canvas size
scale(width/640, height/480);
// Draw all the tracked hand points
for (let i = 0; i < hands.length; i++) {
let hand = hands[i];
for (let j = 0; j < hand.keypoints.length; j++) {
let keypoint = hand.keypoints[j];
fill(0,255,0);
noStroke();
circle(keypoint.x, keypoint.y, 10);
}
let whichHand = hand.handedness;
let wx = hand.keypoints[ML5HAND_WRIST].x;
let wy = hand.keypoints[ML5HAND_WRIST].y;
textSize(24);
text(whichHand, wx,wy-50);
}
pop();
}
// Callback function for when handpose outputs data
function gotHands(results) {
// save the output to the hands variable
hands = results;
}
// The following index labels may be helpful:
const ML5HAND_WRIST = 0;
const ML5HAND_THUMB_CMC = 1;
const ML5HAND_THUMB_MCP = 2;
const ML5HAND_THUMB_IP = 3;
const ML5HAND_THUMB_TIP = 4;
const ML5HAND_INDEX_FINGER_MCP = 5;
const ML5HAND_INDEX_FINGER_PIP = 6;
const ML5HAND_INDEX_FINGER_DIP = 7;
const ML5HAND_INDEX_FINGER_TIP = 8;
const ML5HAND_MIDDLE_FINGER_MCP = 9;
const ML5HAND_MIDDLE_FINGER_PIP = 10;
const ML5HAND_MIDDLE_FINGER_DIP = 11;
const ML5HAND_MIDDLE_FINGER_TIP = 12;
const ML5HAND_RING_FINGER_MCP = 13;
const ML5HAND_RING_FINGER_PIP = 14;
const ML5HAND_RING_FINGER_DIP = 15;
const ML5HAND_RING_FINGER_TIP = 16;
const ML5HAND_PINKY_MCP = 17;
const ML5HAND_PINKY_PIP = 18;
const ML5HAND_PINKY_DIP = 19;
const ML5HAND_PINKY_TIP = 20;
See More Shortcuts
Please verify your email to comment
Verify Email