Skip to main content

MooseGesture

A mouse gesture recognition module for Python 2 and 3.

This module is fed a series of XY coordinates (which can come from the mouse or another source) and can recognize when the mouse is moving in one of the eight cardinal/diagonal directions.

These mouse movements can be combined to form “mouse gestures” to perform different commands.

Installation

pip install moosegesture

Quickstart Guide

Pass a path as sequence of (x, y) tuples to getGesture(), which will return a list of directions that the path takes. These are the up, down, left, right, and diagonal directions represented by the following strings:

'U', 'D', 'L', 'R'

'UL', 'UR', 'DL', 'DR'

They are stored in the following constants:

UP, DOWN, LEFT, RIGHT

UPLEFT, UPRIGHT, DOWNLEFT, DOWNRIGHT

Example usage:

>>> import moosegesture
>>> moosegesture.getGesture([(332, 385), (332, 287), (332, 175), (330, 69), (324, 13), (322, 0)])
['U']

MooseGesture can also find the closest matching gesture in a list of gestures, using Levenshtein edit distance:

>>> path  = ['D', 'L', 'R']
>>> gestures = [['D', 'L', 'D'], ['D', 'R', 'UR']]
>>> moosegesture.findClosestMatchingGesture(path, gestures)
['D', 'L', 'D']

The same direction will never appear consecutively, i.e. there will never be a “right-left-left” gesture, only “right-left”.

Demo Programs

The repo at https://github.com/asweigart/moosegesture contains a tests/demoGestureApp.py which uses Pygame to display a small window. You can draw gestures in this window by dragging the mouse, and the recognized gesture will appear at the bottom.

The simongesture.py game is a Simon game that make uses of moosegesture. It requires Pygame to play.

Metadata

Release files for MooseGesture 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MooseGesture 1.0.2
File Size Uploaded Provenance Actions
MooseGesture-1.0.2.tar.gz 18.1 kB Without provenance Details for MooseGesture-1.0.2.tar.gz

Release files / MooseGesture-1.0.2.tar.gz

Download URL MooseGesture-1.0.2.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
72dcc56b3a2749e8d72abc77c7d9028222551b3019ac06e08eed9cbd754f2f47
BLAKE2b-256 checksum
How to use checksums
cd69f72a254e71e071f119fcb1be271c3f466996934bcd3d30a8a3829f4bfefd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

Security for MooseGesture 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page