|
1 | 1 | from pedestrian_utils import * |
| 2 | +from combined_detection_utils import add_bounding_box |
2 | 3 | from ultralytics import YOLO |
3 | 4 | import cv2 |
4 | 5 | from scipy.spatial.transform import Rotation as R |
|
9 | 10 | import time |
10 | 11 |
|
11 | 12 | # Publisher imports: |
12 | | -from jsk_recognition_msgs.msg import BoundingBox, BoundingBoxArray |
13 | | -from geometry_msgs.msg import Pose, Vector3 |
| 13 | +from jsk_recognition_msgs.msg import BoundingBoxArray |
| 14 | +# from geometry_msgs.msg import Pose, Vector3 |
14 | 15 |
|
15 | 16 |
|
16 | 17 | class YoloNode(): |
@@ -220,49 +221,20 @@ def synchronized_callback(self, image_msg, lidar_msg): |
220 | 221 | yaw = np.arctan2(R_vehicle[1, 0], R_vehicle[0, 0]) |
221 | 222 |
|
222 | 223 | refined_center = refined_center_vehicle |
223 | | - |
224 | | - # Create a ROS BoundingBox message |
225 | | - box_msg = BoundingBox() |
226 | | - box_msg.header.frame_id = 'currentVehicleFrame' |
227 | | - box_msg.header.stamp = lidar_msg.header.stamp |
228 | | - |
229 | | - # Set the pose |
230 | | - box_msg.pose.position.x = float(refined_center_vehicle[0]) |
231 | | - box_msg.pose.position.y = float(refined_center_vehicle[1]) |
232 | | - box_msg.pose.position.z = float(refined_center_vehicle[2]) |
233 | | - |
234 | | - # Convert yaw to quaternion |
235 | | - quat = R.from_euler('z', yaw).as_quat() |
236 | | - box_msg.pose.orientation.x = float(quat[0]) |
237 | | - box_msg.pose.orientation.y = float(quat[1]) |
238 | | - box_msg.pose.orientation.z = float(quat[2]) |
239 | | - box_msg.pose.orientation.w = float(quat[3]) |
240 | | - |
241 | | - # Set the dimensions |
242 | | - # Swapped dims[2] and dims[0] |
243 | | - box_msg.dimensions.x = float(dims[2]) # length |
244 | | - box_msg.dimensions.y = float(dims[1]) # width |
245 | | - box_msg.dimensions.z = float(dims[0]) # height |
246 | 224 |
|
247 | | - # if self.debug: |
248 | | - # print("X") |
249 | | - # print(refined_center_vehicle[0]) |
250 | | - # print("L") |
251 | | - # print(dims[0]) |
252 | | - # print("Y") |
253 | | - # print(refined_center_vehicle[1]) |
254 | | - # print("W") |
255 | | - # print(dims[1]) |
256 | | - # print("Z") |
257 | | - # print(refined_center_vehicle[2]) |
258 | | - # print("H") |
259 | | - # print(dims[2]) |
260 | | - |
261 | | - # Add confidence score and label |
262 | | - box_msg.value = float(conf_scores[i]) |
263 | | - box_msg.label = 0 # person/pedestrian class |
264 | | - |
265 | | - boxes.boxes.append(box_msg) |
| 225 | + boxes = add_bounding_box(boxes=boxes, |
| 226 | + frame_id='currentVehicleFrame', |
| 227 | + stamp=lidar_msg.header.stamp, |
| 228 | + x=refined_center_vehicle[0], |
| 229 | + y=refined_center_vehicle[1], |
| 230 | + z=refined_center_vehicle[2], |
| 231 | + l=dims[2], # length |
| 232 | + w=dims[1], # width |
| 233 | + h=dims[0], # height |
| 234 | + yaw=yaw, |
| 235 | + conf_score=float(conf_scores[i]), |
| 236 | + label=0 # person/pedestrian class |
| 237 | + ) |
266 | 238 |
|
267 | 239 | rospy.loginfo(f"Person detected at ({refined_center_vehicle[0]:.2f}, {refined_center_vehicle[1]:.2f}, {refined_center_vehicle[2]:.2f}) with score {conf_scores[i]:.2f}") |
268 | 240 |
|
|
0 commit comments