Skip to main content

Screenshot using Gesture hand detection

Project description

Screenshot Capture Using Hand Gestures

This project enables users to take screenshots using hand gestures detected via a webcam. It leverages the MediaPipe library for hand detection and OpenCV for video processing. The logic uses the transition of hand gestures (from an open palm to a fist) to trigger a screenshot.

Features

  • Real-time hand gesture recognition.
  • Screenshot capture when an open palm transitions to a fist gesture.
  • Configurable and extensible for other gesture-based controls.

Requirements

To run this project, you need the following dependencies:

  • Python 3.7+
  • OpenCV (cv2)
  • MediaPipe (mediapipe)
  • A library or function for taking screenshots, such as ss_taker. Replace take_screenshot in the code with your screenshot functionality.

Installation

  1. Clone the repository or download the source code.
  2. Install the required Python packages:
    pip install opencv-python mediapipe
    
  3. Ensure your Python environment includes the ss_taker library or a custom implementation for taking screenshots.

Usage

  1. Save the script to a file, e.g., gesture_screenshot.py.
  2. Run the script:
    python gesture_screenshot.py
    
  3. The webcam will activate, and the program will begin detecting hand gestures.
  4. Show an open palm to the camera, then transition to a fist gesture to capture a screenshot.
  5. Press q to quit the program.

Usage Example

from screenshot import capture_screenshot

capture_screenshot()

How It Works

Gesture Detection

The script uses the MediaPipe library to detect hand landmarks and determine whether the hand is open or closed:

  • Open palm: All fingers extended (based on landmark positions).
  • Fist: All fingers closed.

Screenshot Trigger

When the script detects a transition from an open palm to a fist, it calls the take_screenshot() function to capture the current screen.

Core Functions

is_palm_open(landmarks)

Determines whether the hand is open by comparing the positions of finger landmarks.

capture_screenshot()

Main function that:

  • Captures video from the webcam.
  • Processes each frame for hand landmarks.
  • Detects gesture transitions and triggers screenshot capture.

Customization

You can modify the script to:

  • Recognize additional gestures.
  • Perform other actions (e.g., send alerts or control devices) based on gestures.

Limitations

  • Requires a clear view of the hand for accurate detection.
  • Designed for a single hand; might need enhancements for multi-hand detection.

Acknowledgments

Contributing

Contributions are welcome! If you have ideas for improvements or additional features, feel free to submit a pull request or open an issue.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

rk_screenshot-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rk_screenshot-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file rk_screenshot-1.0.0.tar.gz.

File metadata

  • Download URL: rk_screenshot-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rk_screenshot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 02b271373d610559bb03fbcc44fee87e4aa98efa038337789e28d1b8b839b72f
MD5 75df2d902840bd757695a79e3cf57c34
BLAKE2b-256 a0aab1b0ea2eee29a13ec1314bb7a79e4b783ae2aa780318d6b1eb88732b7377

See more details on using hashes here.

File details

Details for the file rk_screenshot-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rk_screenshot-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rk_screenshot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6afd90399ae03a340f06de5b73dee4222a67559ebcb09f990c63d0a933b29f84
MD5 5e1dd56fb4caa5ef91341a407e0d37fb
BLAKE2b-256 754583aae563a7fd693fd0fcefeb69b545348e40a36eb2d941c2a98315bfbcf6

See more details on using hashes here.

Supported by

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