The goal of this assignment is to create a Computer Vision program to track the movement of balls of different colors across various quadrants in a provided video. The program records events of each ball entering and exiting numbered quadrants, with event data formatted as Time, Quadrant Number, Ball Colour, and Event Type (Entry or Exit). Timestamps are computed based on the video duration, considering the start of the video as 0 seconds.
The Python script utilizes the OpenCV library for computer vision tasks. It detects squares and circles in the video frames, determines their color, and assigns them to specific quadrants. The resulting event data is recorded in the specified format and saved to a text file.
- Python
- OpenCV
- NumPy
-
Install the required dependencies:
pip install opencv-python numpy
-
Replace the video = cv2.VideoCapture('C:\Users\manav\OneDrive\Desktop\AI Assi\AI Assignment video.mp4') line in the code with the path to your downloaded video.
-
Run the script, and it will process the video, creating a processed video with ball tracking and generating a text file with event records.
-
The video will display tracked balls with color labels. Entry and exit events are overlaid with a timestamp at the time of occurrence. Text File:
-
The output text file, named output.txt.txt, contains records in the specified format (Time, Quadrant Number, Ball Colour, Event Type).
- The program considers the start of the video as time 0 seconds.
- To use a different video, modify the video = cv2.VideoCapture('path_to_your_video.mp4') line in the code.
- If you encounter any issues or have questions, please feel free to reach out for clarification.