You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
729 B
Python

import json
import os
import math
# this script translates labels from old version
# x-y rotation are switched, and x goes forward.
# ref commit ab0c8dff4e31839de02da8897c4a3df424becd09
root_dir = "./data/example/label"
for f in os.listdir(root_dir):
fpath = os.path.join(root_dir, f)
if os.path.splitext(f)[1] == ".json":
with open(fpath, "r") as fin:
objs = json.load(fin)
for o in objs:
o["psr"]["rotation"]["z"] = math.pi/2 + o["psr"]["rotation"]["z"]
o["psr"]["scale"]["y"], o["psr"]["scale"]["x"] = o["psr"]["scale"]["x"],o["psr"]["scale"]["y"]
print(fpath)
#print(objs)
with open(fpath, "w") as fout:
json.dump(objs, fout)