This project demonstrates real-time object detection using the YOLOv9 deep learning model integrated with OpenCV. It captures live video from a webcam, detects multiple objects using pre-trained YOLOv9 weights, and displays annotated frames in real-time with bounding boxes and labels. It also tracks the count of each detected object and saves it to a Python file.
- Real-time object detection using YOLOv9
- Live webcam input with OpenCV
- CUDA GPU acceleration support
- Displays object labels and confidence scores
- Tracks and logs object count in a Python dictionary
- Python
- OpenCV
- PyTorch
- Ultralytics YOLOv9
- Collections (
defaultdict)
Install dependencies using pip:
pip install torch torchvision torchaudio opencv-python ultralytics
⚠️ Make sure your system supports CUDA if using GPU.
- Clone this repository:
git clone https://github.com/your-username/YOLOv9-Object-Detection.git
cd YOLOv9-Object-Detection-
Place your
yolov9c.ptweight file in the root directory. -
Run the detection script:
python detect.pyPress
qto stop detection. The object counts will be saved tocount.py.
After running, a file named count.py will be generated with a dictionary like:
object_counts = {
'person': 5,
'car': 2,
'dog': 1,
}Akanksha 📧 akankshaprashar5244@gmail.com
This project is licensed under the MIT License.