Skip to content
Snippets Groups Projects
Commit d9157525 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

An attempt to do a FAQ page

parent 3161603c
No related branches found
No related tags found
1 merge request!115An attempt to do a FAQ page
Pipeline #49878 passed
.. _bob.bio.face.faq:
===
FAQ
===
How to crop a face ?
====================
The recipe below helps you to set a face cropper based on eye positions.
.. literalinclude:: faq/facecrop.py
.. figure:: ./faq/img/ada_cropped.png
\ No newline at end of file
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.11.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# ## How to crop a face
# +
import bob.bio.face
import bob.io.image
# Loading Ada's images
image = bob.io.image.load("./img/838_ada.jpg")
# Setting Ada's eyes
annotations = dict()
annotations['reye'] = (265, 203)
annotations['leye'] = (278, 294)
# Final cropped size
cropped_image_size = (224, 224)
# Defining where we want the eyes to be located after the crop
cropped_positions = {"leye": (65, 150), "reye": (65, 77)}
face_cropper=bob.bio.face.preprocessor.FaceCrop(
cropped_image_size=cropped_image_size,
cropped_positions=cropped_positions,
color_channel="rgb")
# Crops always a batch of images
cropped_image = face_cropper.transform([image], annotations=[annotations])
# +
# %matplotlib widget
import matplotlib.pyplot as plt
figure = plt.figure()
plt.subplot(121)
bob.io.image.imshow(image)
plt.subplot(122)
bob.io.image.imshow(cropped_image[0].astype("uint8"))
figure.show()
# -
doc/faq/img/838_ada.jpg

103 KiB

doc/faq/img/ada_cropped.png

252 KiB

...@@ -51,6 +51,7 @@ Users Guide ...@@ -51,6 +51,7 @@ Users Guide
leaderboard/leaderboard leaderboard/leaderboard
references references
annotators annotators
faq
Reference Manual Reference Manual
================ ================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment