Skip to main content

PerceptionPro is a package for computer vision tasks such as head pose estimation, eye tracking, and object detection.

Project description

PerceptionPro

PerceptionPro is a Python package designed for real-time monitoring and alert systems. It provides modular components for head pose estimation, eye tracking, and object detection, all integrated into a cohesive alert system.

Features

  • Head Pose Estimation: Tracks the orientation of the user's head in real-time.
  • Eye Tracking: Detects and analyzes eye movements and gaze direction.
  • Object Detection: Identifies objects in the background to ensure environment compliance.
  • Core: Combines all modules for real-time monitoring and alert generation.

Installation

pip install perceptionpro

Usage

import cv2
import time
import keyboard 
import perceptionpro
from perceptionpro.core import perceptionproInit

def main():
    """
    Main function to initialize the camera, process video frames,
    and handle user input to quit.
    """
    try:
        # Initialize the camera
        camera = cv2.VideoCapture(0)

        if not camera.isOpened():
            print("Error: Camera could not be opened.")
            return
        else:
            print("Camera opened successfully.")

        # Initialize the perceptionproInit with speech enabled
        perceptionpro = perceptionproInit(camera, model_path="https://github.com/UmarBalak/perceptionpro/raw/refs/heads/main/yolov8s.pt")

        # Initialize variables
        violation_count = 0
        prev_time = time.time()

        while True:
            # Capture frame-by-frame
            ret, frame = camera.read()

            if not ret:
                print("Failed to capture video. Check your camera connection.")
                break

            # Calculate frame rate
            current_time = time.time()
            elapsed_time = current_time - prev_time
            fps = 1 / elapsed_time if elapsed_time > 0 else 0
            prev_time = current_time

            # Process frame metrics
            result, eye_d, head_d, fps, obj_d, alert_msg = perceptionpro.track()
            print("Procesed")

            if not result:
                violation_count += 1
                print(f"Warning: {violation_count} - {alert_msg}")

                if violation_count == 4:
                    print("The exam has been terminated.")
                    break
            else:
                pass
                # Print real-time metrics to console
                print(f"FPS: {fps:.2f}")
                print(f"Eye Direction: {eye_d}")
                print(f"Head Direction: {head_d}")
                print(f"Background: {'Ok' if obj_d else 'Object detected'}")

            # Check if 'q' is pressed to exit the loop
            if keyboard.is_pressed('q'):
                print("User requested to stop the process.")
                break

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

    finally:
        # Always release the camera and close windows
        if 'camera' in locals() and camera.isOpened():
            camera.release()
        print("Camera released. Process complete.")

if __name__ == "__main__":
    main()

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

perceptionpro-0.1.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

perceptionpro-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file perceptionpro-0.1.1.tar.gz.

File metadata

  • Download URL: perceptionpro-0.1.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for perceptionpro-0.1.1.tar.gz
Algorithm Hash digest
SHA256 90523535cefb546503ca35d60e5c2dcd0039bad88feb5f6466a9558b017d5a3d
MD5 0ce20d3c37bd55fe48ac33010a1366c0
BLAKE2b-256 e3a585ea6ccb6cce2e3cf583f3ce673076a9eb343f72d72f7b8a61d691b746cd

See more details on using hashes here.

File details

Details for the file perceptionpro-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: perceptionpro-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for perceptionpro-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 918a7865bd8e10a1332812b267b0352815b234e5829449b02172fe6d797cea71
MD5 aae278e3ed2a992d6f6d57d657c3feea
BLAKE2b-256 b53d44bd9d1e3e9facfab4eec347d151f3f92c1ff89df8869d62e4e7c0606978

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