Commit 30d632bb authored by oscar's avatar oscar

提交更新

parent 1f61685d
......@@ -465,21 +465,23 @@ g_showCloud = 0 #0不显示,1显示
g_pcd_info = {}
g_no_save_count = 0
g_save_count = 0
MAX_SAVE_FILE_NUM = 100
MAX_SAVE_FILE_NUM = 1000
g_thread_lock = threading.Lock()
g_map_lock = threading.Lock()
def Save_Cloud_File(cloud,json):
global g_saveFileType
global g_showCloud
global g_save_count
global MAX_SAVE_FILE_NUM
global g_thread_lock
#去除boxx内的点
drawpointcloud = []
jsn_pcd = {}
jsn_pcd["labels_box3D"] = []
jsn_pcd["fileuri"] = ""
jsn_pcd["box_num"] = {'big': 0, 'little':0,'pedestrian':0,'mid':0,'cyclist':0}
jsn_pcd["labels_box3D"] = []
for bbox in cloud["boxes"]:
jsn_box = {}
jsn_box["box3D"] = {}
......@@ -526,7 +528,7 @@ def Save_Cloud_File(cloud,json):
drawpointcloud += [axis_pcd]
custom_draw_geometry_with_key_callback(drawpointcloud, "")
g_save_count += 1
print("save file g_save_count = ",g_save_count," file = ",cloud["pcdName"])
print("save file g_save_count = ",g_save_count," file = ",cloud["pcdName"]," box num = ",jsn_pcd["box_num"] )
g_thread_lock.release()
......@@ -564,6 +566,7 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
elif index == 1 and len(save_cloud) >= 100 :
save_cloud[0]["isSave"] = 1
if add_idx == -1:
if len(save_cloud) < 60:
new_cloud = {}
new_cloud["np_pcd"] = np.array(pcd.points)
new_cloud["boxes"] = []
......@@ -572,9 +575,11 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
new_cloud["path"] = path
save_cloud.append(new_cloud)
add_idx = len(save_cloud) - 1;
else:
print(" save_cloud is too big > 100")
return add_idx
Thread_NUM = 2
Thread_NUM =3
threads = []
threadID = 1
......@@ -595,12 +600,12 @@ class pcdThread (threading.Thread):
global g_save_count
global MAX_SAVE_FILE_NUM
global g_saveFileType
global g_map_lock
print ("开启线程:" + self.name)
isStop = 0
index = self.begin
dir_pcd_list = self._dir_pcd_list
dirs = self._dirs
thread_idx = self.begin
save_cloud_list = self.save_list #保存点云的数组
json_list = self.jsn_list
while isStop == 0:
......@@ -631,7 +636,9 @@ class pcdThread (threading.Thread):
lidar_loc_ex,out_BL_ex,exportCenterBL = get_loc([bbox[4][0], bbox[4][1], bbox[4][2],bbox[6][0],bbox[6][1],bbox[6][2],bbox[2]], 0, self.trans,self.kit2ori)
# print(exportCenterBL)
angle2 = car_yaw_cal(generate_car_yaw_cal_angle,bbox[2])
g_map_lock.acquire()
mapInfoExport = get_map_data(exportCenterBL[0],exportCenterBL[1],angle2)
g_map_lock.release()
# print("call get ex data isInMap = ",mapInfoExport)
if mapInfoExport[0] != 1:
continue;
......@@ -678,10 +685,10 @@ class pcdThread (threading.Thread):
if isDeal == 1:
index += self.idx
if (index - self.begin) % 10*self.idx == 0:
print("while thread idx = ",self.begin," index = ",index)
if index >= 50:
break
if (index - self.begin) % 2*self.idx == 0:
print("while thread idx = ",self.threadID," index = ",index," cloud list = ",len(save_cloud_list))
# if index >= 100:
# break
else:
isStop = 1
print("finish all the data")
......@@ -748,16 +755,16 @@ if __name__ == '__main__':
for an in annos:
fileuri = os.path.join(origin_root_path,dir)+ "/pcd/" + an['fileuri'].split("/")[-1]
anno[fileuri] = an['labels_box3D']
fp.close()
dir_pcd_list[dir].append(anno)
for i in range(Thread_NUM):
list = []
save_cloud_list.append(list)
jsn_list = []
save_json_list.append(jsn_list)
thread = pcdThread(threadID, "Thread"+ str(i) ,i,Thread_NUM,dirs,dir_pcd_list,save_cloud_list[i],save_json_list[i],generate_Trans,generate_kitti2origin)
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)
thread.start()
threads.append(thread)
threadID += 1
for t in threads:
t.join()
for _ind,cloud_i in enumerate(save_cloud_list):
......@@ -770,7 +777,7 @@ if __name__ == '__main__':
jsn_path = os.path.join(generate_root_path,generate_child_dir + ".json")
with open(jsn_path,'w') as file_obj:
json.dump(save_json,file_obj,cls=NumpyEncoder)
json.dump(save_json,file_obj,cls=NumpyEncoder,indent=4)
# isStop = 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