1,
                        (255, 255, 255),
                        1,
                    )
                    cv2.putText(
                        frame, str(confidence), (x - 2, y + h + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1
                    )
                else:
                    cv2.putText(frame, "Unbekannt", (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)

            else:
                cv2.putText(frame, "Unbekannt", (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)

                # Wenn die Person nah genug ist
            if h > 250:
                eyes = face.detect_eyes(face.crop(image, x, y, w, h))
                for i in range(0, len(eyes)):
                    x, y, w, h = eyes[i]
                    cv2.rectangle(
                        frame, (x + x_face, y + y_face - 30), (x + x_face + w + 10, y + y_face + h - 40), (94, 255, 0)
                    )
                    cv2.putText(
                        frame,
                        "Auge " + str(i),
                        (x + x_face, y + y_face - 5),
                        cv2.FONT_HERSHEY_SIMPLEX,
                        0.5,
                        (255, 255, 255),
                        1,
                    )
Example #2
0
            print(label_str)

            # face rectable
            cv2.rectangle(frame, (x, y), (x + w, y + h), 255)
            # height
            cv2.putText(frame, str(int(h)), (x + w, y + h + 15),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
            # label user
            cv2.putText(frame, label_str, (x - 3, y - 8),
                        cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)
            # confidence
            cv2.putText(frame, str(int(confidence)), (x - 2, y + h + 15),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
            if h > 250:
                # If person is close enough, mark the eyes
                eyes = face.detect_eyes(face.crop(image, x, y, w, h))
                for i in range(0, len(eyes)):
                    x, y, w, h = eyes[i]
                    cv2.rectangle(frame, (x + x_face, y + y_face - 30),
                                  (x + x_face + w + 10, y + y_face + h - 40),
                                  (94, 255, 0))
                    cv2.putText(frame, "Eye " + str(i),
                                (x + x_face, y + y_face - 5),
                                cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255),
                                1)

    if ('DISPLAY' in os.environ):
        # Display Image
        cv2.imshow('Facial recognition', frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break