Search code examples
pythonquaternionsopen3d

How do I get the orientation from a open3d.geometry.OrientedBoundingBox?


I've created a Oriented Bounding Box from a clustered sub point cloud of a Velodyne Lidar (rotating laser sensor). I want to get the orientation of the Bounding Box (preferable as a quaternion).

subpcd_o3d = o3d.utility.Vector3dVector(np.array(subpcd))
o3d_bbox = o3d.geometry.OrientedBoundingBox.create_from_points(subpcd_o3d)

The Documentation has no such method: http://www.open3d.org/docs/latest/python_api/open3d.geometry.OrientedBoundingBox.html

This is confusing. Why is there apparently no orientation of the oriented bounding box?


Solution

  • Looking at the link you shared, I see the OrientedBoundingBox object has the following properties: center, extent, and R. If you can access them then you can get position and orientation. Center is a point (x, y, z), extent are three lengths in x, y and z direction and R is a rotation matrix. Columns of R are three orthogonal unit-vectors pointing on rotated x, y and z directions.

    I think you are interested in orientation, so R is the orientation matrix. You can convert it to quaternion using the matrix-to-quaternion method on this page: https://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/