Untitled Note

By: Anonymous6/2/202217 views Public Note
import os import json import random json_path="C:/Users/1942048/Desktop/Lidar Output" json_files=os.listdir(json_path) annotations_frames_list=[] object_list=[] object_dict={} fig_dict={} key=0 for index,i in enumerate(json_files): frame_no=i.split("_")[0] f = open(json_path "/" i, 'r') jsondata = f.read() annodata = json.loads(jsondata) fig_list=annodata["figures"] id_geo_dict={} for j in fig_list: id_geo_dict[j["objectId"]]=j["geometry"] obj_list=annodata["objects"] annotations_fig_list=[] for j in id_geo_dict.keys(): for k in obj_list: if k["id"]==j: if k["classTitle"] in object_dict.keys(): fig_ele={ "key":object_dict[k["classTitle"]], "objectKey":object_dict[k["classTitle"]], "geometryType": "cuboid_3d", "geometry":id_geo_dict[j] } annotations_fig_list.append(fig_ele) else: key =1 hexkey="2x"%key object_dict[k["classTitle"]]=hexkey obj_ele={ "key":hexkey, "classTitle":k["classTitle"], "tags":[] } object_list.append(obj_ele) fig_ele={ "key":object_dict[k["classTitle"]], "objectKey":object_dict[k["classTitle"]], "geometryType": "cuboid_3d", "geometry":id_geo_dict[j] } annotations_fig_list.append(fig_ele) frame_ele={ "index":int(frame_no), "figures":annotations_fig_list } annotations_frames_list.append(frame_ele) annotations_file={ "description": "", "key": "00000000000000000000000000000001", "tags": [], "objects":object_list, "framesCount": 100, "frames":annotations_frames_list } key_id_file={ "tags":{}, "objects":{}, "figures":{}, "videos":{"00000000000000000000000000000001": 1, "00000000000000000000000000000002": 2, "00000000000000000000000000000003": 3, "00000000000000000000000000000004": 4, "00000000000000000000000000000005": 5, "00000000000000000000000000000006": 6, "00000000000000000000000000000007": 7, "00000000000000000000000000000008": 8, "00000000000000000000000000000009": 9, "0000000000000000000000000000000a": 10, "0000000000000000000000000000000b": 11, "0000000000000000000000000000000c": 12, "0000000000000000000000000000000d": 13, "0000000000000000000000000000000e": 14, "0000000000000000000000000000000f": 15, "00000000000000000000000000000010": 16, "00000000000000000000000000000011": 17, "00000000000000000000000000000012": 18, "00000000000000000000000000000013": 19, "00000000000000000000000000000014": 20, "00000000000000000000000000000015": 21, "00000000000000000000000000000016": 22, "00000000000000000000000000000017": 23, "00000000000000000000000000000018": 24, "00000000000000000000000000000019": 25, "0000000000000000000000000000001a": 26, "0000000000000000000000000000001b": 27, "0000000000000000000000000000001c": 28, "0000000000000000000000000000001d": 29, "0000000000000000000000000000001e": 30, "0000000000000000000000000000001f": 31, "00000000000000000000000000000020": 32, "00000000000000000000000000000021": 33, "00000000000000000000000000000022": 34, "00000000000000000000000000000023": 35, "00000000000000000000000000000024": 36, "00000000000000000000000000000025": 37, "00000000000000000000000000000026": 38, "00000000000000000000000000000027": 39, "00000000000000000000000000000028": 40, "00000000000000000000000000000029": 41, "0000000000000000000000000000002a": 42, "0000000000000000000000000000002b": 43, "0000000000000000000000000000002c": 44, "0000000000000000000000000000002d": 45, "0000000000000000000000000000002e": 46, "0000000000000000000000000000002f": 47, "00000000000000000000000000000030": 48, "00000000000000000000000000000031": 49, "00000000000000000000000000000032": 50, "00000000000000000000000000000033": 51, "00000000000000000000000000000034": 52, "00000000000000000000000000000035": 53, "00000000000000000000000000000036": 54, "00000000000000000000000000000037": 55, "00000000000000000000000000000038": 56, "00000000000000000000000000000039": 57, "0000000000000000000000000000003a": 58, "0000000000000000000000000000003b": 59, "0000000000000000000000000000003c": 60, "0000000000000000000000000000003d": 61, "0000000000000000000000000000003e": 62, "0000000000000000000000000000003f": 63, "00000000000000000000000000000040": 64, "00000000000000000000000000000041": 65, "00000000000000000000000000000042": 66, "00000000000000000000000000000043": 67, "00000000000000000000000000000044": 68, "00000000000000000000000000000045": 69, "00000000000000000000000000000046": 70, "00000000000000000000000000000047": 71, "00000000000000000000000000000048": 72, "00000000000000000000000000000049": 73, "0000000000000000000000000000004a": 74, "0000000000000000000000000000004b": 75, "0000000000000000000000000000004c": 76, "0000000000000000000000000000004d": 77, "0000000000000000000000000000004e": 78, "0000000000000000000000000000004f": 79, "00000000000000000000000000000050": 80, "00000000000000000000000000000051": 81, "00000000000000000000000000000052": 82, "00000000000000000000000000000053": 83, "00000000000000000000000000000054": 84, "00000000000000000000000000000055": 85, "00000000000000000000000000000056": 86, "00000000000000000000000000000057": 87, "00000000000000000000000000000058": 88, "00000000000000000000000000000059": 89, "0000000000000000000000000000005a": 90, "0000000000000000000000000000005b": 91, "0000000000000000000000000000005c": 92, "0000000000000000000000000000005d": 93, "0000000000000000000000000000005e": 94, "0000000000000000000000000000005f": 95, "00000000000000000000000000000060": 96, "00000000000000000000000000000061": 97, "00000000000000000000000000000062": 98, "00000000000000000000000000000063": 99, "00000000000000000000000000000064": 100} } amount=0 for l in object_dict.keys(): amount =1 key_id_file["objects"][object_dict[l]]=amount key_id_file["figures"][object_dict[l]]=amount meta_file={ "classes":[], "tags":[], "projectType": "point_clouds" } classes_list=[] for l in object_dict.keys(): r = lambda: random.randint(0,255) col='#XXX' % (r(),r(),r()) ele={ "title":l, "shape":"cuboid_3d", "color":col } classes_list.append(ele) meta_file["classes"]=classes_list frame_pointcloud_map_file={} for l in range(0,100): frame_pointcloud_map_file[l]=str(l) ".pcd" out_file1 = open("C:/Users/1942048/Desktop/annotation.json", 'w') json.dump(annotations_file,out_file1,indent=5) # out_file1 = open("C:/Users/1942048/Desktop/key_id_map.json", 'w') # json.dump(key_id_file,out_file1,indent=5) # out_file1 = open("C:/Users/1942048/Desktop/meta.json", 'w') # json.dump(meta_file,out_file1,indent=5) # out_file1 = open("C:/Users/1942048/Desktop/frame_pointcloud_map.json", 'w') # json.dump(frame_pointcloud_map_file,out_file1,indent=5)

Want to create your own notes?

Join thousands of users writing securely on ProNotepad.