Commit 7e0056b4 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira

Merge branch 'dev_branch' into 'master'

This fixes the issue with negative coordinates in the face bounding box.

See merge request !4
parents ade99880 52b1f3f1
Pipeline #13310 failed with stages
in 29 minutes and 40 seconds
......@@ -36,12 +36,23 @@ class FaceDetector(object):
"""
assert image is not None
if len(image.shape) == 2:
rows, cols = image.shape
if len(image.shape) == 3:
_, rows, cols = image.shape
try:
rectangles = self.face_detector(bob_to_dlib_image_convertion(image), 1)
bbs = []
for r in rectangles:
bbs.append(BoundingBox((r.top(), r.left()),
(r.width(), r.height()),
top = numpy.max( [0, r.top()] )
left = numpy.max( [0, r.left()])
height = numpy.min( [rows-top, r.height()] )
width = numpy.min( [cols-left, r.width() ] )
bbs.append(BoundingBox((top, left),
(height, width),
))
# This detector does not have the `quality` of the detection so I will fill it up with 100
......
......@@ -9,6 +9,10 @@ import numpy as np
from .. import FaceDetector
import pkg_resources
import bob.io.base
def test_face_detector():
"""
Test FaceDetector class.
......@@ -24,4 +28,19 @@ def test_face_detector():
result = FaceDetector().detect_single_face(image)
assert result is None
\ No newline at end of file
assert result is None
# test on the actual image:
test_file = pkg_resources.resource_filename('bob.ip.dlib', 'data/test_image.hdf5')
f = bob.io.base.HDF5File(test_file) #read only
image = f.read('image') #reads integer
del f
result = FaceDetector().detect_single_face(image)
assert result[0].topleft == (0, 236)
assert result[0].bottomright == (84, 312)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment