Skip to main content

Hand gestures as an input device

Project description

gest

Hand gestures as an input device

example

Why

For health related reasons, I had to stop using a mouse and a keyboard. Talon allowed me to type with my voice and move the cursor with my eyes. This project was started to complement this setup with hand gestures.

Development status

The project is in an early stage of development. I use it on daily basis, so it should be good enough for some.

What is implemented:

  • pinching gesture recognition, in one hand orientation
  • heatmap output, separate for left and right hand, indicating pinched point position
  • demo for testing recognition models
  • example script for simulating mouse clicks and scrolling
  • scripts for producing and reviewing training data

Bias

The gesture recognition model was trained on images of my hands, taken with my hardware in my working environment, so it is probably heavily biased. I hope people who want to use it, but recognition quality prevents them from it, would capture some images of their hands using included tooling and donate it to the project, so that over time it works well for everyone.

Installation

Use Python 3.6, 3.7 or 3.8 and in a virtual environment run

pip install gest

If you clone this repository, you can get the exact versions of required libraries that I am using with Poetry

poetry install

Walkthrough

Demo

First check how the included model works for you. Run

python -m gest.demo

and see if it recognizes your gestures as here:

demo

If you have multiple cameras, you can pick one like

python -m gest.demo --camera 2

Camera numbers are not necessarily consecutive. Two cameras may be accessible as 0 and 2. This option is supported by other commands as well.

Example script

In the presentation on top I am running

python -m gest.examples.two_handed_scroll_and_click

It only acts if it detects both hands pinching and based on their relative position:

  • double clicks if you cross your hands
  • scrolls up or down if your hands pinch at different heights
  • left clicks if your hands (almost) touch
  • right clicks if your hands are on the same height, but not close horizontally (this action is delayed by a fraction of a second to prevent accidental use)

Controlling CPU load

For everyday use, you don't want to dedicate too much resources to gesture recognition. You can control it by setting OMP_NUM_THREADS, as in

OMP_NUM_THREADS=2 python -m gest.examples.two_handed_scroll_and_click

Try different values to find balance between responsiveness and CPU load.

Custom scripts

The demo and example scripts serve two additional purposes: they can be used as templates for custom scripts and they define the public API for the purpose of semantic versioning.

Training data annotation

Capturing

python -m gest.annotation.capture --countdown 5 data_directory

will help you create annotated images. Once you start automatic annotation (press a to start/stop) it will ask you to pinch a given point with your left or right hand, or to not pinch ("background").

You will have 5 seconds before the image is captured (the --countdown).

You will also see the last annotated image for quick review. It can be deleted with d.

Reviewing

python -m gest.annotation.review --time 1 data_directory closed_pinch_left

will let you review all images annotated as left hand pinch in data_directory, showing you each for 1 second if you start/stop automatic advancing with a. Otherwise you can go to the next/previous image with n/p. Delete incorrectly annotated images with d.

You should also review closed_pinch_right and background.

Annotation guidelines

It makes sense to annotate realistic training data that the model performs poorly on, like if

  • it mistakenly detects a pinch when you pick up the phone,
  • it doesn't detect pinching when you wear a skin colored shirt.

If it performs poorly overall, it's good to capture the images in many short sessions, with different lighting, clothes, background, camera angle.

The point isn't though to look for tricky cases or stretch the definition of a pinching gesture to include a different hand orientation (eg. with pinching fingers pointing towards the camera).

Donating annotated data

Contact me b.marcinkowski@leomail.pl

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gest-0.3.0.tar.gz (307.6 kB view details)

Uploaded Source

Built Distribution

gest-0.3.0-py3-none-any.whl (307.6 kB view details)

Uploaded Python 3

File details

Details for the file gest-0.3.0.tar.gz.

File metadata

  • Download URL: gest-0.3.0.tar.gz
  • Upload date:
  • Size: 307.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.3 CPython/3.8.5 Linux/5.6.0-1028-oem

File hashes

Hashes for gest-0.3.0.tar.gz
Algorithm Hash digest
SHA256 155e502d844f84aac59fbc4c3e47b26071ac69b8df746d952b959cc5383a8005
MD5 a33b76386d5c6ed6ab0f4adaf68e65aa
BLAKE2b-256 5e86728768687d35b0c127826f5c1eedefd0fc4b794490f119fe80174fd24257

See more details on using hashes here.

File details

Details for the file gest-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: gest-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 307.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.3 CPython/3.8.5 Linux/5.6.0-1028-oem

File hashes

Hashes for gest-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be8abf85ea98be73092488a54174cb62803ee54b0c0ed9fbc50af82c554297e9
MD5 9ef5cf0558a77b06a66d68d42ac866d9
BLAKE2b-256 120265d0b712c570e5468390793b35098c2c532784eaae11c3dc26da9dad9b2e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page