For this project, we wanted to present our take on Snapchat's face filters.
frames:
- This folder was created to contain the output of cell 9. This was created to test the video2imageFolder function in utils.py.
samples:
- This folder is used to store your input images and videos.
results:
- This folder is the location of processed output video.
Final_project.ipynb
- The main project file. Run this code to generate the output video.
utils.py
- Python file containing helper functions from previous CS445 MPs.
haarcascade_frontalface_default.xml
- Frontal face detection xml file.
shape_predictor_68_face_landmarks.dat
- Face landmark detection data file. Download it here: https://github.com/italojs/facial-landmarks-recognition/blob/master/shape_predictor_68_face_landmarks.dat
- Place this file in the same folder as haarcascade_frontalface_default.xml.
To build the project, be sure to download the following software and packages:
- Python 3
- Jupyter Lab/Notebook
- cv2
- ffmpeg
- numpy
- matplotlib
- dlib
Once you open the project file, be sure to change the file path in cell 3 to the location of your downloaded repository.
After this is done, you may run cells 1 through 7. In the 8th cell, this is where you will input your desired input images and .mp4 files for processing.
Be sure to change the file path for the variables cap and output_video_path. In order to change your input video and image, you need to edit the filenames in the variables face_image and cap. As seen in the image above, the input image face.png and input video snapchat.mp4 are currently loaded. Once you have changed these parameters, run the cell to generate your processed video. The output of this cell will be located in the samples folder in your computer's repository directory.
If you decide to use a video other than snapchat.mp4, then make sure to comment out this code:
top_quarter_height = filter_frame.shape[0] // 4
if filter_face_bbox[1] + filter_face_bbox[3] // 2 > top_quarter_height:
continue # Skip this frame if the face is not in the top quarter