Commit 01432cd8 authored by oscar's avatar oscar

提交参数整理,可以方便修改

parent 0fa52f5f
...@@ -485,12 +485,21 @@ def InitCarYawAngle(): ...@@ -485,12 +485,21 @@ def InitCarYawAngle():
InitCarYawAngle() InitCarYawAngle()
####################下面是可以调节的参数#################
Thread_NUM = 10 #启动几个线程处理数据
car_car_distance_ratio = 1.0 #车与车之间间距系数,范围 > 0.5, 数据越小车间距越小,最小为0.5
max_cloud_boxes_num = 30 #每帧点云放入多少个车辆时可以保存点云数据了,不需要放入很多的车辆。
need_save_cloud_list_max = 100 #处理队列数量多少时,开始检查保存点云数据,其中还需要参数来做判断
min_cloud_boxes_num = 5 #当队列达到need_save_cloud_list_max数量之后,需要判断点云中车辆数据大于多少就保存。
must_save_cloud_list_max_limit = 200 #当队列达到多少数量需要强行保存点云数据,为了避免队列无限大。
lane_car_angle = 30 #道路和车辆朝向夹角小于多少认为符合要求
MAX_SAVE_FILE_NUM = 10000 # 每个空点云最多生成多少帧点云数据
#######################################################
g_saveFileType = 1 #0为pcd文件,1是bin文件 g_saveFileType = 1 #0为pcd文件,1是bin文件
g_showCloud = 0 #0不显示,1显示 g_showCloud = 0 #0不显示,1显示
g_pcd_info = {} g_pcd_info = {}
g_no_save_count = 0 g_no_save_count = 0
g_save_count = 0 g_save_count = 0
MAX_SAVE_FILE_NUM = 10000
g_thread_lock = threading.Lock() g_thread_lock = threading.Lock()
g_map_lock = threading.Lock() g_map_lock = threading.Lock()
...@@ -570,12 +579,17 @@ def Add_Cloud_box(save_cloud,add_idx,bbox,pickcloud,json,dir_g): ...@@ -570,12 +579,17 @@ def Add_Cloud_box(save_cloud,add_idx,bbox,pickcloud,json,dir_g):
def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index): def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
global g_save_count global g_save_count
global car_car_distance_ratio
global max_cloud_boxes_num
global need_save_cloud_list_max
global min_cloud_boxes_num
global must_save_cloud_list_max_limit
add_idx = -1 add_idx = -1
for cloud_idx,cloud in enumerate(save_cloud): for cloud_idx,cloud in enumerate(save_cloud):
#查找可以添加的点云 #查找可以添加的点云
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]) and abs(bbox[4][1] - box[4][1]) < (bbox[6][0] + box[6][0]): if abs(bbox[4][0] - box[4][0]) < (bbox[6][0] + box[6][0])*car_car_distance_ratio and abs(bbox[4][1] - box[4][1]) < (bbox[6][0] + box[6][0])*car_car_distance_ratio:
interactive = 1 interactive = 1
if interactive == 1 : if interactive == 1 :
continue continue
...@@ -584,13 +598,13 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index): ...@@ -584,13 +598,13 @@ 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) >= 100 and len(save_cloud[0]["boxes"]) >= 5 : if index == 1 and len(save_cloud) >= need_save_cloud_list_max and len(save_cloud[0]["boxes"]) >= min_cloud_boxes_num :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
elif index == 1 and len(save_cloud) > 0 and len(save_cloud[0]["boxes"]) > 30 : elif index == 1 and len(save_cloud) > 0 and len(save_cloud[0]["boxes"]) > max_cloud_boxes_num :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
elif index == 1 and len(save_cloud) >= 200 : elif index == 1 and len(save_cloud) >= must_save_cloud_list_max_limit :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
max_cloud_list_num = 200 max_cloud_list_num = must_save_cloud_list_max_limit
if add_idx == -1: if add_idx == -1:
if len(save_cloud) < max_cloud_list_num: if len(save_cloud) < max_cloud_list_num:
new_cloud = {} new_cloud = {}
...@@ -605,7 +619,7 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index): ...@@ -605,7 +619,7 @@ 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 = 10
threads = [] threads = []
threadID = 1 threadID = 1
...@@ -632,6 +646,7 @@ class pcdThread (threading.Thread): ...@@ -632,6 +646,7 @@ class pcdThread (threading.Thread):
global g_saveFileType global g_saveFileType
global g_map_lock global g_map_lock
global car_yaw_cal_angle global car_yaw_cal_angle
global lane_car_angle
print ("开启线程:" + self.name) print ("开启线程:" + self.name)
isStop = 0 isStop = 0
index = self.begin index = self.begin
...@@ -685,7 +700,7 @@ class pcdThread (threading.Thread): ...@@ -685,7 +700,7 @@ class pcdThread (threading.Thread):
while detaAngel < -180: while detaAngel < -180:
detaAngel += 360 detaAngel += 360
# print("angle = ",angle2," laneAngle = ",laneAngle," detaAngel = ",detaAngel) # print("angle = ",angle2," laneAngle = ",laneAngle," detaAngel = ",detaAngel)
if bbox[0] != "pedestrian" and abs(detaAngel) > 30: if bbox[0] != "pedestrian" and abs(detaAngel) > lane_car_angle:
continue continue
if bbox[0] == "pedestrian" and isInCross == 0: if bbox[0] == "pedestrian" and isInCross == 0:
continue continue
...@@ -862,7 +877,7 @@ if __name__ == '__main__': ...@@ -862,7 +877,7 @@ if __name__ == '__main__':
t.join() t.join()
for _ind,cloud_i in enumerate(save_cloud_list): for _ind,cloud_i in enumerate(save_cloud_list):
for cloud in cloud_i: for cloud in cloud_i:
if len(cloud["boxes"]) >=10: if len(cloud["boxes"]) >= min_cloud_boxes_num:
Save_Cloud_File(cloud,save_json_list[_ind],dir_g) Save_Cloud_File(cloud,save_json_list[_ind],dir_g)
for t_idx in save_json_list: for t_idx in save_json_list:
for jsn in t_idx: for jsn in t_idx:
......
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