Esempio n. 1
0
def find_people(image, faces, people, threshold):
    """ Finds people in `image` using faces from `faces` that
    souits the `threshold` limit
    """
    matches = []
    for face in extract(image, faces):
        for person in parse_folder(people, lambda name: isdir(name)):
            dist, match = PyFaces(face, person, threshold=threshold).match()
            if match:
                matches.append((basename(person), match, dist))
    return reduce_result(matches)
Esempio n. 2
0
def find_people(image, faces, people, threshold):
    """ Finds people in `image` using faces from `faces` that
    souits the `threshold` limit
    """
    matches = []
    for face in extract(image, faces):
        for person in parse_folder(people, lambda name: isdir(name)):
            dist, match = PyFaces(face, person, threshold=threshold).match()
            if match:
                matches.append((basename(person), match, dist))
    return reduce_result(matches)
Esempio n. 3
0
                      dest='show')
    parser.add_option('-p', '--people', default=PEOPLE_DIRECTORY,
                      dest='people')

    (options, args) = parser.parse_args()


    if options.extract:
        if not options.faces or not options.extract_src:
            parser.print_help()
            sys.exit(2)
        src = options.extract_src
        images = listdir(src)
        if images:
            for image in images:
                faces = extract(join(src, image), options.faces)
                print 'Faces found for "%s": %s' % (image, ', '.join(faces))
        else:
            print 'No faces recognised on the photo'
    else:
        if not options.image or not options.faces:
            parser.print_help()
            sys.exit(2)
        people = find_people(options.image, options.faces, options.people,
                             options.threshold)
        if people:
            print 'People found on "%s": %s' % \
                    (options.image,
                     ', '.join(('\n\t%s (%s %s)' % person for person in people)))

            if options.show:
Esempio n. 4
0
    parser.add_option('-p',
                      '--people',
                      default=PEOPLE_DIRECTORY,
                      dest='people')

    (options, args) = parser.parse_args()

    if options.extract:
        if not options.faces or not options.extract_src:
            parser.print_help()
            sys.exit(2)
        src = options.extract_src
        images = listdir(src)
        if images:
            for image in images:
                faces = extract(join(src, image), options.faces)
                print 'Faces found for "%s": %s' % (image, ', '.join(faces))
        else:
            print 'No faces recognised on the photo'
    else:
        if not options.image or not options.faces:
            parser.print_help()
            sys.exit(2)
        people = find_people(options.image, options.faces, options.people,
                             options.threshold)
        if people:
            print 'People found on "%s": %s' % \
                    (options.image,
                     ', '.join(('\n\t%s (%s %s)' % person for person in people)))

            if options.show: