Commit 053bf233 authored by oscar's avatar oscar

提交更新

parent def778d5
...@@ -460,6 +460,7 @@ class NumpyEncoder(json.JSONEncoder): ...@@ -460,6 +460,7 @@ class NumpyEncoder(json.JSONEncoder):
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 = {}
def Save_Cloud_File(cloud,json): def Save_Cloud_File(cloud,json):
#去除boxx内的点 #去除boxx内的点
...@@ -504,7 +505,7 @@ def Save_Cloud_File(cloud,json): ...@@ -504,7 +505,7 @@ def Save_Cloud_File(cloud,json):
axis_pcd = o3d.geometry.TriangleMesh.create_coordinate_frame(size=5, origin=[0, 0, 0]) axis_pcd = o3d.geometry.TriangleMesh.create_coordinate_frame(size=5, origin=[0, 0, 0])
drawpointcloud += [axis_pcd] drawpointcloud += [axis_pcd]
custom_draw_geometry_with_key_callback(drawpointcloud, "") custom_draw_geometry_with_key_callback(drawpointcloud, "")
g_pcd_info[cloud["pcdName"]] = len(cloud["boxes"])
...@@ -532,10 +533,14 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index): ...@@ -532,10 +533,14 @@ 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) >= 20 and len(save_cloud[0]["boxes"]) >= 5 : if index > 1 and len(save_cloud) >= 50 and len(save_cloud[0]["boxes"]) >= 10 :
save_cloud[0]["isSave"] = 1
elif index > 1 and len(save_cloud) > 0 and len(save_cloud[0]["boxes"]) > 20 :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
elif index > 1 and len(save_cloud) > 0 and len(save_cloud[0]["boxes"]) > 10 : elif index > 1 and len(save_cloud) >= 100 :
save_cloud[0]["isSave"] = 1 save_cloud[0]["isSave"] = 1
if len(save_cloud[0]["boxes"]) < 10:
print("save cloud file = ",save_cloud[0]["pcdName"], " box num = ", len(save_cloud[0]["boxes"]))
if add_idx == -1: if add_idx == -1:
new_cloud = {} new_cloud = {}
new_cloud["np_pcd"] = np.array(pcd.points) new_cloud["np_pcd"] = np.array(pcd.points)
...@@ -634,10 +639,10 @@ if __name__ == '__main__': ...@@ -634,10 +639,10 @@ if __name__ == '__main__':
for bbox in bboxes: for bbox in bboxes:
# exportCenterBL = get_loc_from_origin([bbox[4][0], bbox[4][1], bbox[4][2]], 0, generate_Trans) # exportCenterBL = get_loc_from_origin([bbox[4][0], bbox[4][1], bbox[4][2]], 0, generate_Trans)
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, generate_Trans,generate_kitti2origin) 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, generate_Trans,generate_kitti2origin)
print(exportCenterBL) # print(exportCenterBL)
angle2 = car_yaw_cal(generate_car_yaw_cal_angle,bbox[2]) angle2 = car_yaw_cal(generate_car_yaw_cal_angle,bbox[2])
mapInfoExport = get_map_data(exportCenterBL[0],exportCenterBL[1],angle2) mapInfoExport = get_map_data(exportCenterBL[0],exportCenterBL[1],angle2)
print("call get ex data isInMap = ",mapInfoExport) # print("call get ex data isInMap = ",mapInfoExport)
if mapInfoExport[0] != 1: if mapInfoExport[0] != 1:
continue; continue;
laneAngle = mapInfoExport[10]; laneAngle = mapInfoExport[10];
...@@ -646,8 +651,8 @@ if __name__ == '__main__': ...@@ -646,8 +651,8 @@ if __name__ == '__main__':
detaAngel -= 360 detaAngel -= 360
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 abs(detaAngel) > 30: if bbox[0] != "pedestrian" and abs(detaAngel) > 30:
continue; continue;
#获取到汽车点云符合条件,可以添加到新点云里 #获取到汽车点云符合条件,可以添加到新点云里
# 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))
...@@ -666,15 +671,17 @@ if __name__ == '__main__': ...@@ -666,15 +671,17 @@ if __name__ == '__main__':
dz = np.array([0,0,delta_z]) dz = np.array([0,0,delta_z])
pickcloud = np.add(pickcloud,dz) pickcloud = np.add(pickcloud,dz)
print(pickcloud) # print(pickcloud)
bbox[1] += dz bbox[1] += dz
Add_Cloud_box(save_cloud_list,idx,bbox,pickcloud,save_json) Add_Cloud_box(save_cloud_list,idx,bbox,pickcloud,save_json)
if isDeal == 1: if isDeal == 1:
index += 1 index += 1
if index >= 10: if index % 10 == 0:
break print("while index = ",index)
# if index >= 10:
# break
else: else:
isStop = 1 isStop = 1
for cloud in save_cloud_list: for cloud in save_cloud_list:
...@@ -682,6 +689,9 @@ if __name__ == '__main__': ...@@ -682,6 +689,9 @@ 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) json.dump(save_json,file_obj,cls=NumpyEncoder)
for file, num in g_pcd_info.items():
if num < 10:
print("file = ",file,", box num = ",num)
# for dir in dirs: # for dir in dirs:
# if os.path.isdir(origin_root_path + "/" + dir) == False: # if os.path.isdir(origin_root_path + "/" + dir) == False:
# continue # continue
......
This diff is collapsed.
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