def from_dict(self, object_dict: dict) -> NDDS_Annotation_Object: check_required_keys(object_dict, required_keys=[ 'class', 'instance_id', 'visibility', 'location', 'quaternion_xyzw', 'pose_transform', 'cuboid_centroid', 'projected_cuboid_centroid', 'bounding_box', 'cuboid', 'projected_cuboid' ]) check_required_keys(object_dict['bounding_box'], required_keys=['top_left', 'bottom_right']) return NDDS_Annotation_Object( class_name=object_dict['class'], instance_id=object_dict['instance_id'], visibility=object_dict['visibility'], location=Point3D.from_list(object_dict['location']), quaternion_xyzw=Quaternion.from_list( object_dict['quaternion_xyzw']), pose_transform=np.array(object_dict['pose_transform']), cuboid_centroid=Point3D.from_list(object_dict['cuboid_centroid']), projected_cuboid_centroid=Point2D.from_list( object_dict['projected_cuboid_centroid']), bounding_box=BBox.from_list( object_dict['bounding_box']['top_left'] + object_dict['bounding_box']['bottom_right'], input_format='pminpmax'), cuboid=Cuboid3D.from_list(object_dict['cuboid'], demarcation=True), projected_cuboid=Cuboid2D.from_list( object_dict['projected_cuboid'], demarcation=True))
def from_dict(cls, item_dict: dict) -> CameraData: check_required_keys(item_dict, required_keys=[ 'location_worldframe', 'quaternion_xyzw_worldframe' ]) return CameraData(location_worldframe=Point3D.from_list( coords=item_dict['location_worldframe']), quaternion_xyzw_worldframe=Quaternion.from_list( coords=item_dict['quaternion_xyzw_worldframe']))
def from_dict(cls, item_dict: dict) -> Linemod_Annotation: return Linemod_Annotation( data_root=item_dict['data_root'], mask_path=item_dict['mask_path'], depth_path=item_dict['depth_path'] if 'depth_path' in item_dict else None, type=item_dict['type'], class_name=item_dict['cls'], corner_2d=Point2D_List.from_list(item_dict['corner_2d'], demarcation=True), corner_3d=Point3D_List.from_list(item_dict['corner_3d'], demarcation=True), center_2d=Point2D.from_list(item_dict['center_2d']), center_3d=Point3D.from_list(item_dict['center_3d']), fps_2d=Point2D_List.from_list(item_dict['fps_2d'], demarcation=True), fps_3d=Point3D_List.from_list(item_dict['fps_3d'], demarcation=True), K=LinemodCamera.from_matrix(np.array(item_dict['K'])), pose=QuaternionList.from_list(item_dict['pose']), image_id=item_dict['image_id'], category_id=item_dict['category_id'], id=item_dict['id'])
def distance_from_camera(self) -> float: return (self.position.distance(Point3D.origin()) if self.position is not None else None)
def position(self) -> Point3D: return (Point3D.from_list(self.object_world_position.tolist()) if self.object_world_position is not None else None)
assert pt2d_0 - const_int == Point2D(x=pt2d_0.x - const_int, y=pt2d_0.y - const_int) assert pt2d_0 - const_float == Point2D(x=pt2d_0.x - const_float, y=pt2d_0.y - const_float) assert pt2d_0 * const_int == Point2D(x=pt2d_0.x * const_int, y=pt2d_0.y * const_int) assert pt2d_0 * const_float == Point2D(x=pt2d_0.x * const_float, y=pt2d_0.y * const_float) assert pt2d_0 / const_int == Point2D(x=pt2d_0.x / const_int, y=pt2d_0.y / const_int) assert pt2d_0 / const_float == Point2D(x=pt2d_0.x / const_float, y=pt2d_0.y / const_float) pt3d_0 = Point3D(x=1.0, y=2.0, z=3.0) pt3d_1 = Point3D(x=4.0, y=5.0, z=6.0) print(f'Point2D Test Passed') pt2d_list_0 = Point2D_List(point_list=[pt2d_0 for i in range(5)]) assert pt2d_list_0 + pt2d_1 == Point2D_List( [point + pt2d_1 for point in pt2d_list_0]) assert pt2d_list_0 + const_int == Point2D_List( [point + const_int for point in pt2d_list_0]) assert pt2d_list_0 - pt2d_1 == Point2D_List( [point - pt2d_1 for point in pt2d_list_0]) assert pt2d_list_0 - const_int == Point2D_List( [point - const_int for point in pt2d_list_0]) assert pt2d_list_0 * const_int == Point2D_List(