except Exception as e:
        print e.message


if __name__ == "__main__":
    # Create destination path
    if os.path.exists(config.PATH_DATA_FEATURES01_COGNITIVE):
        print("Folder {} exists, no need to generate dataset.".format(
            config.PATH_DATA_FEATURES01_COGNITIVE))
        exit()
    os.makedirs(config.PATH_DATA_FEATURES01_COGNITIVE)
    # Load raw dataset
    data_raw = Data(config.PATH_DATA_RAW)
    data_cognitive = []
    # Cognitive JSON files follows raw dataset structure.
    for datum_raw in data_raw.iterate():
        img_path = datum_raw['img_path'][len(config.PATH_DATA_RAW):]
        json_cognitive_path = "{}{}.fix.json".format(
            config.PATH_DATA_COGNITIVE, img_path[:-4])
        if os.path.exists(json_cognitive_path):
            with open(json_cognitive_path, 'r') as fd:
                datum_cognitive = json.load(fd)
            try:
                marks = datum_cognitive['faceLandmarks']
                datum_new = {
                    'face_x':
                    datum_cognitive['faceRectangle']['left'],
                    'face_y':
                    datum_cognitive['faceRectangle']['top'],
                    'face_width':
                    datum_cognitive['faceRectangle']['width'],
Example #2
0
                    # 'eye_left_image': None,
                    'eye_right_x': eye_right[0],
                    'eye_right_y': eye_right[1],
                    'eye_right_width': eye_right[2],
                    'eye_right_height': eye_right[3],
                    # 'eye_right_image': None,
                }
            else:
                print "[WARNING] '{}' 2 EYES NOT FOUND".format(img_path)
        else:
            print "[WARNING] '{}' FACE NOT FOUND".format(img_path)
        return retval


if __name__ == "__main__":
    import config
    from utils import Data

    features = Features01()
    data = Data(config.PATH_DATA_RAW)
    count = 0
    i = 0
    for datum in data.iterate():
        # print datum

        # print features.extract_features(datum['img_path'])
        if features.extract_features(datum['img_path']):
            count += 1
        i += 1
    print i, count
            if event.type == KEYUP:
                if event.key == K_ESCAPE:
                    exit = True
                    click = True
                elif event.key == K_RIGHT:
                    if i_data < len(data_list) - 1:
                        i_data += 1
                        click = True
                elif event.key == K_LEFT:
                    if i_data > 0:
                        i_data -= 1
                        click = True
                elif event.key == K_d:  # Switch dot (where the user looks)
                    flag_dot = False if flag_dot else True
                    click = True
                elif event.key == K_1:  # Switch DS01 mscognitive, dlib
                    ds01_key_index = (ds01_key_index + 1) % len(DATASETS_01)
                    print ds01_key_index
                    click = True
            pygame.event.clear()
    pygame.display.quit()


data = Data(config.PATH_DATA_RAW)
data_list = list(data.iterate())
if data_list:
    print "NUMBER OF SAMPLES: {}".format(len(data_list))
    loop(data_list)
else:
    print "No data"