Hi, you should be able to provide the look_at
a distribution, i.e. put a list of prim paths inside of a distribution sequence so it can focus on a different object each frame.
In terms of getting the transforms of all the objects in the scene, we unfortunately don’t have that exposed yet but I can provide you some code to help. I have done some 3d bbox projections with the replicator data - i assume you have been using basic writer?
Parsing bbox data:
class ObjectDetection: # this can store both 2D and 3D bounding box data
def __init__(self, object_type=None, npy_bbox2d=None, npy_bbox3d=None):
if object_type is not None:
self.type = object_type
else:
self.type = None
if npy_bbox2d is not None:
self.xmin = npy_bbox2d[1]
self.ymin = npy_bbox2d[2]
self.xmax = npy_bbox2d[3]
self.ymax = npy_bbox2d[4]
if npy_bbox3d is not None:
self.xmin = npy_bbox3d[1] # these mins and maxes specify the bbox extents of the canonical shape size.
self.ymin = npy_bbox3d[2]
self.zmin = npy_bbox3d[3]
self.xmax = npy_bbox3d[4]
self.ymax = npy_bbox3d[5]
self.zmax = npy_bbox3d[6]
self.T = np.transpose(npy_bbox3d[7]) # the diagonal elements scale the mins and maxes of the bbox extents
parsing camera params:
class CameraParams: # this stores camera params, which are required for projecting a 3d bounding box into image space
def __init__(self, camera_params):
self.cameraFisheyeMaxFOV = camera_params["cameraFisheyeMaxFOV"]
self.cameraFisheyeNominalHeight = camera_params["cameraFisheyeNominalHeight"]
self.cameraFisheyeNominalWidth = camera_params["cameraFisheyeNominalWidth"]
self.cameraFisheyeOpticalCentre = camera_params["cameraFisheyeOpticalCentre"]
self.cameraFisheyePolynomial = camera_params["cameraFisheyePolynomial"]
self.cameraModel = camera_params["cameraModel"]
self.cameraNearFar = camera_params["cameraNearFar"]
self.cameraProjection = np.transpose(np.array(camera_params["cameraProjection"]).reshape(4, 4))
self.cameraViewTransform = np.transpose(np.array(camera_params["cameraViewTransform"]).reshape(4, 4))
self.metersPerSceneUnit = camera_params["metersPerSceneUnit"]
project to image coords:
def proj_3dbbox_to_image_coords(bbox3d_list, camera_params, im_size, im_center):
r"""
Takes as input a list of 3D bounding boxes in the world frame and projects them into 2D using the camera extrinsics.
Args:
bbox3d_list: A list of 3D bounding boxes in the world frame, each of which contain min / max extents for x, y, z, and a 4x4 world transform.
camera_params: Camera parameters that include a view transform matrix and a projection matrix.
im_center: coordinates for the center of the image (H/2 and W/2)
Returns:
A list of 2D image coordinates for all 8 corners of the bounding box.
"""
im_size_proj = list(im_size)
data = {}
data["bounding_box_3d"] = {}
data["bounding_box_3d"]["x_min"] = []
data["bounding_box_3d"]["y_min"] = []
data["bounding_box_3d"]["z_min"] = []
data["bounding_box_3d"]["x_max"] = []
data["bounding_box_3d"]["y_max"] = []
data["bounding_box_3d"]["z_max"] = []
data["bounding_box_3d"]["transform"] = []
for bbox3d in bbox3d_list:
data["bounding_box_3d"]["x_min"].append(bbox3d.xmin)
data["bounding_box_3d"]["y_min"].append(bbox3d.ymin)
data["bounding_box_3d"]["z_min"].append(bbox3d.zmin)
data["bounding_box_3d"]["x_max"].append(bbox3d.xmax)
data["bounding_box_3d"]["y_max"].append(bbox3d.ymax)
data["bounding_box_3d"]["z_max"].append(bbox3d.zmax)
data["bounding_box_3d"]["transform"].append(np.transpose(bbox3d.T))
bbox3d_corners = get_bbox_3d_corners(data["bounding_box_3d"])
bbox3d_proj = []
for i, bbox3d in enumerate(bbox3d_list):
points_in_world_frame = bbox3d_corners[i]
if camera_params.cameraModel == "fisheyePolynomial" or camera_params.cameraModel == "ftheta":
points_proj = project_fish_eye_polynomial(points_in_world_frame, camera_params)
im_size_proj = [camera_params.cameraFisheyeNominalWidth, camera_params.cameraFisheyeNominalHeight]
# print(points_in_world_frame, points_proj, im_size_proj, im_center, "points")
else:
points_proj = project_pinhole(points_in_world_frame, im_center, camera_params)
bbox3d_proj.append(list(points_proj))
return bbox3d_proj, im_size_proj
overlay on the image:
def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags):
r"""
Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library.
Args:
im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side.
im_size: The size of the image in pixels.
bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space.
bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag.
bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear.
"""
x_adj, y_adj = 1, 1
# move the bounding boxes up or down depending on aspect ratio of the image
if im_size[1] > im_size[0]:
x_adj = float(im_size[0]) / float(im_size[1])
if im_size[1] < im_size[0]:
y_adj = float(im_size[1]) / float(im_size[0])
im_aspect_ratio = float(im_size[0]) / float(im_size[1])
im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio])
scene_view = sc.SceneView(
aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio
)
with scene_view.scene:
with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)):
for idx in range(len(bbox3d_data_list[0])):
point_set = bbox3d_proj[idx]
point_set = bbox3d_proj[idx]
bbox_data = bbox3d_data_list[0][idx]
if bbox_tags[bbox_data.type] == True:
# colour = data_to_colour(bbox_data.type, 0.6)
colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6]
u = {}
v = {}
for corner in range(8):
u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj
v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj
line_coord_list = [
[u[0], v[0], u[1], v[1]],
[u[0], v[0], u[2], v[2]],
[u[0], v[0], u[4], v[4]],
[u[1], v[1], u[3], v[3]],
[u[1], v[1], u[5], v[5]],
[u[2], v[2], u[3], v[3]],
[u[2], v[2], u[6], v[6]],
def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ra def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colo def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(n def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colo def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colo def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_v def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)ur(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)ur(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)p.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14) [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)ur(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)tio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = def sceneOverlay3dbbox(im_size, bbox3d_proj, bbox3d_data_list, bbox_tags): r""" Creates 3D bounding box overlays for each bounding box in the image using the omni.ui.scene library. Args: im_loc: 2D image location in the viewport. Typically this is [0, 0] for viewing a single image, or otherwise some shift in the x direction if viewing side by side. im_size: The size of the image in pixels. bbox3d_proj: A list of lists, where each sublist contains points for the 8 corners of the 3d bounding box projected in image space. bbox_data_list: A list of 3D bounding box data, where each bounding box includes a type attribute to denote the class tag. bbox_tags: A list of the overlay class tags that should be included in the overlay. If bbox_data.type is not in bbox_tags, it will not appear. """ x_adj, y_adj = 1, 1 # move the bounding boxes up or down depending on aspect ratio of the image if im_size[1] > im_size[0]: x_adj = float(im_size[0]) / float(im_size[1]) if im_size[1] < im_size[0]: y_adj = float(im_size[1]) / float(im_size[0]) im_aspect_ratio = float(im_size[0]) / float(im_size[1]) im_scale_factor = 2 * max([im_aspect_ratio, 1.0 / im_aspect_ratio]) scene_view = sc.SceneView( aspect_ratio_policy=sc.AspectRatioPolicy.PRESERVE_ASPECT_FIT, screen_aspect_ratio=im_aspect_ratio ) with scene_view.scene: with sc.Transform(transform=sc.Matrix44.get_scale_matrix(im_scale_factor, im_scale_factor, im_scale_factor)): for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj line_coord_list = [ [u[0], v[0], u[1], v[1]], [u[0], v[0], u[2], v[2]], [u[0], v[0], u[4], v[4]], [u[1], v[1], u[3], v[3]], [u[1], v[1], u[5], v[5]], [u[2], v[2], u[3], v[3]], [u[2], v[2], u[6], v[6]], [u[3], v[3], u[7], v[7]], [u[4], v[4], u[5], v[5]], [u[4], v[4], u[6], v[6]], [u[5], v[5], u[7], v[7]], [u[7], v[7], u[6], v[6]], ] for line_coord in line_coord_list: # print(line_coord, x_adj, y_adj) # check if both are out c1 = rv.overlay.check_coord( line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) c2 = rv.overlay.check_coord( line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) if c1 is True and c2 is True: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) else: if c1 is False and c2 is False: continue x_point = rv.overlay.find_intersection( line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj] ) # print(x_point, line_coord, [x_adj, y_adj], c1, c2) if c1 is False and c2 is True and x_point[0] is not None: sc.Line( start=(x_point[0], x_point[1], 100), end=(line_coord[2], line_coord[3], 100), color=colour, thickness=2, ) elif c1 is True and c2 is False and x_point[0] is not None: sc.Line( start=(line_coord[0], line_coord[1], 100), end=(x_point[0], x_point[1], 100), color=colour, thickness=2, ) for idx in range(len(bbox3d_data_list[0])): point_set = bbox3d_proj[idx] point_set = bbox3d_proj[idx] bbox_data = bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)bbox3d_data_list[0][idx] if bbox_tags[bbox_data.type] == True: # colour = data_to_colour(bbox_data.type, 0.6) colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6] u = {} v = {} for corner in range(8): u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]]) v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]]) if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)): sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14) [u[3], v[3], u[7], v[7]],
[u[4], v[4], u[5], v[5]],
[u[4], v[4], u[6], v[6]],
[u[5], v[5], u[7], v[7]],
[u[7], v[7], u[6], v[6]],
]
for line_coord in line_coord_list:
# print(line_coord, x_adj, y_adj)
# check if both are out
c1 = rv.overlay.check_coord(
line_coord[0:2], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj]
)
c2 = rv.overlay.check_coord(
line_coord[2:4], [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj]
)
if c1 is True and c2 is True:
sc.Line(
start=(line_coord[0], line_coord[1], 100),
end=(line_coord[2], line_coord[3], 100),
color=colour,
thickness=2,
)
else:
if c1 is False and c2 is False:
continue
x_point = rv.overlay.find_intersection(
line_coord, [-0.5 * x_adj, -0.5 * y_adj, 0.5 * x_adj, 0.5 * y_adj]
)
# print(x_point, line_coord, [x_adj, y_adj], c1, c2)
if c1 is False and c2 is True and x_point[0] is not None:
sc.Line(
start=(x_point[0], x_point[1], 100),
end=(line_coord[2], line_coord[3], 100),
color=colour,
thickness=2,
)
elif c1 is True and c2 is False and x_point[0] is not None:
sc.Line(
start=(line_coord[0], line_coord[1], 100),
end=(x_point[0], x_point[1], 100),
color=colour,
thickness=2,
)
for idx in range(len(bbox3d_data_list[0])):
point_set = bbox3d_proj[idx]
point_set = bbox3d_proj[idx]
bbox_data = bbox3d_data_list[0][idx]
if bbox_tags[bbox_data.type] == True:
# colour = data_to_colour(bbox_data.type, 0.6)
colour = list(np.array(rv.overlay.data_to_colour(bbox_data.type)) / 255.0) + [0.6]
u = {}
v = {}
for corner in range(8):
u[corner] = point_set[corner][0] / max(im_size) - 0.5 * x_adj
v[corner] = -point_set[corner][1] / max(im_size) + 0.5 * y_adj
u_label = min([u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]])
v_label = max([v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]])
if -0.5 * y_adj - 0.02 <= v_label <= 0.5 * y_adj and -0.5 * x_adj - 0.02 <= u_label <= 0.5 * x_adj:
with sc.Transform(transform=sc.Matrix44.get_translation_matrix(u_label, v_label, 0)):
sc.Label(bbox_data.type, alignment=ui.Alignment.LEFT_BOTTOM, color=colour, size=14)