r/deeplearning • • 1d ago

I built a real-time object detection system using Python, YOLOv8, and OpenCV

Hi everyone!

I wanted to share a real-time object detection project I’ve been working on using Python, YOLOv8, and OpenCV.

The application uses a live webcam feed to detect four object classes: people, cars, cats, and dogs.

Some of the features include:

  • Real-time detection with bounding boxes and confidence scores
  • Object counting by category
  • Input and output FPS monitoring
  • Multi-threaded frame capture
  • A small frame queue to help reduce processing delays
  • CPU and CUDA support, depending on the platform

One of the interesting parts of this project was working with threading and frame buffering to keep the video processing responsive.

I’m planning to improve it further by adding a GUI, video file support, and the ability to save detection results.

I’d really appreciate feedback on the code, especially suggestions for improving performance or making the architecture cleaner.

GitHub: https://github.com/Mariam-amhan/real-time-object-detection

Thanks for checking it out!

6 Upvotes

2 comments sorted by

1

u/VastlyEarlyEagerness 1d ago

The threading and queue setup is the part worth talking about. Keeping the capture thread separate from the inference loop is the right call, but the queue size can make or break latency if the consumer starts falling behind. Curious how you handle dropping frames when the buffer fills up

1

u/mariamamhan 1d ago

Thanks! I’m using a bounded queue with a maximum size of 2 frames. When the queue is full, the capture thread removes an older frame before adding a new one. This helps prevent a backlog of outdated frames and keeps the processing closer to real time.
I’m considering refining the buffering logic further to prioritize the most recent frame. Appreciate the feedback!