diff --git a/doc/faq.rst b/doc/faq.rst new file mode 100644 index 0000000000000000000000000000000000000000..e60e626f6f9815f7a2c9a77b7819e6374dd8f16c --- /dev/null +++ b/doc/faq.rst @@ -0,0 +1,14 @@ +.. _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 diff --git a/doc/faq/facecrop.py b/doc/faq/facecrop.py new file mode 100644 index 0000000000000000000000000000000000000000..c377c4da2e6b3d1bc13ecafeeeee0c52a9dd345a --- /dev/null +++ b/doc/faq/facecrop.py @@ -0,0 +1,58 @@ +# --- +# 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() +# - + + diff --git a/doc/faq/img/838_ada.jpg b/doc/faq/img/838_ada.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6fbf8db609b2f2d57c7e6a0458fb9b68545e19ee Binary files /dev/null and b/doc/faq/img/838_ada.jpg differ diff --git a/doc/faq/img/ada_cropped.png b/doc/faq/img/ada_cropped.png new file mode 100644 index 0000000000000000000000000000000000000000..48dd28b552b4739b37e44089dd526240cfa5a2a4 Binary files /dev/null and b/doc/faq/img/ada_cropped.png differ diff --git a/doc/index.rst b/doc/index.rst index e0fbecd27ea700dc708cb89bb58339ec9312e274..776d35c6c8d8eaf706e1ba713f3fc8f1c75eee69 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -51,6 +51,7 @@ Users Guide leaderboard/leaderboard references annotators + faq Reference Manual ================