This repository provides a comprehensive toolkit designed for efficient video processing and analysis, specifically tailored for surveillance applications. The toolkit includes features such as background generation, object detection, video synopsis, and more, making it ideal for research, security, and monitoring projects.
To set up the surveillance toolkit, follow these steps:
-
Clone the repository:
git clone https://github.com/vinay-852/Video_Synopsis.git cd Video_Synopsis
-
Install the required dependencies:
pip install -r requirements.txt
-
Generate Background for surveillance video:
from Components.generate_background import generate_background generate_background('surveillance_video.mp4', 'background.jpg', method='median', num_frames=30)
The following Python packages are needed for the surveillance video toolkit:
supervision
git+https://github.com/THU-MIG/yolov10.git
deep-sort-realtime
opencv-python-headless
absl-py
torch
tqdm
requests
ipython
To download the MEVID dataset, use the text_retriever
and download_file
functions:
from Components.text_retriever import text_retriever
from Components.download_file import download_file
urls = text_retriever("https://raw.githubusercontent.com/Kitware/MEVID/refs/heads/main/mevid-v1-video-URLS.txt")
for url in urls:
download_file(url, "dataset")
Preprocess the video for analysis using the initialize_video
function:
from Components.preprocessing import initialize_video
video_cap, writer, total_frames, frame_width, frame_height = initialize_video('surveillance_video.mp4', 'output_video.mp4')
Extract tracks for moving objects (people, vehicles, etc.) using extract_object_tracks
:
from extractObjectTracks import extract_object_tracks
extract_object_tracks('model_file.pth', 'surveillance_video.mp4', 'output_tracks.csv', conf_threshold=0.5, threshold=0.3)
Calculate the area and velocity of moving objects from extracted tracks:
from calculate_area_velocity_tubes import calculate_area_velocity_tubes
input_csv = 'object_tracks.csv'
output_csv = 'object_tracks_with_area_velocity.csv'
calculate_area_velocity_tubes(input_csv, output_csv)
Optimize the object tracks for generating an efficient video synopsis:
from optimise import simulated_annealing
optimized_tracks = simulated_annealing(database, initial_temperature=1000, cooling_rate=0.995, mutation_rate=0.1, max_generations=100)
Create a compressed video synopsis that highlights key activity from the surveillance video:
from videoSynopsis import generate_video_synopsis
generate_video_synopsis('background.jpg', 'optimized_object_tracks.csv', 'crops_dir', 'synopsis_frames', video_output='synopsis_video.mp4', fps=30, max_objects_per_frame=4)
This function will create a time-compressed surveillance video that highlights key actions, enabling efficient review of long surveillance footage.
We welcome contributions! If you encounter bugs or have suggestions for improvements, feel free to submit a pull request or open an issue.