diff --git a/uwu_detector/index.html b/uwu_detector/index.html new file mode 100644 index 0000000..d903fa1 --- /dev/null +++ b/uwu_detector/index.html @@ -0,0 +1,35 @@ + + + + + + handtracking + + + + + + + + +

No uwu detected

+

+ + + \ No newline at end of file diff --git a/uwu_detector/sketch.js b/uwu_detector/sketch.js new file mode 100644 index 0000000..9b1d506 --- /dev/null +++ b/uwu_detector/sketch.js @@ -0,0 +1,41 @@ +let video; +let handPose; +let hands = []; + +function preload() { + handPose = ml5.handPose({ flipped: true }); +} + +function setup() { + noCanvas(); + video = createCapture({ + video: { + }, + audio: false, + flipped: true, + }); + handPose.detectStart(video, (results) => { hands = results; }); + video.hide(); + +} + +function draw() { + let fDist = null; + if (hands.length == 2) { + let leftHand = hands[0]; + let rightHand = hands[1]; + fDist = dist( + leftHand.index_finger_tip.x, leftHand.index_finger_tip.y, + rightHand.index_finger_tip.x, rightHand.index_finger_tip.y + ); + if (fDist < 50 && leftHand.thumb_tip.y < leftHand.wrist.y && rightHand.thumb_tip.y < rightHand.wrist.y) { + detector.innerText = "uwu\nšŸ‘‰šŸ‘ˆ"; + } else { + detector.innerText = "No uwu detected"; + } + + } + // debug.innerText = `Hands detected: ${hands.length}\ndistance: ${hands.length == 2 ? fDist : "N/A"}`; +} + +const clamp = (min, num, max) => Math.min(Math.max(num, min), max); \ No newline at end of file