in loaders/video_dataset.py [0:0]
def __init__(self, path: str, meta_file: str = None):
"""
Args:
path: folder path of the 3D video
"""
self.color_fmt = pjoin(path, "color_down", "frame_{:06d}.raw")
if not os.path.isfile(self.color_fmt.format(0)):
self.color_fmt = pjoin(path, "color_down", "frame_{:06d}.png")
self.mask_fmt = pjoin(path, "mask", "mask_{:06d}_{:06d}.png")
self.flow_fmt = pjoin(path, "flow", "flow_{:06d}_{:06d}.raw")
if meta_file is not None:
with open(meta_file, "rb") as f:
meta = np.load(f)
self.extrinsics = torch.tensor(meta["extrinsics"], dtype=_dtype)
self.intrinsics = torch.tensor(meta["intrinsics"], dtype=_dtype)
assert (
self.extrinsics.shape[0] == self.intrinsics.shape[0]
), "#extrinsics({}) != #intrinsics({})".format(
self.extrinsics.shape[0], self.intrinsics.shape[0]
)
flow_list_fn = pjoin(path, "flow_list.json")
if os.path.isfile(flow_list_fn):
with open(flow_list_fn, "r") as f:
self.flow_indices = json.load(f)
else:
names = os.listdir(os.path.dirname(self.flow_fmt))
self.flow_indices = [
self.parse_index_pair(name)
for name in names
if os.path.splitext(name)[-1] == os.path.splitext(self.flow_fmt)[-1]
]
self.flow_indices = sampling.to_in_range(self.flow_indices)
self.flow_indices = list(sampling.SamplePairs.to_one_way(self.flow_indices))