Devlog2_RoboSnoop_10/06/26
I figured out how to attach a slider to the RoboSnoop OS, but I only got it to move based on the position of my hand along the x axis of the screen instead of based on the angle at which my fingers curl.
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/control_utils/control_utils.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js"></script>
<video id="camera" autoplay playsinline></video>
<canvas id="output"></canvas>
<script>
const slider = document.querySelector("#slider");
let thumbAngle = slider.value;
slider.addEventListener("input", function () {
thumbAngle = slider.value;
});
</script>
<script>
const hands = new Hands({
locateFile: (file) => {
return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`;
},
});
hands.setOptions({
maxNumHands: 1,
modelComplexity: 1,
minDetectionConfidence: 0.5,
minTrackingConfidence: 0.5,
});
hands.onResults((results) => {console.log("Found the handdd!", results)});
const camera = new Camera (video,{onFrame: async () => {
await hands.send({image: video});
}, width: 700, height: 500});
camera.start();
hands.onResults((results) => {
if (!results.multiHandLandmarks || !results.multiHandLandmarks.length) return;
const indexTip = results.multiHandLandmarks[0][8]; // index fingertip
const min = Number(slider.min);
const max = Number(slider.max);
const value = min + indexTip.x * (max - min);
slider.value = value;
thumbAngle = value;
});
</script>
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.