This simple Python script uses the OpenCV library to perform car tracking and stop sign detection in a video stream. It utilizes Haar cascades for both cars and stop sign detection.
- OpenCV:
pip install opencv-python
-
Download the pre-trained Haar cascade XML files for vehicle and stop sign detection and place them in the "CarTracking" directory.
-
Update the video file path in the script:
vid = cv2.VideoCapture("video/file.mp4")
-
Run the script:
python main.py
-
The script will display the video stream with rectangles around detected cars and stop signs.
- The script initializes Haar cascade classifiers for car and stop sign detection.
- It reads frames from the specified video file and converts them to grayscale.
- Car and stop sign detection is performed using
detectMultiScalemethod. - Rectangles are drawn around detected cars and stop signs, and labels are added.
- The processed frames are displayed in a window named "Face Detector app."
- Press 'q' to exit the application.
Abdulrahman Mendahawi
Feel free to modify and extend this script according to your requirements.