common
Box3D
Box3D(center: List[float], size: List[float], orientation: Quaternion, label: int = np.nan, score: float = np.nan, velocity: Tuple = (np.nan, np.nan, np.nan), name: str = None, token: str = None)
An wrapper of NuScenes Box.
Construct instance.
Parameters:
-
center
(List[float]
) –Center of box given as (x, y, z).
-
size
(List[float]
) –Size of box given as (width, length, height).
-
orientation
(Quaternion
) –Box orientation.
-
label
(int
, default:nan
) –Integer label.
-
score
(float
, default:nan
) –Classification score.
-
velocity
(Tuple
, default:(nan, nan, nan)
) –Box velocity given as (vx, vy, vz).
-
name
(str
, default:None
) –Box category name.
-
token
(str
, default:None
) –Unique string identifier.
Box2D
Box2D(roi: RoiType, label: int = -1, score: float = np.nan, name: str | None = None, token: str | None = None)
A class to represent 2D box.
Construct instance.
Parameters:
-
roi
(RoiType
) –Roi elements, which is the order of (xmin, ymin, xmax, ymax).
-
label
(int
, default:-1
) –Box label.
-
score
(float
, default:nan
) –Box score.
-
name
(str | None
, default:None
) –Category name.
-
token
(str | None
, default:None
) –Unique identifier token corresponding to
token
ofobject_ann
.
distance_color
distance_color(distances: Number | ArrayLike, cmap: str | None = None, v_min: float = 3.0, v_max: float = 75.0) -> tuple[float, float, float] | NDArrayF64
Return color map depending on distance values.
Parameters:
-
distances
(Number | ArrayLike
) –Array of distances in the shape of (N,).
-
cmap
(str | None
, default:None
) –Color map name in matplotlib. If None,
turbo_r
will be used. -
v_min
(float
, default:3.0
) –Min value to normalize.
-
v_max
(float
, default:75.0
) –Max value to normalize.
Returns:
-
tuple[float, float, float] | NDArrayF64
–Color map in the shape of (N,). If input type is any number, returns a color as
tuple[float, float, float]
. Otherwise, returns colors asNDArrayF64
.
view_points
view_points(points: NDArrayF64, intrinsic: NDArrayF64, distortion: NDArrayF64 | None = None, *, normalize: bool = True) -> NDArrayF64
Project 3d points on a 2d plane. It can be used to implement both perspective and orthographic projections.
It first applies the dot product between the points and the view.
Parameters:
-
points
(NDArrayF64
) –Matrix of points, which is the shape of (3, n) and (x, y, z) is along each column.
-
intrinsic
(NDArrayF64
) –nxn camera intrinsic matrix (n <= 4).
-
distortion
(NDArrayF64 | None
, default:None
) –Camera distortion coefficients, which is the shape of (n,) (n >= 5).
-
normalize
(bool
, default:True
) –Whether to normalize the remaining coordinate (along the 3rd axis).
Returns:
-
NDArrayF64
–Projected points in the shape of (3, n). If
normalize=False
, the 3rd coordinate is the height.
is_box_in_image
is_box_in_image(box: Box3D, intrinsic: NDArrayF64, img_size: tuple[int, int], visibility: VisibilityLevel = VisibilityLevel.NONE) -> bool
Check if a box is visible inside of an image without considering its occlusions.
Parameters:
-
box
(Box3D
) –The box to be checked.
-
intrinsic
(NDArrayF64
) –3x3 camera intrinsic matrix.
-
img_size
(tuple[int, int]
) –Image size in the order of (width, height).
-
visibility
(VisibilityLevel
, default:NONE
) –Enum member of VisibilityLevel.
Returns:
-
bool
–Return True if visibility condition is satisfied.
load_json
Load json data from specified filepath.
Parameters:
-
filename
(str
) –File path to .json file.
Returns:
-
Any
–Loaded data.