Beispiel #1
0
    def __init__(self, result_dir):
        self.result_dir = os.path.join(result_dir, cfg.test.dataset)
        os.system('mkdir -p {}'.format(self.result_dir))

        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.coco = coco.COCO(self.ann_file)

        data_root = args['data_root']
        cls = cfg.cls_type
        model_path = os.path.join('data/linemod', cls, cls + '.ply')
        self.model = pvnet_data_utils.get_ply_model(model_path)
        self.diameter = linemod_config.diameters[cls] / 100

        self.proj2d = []
        self.add = []
        self.cmd5 = []

        self.icp_proj2d = []
        self.icp_add = []
        self.icp_cmd5 = []

        self.mask_ap = []

        self.height = 480
        self.width = 640

        model = inout.load_ply(model_path)
        model['pts'] = model['pts'] * 1000
        self.icp_refiner = icp_utils.ICPRefiner(
            model, (self.width, self.height)) if cfg.test.icp else None
Beispiel #2
0
def run_render():
    from lib.utils.renderer import opengl_utils
    from lib.utils.vsd import inout
    from lib.utils.linemod import linemod_config
    import matplotlib.pyplot as plt

    obj_path = 'data/linemod/cat/cat.ply'
    model = inout.load_ply(obj_path)
    model['pts'] = model['pts'] * 1000.
    im_size = (640, 300)
    opengl = opengl_utils.NormalRender(model, im_size)

    K = linemod_config.linemod_K
    pose = np.load('data/linemod/cat/pose/pose0.npy')
    depth = opengl.render(im_size, 100, 10000, K, pose[:, :3], pose[:, 3:] * 1000)

    plt.imshow(depth)
    plt.show()
Beispiel #3
0
    def __init__(self, result_dir):
        self.result_dir = result_dir
        args = DatasetCatalog.get(cfg.test.dataset)
        self.ann_file = args['ann_file']
        self.obj_id = int(args['obj_id'])
        self.coco = coco.COCO(self.ann_file)
        self.gt_img_ids = self.coco.getImgIds(catIds=[self.obj_id])

        model_dir = 'data/tless/models_cad'
        obj_path = os.path.join(model_dir,
                                'obj_{:02d}.ply'.format(self.obj_id))
        self.model = inout.load_ply(obj_path)
        self.model_pts = self.model['pts'] / 1000.

        model_info = yaml.load(open(os.path.join(model_dir,
                                                 'models_info.yml')))
        self.diameter = model_info[self.obj_id]['diameter'] / 1000.

        self.vsd = []
        self.adi = []
        self.cmd5 = []

        self.icp_vsd = []
        self.icp_adi = []
        self.icp_cmd5 = []

        self.pose_per_id = []
        self.pose_icp_per_id = []
        self.img_ids = []

        self.height = 540
        self.width = 720

        if cfg.test.icp or cfg.test.vsd:
            self.icp_refiner = icp_utils.ICPRefiner(self.model,
                                                    (self.width, self.height))