![Project Banner]
The Traffic Violation Detection project uses Spark and Kafka to detect traffic violations in real-time from video streams. This project aims to provide a scalable and efficient solution for monitoring traffic and enforcing traffic rules.
- Real-time video stream processing
- Traffic violation detection using YOLOv10
- Scalable architecture with Apache Kafka and Spark
- Detailed logging and monitoring
- Easy configuration and deployment
The architecture of the project consists of the following components:
- Video Stream Producer: Captures video frames and sends them to a Kafka topic.
- Spark Consumer: Reads frames from Kafka, processes them with a UDF for bounding box prediction, and streams the processed frames to another Kafka topic.
- Processed Frame Consumer: Reads processed frames from Kafka, displays them using OpenCV and stores in MongoDB.
- Python 3.8+
- Apache Kafka (current version: 3.7.0)
- Apache Spark (current version: 3.5.1, scala: 2.12.18)
- JDK 11
- OpenCV
-
Clone the repository:
git clone https://github.com/boo283/Traffic_Violation_Detection.git
-
Create a virtual environment and activate it:
python -m venv myenv source myenv/bin/activate # On Windows, use `myenv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Start Kafka and create the required topics:
- instruction in the file 'Traffic_Violation_Detection/docs/kafka_run.txt'
- detection.py: model_path, checkpoint_path
- kafka_producer: video_path, config_file_path
python ./pipelines/kafka_producer.py
python ./pipelines/detection.py
python ./pipelines/app.py
python ./pipelines/kafkaAPI.py
- kafka_config.yml: Kafka producer and consumer settings.
- logging_config.yml: Logging settings.
- Ensure you update these files according to your environment.
- You have to set up SPARK, HADOOP, JAVA environment / system env paths
- Try to delete folder "C:/temp" and restart kafka
- Keep cool off and wait
- LinkedIn: https://www.linkedin.com/in/phutrungnguyen283/
- Facebook: https://www.facebook.com/ngphtrungboo
- Email: trung280302@gmail.com
Feel free to adjust my code, practice makes perfect ❤️❤️❤️