Skip to content
/ autocrop Public
forked from leblancfg/autocrop

🆔 Automatically crops faces from batches of pictures

License

Notifications You must be signed in to change notification settings

CSCG/autocrop

Repository files navigation

autocrop

Basic script using openCV, that automatically detects and crops faces from batches of photos.

Perfect for batch work for ID cards or profile pictures, will output images centered around the biggest face detected. It can also add a touch of auto gamma correction.

Installation

N.B. 28/019/2017: pip install autocrop should now work on most platforms, as well as a basic command-line interface (CLI). Testing on further platforms is currently under way. If this fails:

The script will process all .jpg files in the /photos directory. The cropped files are placed in photos/crop, and originals are moved to photos/bkp.

If it can't find a face in the picture, it'll simply leave it in /photos.

conda

The easiest way to run autocrop is to use the Anaconda Python distribution and run the following:

git clone https://github.com/leblancfg/autocrop
conda install --channel conda-forge --file requirements.txt

Move your pictures to be cropped in the photos directory, then run the script with:

cd autocrop
python autocrop.py

If running on Windows, this is by far the sanest way to approach this problem. Also, installing Anaconda doesn't require admin privileges on Windows.

pip

Otherwise, binaries for the Python-only bindings for OpenCV have recently been made available through pip, which makes installation a breeze.

git clone https://github.com/leblancfg/autocrop
pip install numpy opencv-python

Move your pictures to be cropped in the photos directory, then run the script with:

cd autocrop
python autocrop.py

Requirements

The script works on Python 2.7 and 3+, and on Windows, macOS and Linux. It has not been tested otherwise.

More Info

Check out:

Adapted from:

About

🆔 Automatically crops faces from batches of pictures

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%