def converts_to_ObjectInBoxe(image_size, ymin, xmin, ymax, xmax, probability=(), object_name_list=(), use_normalized_coordinates=True, do_rectify=False): """Adds a bounding box to an image. Bounding box coordinates can be specified in either absolute (pixel) or normalized coordinates by setting the use_normalized_coordinates argument. Each string in display_str_list is displayed on a separate line above the bounding box in black text on a rectangle filled with the input 'color'. If the top of the bounding box extends to the edge of the image, the strings are displayed below the bounding box. Args: image_size: image_size. ymin: ymin of bounding box. xmin: xmin of bounding box. ymax: ymax of bounding box. xmax: xmax of bounding box. object_name_list: list of strings to display in box (each to be shown on its own line). use_normalized_coordinates: If True (default), treat coordinates ymin, xmin, ymax, xmax as relative to the image. Otherwise treat coordinates as absolute. """ im_height, im_width = image_size if use_normalized_coordinates: (left, right, top, bottom) = (xmin * im_width, xmax * im_width, ymin * im_height, ymax * im_height) else: (left, right, top, bottom) = (xmin, xmax, ymin, ymax) object = Object() object.object_name = object_name_list[0] object.probability = probability[0] roi = RegionOfInterest() roi.x_offset = int(left) roi.y_offset = int(top) roi.height = int(bottom - top) roi.width = int(right - left) roi.do_rectify = do_rectify object_in_box = ObjectInBox() object_in_box.object = object object_in_box.roi = roi return object_in_box
def get_ros_msg(x, y, yaw, v, id): quat = tf.transformations.quaternion_from_euler(0, 0, yaw) m = Marker() m.header.frame_id = "/map" m.header.stamp = rospy.Time.now() m.id = id m.type = m.CUBE m.pose.position.x = x + 1.3 * math.cos(yaw) m.pose.position.y = y + 1.3 * math.sin(yaw) m.pose.position.z = 0.75 m.pose.orientation = Quaternion(*quat) m.scale.x = 4.475 m.scale.y = 1.850 m.scale.z = 1.645 m.color.r = 93 / 255.0 m.color.g = 122 / 255.0 m.color.b = 177 / 255.0 m.color.a = 0.97 o = Object() o.header.frame_id = "/map" o.header.stamp = rospy.Time.now() o.id = id o.classification = o.CLASSIFICATION_CAR o.x = x o.y = y o.yaw = yaw o.v = v o.L = m.scale.x o.W = m.scale.y return { "object_msg": o, "marker_msg": m, "quaternion": quat }
def to_ros(self): quat = tf.transformations.quaternion_from_euler(0, 0, self.yaw) self.tf_broadcaster.sendTransform((self.x, self.y, 1.5), quat, rospy.Time.now(), "/car_" + str(self.id), "/map") o = Object() o.header.frame_id = "/map" o.header.stamp = rospy.Time.now() o.id = self.id o.classification = o.CLASSIFICATION_CAR o.x = self.x o.y = self.y o.yaw = self.yaw o.v = self.v # input u o.a = self.accel o.delta = self.delta o.L = 4.475 o.W = 1.850 self.object_pub.publish(o)