(frame, predictions)
return opencvimage
Shows the face recognition results visually.

    :param frame: frame to show the predictions on
    :param predictions: results of the predict function
    :return opencv suited image to be fitting with cv2.imshow fucntion:
Shows the face recognition results visually.
Shows the face recognition results visually .
def show_prediction_labels_on_image(frame, predictions):
    """
    Shows the face recognition results visually.

    :param frame: frame to show the predictions on
    :param predictions: results of the predict function
    :return opencv suited image to be fitting with cv2.imshow fucntion:
    """
    pil_image = Image.fromarray(frame)
    draw = ImageDraw.Draw(pil_image)

    for name, (top, right, bottom, left) in predictions:
        # enlarge the predictions for the full sized image.
        top *= 2
        right *= 2
        bottom *= 2
        left *= 2
        # Draw a box around the face using the Pillow module
        draw.rectangle(((left, top), (right, bottom)), outline=(0, 0, 255))

        # There's a bug in Pillow where it blows up with non-UTF-8 text
        # when using the default bitmap font
        name = name.encode("UTF-8")

        # Draw a label with a name below the face
        text_width, text_height = draw.textsize(name)
        draw.rectangle(((left, bottom - text_height - 10), (right, bottom)), fill=(0, 0, 255), outline=(0, 0, 255))
        draw.text((left + 6, bottom - text_height - 5), name, fill=(255, 255, 255, 255))

    # Remove the drawing library from memory as per the Pillow docs.
    del draw
    # Save image in open-cv format to be able to show it.

    opencvimage = np.array(pil_image)
    return opencvimage
def show_prediction_labels_on_image ( frame , predictions ) : pil_image = Image . fromarray ( frame ) draw = ImageDraw . Draw ( pil_image ) for name , ( top , right , bottom , left ) in predictions : # enlarge the predictions for the full sized image. top *= 2 right *= 2 bottom *= 2 left *= 2 # Draw a box around the face using the Pillow module draw . rectangle ( ( ( left , top ) , ( right , bottom ) ) , outline = ( 0 , 0 , 255 ) ) # There's a bug in Pillow where it blows up with non-UTF-8 text # when using the default bitmap font name = name . encode ( "UTF-8" ) # Draw a label with a name below the face text_width , text_height = draw . textsize ( name ) draw . rectangle ( ( ( left , bottom - text_height - 10 ) , ( right , bottom ) ) , fill = ( 0 , 0 , 255 ) , outline = ( 0 , 0 , 255 ) ) draw . text ( ( left + 6 , bottom - text_height - 5 ) , name , fill = ( 255 , 255 , 255 , 255 ) ) # Remove the drawing library from memory as per the Pillow docs. del draw # Save image in open-cv format to be able to show it. opencvimage = np . array ( pil_image ) return opencvimage