AS
All work

Project 02 · 2024

Hand Rehabilitation Platform

Therapy exercises you play with your hand, and a webcam

Hand therapy after a stroke or an injury is repetitive, and it is done at home where nobody is watching. So it gets skipped, and there is no record of what was actually done. This turns the exercises into games driven by a webcam, with the difficulty calibrated to the patient's own range of motion and the results going back to their therapist.

MediaPipeComputer VisionPythonOpenCVPygamePyQt5TypeScriptMedical Devices
Tracking
21 hand landmarks, webcam only
Movements
6, calibrated per patient
Exercises
7 games
Demo
One of them, playable below

Try it

This is the Free Drawing exercise, ported from the original to run in the browser. Pinch your index finger and thumb together to put the pen down, open them to lift it. The hand tracking model runs inside this tab, so the video never leaves your device and nothing is uploaded anywhere.

Pinch your index finger and thumb together to draw, and open them to lift the pen. The video never leaves your device: the model runs in this tab.

ratio no hand

The same 21 landmark model and the same pinch detection as the Python build, running in WebAssembly. The orange bone is the thumb's proximal phalanx, which is what the measurement is divided by. Which finger opposes the thumb is a per-exercise setting in the original, so it is a control here too. Move the threshold slider to see what patient calibration actually changes.

How a gesture becomes a measurement

A webcam gives 21 landmarks per hand and nothing else. Everything clinical has to be derived from them, and the hard part is not detecting the gesture once, it is detecting it the same way tomorrow, in a different room, with the patient sitting closer to the camera.

Normalise by a bone, not by pixels

A pinch is the distance between the index tip and the thumb tip, but in pixels that distance halves when the patient sits twice as far away. So it is divided by the length of the thumb's proximal phalanx, a bone the hand carries with it. The ratio is scale-invariant, which is what lets one calibrated threshold keep meaning the same gesture across sessions.

The threshold is the patient, not the game

That ratio is compared against a number measured during calibration from the patient's own range of motion. A hand that cannot close fully gets a threshold that its best pinch can still reach, so the exercise stays winnable and the progression is a number the therapist can move deliberately rather than a difficulty setting.

Six movements, one geometry problem each

Pinch and lateral pinch come out of fingertip distances. Wrist flexion, extension, abduction and adduction come out of the angle between the forearm vector and the hand vector. Pronosupination comes out of how the palm's landmark spread collapses as the hand rotates, which is the awkward one, since rotation about the camera axis is exactly what a single 2D view sees worst.

Seven exercises

Each game trains a movement, but the reason there are seven is adherence. The same pinch repeated four hundred times is the thing patients stop doing, so the movement stays fixed and the game around it changes.

Free Drawing exercise
Free Drawing · pinch
Drag and Match exercise
Drag & Match · pinch
Trace Master exercise
Trace Master · trace
Fast Cars exercise
Fast Cars · wrist
Catch a Sandwich exercise
Catch a Sandwich · grip
Simon exercise
Simon · finger tapping

Every exercise takes the same configuration block, so the therapist tunes the session rather than picking a preset: level, repetitions or elapsed time as the stopping condition, which hand, whether to calibrate first, which fingers are in play, collision tolerance, and a cognitive load flag that adds a decision on top of the movement. High contrast, sound and negative feedback are separate switches, because the population includes patients for whom each of those is the wrong choice.

The half that is not a game

A rehabilitation exercise that no clinician can prescribe or read back is a toy. So the other half of the project is a desktop application for the therapist: patients and professionals with their relationship between them, routines assembled from configured exercises, stored calibrations, a calendar of scheduled sessions, and export to PDF for the clinical record. Credentials are stored encrypted, and the patient never sees this side of it at all.

What I would fix

  • A single camera sees rotation about its own axis worst, which is exactly what pronosupination is. Depth from a second camera, or a model that predicts landmark depth, would make that one movement much more honest than it currently is.
  • The clinical claim is untested. Everything here is validated as software, not as therapy: there is no trial, no comparison against conventional rehabilitation, and no evidence about outcomes. That is the study this needs next, and it is a different kind of work than the one I did.

Next project

Quadruped Walking Robot