in dataset/mocap.py [0:0]
def _index_dir(self, path):
"""Recursively add paths to the set of
indexed files
Arguments:
path {str} -- folder path
Returns:
dict -- indexed files per root dir
"""
indexed_paths = dict()
sub_dirs, _ = io.get_subdirs(path)
if set(self.ROOT_DIRS) <= set(sub_dirs):
# get files from subdirs
n_frames = -1
# let's extract the rgba and json data per frame
for sub_dir in self.ROOT_DIRS:
d_path = os.path.join(path, sub_dir)
_, paths = io.get_files(d_path)
if n_frames < 0:
n_frames = len(paths)
else:
if len(paths) != n_frames:
self.logger.error(
'Frames info in {} not matching other passes'.format(d_path))
encoded = [p.encode('utf8') for p in paths]
indexed_paths.update({sub_dir: encoded})
return indexed_paths
# initialize indexed_paths
for sub_dir in self.ROOT_DIRS:
indexed_paths.update({sub_dir: []})
# check subdirs of path and merge info
for sub_dir in sub_dirs:
indexed = self._index_dir(os.path.join(path, sub_dir))
for r_dir in self.ROOT_DIRS:
indexed_paths[r_dir].extend(indexed[r_dir])
return indexed_paths