Skip to content

Commit a9a3c8f

Browse files
authored
Fix sai-cli process (#22)
1 parent 5ebd1d1 commit a9a3c8f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

python/cli/process/process.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ def transform_camera(c):
113113
by_camera[cam_id] = params
114114

115115
converted = {
116-
'file_path': "./images/" + c['image_path'].split('/')[-1],
116+
'file_path': os.path.join("./images", c['image_path'].split('/')[-1]),
117117
"transform_matrix": transform_camera(c['T_pointcloud_camera'])
118118
}
119119
if 'depth_image_path' in c:
120-
converted['depth_file_path'] = "./images/" + c['depth_image_path'].split('/')[-1]
120+
converted['depth_file_path'] = os.path.join("./images", c['depth_image_path'].split('/')[-1])
121121

122122
by_camera[cam_id]['frames'].append(converted)
123123

@@ -390,12 +390,12 @@ def onMappingOutput(output):
390390

391391
oldImgName = f"{tmp_dir}/frame_{frameId:05}.{args.image_format}"
392392
newImgName = f"{args.output}/images/frame_{index:05}.{args.image_format}"
393-
os.rename(oldImgName, newImgName)
393+
shutil.move(oldImgName, newImgName)
394394

395395
oldDepth = f"{tmp_dir}/depth_{frameId:05}.png"
396396
newDepth = f"{args.output}/images/depth_{index:05}.png"
397397
if os.path.exists(oldDepth):
398-
os.rename(oldDepth, newDepth)
398+
shutil.move(oldDepth, newDepth)
399399
frame['depth_image_path'] = f"data/{name}/images/depth_{index:05}.png"
400400

401401
if (index + 3) % 7 == 0:
@@ -585,6 +585,9 @@ def detect_device_preset(input_dir):
585585
print(f"Something went wrong! {e}", flush=True)
586586
raise e
587587

588+
# Make sure replay is closed, so that we can delete the tmp_input directory.
589+
replay = None
590+
588591
try:
589592
shutil.rmtree(tmp_dir)
590593
except:
@@ -619,4 +622,3 @@ def parse_args():
619622
parser = define_args(parser)
620623
return parser.parse_args()
621624
process(parse_args())
622-

0 commit comments

Comments
 (0)