This is a computer vision project for face analysis from surveillance videos. Currently includes STEP-1 through STEP-4.
This step focuses on video dataset preparation and access.
- Place your video files (AVI/MP4) in the
dataset/videos/directory. - Run the script:
python src/video_dataset_prep.py
The script will scan all video files, validate them, and display their properties (filename, FPS, total frames, duration).
For each valid video:
- Video filename
- FPS
- Total frames
- Duration in seconds
For invalid videos, an error message is logged, and processing continues.
This step performs frame-by-frame traversal of videos and calculates timestamps for each frame.
- Ensure videos are in
dataset/videos/directory. - Run the script:
python src/video_frame_traversal.py
The script will process each video frame-by-frame, calculate timestamps, and log progress every 100 frames.
For each video:
- Processing start message with FPS
- Progress logs: Frame number, timestamp in HH:MM:SS and seconds
- Completion message with total frames processed
This step performs face detection on each frame using Haar Cascade.
- Install MTCNN:
Or ensure it's in requirements.txt.
pip install mtcnn
- Ensure videos are in
dataset/videos/and Haar Cascade XML is inmodels/. - Run the script:
python src/face_detection.py
The script will process each video frame-by-frame, detect faces using MTCNN, and save cropped faces.
When faces are detected and saved:
- Video name, frame number, timestamp, number of faces saved
Faces are saved in dataset/faces/<video_name>/face_f<frame>_t<timestamp>_p<index>.jpg
This step crops detected faces, resizes them, and saves them intelligently to avoid duplicates.
- Ensure videos are in
dataset/videos/and Haar Cascade XML is inmodels/. - Run the script:
python src/face_cropping.py
The script will process each video, detect faces, crop and resize them (160x160), and save all faces at fixed intervals (every 30 frames).
When faces are saved (every 30 frames):
- Video name, frame number, timestamp, number of faces saved
Faces are saved in dataset/faces/<video_name>/face_f<frame>_t<timestamp>_p<index>.jpg
dataset/videos/: Place your video files here (AVI and MP4 formats)dataset/faces/: Cropped face images saved here, organized by videosrc/: Source codemodels/: DNN model files (prototxt, caffemodel) and other modelslogs/: Reserved for future logging (not used in current steps)
- Python 3.11+
- OpenCV
- Clone or download the project.
- Install dependencies:
pip install -r requirements.txt
- Ensure videos are in
dataset/videos/directory. - Supported formats: AVI, MP4.
- If OpenCV fails to read a video, check if the file is corrupted or in an unsupported codec.