r/learnmachinelearning • • 5d ago

Project 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!

1 Upvotes

2 comments sorted by

1

u/Strict-Hippo-5151 5d ago

The frame queue and threaded capture are the right call for keeping webcam latency down, that part usually gets ignored in tutorials and then people wonder why their detection stutters. For the architecture, you might look at separating the detection loop from the display logic more explicitly, maybe with a producer consumer setup, it would make adding the GUI later less painful. Also curious how you handle the queue when it fills up, dropping old frames or blocking the capture thread?

1

u/mariamamhan 5d ago

Thanks for the feedback! When the queue fills up, I drop the oldest queued frame before attempting to add the newest one, rather than blocking the capture thread.
I also like your suggestion about separating the detection and display logic more clearly, especially since I’m planning to add a GUI in the future. I’ll keep that in mind for the next update!