This is a project for object detection using the YOLO (You Only Look Once) model and the OpenCV library. The detector identifies objects in an image and draws bounding boxes around them, along with class labels and confidence scores.
- Python 3.x
- OpenCV 4.5.3.56
- YOLO model files (yolov3.cfg, yolov3.weights)
- Class names file (coco.names)
- An input image with a perspective similar to the human eye
In order to get the weights for the algorithm, click on this drive link: https://drive.google.com/drive/u/1/folders/1QuR4pli3nyPK-cK6GsfhSq2tLd4ydvLW
-
Clone or download this repository to your local machine.
-
Ensure you have the correct version of OpenCV (4.5.3.56) installed. You can install it using pip:
pip install opencv-python==4.5.3.56
-
Place the YOLO model files (
yolov3.cfg
andyolov3.weights
) in the project directory. -
Place the class names file (
coco.names
) in the project directory. -
Make sure you have an input image with a perspective similar to the human eye. Rename it to
yolo_prueba.png
and place it in the project directory.
Run the main.py
script to execute the object detector on the input image. Detected objects will be highlighted with bounding boxes and class labels, and the resulting image will be saved as output_image.jpg
.
Adjust the confidence threshold by modifying the confidence_threshold
variable in the main.py
script to suit your needs.
confidence_threshold = 0.5 # Set your desired confidence threshold
Below is an example of the output from the YOLO and OpenCV object detection:
In the sample image, detected objects are highlighted with bounding boxes and class labels, along with their respective confidences.