예제 #1
0
def write_annotation_to_numpy(annotation_file):
    #   data = cwd / 'data'
    data = pwd
    numpy_dir = data / 'numpy'
    filename = (Path(cwd) / Path(annotation_file)).as_posix()
    annotations = [line.rstrip() for line in open(filename)]
    annotations = [os.path.join(data, p) for p in annotations]

    for annotation in annotations:
        elements = annotation.split('/')
        test_or_train = 'test' if 'test' in elements else 'train'
        filename = test_or_train + '_' + ''.join([elements[-2], '.npy'])
        outfile = os.path.join(numpy_dir, elements[-4], filename)
        print(f'Writing to {outfile}')
        try:
            indoor3d_util.collect_point_label(annotation, outfile, 'numpy')
        except:
            print(f'Failed to write {outfile}')
예제 #2
0
import os
import sys
import shutil
from indoor3d_util import DATA_PATH, collect_point_label

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.dirname(BASE_DIR)
sys.path.append(BASE_DIR)

anno_paths = [line.rstrip() for line in open(os.path.join(BASE_DIR, 'meta/anno_paths.txt'))]
anno_paths = [os.path.join(DATA_PATH, p) for p in anno_paths]

output_folder = os.path.join(ROOT_DIR, 'data/stanford_indoor3d')
if not os.path.exists(output_folder):
    os.mkdir(output_folder)

# Note: there is an extra character in the v1.2 data in Area_5/hallway_6. It's fixed manually.
for anno_path in anno_paths:
    print(anno_path)
    try:
        elements = anno_path.split('/')
        out_filename = elements[-3]+'_'+elements[-2]+'.npy' # Area_1_hallway_1.npy
        collect_point_label(anno_path, os.path.join(output_folder, out_filename), 'numpy')
        shutil.rmtree(anno_path[:-12])
    except:
        print(anno_path, 'ERROR!!')
DATA_BASE_PATH = os.path.abspath('./Stanford3dDataset_v1.2_Aligned_Version')
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.dirname(BASE_DIR)
sys.path.append(BASE_DIR)
import indoor3d_util

anno_paths = [line.rstrip() for line in open(os.path.join(BASE_DIR, 'meta/anno_paths.txt'))]
# anno_paths = [os.path.join(indoor3d_util.DATA_PATH, p) for p in anno_paths]
anno_paths = [os.path.join(DATA_BASE_PATH, p) for p in anno_paths]

output_folder = os.path.join(ROOT_DIR, 'data/stanford_indoor3d')
if not os.path.exists(output_folder):
    os.mkdir(output_folder)

# Note: there is an extra character in the v1.2 data in Area_5/hallway_6. It's fixed manually.
for anno_path in anno_paths:
    print(anno_path)
    elements = anno_path.split('/')
    out_filename = elements[-3] + '_' + elements[-2] + '.npy'  # Area_1_hallway_1.npy
    out_filepath = os.path.join(output_folder, out_filename)
    if os.path.exists(out_filepath):
        print('Exist {}'.format(out_filename))
        continue

    indoor3d_util.collect_point_label(anno_path, out_filepath, 'numpy')

    try:

        indoor3d_util.collect_point_label(anno_path, out_filepath, 'numpy')
    except:
        print(anno_path, 'ERROR!!')
예제 #4
0
import os
import sys

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
import indoor3d_util

anno_paths = [
    line.rstrip()
    for line in open(os.path.join(BASE_DIR, 'meta/anno_paths.txt'))
]
anno_paths = [os.path.join(indoor3d_util.DATA_PATH, p) for p in anno_paths]
print('anno_paths:', anno_paths)

output_folder = os.path.join(BASE_DIR, 'data/stanford_indoor3d_ins.sem')
if not os.path.exists(output_folder):
    os.mkdir(output_folder)

# Note: there is an extra character in the v1.2 data in Area_5/hallway_6. It's fixed manually.
for anno_path in anno_paths:
    print(anno_path)
    try:
        elements = anno_path.split('/')
        out_filename = elements[-3] + '_' + elements[
            -2] + '.npy'  # Area_1_hallway_1.npy
        indoor3d_util.collect_point_label(
            anno_path, os.path.join(output_folder, out_filename), 'numpy')
    except:
        print(anno_path, 'ERROR!!')
예제 #5
0
import indoor3d_util
'''
Call:

python txt_to_npy.py --path_in ../data/txt/ --path_out ../data/npy/ --path_cls meta/class_names.txt
'''

parser = argparse.ArgumentParser()
parser.add_argument('--path_in', help='path to the txt data folder.')
parser.add_argument('--path_out', help='path to save ply folder.')
parser.add_argument('--path_cls', help='path to classes txt.')

parsed_args = parser.parse_args(sys.argv[1:])

path_in = parsed_args.path_in
path_out = parsed_args.path_out
path_cls = parsed_args.path_cls

if not os.path.exists(path_out):
    os.mkdir(path_out)

for folder in natsorted(os.listdir(path_in)):

    path_annotation = os.path.join(path_in, folder, "annotations")
    print(path_annotation)

    elements = path_annotation.split('/')
    out_filename = os.path.join(path_out, elements[-2] + '.npy')
    indoor3d_util.collect_point_label(path_annotation, out_filename, path_cls,
                                      'numpy')
예제 #6
0
    _cfg = json.load(f)
    print(_cfg)

UTILS_DIR = os.path.dirname(os.path.abspath(__file__))
META_ROOT = os.path.join(UTILS_DIR, 's3dis_meta')

RAW_ROOT = _cfg['s3dis_aligned_raw']
OUTPUT_ROOT = _cfg['s3dis_data_root']

print('meta root:', META_ROOT)
print('raw root:', RAW_ROOT)
print('output root:', OUTPUT_ROOT)
anno_paths = os.path.join(META_ROOT, 'annotations.txt')
anno_paths = [line.rstrip() for line in open(anno_paths)]

output_folder = OUTPUT_ROOT
if not os.path.exists(output_folder):
    os.mkdir(output_folder)

# NOTE: there is an extra character in the v1.2 data in Area_5/hallway_6. It's fixed manually.
for anno_path in anno_paths:
    print(anno_path)
    elements = anno_path.split('/')
    out_filename = elements[-3] + '_' + \
        elements[-2] + '.npy'
    if os.path.exists(os.path.join(output_folder, out_filename)):
        continue
    indoor3d_util.collect_point_label(
        os.path.join(RAW_ROOT, anno_path),
        os.path.join(output_folder, out_filename), 'numpy', False)
import os
import sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.dirname(BASE_DIR)
sys.path.append(BASE_DIR)
import indoor3d_util

anno_paths = [line.rstrip() for line in open(os.path.join(BASE_DIR, 'meta/anno_paths.txt'))]
anno_paths = [os.path.join(indoor3d_util.DATA_PATH, p) for p in anno_paths]

output_folder = os.path.join(ROOT_DIR, 'data/stanford_indoor3d') 
if not os.path.exists(output_folder):
    os.mkdir(output_folder)

# Note: there is an extra character in the v1.2 data in Area_5/hallway_6. It's fixed manually.
for anno_path in anno_paths:
    print(anno_path)
    try:
        elements = anno_path.split('/')
        out_filename = elements[-3]+'_'+elements[-2]+'.npy' # Area_1_hallway_1.npy
        indoor3d_util.collect_point_label(anno_path, os.path.join(output_folder, out_filename), 'numpy')
    except:
        print(anno_path, 'ERROR!!')