@@ -377,9 +377,12 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
377377 downsample = False
378378 if self .latest_image is None or self .latest_lidar is None :
379379 return {}
380-
380+ lastest_image = self . latest_image . copy ()
381381 # Ensure data/ exists and build timestamp
382-
382+ if downsample :
383+ lidar_down = downsample_points (self .latest_lidar , voxel_size = 0.1 )
384+ else :
385+ lidar_down = self .latest_lidar .copy ()
383386 current_time = self .vehicle_interface .time ()
384387 if self .start_time is None :
385388 self .start_time = current_time
@@ -389,7 +392,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
389392 os .makedirs ("data" , exist_ok = True )
390393 tstamp = int (self .vehicle_interface .time () * 1000 )
391394 # 1) Dump raw image
392- cv2 .imwrite (f"data/{ tstamp } _image.png" , self . latest_image )
395+ cv2 .imwrite (f"data/{ tstamp } _image.png" , lastest_image )
393396 # 2) Dump raw LiDAR
394397 np .savez (f"data/{ tstamp } _lidar.npz" , lidar = self .latest_lidar )
395398 # 3) Write BEFORE_TRANSFORM
@@ -425,11 +428,10 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
425428 f"frame={ mode } \n "
426429 )
427430 start = time .time ()
428- undistorted_img , current_K = self .undistort_image (self . latest_image , self .K , self .D )
431+ undistorted_img , current_K = self .undistort_image (lastest_image , self .K , self .D )
429432 end = time .time ()
430433 # print('-------processing time undistort_image---', end -start)
431434 self .current_K = current_K
432- self .latest_image = undistorted_img
433435 orig_H , orig_W = undistorted_img .shape [:2 ]
434436
435437 # --- Begin modifications for three-angle detection ---
@@ -484,10 +486,7 @@ def update(self, vehicle: VehicleState) -> Dict[str, AgentState]:
484486 cv2 .FONT_HERSHEY_SIMPLEX , 0.6 , color , 2 )
485487 cv2 .imshow ("Detection - Cone 2D" , undistorted_img )
486488
487- if downsample :
488- lidar_down = downsample_points (self .latest_lidar , voxel_size = 0.1 )
489- else :
490- lidar_down = self .latest_lidar .copy ()
489+
491490 start = time .time ()
492491 pts_cam = transform_points_l2c (lidar_down , self .T_l2c )
493492 projected_pts = project_points (pts_cam , self .current_K , lidar_down )
0 commit comments