Skip to main content

Combines Intel RealSense and Mediapipe for hand tracking.

Project description

Realsense Mediapipe Tracking

This is a project to integrate the use of a Realsense d435 depth camera with Mediapipe for tracking the position of a subjects hand.

Using UV for package management.

Mediapipe requires python 3.12 or older unless built from source.

Example Streaming

import sys
import os
sys.path.append(os.path.abspath("src/realsense_mediapipe_tracking"))
import time
from src.realsense_mediapipe_tracking.camera import realsenseCamera
from src.realsense_mediapipe_tracking.hand_tracking import handTrack

def main():
    # Initialize the RealSense camera with desired parameters
    cam = realsenseCamera(width=640, height=480, fps=30)

    # Initialize the hand tracking class with the camera object
    track = handTrack(cam)

    try:
        # Start streaming
        print("Starting stream...")
        track.stream()
        
    except Exception as e:
        print(f"An error occurred: {e}")
    
    finally:
        # Stop the camera and release resources
        cam.stop()

if __name__ == "__main__":
    main()

Example direct x y z coordinate printing

import sys
import os
sys.path.append(os.path.abspath("src/realsense_mediapipe_tracking"))

from src.realsense_mediapipe_tracking.camera import realsenseCamera
from src.realsense_mediapipe_tracking.hand_tracking import handTrack

def main():
    # Initialize the RealSense camera
    cam = realsenseCamera()

    # Initialize the hand tracking class with the camera object
    tracker = handTrack(cam)

    try:
        while True:
            color_image, depth_image, depth_frame = tracker.cam.get_frames()
            
            if color_image is None or depth_image is None:
                continue

            landmarks_xyz, results = tracker.tracking(color_image, depth_frame)

            # Print the XYZ coordinates for each hand
            for hand_xyz in landmarks_xyz:
                for idx, (X, Y, Z) in enumerate(hand_xyz):
                    print(f"Landmark {idx}: X={X:.2f}m, Y={Y:.2f}m, Z={Z:.2f}m")

    except Exception as e:
        print(f"An error occurred: {e}")

    finally:
        cam.stop()

if __name__ == "__main__":
    main()

Required external libraries: https://github.com/IntelRealSense/librealsense

Licensed under GNU GPLv3

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

realsense_mediapipe_tracking-0.1.3.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

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

realsense_mediapipe_tracking-0.1.3-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file realsense_mediapipe_tracking-0.1.3.tar.gz.

File metadata

File hashes

Hashes for realsense_mediapipe_tracking-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fc6ffe0027fab3029435a0acace668c2956d99d48c034b43d16bb24f0a2dacef
MD5 e535f5ea70a5dfb4fa24f69fa773bba6
BLAKE2b-256 b902c98269f02a383fbe7a7853d06e7dcc3577286bd17f3bb35890bb81e3f3ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for realsense_mediapipe_tracking-0.1.3.tar.gz:

Publisher: publish.yml on vi-vi-3482/realsense_mediapipe_tracking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file realsense_mediapipe_tracking-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for realsense_mediapipe_tracking-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f469fe6369b1bb1e7b532d5a3828408735837344e656ef340d2c3fc13f8c9738
MD5 1f8220300d47601b7f8ce7c62b36e050
BLAKE2b-256 c9d56afa535c889887be6bb99c2bba9bc3d230d764bf1708af31f9a8b083a561

See more details on using hashes here.

Provenance

The following attestation bundles were made for realsense_mediapipe_tracking-0.1.3-py3-none-any.whl:

Publisher: publish.yml on vi-vi-3482/realsense_mediapipe_tracking

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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