Using facial recognition and pixelsorting on images to create glitched, Snapchat-like lenses.
Utilizes pixelsort, another project I am involved in. Make sure to check it out!
With Docker:
git clone https://github.com/BernardZhao/lenssort.git
cd lenssort
docker-compose up
# Make sure to include the -o flag, previews won't show up in the container.
docker-compose run lenssort python -m lenssort examples/example1.jpg -m face -o example_result.png
Manually:
Requires Python 3.6 >=. Make sure you have dlib Python bindings installed!
git clone https://github.com/BernardZhao/lenssort.git
cd lenssort
# Can skip virtual environment if desired
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m lenssort %PathToImage% [mask_type] [params]
Mask name | Description |
---|---|
eyes |
Sort the eyes. |
face |
Sort the face, within the brows and chin. |
shuffle |
Sort a polygon randomly generated over facial features. |
censored |
Sort the eye area with a thick bar. |
facemask |
Sort the area of the face under the eyes. |
tears |
Sort tear-like lines below the eyes. |
Parameter | Flag | Description |
---|---|---|
Invert | -i |
Inverts the mask. May produce cool results. |
Angle | -a |
Sorting angle. Overrides internal default for the mask. |
Output path | -o |
File output path. Previews image if not provided. |
python -m lenssort examples/example1.jpg -m face
python -m lenssort examples/example1.jpg -m face -i -a 90
python -m lenssort examples/example1.jpg -m eyes -i
python -m lenssort examples/example3.jpg -m facemask
python -m lenssort examples/example3.jpg -m shuffle
python -m lenssort examples/example2.jpg -m censored
- Expose pixelsort args: sorting function, interval function, etc.
- Validate mask: No out of bounds
- Mask compositions: Ex: (face - eyes + ...)
And more masks ofc πͺ