Metadata-Version: 2.4
Name: gestureplaykit
Version: 0.1.0
Summary: Friendly webcam, hand gesture, facial landmark and picture-overlay tools for creative Python projects
Author: GesturePlayKit contributors
License-Expression: MIT
Keywords: gestures,webcam,hand tracking,mediapipe,AR,computer vision
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Multimedia :: Graphics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mediapipe>=0.10.20
Requires-Dist: numpy<3,>=1.26
Requires-Dist: opencv-contrib-python>=4.8
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Dynamic: license-file

# GesturePlayKit 🖐️

**Write interactive webcam apps in plain Python without rewriting MediaPipe setup or OpenCV image-overlays each time.**

GesturePlayKit is an **open-source-ready library scaffold** (MIT licensed). It is **not published on PyPI or GitHub yet**. Its job is to supply reusable webcam, gesture and image primitives—not your application rules.

## Installation (Windows PowerShell)

```powershell
cd gestureplaykit
python -m pip install -e .
```

One-time download of Google's hand/face AI model files:

```powershell
python -c "from gestureplaykit import download_models; print(download_models('models'))"
```

After this download, **tracking works offline**. If you use pictures from internet URLs, download those in advance too for offline use.

## A tiny program

Save this as `try_it.py` in the project folder:

```python
from gestureplaykit import Camera, Vision, load_picture, show_picture, show_text

chip = load_picture("examples/chip.png", size=(100, 100))

with Camera() as camera, Vision(models_dir="models") as vision:
    while True:
        frame = camera.read()
        if frame is None:
            break
        vision.update(frame)

        hand = vision.hand
        face = vision.face
        if hand and hand.pinching:
            show_picture(frame, chip, at=hand.pinch_center)
        if hand and hand.double_pinched:
            print("DOUBLE PINCH!")
        if face and face.mouth_open:
            show_text(frame, "MOUTH OPEN", at=(15, 70))

        if not camera.show(frame, title="My Project"):
            break
```

Press **Q** or Escape to exit.

## Quick reference

| What you want | What to write |
|---|---|
| Open webcam | `with Camera() as camera:` |
| Get video frame | `frame = camera.read()` |
| Track hand and face | `vision.update(frame)` |
| First hand found? | `if vision.hand:` |
| Are thumb/index touching? | `if vision.hand.pinching:` |
| Pinch began **this frame**? | `if vision.hand.pinch_started:` |
| Double pinch **this frame**? | `if vision.hand.double_pinched:` |
| Thumb tip coordinate | `hand.landmark(4)` |
| Index tip coordinate | `hand.landmark(8)` |
| Center between fingertips | `hand.pinch_center` |
| Palm center | `hand.palm_center` |
| Any landmarks touching? | `hand.touching(4, 12)` |
| Is mouth open? | `if face and face.mouth_open:` |
| Mouth just closed? | `if face and face.mouth_just_closed:` |
| Mouth screen position | `face.mouth_center` |
| Is pixel point near mouth? | `face.near_mouth((x, y), max_distance=70)` |
| Local / web picture | `chip = load_picture("image.png")` or `load_picture("https://example.com/picture.png")` |
| Draw picture | `show_picture(frame, chip, at=(x, y))` |
| Draw text | `show_text(frame, "Hello!", at=(10, 30))` |
| Display webcam | `if not camera.show(frame): break` |

## Your own app logic

The library **does not** decide whether someone ate a chip, award points, freeze objects, manage skins, implement a shop, or save game state. Those are the interesting program features for you to design. Look at `examples/03_build_your_own_game.py` for an intentionally unfinished starter.

## Images

`load_picture(...)` accepts local PNG/JPG or a direct HTTP(S) image URL. It downloads and decodes the URL only once per unique URL in the current Python process. For speed, load before entering the camera loop. Transparent PNGs are supported; pictures clip safely when partly offscreen.

The included `examples/chip.png` is a simple bundled example graphic; change it however you like.

## Models and privacy

Hand and face detection runs **on your computer**, using Google MediaPipe Tasks. The library does **not upload webcam frames**. Calling `download_models()` or `load_picture("https://...")` connects to those respective web hosts. You may need to adjust gesture ratios in different lighting, with occlusions or different camera angles. The API only estimates apparent fingertip contact and mouth opening—it cannot prove actual touch or eating.

## Build your own published package

```powershell
python -m pip install build
python -m build
```

The generated `.whl` and `.tar.gz` appear under `dist/`. Read Python Packaging's publishing guidance before releasing to PyPI. You can also place this folder in a **public GitHub repository**, including `LICENSE` and `README.md`.

## Attribution and competition honesty

This initial GesturePlayKit implementation and parts of its documentation were produced with AI assistance. Record that attribution if you reuse it. Open-source libraries may be cited, but your competition project's **significant code must still be your own work**. It is not enough to repackage an AI-written application behind a library. Build your original game rules, state transitions, interface, and other meaningful software yourself.

## Testing

```powershell
python -m pip install pytest
python -m pytest -q
```

Camera/model integration requires testing on your own hardware. Automated tests cover image overlays and public helper behavior using fake tracking results.
