pytorch/projects/tools/completion.py [102:157]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def rename_output_octree():
  filelist = os.path.join(root_folder, 'filelist_test_scans.txt')
  filenames = []
  with open(filelist, 'r') as fid:
    for line in fid:
      filename = line.split()[0]
      filenames.append(filename[:-6] + 'octree')

  idx = 0
  folder_in = args.octree
  octree_in = os.listdir(folder_in)
  octree_in.sort()
  folder_out = os.path.join(root_folder, 'output.octree')
  for o in octree_in:
    if o.endswith('output.octree'):
      name_in = os.path.join(folder_in, o)
      name_out = os.path.join(folder_out, filenames[idx])
      os.renames(name_in, name_out)
      idx += 1
  assert (idx == 1200)


def _convert_octree_to_points(suffix='ply'):
  octree_folder = os.path.join(root_folder, 'output.octree')
  points_folder = os.path.join(root_folder, 'output.' + suffix)

  folders = os.listdir(octree_folder)
  for folder in folders:
    curr_folder = os.path.join(octree_folder, folder)

    # write filelist to disk
    filenames = os.listdir(curr_folder)
    filelist_name = os.path.join(curr_folder, 'filelist.txt')
    with open(filelist_name, 'w') as fid:
      for filename in filenames:
        if filename.endswith('.octree'):
          fid.write(os.path.join(curr_folder, filename) + '\n')

    # run octree2points
    output_path = os.path.join(points_folder, folder)
    if not os.path.exists(output_path):
      os.makedirs(output_path)
    cmd = '%s --filenames %s --output_path %s --verbose 0 --suffix %s' % \
          (octree2pts, filelist_name, output_path, suffix)
    print(cmd)
    os.system(cmd)
    os.remove(filelist_name)


def convert_octree_to_points():
  _convert_octree_to_points('points')
  _convert_octree_to_points('ply')


if __name__ == '__main__':
  eval('%s()' % args.run)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



tensorflow/data/completion.py [142:197]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def rename_output_octree():
  filelist = os.path.join(root_folder, 'filelist_test_scans.txt')
  filenames = []
  with open(filelist, 'r') as fid:
    for line in fid:
      filename = line.split()[0]
      filenames.append(filename[:-6] + 'octree')

  idx = 0
  folder_in = args.octree
  octree_in = os.listdir(folder_in)
  octree_in.sort()
  folder_out = os.path.join(root_folder, 'output.octree')
  for o in octree_in:
    if o.endswith('output.octree'):
      name_in = os.path.join(folder_in, o)
      name_out = os.path.join(folder_out, filenames[idx])
      os.renames(name_in, name_out)
      idx += 1
  assert (idx == 1200)


def _convert_octree_to_points(suffix='ply'):
  octree_folder = os.path.join(root_folder, 'output.octree')
  points_folder = os.path.join(root_folder, 'output.' + suffix)

  folders = os.listdir(octree_folder)
  for folder in folders:
    curr_folder = os.path.join(octree_folder, folder)

    # write filelist to disk
    filenames = os.listdir(curr_folder)
    filelist_name = os.path.join(curr_folder, 'filelist.txt')
    with open(filelist_name, 'w') as fid:
      for filename in filenames:
        if filename.endswith('.octree'):
          fid.write(os.path.join(curr_folder, filename) + '\n')

    # run octree2points
    output_path = os.path.join(points_folder, folder)
    if not os.path.exists(output_path):
      os.makedirs(output_path)
    cmd = '%s --filenames %s --output_path %s --verbose 0 --suffix %s' % \
          (octree2pts, filelist_name, output_path, suffix)
    print(cmd)
    os.system(cmd)
    os.remove(filelist_name)


def convert_octree_to_points():
  _convert_octree_to_points('points')
  _convert_octree_to_points('ply')


if __name__ == '__main__':
  eval('%s()' % args.run)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



