Commit 3fdab6bd authored by oscar's avatar oscar

提交修改

parent 264b8663
......@@ -438,6 +438,8 @@ def shadow_casting(points,bbox):
far_points = bbox * 1.5
hull = np.concatenate((bbox,far_points),axis=0)
flag = in_hull(points,hull)
del_flag = in_hull(points,bbox)
flag = flag^del_flag
#print("X"*100, np.count_nonzero(flag))
#print(points[flag])
return flag
......@@ -445,11 +447,11 @@ def shadow_casting(points,bbox):
def Save_Cloud_File(cloud):
#去除boxx内的点
drawpointcloud = []
for bbox in cloud.boxes:
flag_del = shadow_casting(cloud.np_pcd,bbox[1])
for bbox in cloud["boxes"]:
flag_del = shadow_casting(cloud["np_pcd"],bbox[1])
#g_np_flag = g_np_flag & (~flag_del)
cloud.np_pcd = cloud.np_pcd[~flag_del]
drawboxesorgin = gen_o3d_3dbboxes(bbox[1])
cloud["np_pcd"] = cloud["np_pcd"][~flag_del]
drawboxes = gen_o3d_3dbboxes(bbox[1])
drawpointcloud += [drawboxes]
heading_point = (bbox[3][0] + bbox[3][2]) / 2
heading_pcd = o3d.geometry.PointCloud()
......@@ -458,7 +460,7 @@ def Save_Cloud_File(cloud):
heading_pcd.colors = o3d.utility.Vector3dVector(colors)
drawpointcloud += [heading_pcd]
pcd_save = o3d.geometry.PointCloud()
pcd_save.points = o3d.utility.Vector3dVector(cloud.np_pcd)
pcd_save.points = o3d.utility.Vector3dVector(cloud["np_pcd"])
drawpointcloud += [pcd_save]
axis_pcd = o3d.geometry.TriangleMesh.create_coordinate_frame(size=5, origin=[0, 0, 0])
drawpointcloud += [axis_pcd]
......@@ -471,8 +473,9 @@ def Save_Cloud_File(cloud):
def Add_Cloud_box(save_cloud,add_idx,bbox,pickcloud):
save_cloud[add_idx]["boxes"].append(bbox)
tmp = np.vstack((save_cloud[add_idx]["np_pcd"],pickcloud))
save_cloud[add_idx]["np_pcd"] = tmp
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])
save_cloud.pop(0)
......@@ -481,12 +484,22 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,child_dir,pcdName,path):
add_idx = -1
for cloud_idx,cloud in enumerate(save_cloud):
#查找可以添加的点云
add_idx = cloud_idx
break;
if add_idx == -1 and len(save_cloud) > 50:
interactive = 0
for box in cloud["boxes"]:
if abs(bbox[4][0] - box[4][0]) < (bbox[6][0] + box[6][0])/2 and abs(bbox[4][1] - box[4][1]) < (bbox[6][0] + box[6][0])/2:
interactive = 1
if interactive == 1 :
continue
else:
add_idx = cloud_idx
break;
if add_idx == -1 :
#需要保存数据了
save_cloud[0].isSave = 1
elif add_idx == -1:
if len(save_cloud) >= 50 and len(save_cloud[0]["boxes"]) >= 10 :
save_cloud[0]["isSave"] = 1
elif len(save_cloud) > 0 and len(save_cloud[0]["boxes"]) >20 :
save_cloud[0]["isSave"] = 1
if add_idx == -1:
new_cloud = {}
new_cloud["np_pcd"] = np.array(pcd.points)
new_cloud["boxes"] = []
......@@ -495,7 +508,7 @@ def Check_Add_Cloud_box(save_cloud,bbox,pcd,child_dir,pcdName,path):
new_cloud["pcdName"] = pcdName
new_cloud["path"] = path
save_cloud.append(new_cloud)
add_idx = 0;
add_idx = len(save_cloud) - 1;
return add_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