Skip to content

codewithcc/Mpkit_cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MPKIT-CC: Enhanced MediaPipe Toolkit πŸš€

PyPI Version License Python Version MediaPipe

MPKIT-CC is a powerful Python wrapper that simplifies MediaPipe's computer vision capabilities with real-time FPS monitoring, customizable visualizations, and intuitive APIs for hand tracking, face detection, facial landmarks, and pose estimation.

Feature Showcase

✨ Key Features

  • Real-time FPS Monitoring - Built-in frame rate display with customizable styling
  • Multi-Feature Detection:
    • βœ‹ Hand tracking with 21 landmarks per hand
    • 😊 Face detection with bounding boxes
    • πŸ‘οΈ 468-point facial mesh detection
    • 🧍 Full-body pose estimation (33 landmarks)
  • Custom Visual Styles:
    • 🎨 Predefined color constants (RED, GREEN, BLUE, etc.)
    • πŸ–ŒοΈ Choice between default MediaPipe styles or custom drawings
    • πŸ”— Toggleable landmark connections
  • Flexible Configuration:
    • πŸ“· Camera settings adjustment (resolution, FPS)
    • βš™οΈ Detection confidence thresholds
    • πŸ–ΌοΈ Multiple image format support (BGR, RGB, grayscale)

πŸ“¦ Installation

pip install mpkit-cc

πŸ§ͺ Example Test Code

Here's a complete demonstration showcasing all features of MPKIT-CC with real-time FPS monitoring:

from mpkit_cc import Mptools
from time import time
from cv2 import imshow, waitKey, destroyAllWindows

# Initialize with custom settings
obj = Mptools(
    image_mode=False,    # Video stream mode
    cam_index=0,         # Default camera
    win_width=640,       # Frame width
    win_height=360,      # Frame height
    cam_fps=30,          # Target FPS
    hand_no=2,           # Detect up to 2 hands
    face_no=1,           # Detect up to 1 face
    tol1=0.5,            # Detection confidence
    tol2=0.5             # Tracking confidence
)

# Start camera
cam = obj.init()
start_time = time()

while cam.isOpened():
    success, image = cam.read()
    if not success:
        print("Ignoring empty frame...")
        continue
    
    # Uncomment the detectors you want to use:
    
    # Hand detection with connections (MediaPipe default style)
    hand_data = obj.find_Hands(
        image=image,
        mode="BGR",
        hand_connection=True,
        show_detect=True,
        detection_style=1
    )
    
    # Face detection with bounding box
    face_data = obj.find_face(
        image=image,
        mode="BGR",
        show_detect=True,
        boundary=True
    )
    
    # Face mesh with 3D connections
    face_meshs = obj.find_face_mesh(
        image=image,
        mode="BGR",
        face_connection=True,
        face_connection_3d=True,
        show_detect=True
    )
    
    # Pose estimation with custom styling
    poses = obj.find_pose(
        image=image,
        mode="BGR",
        body_connection=True,
        show_detect=True,
        detection_style=0
    )
    
    # Print results if detections found
    if hand_data and hand_data != ([], [], []):
        print(f"Hands detected: {hand_data[1]} (Confidence: {hand_data[2]}%)")
    
    if face_data and face_data != ([], [], []):
        print(f"Face detected (Confidence: {face_data[2]}%)")
    
    if face_meshs:
        print(f"Face mesh points: {len(face_meshs)} landmarks")
    
    if poses:
        print(f"Body pose points: {len(poses)} landmarks")
    
    # Calculate and display FPS
    end_time = time()
    fps = int(1 / (end_time - start_time))
    start_time = end_time
    image = obj.show_FPS(
        image=image,
        mode="BGR",
        fps_rate=fps,
        fore_bg=Mptools.YELLOW,
        back_bg=Mptools.RED
    )
    
    # Display output
    imshow("MPKIT-CC Real-time Detection", image)
    
    # Exit on 'q' key press
    if waitKey(1) == ord("q"):
        break

# Cleanup
cam.release()
destroyAllWindows()

About

mpkit-cc - A Python wrapper for MediaPipe that simplifies real-time hand, face, and pose detection. Just pip install mpkit-cc to add computer vision superpowers to your projects with minimal code. Perfect for gesture control, AR apps, and motion tracking. πŸ”₯

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages