def loadBoundingBoxes(self): transformList = [] bboxidList = [] for globalId, v in self.annotation3D.objects.items(): # skip dynamic objects if len(v) > 1: continue for obj in v.values(): if str(obj) is not 'building': continue lines = np.array(obj.lines) vertices = obj.vertices faces = obj.faces mesh = open3d.geometry.TriangleMesh() mesh.vertices = open3d.utility.Vector3dVector(obj.vertices) mesh.triangles = open3d.utility.Vector3iVector(obj.faces) color = self.assignColor(globalId, 'semantic') semanticId, instanceId = global2local(globalId) transformList.append(obj.transform) bboxidList.append(instanceId) mesh.paint_uniform_color(color.flatten()) mesh.compute_vertex_normals() self.bboxes.append(mesh) self.bboxes_window.append([obj.start_frame, obj.end_frame]) return transformList, bboxidList
def assignColor(self, globalIds, gtType='semantic'): if not isinstance(globalIds, (np.ndarray, np.generic)): globalIds = np.array(globalIds)[None] color = np.zeros((globalIds.size, 3)) for uid in np.unique(globalIds): semanticId, instanceId = global2local(uid) if gtType == 'semantic': color[globalIds == uid] = id2label[semanticId].color elif instanceId > 0: color[globalIds == uid] = self.getColor(instanceId) else: color[globalIds == uid] = (96, 96, 96) # stuff objects in instance mode color = color.astype(np.float) / 255.0 return color
def loadBoundingBoxWireframes(self): self.lineSets = [] for globalId, v in self.annotation3D.objects.items(): # skip dynamic objects if len(v) > 1: continue for obj in v.values(): lines = np.array(obj.lines) points = obj.vertices color = self.assignColor(0, 'semantic') semanticId, instanceId = global2local(globalId) if 'pole' in id2label[semanticId].name: radius = 0.05 else: radius = 0.08 color = np.tile(color, (lines.shape[0], 1)) line_set = open3d.geometry.LineSet( points=open3d.utility.Vector3dVector(points), lines=open3d.utility.Vector2iVector(lines), ) line_set.colors = open3d.utility.Vector3dVector(color) self.lineSets.append(line_set)