Face cropping by bounding box fails with negative top/left coordinates
In case of negative annotations of the bounding box, cropping the face will result in an error. Apparently, the range
X[...,top:bottom,left:right]
will result in a dimension of 0 when top or left is negative, and therefore the cropping via OpenCV will fail: https://gitlab.idiap.ch/bob/bob.bio.face/-/blob/fb8ffece2423465fdbe6325c75845817d4b53a92/bob/bio/face/preprocessor/croppers.py#L390
Please note that the cropping works well for FaceEyesNorm
, where the corresponding dimensions are padded before extraction: https://gitlab.idiap.ch/bob/bob.bio.face/-/blob/fb8ffece2423465fdbe6325c75845817d4b53a92/bob/bio/face/preprocessor/croppers.py#L294
Maybe we can make use of the FaceEyesNorm
class here instead of trying to do the cropping by hand.
Additionally, in the same line of code, it is assumed that the bounding box has the same aspect ratio as the self.final_image_size
.
If this is not the case, the facial image will be distorted.
It would be great if we could adapt top/bottom or left/right such that the aspect ratio of the target size is kept (as far as possible, despite rounding issues).