Esempio n. 1
0
def identify(save=True, force_input=False, from_file=False):
    """
    Takes a picture with configured camera and identifies all of the faces in the picture
    Parameters:
    -----------
    save (boolean):
        whether or not to add the captured image to the database
    from_file(boolean):
        whether or not expect a filename instead of taking a picture
    
    Returns:
    --------
    names (list)
        the list of the name of each person in the picture
    """
    if not from_file:
        img = ImageLoader.get_img_from_camera()
        dets = ImageLoader.find_faces(img)
        descs = ImageLoader.find_descriptors(img, dets)
    else:
        filepath = input('Please enter the location (filepath) of the image: ')
        img = ImageLoader.get_img_from_file(filepath)
        dets = ImageLoader.find_faces(img)
        descs = ImageLoader.find_descriptors(img, dets)
    names = ImageCompare.compare_faces(descs, database.database, threshold=0.4)
    if save:
        if len(descs) > 1:
            print("Cannot add multiple people at once.")
        elif len(descs) < 1:
            print("There's no one there!")
        else:
            if force_input:
                database.add_image(descs[0])
            else:
                database.add_image(descs[0], name=names[0])
    draw_faces(dets, names, img)
    return names
Esempio n. 2
0
def go():
    """
    Takes a picture from the configured camera and displays the image with recognized faces and labels
    Parameters:
    -----------
    None
    
    Returns:
    --------
    None; shows the image with captioned faces
    """
    img = ImageLoader.get_img_from_camera()
    dets = ImageLoader.find_faces(img)
    descs = ImageLoader.find_descriptors(img, dets)
    compared = ImageCompare.compare_faces(descs, database.database)
    draw_faces(dets, compared, img)
Esempio n. 3
0
def add_file(filepath):
    """
    Adds a person to the database given a picture of their face
    Will ask for their name
    
    Parameters
    ----------
    filepath (string):
        the location of the file that is the picture of the person's face
    Returns:
    --------
    None
    """
    img = ImageLoader.get_img_from_file(filepath)
    det = ImageLoader.find_faces(img)
    descriptor = ImageLoader.find_descriptors(img, det)
    database.add_image(descriptor)