This Python script uses Dlib's face detection capabilities to analyze a video file, detect faces in key frames, and save these faces as separate image files in a specified output folder. It's designed to be user-friendly, even for those not familiar with GitHub or Python programming.
Before running the script, ensure you have the following prerequisites installed:
-
Python: The script is written in Python, so you need Python installed on your computer. You can download it from python.org.
-
Required Libraries:
- Dlib: A toolkit for making real world machine learning and data analysis applications in C++ and Python.
- OpenCV (cv2): An open source computer vision and machine learning software library.
- NumPy: A library for the Python programming language, adding support for large, multi-dimensional arrays and matrices.
- tqdm: A library for adding progress meters to Python loops.
You can install these libraries using pip (Python's package installer). Run the following command in your terminal or command prompt:
pip install dlib opencv-python numpy tqdm
-
Download the Script: If you're not familiar with GitHub, simply download the script file directly from the GitHub repository. Look for a button or link named 'Download' or 'Clone' and choose the option to download the file.
-
Save the Script: Save the script on your computer in a location where you can easily access it, like your desktop or a specific folder dedicated to scripts or projects.
-
Open Command Line:
- On Windows, press
Win + R
, typecmd
, and press Enter. - On MacOS, open the Terminal app.
- On Linux, open your preferred terminal emulator.
- On Windows, press
-
Navigate to the Script Location: Use the
cd
command to navigate to the directory where you saved the script. For example, if you saved it on the desktop, you would use:cd Desktop
-
Run the Script: Type
python script_name.py
in the terminal, replacingscript_name.py
with the actual name of the script file.
When you run the script, it will ask for two inputs:
-
Video File Path: Enter the full path to the video file you want to process. Ensure there are no quote marks around the path.
-
Output Folder Path: Enter the path to the folder where you want to save the extracted face images. If the folder does not exist, the script will create it.
If you encounter any errors:
- Make sure all required libraries are installed.
- Check the video file path and output folder path for accuracy.
- Ensure Python is correctly installed on your system.