MCPcopy Create free account
hub / github.com/InternRobotics/EmbodiedScan / yaw2local

Function yaw2local

embodiedscan/structures/bbox_3d/utils.py:434–453  ·  view source on GitHub ↗

Transform global yaw to local yaw (alpha in kitti) in camera coordinates, ranges from -pi to pi. Args: yaw (Tensor): A vector with local yaw of each box in shape (N, ). loc (Tensor): Gravity center of each box in shape (N, 3). Returns: Tensor: Local yaw (alpha i

(yaw: Tensor, loc: Tensor)

Source from the content-addressed store, hash-verified

432
433
434def yaw2local(yaw: Tensor, loc: Tensor) -> Tensor:
435 """Transform global yaw to local yaw (alpha in kitti) in camera
436 coordinates, ranges from -pi to pi.
437
438 Args:
439 yaw (Tensor): A vector with local yaw of each box in shape (N, ).
440 loc (Tensor): Gravity center of each box in shape (N, 3).
441
442 Returns:
443 Tensor: Local yaw (alpha in kitti).
444 """
445 local_yaw = yaw - torch.atan2(loc[:, 0], loc[:, 2])
446 larger_idx = (local_yaw > np.pi).nonzero(as_tuple=False)
447 small_idx = (local_yaw < -np.pi).nonzero(as_tuple=False)
448 if len(larger_idx) != 0:
449 local_yaw[larger_idx] -= 2 * np.pi
450 if len(small_idx) != 0:
451 local_yaw[small_idx] += 2 * np.pi
452
453 return local_yaw
454
455
456def get_lidar2img(cam2img: Tensor, lidar2cam: Tensor) -> Tensor:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected