MCPcopy Create free account
hub / github.com/albertpumarola/GANimation / detect_biggest_face

Function detect_biggest_face

utils/face_utils.py:21–42  ·  view source on GitHub ↗

Detect biggest face in image :param img: cv::mat HxWx3 RGB :return: 4

(img)

Source from the content-addressed store, hash-verified

19 yield x, y, (right - x), (bottom - y)
20
21def detect_biggest_face(img):
22 '''
23 Detect biggest face in image
24 :param img: cv::mat HxWx3 RGB
25 :return: 4 <x,y,w,h>
26 ''&#x27;
27 # detect faces
28 bbs = face_recognition.face_locations(img)
29
30 max_area = float('-inf')
31 max_area_i = 0
32 for i, (y, right, bottom, x) in enumerate(bbs):
33 area = (right - x) * (bottom - y)
34 if max_area < area:
35 max_area = area
36 max_area_i = i
37
38 if max_area != float('-inf'):
39 y, right, bottom, x = bbs[max_area_i]
40 return x, y, (right - x), (bottom - y)
41
42 return None
43
44def crop_face_with_bb(img, bb):
45 ''&#x27;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected