Capture
OpenCV mirrors a 1280 × 720 webcam feed for natural interaction.
Computer vision × physical computing
Five fingers become five bits. Five bits become five physical lights.
Project overview
The project uses a laptop webcam to recognize which fingers are open, reduces that hand pose to a five-bit message, and sends the state to an Arduino Nano. Each bit controls the LED in the same physical finger position.
Opening the middle finger produces 00100 and lights the center LED. Opening several fingers produces several active bits, so the matching lights respond together.
The control loop
OpenCV mirrors a 1280 × 720 webcam feed for natural interaction.
MediaPipe returns 21 three-dimensional landmarks for one detected hand.
Joint angles and palm-relative distances determine each finger’s state.
A five-frame majority vote prevents small tracking changes from flickering LEDs.
Only changed five-bit commands are sent over serial at 9,600 baud.
The Arduino Nano maps each bit to the corresponding physical LED.
Detection logic
A simple rule such as “tip above knuckle” breaks when the hand rotates. This implementation checks two 3D joint angles for every regular finger. The thumb gets its own test because its motion is different: two angles plus its distance from the index knuckle, normalized by palm width.
pip_angle = angle_3d(mcp, pip, dip)
dip_angle = angle_3d(pip, dip, tip)
return (
pip_angle > 155
and dip_angle > 150
)
# Five classifications become one command
command = "".join(str(state) for state in states)
connection.write(f"{command}\n".encode("utf-8"))Signal stability
Landmark detection shifts slightly between camera frames. A deque retains the most recent five classifications, then each finger gets an independent majority vote. This keeps a brief tracking error from becoming a visible hardware change.
Reliability decisions
The previous command is retained, so identical frames do not flood the serial link with redundant messages.
If the hand disappears, history is cleared and 00000 turns every LED off instead of preserving a stale gesture.
On exit, the app makes one final all-off write, releases the camera, closes the interface window, and closes serial.
If the configured port cannot open, the program lists detected serial devices to make setup failures easier to resolve.
Outcome
A gesture becomes a protocol.
A protocol becomes light.
This prototype demonstrates a complete real-time physical computing loop across computer vision, geometric classification, temporal filtering, serial communication, microcontroller output, and safe cleanup.