Commit 2b8e05d9 authored by oscar's avatar oscar

提交统计逻辑

parent 8ae15a70
...@@ -550,7 +550,7 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index): ...@@ -550,7 +550,7 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
#查找可以添加的点云 #查找可以添加的点云
interactive = 0 interactive = 0
for box in cloud["boxes"]: for box in cloud["boxes"]:
if abs(bbox[4][0] - box[4][0]) < (bbox[6][0] + box[6][0])*2/3 and abs(bbox[4][1] - box[4][1]) < (bbox[6][0] + box[6][0])*2/3: if abs(bbox[4][0] - box[4][0]) < (bbox[6][0] + box[6][0]) and abs(bbox[4][1] - box[4][1]) < (bbox[6][0] + box[6][0]):
interactive = 1 interactive = 1
if interactive == 1 : if interactive == 1 :
continue continue
...@@ -559,11 +559,11 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index): ...@@ -559,11 +559,11 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
break; break;
if add_idx == -1 : if add_idx == -1 :
#需要保存数据了 #需要保存数据了
if index == 1 and len(save_cloud) >= 50 and len(save_cloud[0]["boxes"]) >= 10 : if index == 1 and len(save_cloud) >= 100 and len(save_cloud[0]["boxes"]) >= 5 :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
elif index == 1 and len(save_cloud) > 0 and len(save_cloud[0]["boxes"]) > 20 : elif index == 1 and len(save_cloud) > 0 and len(save_cloud[0]["boxes"]) > 30 :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
elif index == 1 and len(save_cloud) >= 100 : elif index == 1 and len(save_cloud) >= 200 :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
max_cloud_list_num = 200 max_cloud_list_num = 200
if add_idx == -1: if add_idx == -1:
...@@ -580,12 +580,12 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index): ...@@ -580,12 +580,12 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
print(" save_cloud is too big > ",max_cloud_list_num) print(" save_cloud is too big > ",max_cloud_list_num)
return add_idx return add_idx
Thread_NUM = 5 Thread_NUM = 10
threads = [] threads = []
threadID = 1 threadID = 1
class pcdThread (threading.Thread): class pcdThread (threading.Thread):
def __init__(self, threadID, name,start,idx, _dirs,_dir_pcd_list,save_list,jsn_list, trans,kit2o): def __init__(self, threadID, name,start,idx, _dirs,_dir_pcd_list,save_list,jsn_list, trans,kit2o,box_info_count):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.threadID = threadID self.threadID = threadID
self.name = name self.name = name
...@@ -597,6 +597,7 @@ class pcdThread (threading.Thread): ...@@ -597,6 +597,7 @@ class pcdThread (threading.Thread):
self.jsn_list = jsn_list self.jsn_list = jsn_list
self.trans = trans self.trans = trans
self.kit2ori = kit2o self.kit2ori = kit2o
self.box_info_count = box_info_count
def run(self): def run(self):
global g_save_count global g_save_count
global MAX_SAVE_FILE_NUM global MAX_SAVE_FILE_NUM
...@@ -661,6 +662,7 @@ class pcdThread (threading.Thread): ...@@ -661,6 +662,7 @@ class pcdThread (threading.Thread):
print("pedestrian in cross, pos = [",exportCenterBL[0],",",exportCenterBL[1],"]") print("pedestrian in cross, pos = [",exportCenterBL[0],",",exportCenterBL[1],"]")
#获取到汽车点云符合条件,可以添加到新点云里 #获取到汽车点云符合条件,可以添加到新点云里
# f1.write('%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\n'%(exportCenterBL[0],exportCenterBL[1],bbox[4][0], bbox[4][1], bbox[4][2],bbox[6][0], bbox[6][1], bbox[6][2],angle2,laneAngle)) # f1.write('%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\n'%(exportCenterBL[0],exportCenterBL[1],bbox[4][0], bbox[4][1], bbox[4][2],bbox[6][0], bbox[6][1], bbox[6][2],angle2,laneAngle))
self.box_info_count[bbox[0]] += 1
name = pcd_file.split("/")[-1] name = pcd_file.split("/")[-1]
if g_saveFileType == 1: if g_saveFileType == 1:
name = name[0:-3] + "bin" name = name[0:-3] + "bin"
...@@ -742,6 +744,7 @@ if __name__ == '__main__': ...@@ -742,6 +744,7 @@ if __name__ == '__main__':
save_json = {} save_json = {}
save_json["annotations"] = [] save_json["annotations"] = []
save_json_list = [] save_json_list = []
cloud_box_count = [] #统计box的数据
dir_pcd_list = {} dir_pcd_list = {}
dirsAll = os.listdir(origin_root_path) dirsAll = os.listdir(origin_root_path)
...@@ -770,7 +773,9 @@ if __name__ == '__main__': ...@@ -770,7 +773,9 @@ if __name__ == '__main__':
save_cloud_list.append(list) save_cloud_list.append(list)
jsn_list = [] jsn_list = []
save_json_list.append(jsn_list) save_json_list.append(jsn_list)
thread = pcdThread(i, "Thread"+ str(i) ,i,Thread_NUM,dirs,dir_pcd_list,save_cloud_list[i],save_json_list[i],generate_Trans,generate_kitti2origin) box_info_cout = {'big': 0, 'little':0,'pedestrian':0,'mid':0,'cyclist':0}
cloud_box_count.append(box_info_cout)
thread = pcdThread(i, "Thread"+ str(i) ,i,Thread_NUM,dirs,dir_pcd_list,save_cloud_list[i],save_json_list[i],generate_Trans,generate_kitti2origin,cloud_box_count[i])
thread.start() thread.start()
threads.append(thread) threads.append(thread)
for t in threads: for t in threads:
...@@ -786,7 +791,17 @@ if __name__ == '__main__': ...@@ -786,7 +791,17 @@ if __name__ == '__main__':
jsn_path = os.path.join(generate_root_path,generate_child_dir + ".json") jsn_path = os.path.join(generate_root_path,generate_child_dir + ".json")
with open(jsn_path,'w') as file_obj: with open(jsn_path,'w') as file_obj:
json.dump(save_json,file_obj,cls=NumpyEncoder,indent=4) json.dump(save_json,file_obj,cls=NumpyEncoder,indent=4)
totel_count = {'big': 0, 'little':0,'pedestrian':0,'mid':0,'cyclist':0}
for count in cloud_box_count:
totel_count['big'] += count['big']
totel_count['little'] += count['little']
totel_count['pedestrian'] += count['pedestrian']
totel_count['mid'] += count['mid']
totel_count['cyclist'] += count['cyclist']
cloud_box_count.append(totel_count)
count_jsn_path = os.path.join(generate_root_path,"count.json")
with open(count_jsn_path,'w') as file_o:
json.dump(cloud_box_count,file_o,cls=NumpyEncoder,indent=4)
# isStop = 0 # isStop = 0
# index = 0 # index = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment