def setUp(self):
     self.face_log = FaceLog()
     self.recognition = Recognition()
class TestEnrolSubjects(unittest.TestCase):

    def setUp(self):
        self.face_log = FaceLog()
        self.recognition = Recognition()

    def test_face_log(self):
        '''
        This onlyt gets run if we do not have a valid sightings file
        which contains the name and a sighting id
        :return:
        '''
        # If we have sightings file, lets return
        if os.path.isfile(SIGHTINGS_FILE):
            return

        # lets delete any subjects we may already have
        subjects = self.recognition.list_subjects()
        for subject in subjects:
            print 'Going to delete {0}'.format(subject['subject_id'])
            deleted_id = self.recognition.delete_subject(subject['subject_id'])
            self.assertEqual(subject['subject_id'], deleted_id)


        # these are the video files
        video_files = {
            'Alberto': '{}/Subjects/Alberto.mov'.format(data_dir),
            'Baris': '{}/Subjects/Baris.mov'.format(data_dir),
            'Fred': '{}/Subjects/Fred.mov'.format(data_dir),
            'Kjetil': '{}/Subjects/Kjetil.mov'.format(data_dir),
            'Laurent': '{}/Subjects/Laurent.mov'.format(data_dir),
            'Marie-Claude': '{}/Subjects/Marie-Claude.mov'.format(data_dir),
            'Olivier': '{}/Subjects/Olivier.mov'.format(data_dir)
        }
        video_files1 = {
            'Alberto': '{}/Subjects/Alberto.mov'.format(data_dir),
        }

        # lets run face-log and get the sightings, enrol the subjects
        sighting_list = {}
        for name, video_file in video_files.iteritems():
            task = self.face_log.apply(video_file=video_file, download=False, gender=True, max_frames=10)
            self.assertTrue(task['success'])
            sightings = task['sightings']
            self.assertEqual(1, len(sightings))
            subject_id = self.recognition.create_subject(name=name)
            sighting_list[subject_id] = sightings[0]['sighting_id']
            print '{} {} {}'.format(subject_id, name, sightings[0]['sighting_id'])

        # save to a file to do some things with
        with open(SIGHTINGS_FILE, 'w') as f:
            f.write(json.dumps(sighting_list))

    def test_enrol(self):
        # check we have a sightings file
        self.assertTrue(os.path.isfile(SIGHTINGS_FILE))

        with open(SIGHTINGS_FILE, 'r') as f:
            sightings = json.load(f)

        for subject_id, sighting_id in sightings.iteritems():
            print subject_id, subject_id
            self.recognition.add_sighting_to_subject(sighting_id=sighting_id, subject_id=subject_id)
Example #3
0
 def do_face_log(self, test_data):
     video_path = os.path.join(face_detect_data_dir, test_data.video_file)
     face_log = FaceLog(verbose=True)
     task = face_log.apply(video_file=video_path, max_frames=test_data.max_frames, min_certainty=test_data.min_certainty)
     return task
Example #4
0
 def do_face_log(self, test_data):
     video_path = os.path.join(face_recognition_data_dir, test_data.video_file)
     face_log = FaceLog(host=host, verbose=True)
     task = face_log.apply(video_file=video_path, max_frames=test_data.max_frames, min_size=test_data.min_size)
     return task
Example #5
0
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
if args.subjects:
    print "Listing all the subjects"
    tags = recognition.list_subjects()

# Delete all subjects
if args.delete_subjects:
    print 'Deleting all the subjects in your database'
    try:
        subjects = recognition.list_subjects()
Example #6
0
    alarm_verification = AlarmVerification(key_file=args.key_file, verbose=args.verbose)
    task = alarm_verification.apply(video_file=args.video, download=args.download)

if args.face_detect:
    print "performing face detection"
    face_detect = FaceDetect(verbose=args.verbose)
    task = face_detect.apply(video_file=args.video,
                             download=args.download,
                             blur=args.blur,
                             start_frame=args.start_frame,
                             max_frames=args.max_frames,
                             min_size=args.min_size)

if args.face_detect_image:
    print "performing face detection on image"
    face_detect_image = FaceDetectImage(verbose=args.verbose)
    task = face_detect_image.apply(image_file=args.image,
                                   download=args.download,
                                   blur=args.blur,
                                   min_size=args.min_size)

if args.face_log:
    print "performing face log"
    face_log = FaceLog(verbose=args.verbose)
    task = face_log.apply(video_file=args.video,
                          download=args.download,
                          blur=args.blur,
                          start_frame=args.start_frame,
                          max_frames=args.max_frames,
                          min_size=args.min_size)