This Python script uses YOLOv8 from Ultralytics for real-time object detection using OpenCV. The script initializes a camera, loads the YOLOv8 model, and processes frames from the camera, annotating detected objects with bounding boxes.
Make sure you have the following libraries installed:
cv2
(OpenCV)ultralytics
supervision
pip install opencv-python
pip install ultralytics
pip install supervision==0.3.0
Clone the repository:
git clone https://github.com/SYED-M-HUSSAIN/YOLOv8-Object-Detection-with-OpenCV-and-Ultralytics
Run the script:
python yolo_inference.py
initialize_camera: Initializes the camera using OpenCV.
load_yolov8_model: Loads the YOLOv8 model from Ultralytics.
process_frame: Processes each frame from the camera using the YOLOv8 model and annotates the detected objects.
main: The main function that captures frames from the camera, processes them, and displays the annotated frames.
You can customize the camera index, model path, and annotation parameters according to your needs.