How can i get face detected bounding-box in face-mesh code example
Example: How can i get face detected bounding-box in face-mesh
if res.multi_face_landmarks:
for faceLms in res.multi_face_landmarks:
mpDraw.draw_landmarks(imgOriginal, faceLms, mpFaceMesh.FACE_CONNECTIONS, drawSpec, drawSpec)
h, w, c = imgOriginal.shape
cx_min = w
cy_min = h
cx_max = cy_max = 0
for id, lm in enumerate(faceLms.landmark):
cx, cy = int(lm.x * w), int(lm.y * h)
if cx < cx_min:
cx_min = cx
if cy < cy_min:
cy_min = cy
if cx > cx_max:
cx_max = cx
if cy > cy_max:
cy_max = cy
cv2.rectangle(imgOriginal, (cx_min, cy_min), (cx_max, cy_max), (255, 255, 0), 2)