Skip to main content

A lightweight palm region-of-interest (ROI) extraction tool using hand landmarks and OpenCV.

Project description

palm_roi - A region-of-interest extraction tool 🖐️

A lightweight palm region-of-interest (ROI) extraction Python library, originally built for use in a palm-vein biometric imaging device. It makes use of OpenCV and hand landmarks (using tools like MediaPipe) to compute an ROI of a palm in an image, calculate a rotation matrix to straighten it out, and process coordinates.

[!NOTE]
The original Raspberry Pi example with a live camera feed has been moved to the examples/ directory. Check out the example's README.md for details on how to set it up!

Installation

You can install palm_roi easily via pip:

pip install palm_roi

Note: Depending on your setup (e.g., using MediaPipe to get the hand landmarks), your Python version compatibility will be constrained. The palm_roi library currently works with Python 3.8+, but MediaPipe currently requires Python <3.13.

Usage

Here's an example using Mediapipe hands with palm_roi to extract hand landmarks and perform ROI computation:

import palm_roi
import cv2
import mediapipe as mp

# 1. Provide an image and get hand landmarks from MediaPipe (or another tool)
image = # - your image data - #
hands = mp.solutions.hands.Hands(static_image_mode=True, max_num_hands=1)
results = hands.process(cv2.cvtColor(image, cv2.COLOR_GRAY2RGB))

if results.multi_hand_landmarks:
    INDEX_FINGER_MCP = results.multi_hand_landmarks[0].landmark[5]
    PINKY_MCP = results.multi_hand_landmarks[0].landmark[17]
    WRIST = results.multi_hand_landmarks[0].landmark[0]

    # 2. Apply padding, rotation, and cropping to your image automatically.
    output, error = palm_roi.extract(image, INDEX_FINGER_MCP, PINKY_MCP, WRIST)

    if not error:
        cv2.imwrite(f"output.png", output) # Save your processed ROI!

    # Alternatively, get the ROI boundaries, rotation matrix, and orientation for manual application.
    R, roi_height, l1, l2, upside_down = palm_roi.get_coords(image, INDEX_FINGER_MCP, PINKY_MCP, WRIST)

See examples/main.py for a full implementation demonstrating real-time camera processing and Mediapipe.

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

palm_roi-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

palm_roi-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file palm_roi-0.1.0.tar.gz.

File metadata

  • Download URL: palm_roi-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for palm_roi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ba5cbc4a8b8553f083de966ea9a71264a6db58a52e50863a661304add9b3123
MD5 28944063400ae0461ca9e8a0fc7ea0ea
BLAKE2b-256 cc4b009fb01c7daebcf9d8a9772507aaa2b56d4c1f0fab8e859646f54696299d

See more details on using hashes here.

File details

Details for the file palm_roi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: palm_roi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for palm_roi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f83c482d286040a5a54eb76d7def9f10b6ba6e11185e1b8c1dc845b2e8623381
MD5 beca925dee49df16cd135f31c1073ef4
BLAKE2b-256 5bc22d5635a0054756ea095ab0552ab83bc480d4f9b0f1a3ac068ae01e8737d1

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