legacy.py 11.3 KB
Newer Older
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
1
2
3
4
#######
# Legacy code extracted from: https://github.com/DuinoDu/mtcnn
#######

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
5
from time import time
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
6
7
8
import caffe
import cv2
import numpy as np
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
9

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
10
11

def bbreg(boundingbox, reg):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
12
13
    reg = reg.T

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
14
15
    # calibrate bouding boxes
    if reg.shape[1] == 1:
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
16
17
18
19
20
21
22
23
24
25
26
        pass  # reshape of reg
    w = boundingbox[:, 2] - boundingbox[:, 0] + 1
    h = boundingbox[:, 3] - boundingbox[:, 1] + 1

    bb0 = boundingbox[:, 0] + reg[:, 0] * w
    bb1 = boundingbox[:, 1] + reg[:, 1] * h
    bb2 = boundingbox[:, 2] + reg[:, 2] * w
    bb3 = boundingbox[:, 3] + reg[:, 3] * h

    boundingbox[:, 0:4] = np.array([bb0, bb1, bb2, bb3]).T
    # print "bb", boundingbox
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
27
28
29
30
    return boundingbox


def pad(boxesA, w, h):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
31
32
33
    boxes = boxesA.copy()  # shit, value parameter!!!
    tmph = boxes[:, 3] - boxes[:, 1] + 1
    tmpw = boxes[:, 2] - boxes[:, 0] + 1
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
34
35
36
37
    numbox = boxes.shape[0]

    dx = np.ones(numbox)
    dy = np.ones(numbox)
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
38
    edx = tmpw
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
39
40
    edy = tmph

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
41
42
43
44
45
    x = boxes[:, 0:1][:, 0]
    y = boxes[:, 1:2][:, 0]
    ex = boxes[:, 2:3][:, 0]
    ey = boxes[:, 3:4][:, 0]

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
46
47
    tmp = np.where(ex > w)[0]
    if tmp.shape[0] != 0:
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
48
49
        edx[tmp] = -ex[tmp] + w - 1 + tmpw[tmp]
        ex[tmp] = w - 1
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
50
51
52

    tmp = np.where(ey > h)[0]
    if tmp.shape[0] != 0:
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
53
54
        edy[tmp] = -ey[tmp] + h - 1 + tmph[tmp]
        ey[tmp] = h - 1
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
55
56
57
58
59
60
61
62
63
64

    tmp = np.where(x < 1)[0]
    if tmp.shape[0] != 0:
        dx[tmp] = 2 - x[tmp]
        x[tmp] = np.ones_like(x[tmp])

    tmp = np.where(y < 1)[0]
    if tmp.shape[0] != 0:
        dy[tmp] = 2 - y[tmp]
        y[tmp] = np.ones_like(y[tmp])
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
65

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
66
    # for python index from 0, while matlab from 1
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
67
68
69
70
71
72
73
74
    dy = np.maximum(0, dy - 1)
    dx = np.maximum(0, dx - 1)
    y = np.maximum(0, y - 1)
    x = np.maximum(0, x - 1)
    edy = np.maximum(0, edy - 1)
    edx = np.maximum(0, edx - 1)
    ey = np.maximum(0, ey - 1)
    ex = np.maximum(0, ex - 1)
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
75

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
76
    return [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph]
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
77
78
79
80


def rerec(bboxA):
    # convert bboxA to square
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
81
82
83
84
85
86
87
    w = bboxA[:, 2] - bboxA[:, 0]
    h = bboxA[:, 3] - bboxA[:, 1]
    max_length = np.maximum(w, h).T

    bboxA[:, 0] = bboxA[:, 0] + w * 0.5 - max_length * 0.5
    bboxA[:, 1] = bboxA[:, 1] + h * 0.5 - max_length * 0.5
    bboxA[:, 2:4] = bboxA[:, 0:2] + np.repeat([max_length], 2, axis=0).T
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
88
89
90
91
92
93
94
95
96
97
98
99
    return bboxA


def nms(boxes, threshold, type):
    """nms
    :boxes: [:,0:5]
    :threshold: 0.5 like
    :type: 'Min' or others
    :returns: TODO
    """
    if boxes.shape[0] == 0:
        return np.array([])
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
100
101
102
103
104
105
106
107
108
    x1 = boxes[:, 0]
    y1 = boxes[:, 1]
    x2 = boxes[:, 2]
    y2 = boxes[:, 3]
    s = boxes[:, 4]
    area = np.multiply(x2 - x1 + 1, y2 - y1 + 1)
    I = np.array(s.argsort())  # read s using I

    pick = []
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
109
110
111
112
113
114
115
116
117
118
119
120
121
    while len(I) > 0:
        xx1 = np.maximum(x1[I[-1]], x1[I[0:-1]])
        yy1 = np.maximum(y1[I[-1]], y1[I[0:-1]])
        xx2 = np.minimum(x2[I[-1]], x2[I[0:-1]])
        yy2 = np.minimum(y2[I[-1]], y2[I[0:-1]])
        w = np.maximum(0.0, xx2 - xx1 + 1)
        h = np.maximum(0.0, yy2 - yy1 + 1)
        inter = w * h
        if type == 'Min':
            o = inter / np.minimum(area[I[-1]], area[I[0:-1]])
        else:
            o = inter / (area[I[-1]] + area[I[0:-1]] - inter)
        pick.append(I[-1])
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
122
        I = I[np.where(o <= threshold)[0]]
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
123
124
125
126
127
128
129
    return pick


def generateBoundingBox(map, reg, scale, t):
    stride = 2
    cellsize = 12
    map = map.T
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
130
131
132
133
    dx1 = reg[0, :, :].T
    dy1 = reg[1, :, :].T
    dx2 = reg[2, :, :].T
    dy2 = reg[3, :, :].T
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
134
135
136
137
    (x, y) = np.where(map >= t)

    yy = y
    xx = x
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
138
139
140

    score = map[x, y]
    reg = np.array([dx1[x, y], dy1[x, y], dx2[x, y], dy2[x, y]])
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
141
142
143
144
145

    if reg.shape[0] == 0:
        pass
    boundingbox = np.array([yy, xx]).T

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
146
147
148
149
    # matlab index from 1, so with "boundingbox-1"
    bb1 = np.fix((stride * (boundingbox) + 1) / scale).T
    bb2 = np.fix((stride * (boundingbox) + cellsize - 1 + 1) /
                 scale).T  # while python don't have to
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
150
151
152
153
154
155
    score = np.array([score])

    boundingbox_out = np.concatenate((bb1, bb2, score, reg), axis=0)

    return boundingbox_out.T

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
156

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
157
def drawBoxes(im, boxes):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
158
159
160
161
    x1 = boxes[:, 0]
    y1 = boxes[:, 1]
    x2 = boxes[:, 2]
    y2 = boxes[:, 3]
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
162
    for i in range(x1.shape[0]):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
163
164
        cv2.rectangle(im, (int(x1[i]), int(y1[i])),
                      (int(x2[i]), int(y2[i])), (0, 255, 0), 1)
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
165
166
    return im

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
167

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
168
_tstart_stack = []
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
169
170


Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
171
172
def tic():
    _tstart_stack.append(time())
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
173
174


Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
175
def toc(fmt="Elapsed: %s s"):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
176
    print(fmt % (time() - _tstart_stack.pop()))
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
177
178
179
180
181


def detect_face(img, minsize, PNet, RNet, ONet, threshold, fastresize, factor):

    factor_count = 0
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
182
    total_boxes = np.zeros((0, 9), np.float)
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
183
184
185
186
187
    points = []
    h = img.shape[0]
    w = img.shape[1]
    minl = min(h, w)
    img = img.astype(float)
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
188
189
190
    m = 12.0 / minsize
    minl = minl * m

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
191
192
193
194
195
196
    # create scale pyramid
    scales = []
    while minl >= 12:
        scales.append(m * pow(factor, factor_count))
        minl *= factor
        factor_count += 1
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
197

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
198
    # first stage
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
199
    # print("#############################")
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
200
    for scale in scales:
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
201
202
        hs = int(np.ceil(h * scale))
        ws = int(np.ceil(w * scale))
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
203
204

        if fastresize:
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
205
206
207
208
209
210
            im_data = (img - 127.5) * 0.0078125  # [0,255] -> [-1,1]
            im_data = cv2.resize(im_data, (ws, hs))  # default is bilinear
        else:
            im_data = cv2.resize(img, (ws, hs))  # default is bilinear
            im_data = (im_data - 127.5) * 0.0078125  # [0,255] -> [-1,1]
        # im_data = imResample(img, hs, ws); print "scale:", scale
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
211
212

        im_data = np.swapaxes(im_data, 0, 2)
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
213
214
        im_data = np.array([im_data], dtype=np.float)
        # print(im_data.shape)
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
215
216
217
        PNet.blobs['data'].reshape(1, 3, ws, hs)
        PNet.blobs['data'].data[...] = im_data
        out = PNet.forward()
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
218
219
220

        boxes = generateBoundingBox(
            out['prob1'][0, 1, :, :], out['conv4-2'][0], scale, threshold[0])
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
221
222
223
        if boxes.shape[0] != 0:
            pick = nms(boxes, 0.5, 'Union')

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
224
            if len(pick) > 0:
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
225
226
227
228
229
230
231
232
233
234
                boxes = boxes[pick, :]

        if boxes.shape[0] != 0:
            total_boxes = np.concatenate((total_boxes, boxes), axis=0)

    numbox = total_boxes.shape[0]
    if numbox > 0:
        # nms
        pick = nms(total_boxes, 0.7, 'Union')
        total_boxes = total_boxes[pick, :]
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
235

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
236
        # revise and convert to square
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
237
238
239
240
241
242
243
244
245
246
247
        regh = total_boxes[:, 3] - total_boxes[:, 1]
        regw = total_boxes[:, 2] - total_boxes[:, 0]
        t1 = total_boxes[:, 0] + total_boxes[:, 5] * regw
        t2 = total_boxes[:, 1] + total_boxes[:, 6] * regh
        t3 = total_boxes[:, 2] + total_boxes[:, 7] * regw
        t4 = total_boxes[:, 3] + total_boxes[:, 8] * regh
        t5 = total_boxes[:, 4]
        total_boxes = np.array([t1, t2, t3, t4, t5]).T

        total_boxes = rerec(total_boxes)  # convert box to square
        total_boxes[:, 0:4] = np.fix(total_boxes[:, 0:4])
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
248
249
250
251
252
253
254
255

        [dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = pad(total_boxes, w, h)

    numbox = total_boxes.shape[0]
    if numbox > 0:
        # second stage

        # construct input for RNet
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
256
        tempimg = np.zeros((numbox, 24, 24, 3))  # (24, 24, 3, numbox)
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
257
        for k in range(numbox):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
258
259
260
261
262
263
264
            tmp = np.zeros((int(tmph[k]) + 1, int(tmpw[k]) + 1, 3))
            tmp[int(dy[k]):int(edy[k]) + 1, int(dx[k]):int(edx[k]) +
                1] = img[int(y[k]):int(ey[k]) + 1, int(x[k]):int(ex[k]) + 1]
            tempimg[k, :, :, :] = cv2.resize(tmp, (24, 24))

        # done in imResample function wrapped by python
        tempimg = (tempimg - 127.5) * 0.0078125
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
265
266
267

        # RNet
        tempimg = np.swapaxes(tempimg, 1, 3)
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
268

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
269
270
271
        RNet.blobs['data'].reshape(numbox, 3, 24, 24)
        RNet.blobs['data'].data[...] = tempimg
        out = RNet.forward()
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
272
273
274
275
276
277
        score = out['prob1'][:, 1]
        pass_t = np.where(score > threshold[1])[0]

        score = np.array([score[pass_t]]).T
        total_boxes = np.concatenate((total_boxes[pass_t, 0:4], score), axis=1)

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
278
        mv = out['conv5-2'][pass_t, :].T
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
279

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
280
281
        if total_boxes.shape[0] > 0:
            pick = nms(total_boxes, 0.7, 'Union')
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
282
            if len(pick) > 0:
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
283
284
285
                total_boxes = total_boxes[pick, :]
                total_boxes = bbreg(total_boxes, mv[:, pick])
                total_boxes = rerec(total_boxes)
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
286

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
287
288
289
        numbox = total_boxes.shape[0]
        if numbox > 0:
            # third stage
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
290

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
291
            total_boxes = np.fix(total_boxes)
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
292
293
294
            [dy, edy, dx, edx, y, ey, x, ex, tmpw,
                tmph] = pad(total_boxes, w, h)

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
295
296
            tempimg = np.zeros((numbox, 48, 48, 3))
            for k in range(numbox):
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
297
298
299
300
301
302
                tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3))
                tmp[int(dy[k]):int(edy[k]) + 1, int(dx[k]):int(edx[k]) + 1] \
                    = img[int(y[k]):int(ey[k]) + 1, int(x[k]):int(ex[k]) + 1]
                tempimg[k, :, :, :] = cv2.resize(tmp, (48, 48))
            tempimg = (tempimg - 127.5) * 0.0078125  # [0,255] -> [-1,1]

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
303
304
305
306
307
            # ONet
            tempimg = np.swapaxes(tempimg, 1, 3)
            ONet.blobs['data'].reshape(numbox, 3, 48, 48)
            ONet.blobs['data'].data[...] = tempimg
            out = ONet.forward()
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
308
309

            score = out['prob1'][:, 1]
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
310
            points = out['conv6-3']
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
311
            pass_t = np.where(score > threshold[2])[0]
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
312
313
            points = points[pass_t, :]
            score = np.array([score[pass_t]]).T
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
314
315
316
            total_boxes = np.concatenate(
                (total_boxes[pass_t, 0:4], score), axis=1)

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
317
            mv = out['conv6-2'][pass_t, :].T
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
318
319
            w = total_boxes[:, 3] - total_boxes[:, 1] + 1
            h = total_boxes[:, 2] - total_boxes[:, 0] + 1
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
320

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
321
322
323
324
325
326
            points[:, 0:5] = np.tile(
                w, (5, 1)).T * points[:, 0:5] + np.tile(
                total_boxes[:, 0], (5, 1)).T - 1
            points[:, 5:10] = np.tile(
                h, (5, 1)).T * points[:, 5:10] + np.tile(
                total_boxes[:, 1], (5, 1)).T - 1
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
327
328

            if total_boxes.shape[0] > 0:
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
329
                total_boxes = bbreg(total_boxes, mv[:, :])
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
330
                pick = nms(total_boxes, 0.7, 'Min')
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
331
332
333

                # print pick
                if len(pick) > 0:
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
334
335
336
337
338
                    total_boxes = total_boxes[pick, :]
                    points = points[pick, :]

    return total_boxes, points

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
339

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
340
341
342
343
344
345
def initFaceDetector():
    minsize = 20
    caffe_model_path = "/home/duino/iactive/mtcnn/model"
    threshold = [0.6, 0.7, 0.7]
    factor = 0.709
    caffe.set_mode_cpu()
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
346
347
348
349
350
351
    PNet = caffe.Net(caffe_model_path + "/det1.prototxt",
                     caffe_model_path + "/det1.caffemodel", caffe.TEST)
    RNet = caffe.Net(caffe_model_path + "/det2.prototxt",
                     caffe_model_path + "/det2.caffemodel", caffe.TEST)
    ONet = caffe.Net(caffe_model_path + "/det3.prototxt",
                     caffe_model_path + "/det3.caffemodel", caffe.TEST)
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
352
353
    return (minsize, PNet, RNet, ONet, threshold, factor)

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
354

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
355
356
357
358
359
360
361
def haveFace(img, facedetector):
    minsize = facedetector[0]
    PNet = facedetector[1]
    RNet = facedetector[2]
    ONet = facedetector[3]
    threshold = facedetector[4]
    factor = facedetector[5]
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
362

Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
363
364
365
366
    if max(img.shape[0], img.shape[1]) < minsize:
        return False, []

    img_matlab = img.copy()
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
367
368
369
370
371
372
373
374
375
    tmp = img_matlab[:, :, 2].copy()
    img_matlab[:, :, 2] = img_matlab[:, :, 0]
    img_matlab[:, :, 0] = tmp

    # tic()
    boundingboxes, points = detect_face(
        img_matlab, minsize, PNet, RNet, ONet, threshold, False, factor)
    # toc()
    containFace = (True, False)[boundingboxes.shape[0] == 0]
Tiago de Freitas Pereira's avatar
Tiago de Freitas Pereira committed
376
    return containFace, boundingboxes