Skip to content

Repository files navigation

checkPersonInCam

This repository contains a Python script that performs real-time object detection using YOLOv8 model from Ultralytics. It captures video from the webcam, detects objects in the frames, and annotates them with bounding boxes. Additionally, it plays a sound whenever a person is detected in the video.

Setup

  1. Install Python: Make sure you have Python 3.x installed on your machine.

  2. Create Virtual Environment (optional but recommended):

    python3 -m venv venv
    source venv/bin/activate
  3. Install Dependencies: Install the required dependencies by running:

    pip install ultralytics supervision pygame opencv-python

Usage

  1. Run the script using the following command:

    python main.py
  2. The script will access your webcam, detect objects in real-time, and annotate the video feed with bounding boxes.

  3. If the script encounters an error, it will attempt to restart itself after a 10-second delay.

  4. To exit the script, press the Esc key.

Notes

  • The YOLOv8 model is loaded from the yolov8l.pt file. Make sure the file is present in the same directory as the script.

  • The script uses the ultralytics library for object detection and the supervision library for annotating the bounding boxes.

  • The script uses the pygame library to play a sound when a person is detected.

  • The script keeps track of the time since the last person detection and plays the sound when a person is detected after a certain period.

  • If you want to modify the webcam resolution, you can do so by editing the --webcam-resolution argument in the main.py script.

Helps

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages