For this week I trained an ml5 neural network on hand gestures, but the part I actually cared about was the data-collection interaction. The examples all collect data by clicking a button, which pulls you out of the gesture every time. So I made the hand do both jobs: you hold a pose with one hand and pinch (thumb + index) to stream samples. No mouse, no mode-switching — the same hand that performs the gesture also triggers the recording, and holding the pinch gathers dozens of samples in a second or two.
🔗 Sketch: https://editor.p5js.org/ervin021013/sketches/UvSikiTYA
Under the hood
- Input: all 21 hand keypoints as (x, y) → a 42-dimensional vector.
- Instead of raw pixel coordinates, I re-center every point on the wrist and divide by hand size. That makes a gesture read the same anywhere in the frame and at any distance — without it, the model just memorizes where my hand happened to be.
- 4 categories (Rock / Paper / Scissors / ThumbsUp), easy to extend. Keys
1–4pick the label,ttrains, then it predicts live with a confidence readout.
Reflecting on the prompts
- Beyond buttons / beyond the camera: pinch-to-collect felt like the most “diegetic” option, but the next step I want to try is using the phone’s
deviceorientation(accelerometer) so tilting is the input — even less hardware than a camera. Audio amplitude + FFT is another real-time signal I’d like to classify. - Beyond color/sound output: the natural extension is a regression model — map hand openness to continuous R/G/B instead of hard categories, so “fist → deep red, open palm → cyan” interpolates smoothly. From there, piping the output over Web Serial to an Arduino (servo / LED strip) turns the prediction into a physical device.
From the readings: 3Blue1Brown’s framing of a network as layers of weighted sums finally made the ml5 black box legible — my 42 inputs are just the first layer, and “training” is nudging all those weights until the gesture clusters separate. Shiffman’s chapter grounded the same idea in code I could actually poke at.
Leave a Reply