Film Generator Life's Photo is a Python script that generates a video by composing images from a directory. The script uses the MediaPipe library to detect facial landmarks and aligns the images based on the location of the eyes.
- Python 3.x
- OpenCV (
cv2
) library - NumPy library
- MediaPipe library
- Clone the repository or download the
film_generator_lifes_photo.py
file. - Install the required dependencies by running the following command:
pip install opencv-python numpy mediapipe
- Place the images you want to include in the video in a directory.
- Update the
img_dir
variable in the script with the path to the image directory. - Adjust the parameters according to your preferences:
left_eye_loc_std
: Specifies the standard location of the left eye (x, y) for alignment. Adjust this if the alignment is incorrect.frame_rate
: Specifies the frame rate of the generated video.frame_size
: Specifies the frame size (width, height) of the generated video.
- Run the script using the following command:
python film_generator_lifes_photo.py
- The script will process the images, align them based on the location of the eyes, and generate a video named
output.mp4
in the current directory.
Note: Make sure the images in the directory have consistent aspect ratios for better alignment results.
- OpenCV: Open Source Computer Vision Library
- NumPy: Fundamental package for scientific computing with Python
- MediaPipe: Cross-platform framework for building multimodal applied machine learning pipelines
Made with ❤️ by Sajad Kamali