@@ -110,7 +110,7 @@ def initialize(self):
110110 self .lidar_sub = Subscriber ('/ouster/points' , PointCloud2 )
111111 self .sync = ApproximateTimeSynchronizer ([
112112 self .rgb_sub , self .lidar_sub
113- ], queue_size = 500 , slop = 0.05 )
113+ ], queue_size = 500 , slop = 0.03 )
114114 self .sync .registerCallback (self .synchronized_callback )
115115
116116 # Initialize the YOLO detector
@@ -185,6 +185,8 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
185185 undistorted_img = latest_image .copy ()
186186 orig_H , orig_W = latest_image .shape [:2 ]
187187 self .current_K = self .K
188+ # print(self.K)
189+ # print(self.T_l2c)
188190 results_normal = self .detector (img_normal , conf = 0.35 , classes = [0 ])
189191 combined_boxes = []
190192 if not self .enable_tracking :
@@ -198,14 +200,18 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
198200 boxes_right = np .array (results_right [0 ].boxes .xywh .cpu ()) if len (results_right ) > 0 else []
199201 for box in boxes_left :
200202 cx , cy , w , h = box
201- new_cx = cy
202- new_cy = orig_W - 1 - cx
203- combined_boxes .append ((new_cx , new_cy , h , w , ObstacleStateEnum .RIGHT ))
203+ new_cx = orig_W - 1 - cy
204+ new_cy = cx
205+ new_w = h # Swap width and height.
206+ new_h = w
207+ combined_boxes .append ((new_cx , new_cy , new_w , new_h , ObstacleStateEnum .RIGHT ))
204208 for box in boxes_right :
205209 cx , cy , w , h = box
206- new_cx = orig_H - 1 - cy
207- new_cy = cx
208- combined_boxes .append ((new_cx , new_cy , h , w , ObstacleStateEnum .LEFT ))
210+ new_cx = cy
211+ new_cy = orig_H - 1 - cx
212+ new_w = h # Swap width and height.
213+ new_h = w
214+ combined_boxes .append ((new_cx , new_cy , new_w , new_h , ObstacleStateEnum .LEFT ))
209215
210216 boxes_normal = np .array (results_normal [0 ].boxes .xywh .cpu ()) if len (results_normal ) > 0 else []
211217 for box in boxes_normal :
@@ -254,17 +260,20 @@ def update(self, vehicle: VehicleState) -> Dict[str, ObstacleState]:
254260
255261 for i , box_info in enumerate (combined_boxes ):
256262 cx , cy , w , h , activity = box_info
263+ # print(cx, cy, w, h)
257264 left = int (cx - w / 1.6 )
258265 right = int (cx + w / 1.6 )
259266 top = int (cy - h / 2 )
260267 bottom = int (cy + h / 2 )
261268 mask = (projected_pts [:, 0 ] >= left ) & (projected_pts [:, 0 ] <= right ) & \
262269 (projected_pts [:, 1 ] >= top ) & (projected_pts [:, 1 ] <= bottom )
263270 roi_pts = projected_pts [mask ]
271+ # print(roi_pts)
264272 if roi_pts .shape [0 ] < 5 :
265273 continue
266274
267275 points_3d = roi_pts [:, 2 :5 ]
276+
268277 points_3d = filter_points_within_threshold (points_3d , 40 )
269278 points_3d = remove_ground_by_min_range (points_3d , z_range = 0.08 )
270279 points_3d = filter_depth_points (points_3d , max_depth_diff = 0.5 )
0 commit comments