예제 #1
0
            if 'rotate' in trans:
                rotates = trans['rotate']
                for rotate in rotates:
                    if type(rotate) == int:
                        rotate = [rotate]
                    if 90 in rotate:
                        img = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE)
                        changed = check_dict_or_str(rotate, 90)

                    if 270 in rotate:
                        img = cv2.rotate(img, cv2.ROTATE_90_COUNTERCLOCKWISE)
                        changed = check_dict_or_str(rotate, 270)

                    if 180 in rotate:
                        img = cv2.rotate(img, cv2.ROTATE_180)
                        changed = check_dict_or_str(rotate, 180)

        if changed:
            self.save_img(output_path, img)


def transform(cfg):
    trans = Transform(cfg)
    trans.handle()


if __name__ == '__main__':
    cfg = load_yml(args.ymlpath)
    transform(cfg)
예제 #2
0
    for i in range(annotations):
        color = colors[i]
        color = colordict[color]

        cv2.namedWindow('image')
        cv2.setMouseCallback('image', on_mouse, param=color)
        cv2.imshow('image', img)
        cv2.waitKey(0)
        if crop:
            crop_index = crop_index + 1
            checkdir(os.path.join(output_folder, str(crop_index)))
            save_crop(img_folder, os.path.join(output_folder, str(crop_index)),
                      [min_y, min_x], height, width)

        img = imgtmp
        save_dir = os.path.join(output_folder, str(save_index))
        annotate_all(save_dir, [min_y, min_x], height, width, color, thickness)
        print('    annotation %d saved' % (i + 1))

    if crop:
        save_index = crop_index

    return save_index + 1


if __name__ == '__main__':
    args = parse_args()
    cfg = load_yml(args.ymlpath, 'comparison_annotation')
    root_dir = cfg['input_dir']
    compare(root_dir, args.ymlpath)