def enrol_from_image(host, key_file, verbose, image, name, tag): try: face_log_image = FaceLogImage(host=host, key_file=key_file, verbose=verbose) result = face_log_image.apply(image_file=image, download=False, min_size=80) if result['number_of_sightings'] != 1: raise Exception('Wrong amount of faces in input image') # The face of interest is the first one face = result['sightings'][0] gender = face['gender'] # Lets create the subject user_data = {'gender': gender, 'notes': ''} subject = recognition.create_subject(name=name, tag=tag, user_data=user_data) subject_id = subject['subject_id'] print 'Created subject with id {}'.format(subject_id) # Now lets join a subject to a detection recognition.add_sighting_to_subject(face['sighting_id'], subject_id) except Exception as err: raise Exception(err)
def do_face_log(self, image_file): face_log_image = FaceLogImage(host=host, verbose=True) image_path = os.path.join(face_detect_data_dir, image_file) task = face_log_image.apply(image_path, min_size=40) return task
parser.add_argument('--add-sighting', dest='add_sighting', help='Add this sighting to a subject with an id') parser.add_argument('--subject-id', dest='subject_id', help='A subject id') parser.add_argument('--subjects', dest='subjects', action='store_true', help='List all subjects in database.') parser.add_argument('--gender', dest='gender', default='Unknown', help='Gender of subject.') parser.add_argument('--tag', dest='tag', default='Unknown', help='A tag name to give a subject.') parser.add_argument('--verbose', dest='verbose', action='store_true', help='Be more verbose') parser.add_argument('--download', dest='download', action='store_true', help='Download any results') parser.set_defaults(download=False) args = parser.parse_args() recognition = Recognition(host=args.host, key_file=args.key_file, verbose=args.verbose) # recognition on an image if args.recognition and args.image: print 'Perform recognition on {}'.format(args.image) face_log_image = FaceLogImage(host=args.host, key_file=args.key_file, verbose=args.verbose) results = face_log_image.apply( image_file=args.image, download=args.download, recognition=True, min_size=80) # recognition on a video if args.recognition and args.video: print 'Perform recognition on {}'.format(args.video) face_log = FaceLog(host=args.host, key_file=args.key_file, verbose=args.verbose) results = face_log.apply( video_file=args.video, download=args.download, recognition=True, min_size=80) # List all subjects