lingvo.tasks.car.transform_util module

Utilities for performing 3D transformations on points.

class lingvo.tasks.car.transform_util.Box2D(x, y, width, length, angle)[source]

Bases: object

A representation of a 2D rotated bounding box.

Box2D is based on conventions for 3D coordinate systems where y-x are switched.

property corners

Returns a [4, 2] numpy matrix containing the four corner points.

_ComputeCorners()[source]

Compute the four corners of the bounding box.

Extrema()[source]

Returns the extrema of the bounding box.

Apply(transform)[source]

Apply transform to the current box and return a new box.

AsNumpy()[source]

Return the 5DOF (xywhh) representation as a numpy array.

lingvo.tasks.car.transform_util.TransformHeading(transform, heading)[source]

Compute ‘heading’ given transform.

The heading provided as input is assumed to be in the original coordinate space. When the coordinate space undergoes a transformation (e.g., with CarToImageTransform), the heading in the new coordinate space must be recomputed.

We compute this by deriving the formula for the angle of transformed unit vector defined by ‘heading’.

Parameters
  • transform – 4x4 numpy matrix used to convert from car to image coordinates.

  • heading – Floating point scalar heading.

Returns

Heading in the transformed coordinate system.

lingvo.tasks.car.transform_util.TransformPoint(transform, x, y, z)[source]

Transform an x, y, z point given the 4x4 transform.

lingvo.tasks.car.transform_util.CopyTransform(transform)[source]

Return a copy of transform.

lingvo.tasks.car.transform_util.MakeCarToImageTransform(pixels_per_meter, image_ref_x, image_ref_y, flip_axes)[source]

Creates a 4x4 numpy matrix for car to top down image coordinates.

Parameters
  • pixels_per_meter – Number of pixels that represent a meter in top down view.

  • image_ref_x – Number of pixels to shift the car in the x direction.

  • image_ref_y – Number of pixels to shift the car in the y direction.

  • flip_axes – Boolean indicating whether the x/y axes should be flipped[ during the transform.

Returns

A 4x4 matrix transform.