Vehicle detection with OpenCV is a computer vision process involving the acquisition of images or video frames, followed by pre-processing for noise reduction through resizing and filtering. Object detection models like SSD or YOLO are employed to identify potential vehicle regions in the input. Relevant features are then extracted from these regions, and classifiers, such as Support Vector Machines or neural networks, are used to determine if a region contains a vehicle. Post-processing techniques refine the results, eliminating false positives. Finally, the detected vehicles are visualized by drawing bounding boxes around them, providing an automated solution for locating and identifying vehicles in images or video streams. Certainly! Below is a basic README text that you can include with your code. Please customize it further based on your specific project details.
This Python script is designed for real-time vehicle detection and counting using YOLOv4, OpenCV, pyttsx3, and a custom object detection module. The system identifies vehicles in a video stream, assigns unique IDs for tracking, and provides a voice-guided interface.
You have to download the python version of the 3.11.4.
Make sure you have Python installed. You can download it from python.org.
pip install opencv-python
pip install numpy
pip install art
pip install pyttsx3
pip install textblob
pip install colorama
Download the YOLOv4 weights fils below the provided link and give the address of that files in object_detection. https://github.com/AlexeyAB/darknet Place the weights and cfg files in the object_detection directory .
-
Open the script in a code editor.
-
Customize the video file path:
video = cv2.VideoCapture("C:\\Users\\DELL\\OneDrive\\Desktop\\Project\\Highway.mp4")
-
Modify the YOLOv4 weights path:
od = ObjectDetection(weights_path="path/to/yolov4.weights")
-
Run the script:
python vehicle_detection.py
Firstly you to download the libraries by using the above commands and then you have to save all the images and video files where your main.py file is located. When you will run the code then you have to answer some questions. When program ask for image processing then you have to put the name of that file only e.g 1 It depens on your image name and extension of image should be .png. For video processing repeat the same process and extension of video file should be .mp4
It can detect cars in smog also.
It can detect and count cars at night also.
You can download the main.exe file from one drive https://drive.google.com/file/d/1TI8mxt4K1U2ikKh_PYyNcLXpf9D88KCJ/view?usp=sharing