Skip to content

Commit 823c886

Browse files
authored
Remove temp input directory (#27)
* Remove temp input directory * Clean code
1 parent 4f99fd7 commit 823c886

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

python/cli/process/process.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -494,16 +494,6 @@ def onMappingOutput(output):
494494
print(f"ERROR: {e}", flush=True)
495495
raise e
496496

497-
def copy_input_to_tmp_safe(input_dir, tmp_input):
498-
# also works if tmp dir is inside the input directory
499-
os.makedirs(tmp_input, exist_ok=True)
500-
shutil.rmtree(tmp_input)
501-
os.makedirs(tmp_input)
502-
for f in os.listdir(input_dir):
503-
full_fn = os.path.join(input_dir, f)
504-
if not os.path.isdir(full_fn): shutil.copy(full_fn, tmp_input)
505-
elif f.startswith("frames"): shutil.copytree(full_fn, f"{tmp_input}/{f}", dirs_exist_ok=True)
506-
507497
def detect_device_preset(input_dir):
508498
cameras = None
509499
calibrationJson = f"{input_dir}/calibration.json"
@@ -549,8 +539,6 @@ def detect_device_preset(input_dir):
549539
os.makedirs(f"{args.output}/images", exist_ok=True)
550540

551541
tmp_dir = tempfile.mkdtemp()
552-
tmp_input = tempfile.mkdtemp()
553-
copy_input_to_tmp_safe(args.input, tmp_input)
554542

555543
device_preset, cameras = detect_device_preset(args.input)
556544

@@ -608,13 +596,10 @@ def detect_device_preset(input_dir):
608596
visArgs.showCameraModel = False
609597
visualizer = Visualizer(visArgs)
610598

611-
with open(tmp_input + "/vio_config.yaml", 'wt') as f:
612-
base_params = 'parameterSets: %s' % json.dumps(parameter_sets)
613-
f.write(base_params + '\n')
614-
print(base_params)
615-
599+
config['parameterSets'] = parameter_sets
616600
print(config)
617-
replay = spectacularAI.Replay(tmp_input, mapperCallback = onMappingOutput, configuration = config)
601+
602+
replay = spectacularAI.Replay(args.input, mapperCallback = onMappingOutput, configuration = config, ignoreFolderConfiguration = True)
618603
replay.setOutputCallback(onVioOutput)
619604

620605
try:
@@ -628,19 +613,13 @@ def detect_device_preset(input_dir):
628613
print(f"Something went wrong! {e}", flush=True)
629614
raise e
630615

631-
# Make sure replay is closed, so that we can delete the tmp_input directory.
632616
replay = None
633617

634618
try:
635619
shutil.rmtree(tmp_dir)
636620
except:
637621
print(f"Failed to clean temporary directory, you can delete these files manually, they are no longer required: {tmp_dir}", flush=True)
638622

639-
try:
640-
shutil.rmtree(tmp_input)
641-
except:
642-
print(f"Failed to clean temporary directory, you can delete these files manually, they are no longer required: {tmp_input}", flush=True)
643-
644623
if not finalMapWritten:
645624
print('Mapping failed: no output generated')
646625
exit(1)

0 commit comments

Comments
 (0)