@@ -18,6 +18,8 @@ def __init__(self):
1818 self .visualization = True
1919 self .confidence = 0.7
2020 self .classes_to_detect = 0
21+ self .ground_threshold = 1.6
22+ self .max_dist_percent = 0.7
2123
2224 # Load calibration data
2325 self .R = load_extrinsics (os .getcwd () + '/GEMstack/onboard/perception/calibration/extrinsics/R.npy' )
@@ -84,18 +86,28 @@ def fusion_callback(self, rgb_image_msg: Image, lidar_pc2_msg: PointCloud2):
8486 (pts [:, 1 ] < bottom_bound )
8587 ]
8688
87- extracted_2d_pts = list (np .array (extracted_pts )[:, :2 ].astype (int ))
89+ #if no points extracted for this bbox, skip
90+ if len (extracted_pts ) < 1 :
91+ continue
92+
93+ extracted_pts = filter_ground_points (extracted_pts , self .ground_threshold )
94+ extracted_pts = filter_far_points (extracted_pts )
95+
96+ extracted_2d_pts = list (extracted_pts [:, :2 ].astype (int ))
8897 flattened_pedestrians_2d_pts = flattened_pedestrians_2d_pts + extracted_2d_pts
89-
90- extracted_3d_pts = list (np . array ( extracted_pts ) [:, - 3 :])
98+
99+ extracted_3d_pts = list (extracted_pts [:, - 3 :])
91100 pedestrians_3d_pts .append (extracted_3d_pts )
92101 flattened_pedestrians_3d_pts = flattened_pedestrians_3d_pts + extracted_3d_pts
93102
94103 # Used for visualization
95104 if (self .visualization ):
96105 cv_image = vis_2d_bbox (cv_image , xywh , box )
97106
98- if len (pedestrians_3d_pts ) > 0 :
107+ if len (flattened_pedestrians_3d_pts ) > 0 :
108+ # print(f"x_dim pedestrians_3d_pts: {np.max(np.array(flattened_pedestrians_3d_pts)[:, 0]), np.min(np.array(flattened_pedestrians_3d_pts)[:, 0])}")
109+ # print(f"y_dim pedestrians_3d_pts: {np.max(np.array(flattened_pedestrians_3d_pts)[:, 1]), np.min(np.array(flattened_pedestrians_3d_pts)[:, 1])}")
110+ # print(f"z_dim pedestrians_3d_pts: {np.max(np.array(flattened_pedestrians_3d_pts)[:, 2]), np.min(np.array(flattened_pedestrians_3d_pts)[:, 2])}")
99111 # Draw projected 2D LiDAR points on the image.
100112 for pt in flattened_pedestrians_2d_pts :
101113 cv2 .circle (cv_image , pt , 2 , (0 , 0 , 255 ), - 1 )
0 commit comments