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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perceptionpro-0.1.0.tar.gz.
File metadata
- Download URL: perceptionpro-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37ababfa59cca4b4933135df87c4c97aed4d829d8b254200b03b40835fff3aa5
|
|
| MD5 |
f69fe12c1bcbaf1cc23ddcc3728e8833
|
|
| BLAKE2b-256 |
fa8fa82062094813c7f112907bc6d319c2f0172384ff60d01b8e72fb97606550
|
File details
Details for the file perceptionpro-0.1.0-py3-none-any.whl.
File metadata
- Download URL: perceptionpro-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a814965f0e5ed30135d36fbb930ba62d4295903700f4b15544e118cad1c35052
|
|
| MD5 |
be1649c02aab2c543a8b79fb7728cb83
|
|
| BLAKE2b-256 |
c1463de2f666aa01abcfbecc539c0db0a1b3e95924aa8de44d3585e44493035c
|