Commit 9aec2b89 authored by oscar's avatar oscar

提交文件名重复的问题

parent 053bf233
......@@ -461,8 +461,20 @@ class NumpyEncoder(json.JSONEncoder):
g_saveFileType = 1 #0为pcd文件,1是bin文件
g_showCloud = 0 #0不显示,1显示
g_pcd_info = {}
g_no_save_count = 0
g_save_count = 0
MAX_SAVE_FILE_NUM = 100
def Save_Cloud_File(cloud,json):
global g_saveFileType
global g_showCloud
global g_pcd_info
global g_no_save_count
global g_save_count
global MAX_SAVE_FILE_NUM
if g_save_count >= MAX_SAVE_FILE_NUM :
return
cloud["pcdName"] = str(g_save_count) + cloud["pcdName"]
#去除boxx内的点
drawpointcloud = []
jsn_pcd = {}
......@@ -506,19 +518,26 @@ def Save_Cloud_File(cloud,json):
drawpointcloud += [axis_pcd]
custom_draw_geometry_with_key_callback(drawpointcloud, "")
g_pcd_info[cloud["pcdName"]] = len(cloud["boxes"])
g_save_count += 1
print("save file g_save_count = ",g_save_count," file = ",cloud["pcdName"])
def Add_Cloud_box(save_cloud,add_idx,bbox,pickcloud,json):
global g_no_save_count
save_cloud[add_idx]["boxes"].append(bbox)
delflag = in_hull(save_cloud[add_idx]["np_pcd"],bbox[1])
save_cloud[add_idx]["np_pcd"] = save_cloud[add_idx]["np_pcd"][~delflag]
save_cloud[add_idx]["np_pcd"] = np.vstack((save_cloud[add_idx]["np_pcd"],pickcloud))
if save_cloud[0]["isSave"] == 1:
Save_Cloud_File(save_cloud[0],json)
if len(save_cloud[0]["boxes"]) >=10:
Save_Cloud_File(save_cloud[0],json)
else:
g_no_save_count += 1
save_cloud.pop(0)
def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
global g_save_count
add_idx = -1
for cloud_idx,cloud in enumerate(save_cloud):
#查找可以添加的点云
......@@ -539,14 +558,12 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
save_cloud[0]["isSave"] = 1
elif index > 1 and len(save_cloud) >= 100 :
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:
new_cloud = {}
new_cloud["np_pcd"] = np.array(pcd.points)
new_cloud["boxes"] = []
new_cloud["isSave"] = 0
new_cloud["pcdName"] = str(len(save_cloud)) + pcdName
new_cloud["pcdName"] = pcdName
new_cloud["path"] = path
save_cloud.append(new_cloud)
add_idx = len(save_cloud) - 1;
......@@ -556,9 +573,9 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,pcdName,path,index):
if __name__ == '__main__':
origin_root_path = "/media/sf_shared/nodes/" #读取数据的总目录
generate_root_path = "/home/oscar/ros/git/jfxmap_python/script/data/5-3/"
generate_root_path = "/media/sf_shared/5-3/"
generate_car_yaw_cal_angle = 79.89299572540227
generate_pcd_path = os.path.join(generate_root_path,"pcd/")
......@@ -568,8 +585,6 @@ if __name__ == '__main__':
os.remove(generate_pcd_path)
os.mkdir(generate_pcd_path)
save_root_path = "/home/oscar/ros/git/jfxmap_python/script/"
generate_child_dir = "N5_3"
generate_cfg_path = generate_root_path + "config/5-3.yaml"
......@@ -619,6 +634,9 @@ if __name__ == '__main__':
isStop = 0
index = 0
while isStop == 0:
if g_save_count >= MAX_SAVE_FILE_NUM:
print("finish g_save_count = ",g_save_count)
break
isDeal = 0
for dir in dirs:
if len(dir_pcd_list[dir][0]) > index:
......@@ -636,6 +654,8 @@ if __name__ == '__main__':
continue
xyzi,pcd,converted_pcd = parse_pandarmind_pcd(pcd_file, rotMat[child_dir])
xyz = np.array(converted_pcd.points)
if xyz.size == 0:
continue;
for bbox in bboxes:
# 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)
......@@ -684,14 +704,16 @@ if __name__ == '__main__':
# break
else:
isStop = 1
print("finish all the data")
for cloud in save_cloud_list:
Save_Cloud_File(cloud,save_json)
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)
for file, num in g_pcd_info.items():
if num < 10:
print("file = ",file,", box num = ",num)
# for file, num in g_pcd_info.items():
# print("file = ",file,", box num = ",num)
print("no save file num = ",g_no_save_count)
# for dir in dirs:
# if os.path.isdir(origin_root_path + "/" + dir) == False:
# continue
......
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