A robust video processing application that combines YOLO object detection with Lucas-Kanade optical flow-based tracking to monitor and analyze video streams for smart surveillance.
- Object Detection: Utilizes YOLOv4 for real-time detection of objects in video frames.
- Object Tracking: Tracks detected objects using Lucas-Kanade Optical Flow, ensuring smooth monitoring across frames.
- Input Flexibility: Supports video files and YouTube URLs for seamless integration.
- Output Video: Saves processed video with tracked objects as
output_video.avi
. - Interactive Display: Visualizes object detection and tracking in each frame during processing.
Ensure the following libraries are installed:
opencv-python
numpy
pytube
(for handling YouTube videos)
Install dependencies using pip:
pip install opencv-python numpy pytube
- YOLO Files:
yolov4.weights
(pre-trained weights)yolov4.cfg
(YOLO configuration file)coco.names
(class labels from the COCO dataset)
-
Clone the repository:
git clone https://github.com/your-username/smart-surveillance.git cd smart-surveillance
-
Run the script:
python smart_surveillance.py
-
Choose input mode:
- Option 1: Upload a video from your local device.
- Option 2: Provide a YouTube video URL.
-
Detection Phase:
- Detects objects in video frames using YOLOv4.
- Applies Non-Maximum Suppression (NMS) to eliminate redundant detections.
-
Tracking Phase:
- Tracks detected objects across frames using Lucas-Kanade Optical Flow.
- Updates object positions dynamically and removes failed trackers.
-
Visualization:
- Draws bounding boxes, labels, and key points for detected and tracked objects.
-
Output:
- Saves the processed video as
output_video.avi
.
- Saves the processed video as
|-- smart_surveillance.py # Main script
|-- yolov4.weights # YOLOv4 weights
|-- yolov4.cfg # YOLOv4 configuration file
|-- coco.names # COCO class labels
- Support for real-time processing via live camera feeds.
- Integration of advanced object tracking algorithms (e.g., DeepSORT).
- Transition to YOLOv8 for improved detection speed and accuracy.
- User-friendly GUI for better interaction.
This project is licensed under the MIT License. See the LICENSE file for details.
- YOLO for the object detection framework.
- OpenCV for computer vision tools and functions.
- PyTube for handling YouTube video downloads.
Feel free to contribute by submitting pull requests or issues! 🎉