def __init__(self, directory, is_2015=False, scale=1.0):
"""
Ground truth dataset iterator
"""
if is_2015:
left_dir, right_dir = 'image_2', 'image_3'
noc_dir, occ_dir = 'disp_noc_0', 'disp_occ_0'
calib_left, calib_right = 'P2', 'P3'
else:
left_dir, right_dir = 'image_0', 'image_1'
noc_dir, occ_dir = 'disp_noc', 'disp_occ'
calib_left, calib_right = 'P0', 'P1'
self.scale = scale
# Stereo is only evaluated on the _10.png images
self.stereo = StereoDatasetReader(os.path.expanduser(directory),
left_template=''.join([left_dir, '/%06i_10.png']),
right_template=''.join([right_dir, '/%06i_10.png']), scale=scale, grayscale=True)
self.noc = ImageDatasetReader(template=os.path.join(os.path.expanduser(directory), noc_dir, '%06i_10.png'))
self.occ = ImageDatasetReader(template=os.path.join(os.path.expanduser(directory), occ_dir, '%06i_10.png'))
def calib_read(fn, scale):
db = AttrDict.load_yaml(fn)
P0 = np.float32(db[calib_left].split(' '))
P1 = np.float32(db[calib_right].split(' '))
fx, cx, cy = P0[0], P0[2], P0[6]
baseline_px = np.fabs(P1[3])
return StereoCamera.from_calib_params(fx, fx, cx, cy, baseline_px=baseline_px)
self.calib = DatasetReader(template=os.path.join(os.path.expanduser(directory), 'calib/%06i.txt'),
process_cb=lambda fn: calib_read(fn, scale))
self.poses = repeat(None)
评论列表
文章目录