Class Frame

Inheritance Relationships

Derived Types

Class Documentation

class Frame

Polymorphic base for sensor frames (LidarFrame, CameraFrame, …).

Holds named fields, per-timestamp poses, and packet/timestamp headers shared by lidar scans and camera images. Concrete frame types add sensor-specific metadata and accessors.

Subclassed by ouster::sdk::core::TypedFrame< CameraInfo >, ouster::sdk::core::TypedFrame< LidarInfo >, ouster::sdk::core::TypedFrame< InfoT >

Public Types

template<typename T>
using Header = Eigen::Array<T, Eigen::Dynamic, 1>

Header typedef.

Public Functions

virtual ~Frame()

Virtual destructor.

Frame is a polymorphic base; instances are commonly held and destroyed through a std::shared_ptr<Frame>.

Frame() = default

Default constructor.

Frame(const Frame&) = default

Copy constructor.

Frame &operator=(const Frame&) = default

Copy assignment operator.

Frame(Frame&&) = default

Move constructor.

Frame &operator=(Frame&&) = default

Move assignment operator.

virtual std::shared_ptr<Frame> clone() const = 0

Deep-copy this frame, preserving its concrete derived type.

Returns:

a shared pointer to a newly allocated copy of the frame.

virtual std::string to_string() const

Human-readable string representation of this frame.

Virtual so that a base Frame& (or shared_ptr<Frame>) prints the concrete frame type’s details (LidarFrame, CameraFrame, …). The base implementation prints the shared header (dimensions) followed by a per-field dump. Derived types override to prepend sensor-specific information.

Returns:

the string representation of the frame.

virtual bool equals(const Frame &other) const

Value equality against another frame.

Virtual so that comparing two frames held as a base Frame& (or shared_ptr<Frame>, as FrameSet does) accounts for the concrete type’s state instead of silently comparing only the members declared here. The base implementation requires both operands to have the same concrete type, then compares the dimensions, packet count, timestamp / pose / status headers, fields, and objects. Derived types override to add their own members and must call this base implementation first.

The associated sensor_info() is deliberately not compared. It is held by shared_ptr, so comparing it would either test pointer identity — making two frames carrying identical data unequal merely because they were read from separate files — or require a deep metadata comparison that callers of frame equality rarely want. Compare sensor_info() explicitly when the calibration matters.

Parameters:

other[in] The frame to compare against.

Returns:

true if this frame and other are of the same concrete type and hold equal data.

const std::shared_ptr<SensorInfo> &sensor_info() const

The sensor metadata (calibration) associated with this frame.

Returns the shared SensorInfo base, so generic code operating on a Frame can read the calibration common to every sensor kind (extrinsics, serial number, w()/h(), the cached XYZLut) without downcasting. Concrete frame types hide this with a same-named accessor returning their own metadata type — see TypedFrame::sensor_info().

Returns:

the associated SensorInfo, or nullptr if none is set.

virtual bool accepts_sensor_info(const SensorInfo &info) const

Whether info describes this frame’s sensor kind.

The base accepts any metadata; TypedFrame<InfoT> narrows it to InfoT. Used by impl::assign_sensor_info() to validate the one write path that cannot be checked at compile time.

Parameters:

info[in] The metadata to test.

Returns:

true if info may be associated with this frame.

std::unordered_map<std::string, Field> &fields()

Reference to the internal fields map.

Returns:

The unordered map of field type and field.

const std::unordered_map<std::string, Field> &fields() const

Reference to the internal fields map.

Returns:

The unordered map of field type and field.

template<typename T>
inline Eigen::Ref<img_t<T>> field(const std::string &name)

Access a lidar data field.

Supported

field<T>() supports element types uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, float16_t, and double.

Throws:
  • std::invalid_argument – if T does not match the runtime field type.

  • std::out_of_range – if field is not present

Template Parameters:

T – The type parameter T must match the dynamic type of the field. See the constructor documentation for expected field types or query dynamically for generic operations.

Parameters:

name[in] the name of the field to view.

Returns:

a view of the field data.

template<typename T>
inline Eigen::Ref<const img_t<T>> field(const std::string &name) const

Access a lidar data field.

Supported

Same element types as the non-const field() template above.

Throws:
  • std::invalid_argument – if T does not match the runtime field type.

  • std::out_of_range – if field is not present

Template Parameters:

T – The type parameter T must match the dynamic type of the field. See the constructor documentation for expected field types or query dynamically for generic operations.

Parameters:

name[in] the name of the field to view.

Returns:

a view of the field data.

Field &field(const std::string &name)

Access a lidar data field.

Throws:

std::out_of_range – if field is not present

Parameters:

name[in] string key of the field to access

Returns:

Field reference of the requested field

const Field &field(const std::string &name) const

Access a lidar data field.

Throws:

std::out_of_range – if field is not present

Parameters:

name[in] string key of the field to access

Returns:

Field reference of the requested field

bool has_field(const std::string &name) const

Check if a field exists.

Parameters:

name[in] string key of the field to check

Returns:

true if the lidar frame has the field, else false

Field &add_field(const std::string &name, FieldDescriptor desc, FieldClass field_class = FieldClass::PIXEL_FIELD, bool zero = true)

Add a new zero-filled field to lidar frame.

Throws:

std::invalid_argument – if key duplicates a preexisting field, or if flags dimensional requirements are not met

Parameters:
  • name[in] string key of the field to add

  • desc[in] descriptor of the field to add

  • field_class[in] class to be assigned to the field, e.g. PIXEL_FIELD

  • zero[in] If true, zero the field otherwise memory is uninitialized.

Returns:

field

Field &add_field(const FieldType &type, bool zero = true)

Add a new zero-filled field to lidar frame.

Throws:

std::invalid_argument – if key duplicates a preexisting field

Parameters:
  • type[in] Descriptor of the field to add.

  • zero[in] If true, zero the field otherwise memory is uninitialized.

Returns:

field The value of the field added.

Field del_field(const std::string &name)

Release the field and remove it from lidar frame.

Throws:

std::invalid_argument – if field under key does not exist

Parameters:

name[in] string key of the field to remove

Returns:

field The deleted field.

FieldType field_type(const std::string &name) const

Get the type of the specified field.

Parameters:

name[in] the string key of the field to query.

Returns:

the type associated with the field.

std::unordered_map<std::string, std::vector<Object>> &objects()

Reference to the internal objects map.

Returns:

The unordered map of names and object lists.

const std::unordered_map<std::string, std::vector<Object>> &objects() const

Reference to the internal objects map.

Returns:

The unordered map of names and object lists.

size_t packet_count() const

Returns the number of lidar packets needed to fill this frame.

Returns:

the number of packets

Eigen::Ref<Header<uint64_t>> timestamp()

Access the measurement timestamp header.

Returns:

a view of timestamps. Length is w for a LidarFrame and 1 for a CameraFrame.

Eigen::Ref<const Header<uint64_t>> timestamp() const

Access the measurement timestamp header.

Returns:

a view of timestamps. Length is w for a LidarFrame and 1 for a CameraFrame.

Eigen::Ref<Header<uint64_t>> receive_timestamp()

Access the per-packet host timestamp headers (usually host time).

Returns:

a view of packet timestamps. Length is w / columns-per-packet for a LidarFrame; for a CameraFrame the length is allowed to vary.

Eigen::Ref<const Header<uint64_t>> receive_timestamp() const

Access the per-packet host timestamp headers (usually host time).

Returns:

a view of packet timestamps. Length is w / columns-per-packet for a LidarFrame; for a CameraFrame the length is allowed to vary.

inline Eigen::Ref<Header<uint64_t>> packet_timestamp()

Deprecated:

Renamed to receive_timestamp(); this alias forwards to it and will be removed in a future release.

Deprecated:

Use receive_timestamp() instead. The last supported version for this will be 2.0.0 .

Returns:

a view of packet timestamps (see receive_timestamp()).

inline Eigen::Ref<const Header<uint64_t>> packet_timestamp() const

Deprecated:

Renamed to receive_timestamp(); this alias forwards to it and will be removed in a future release.

Deprecated:

Use receive_timestamp() instead. The last supported version for this will be 2.0.0 .

Deprecated:

Use receive_timestamp() instead. The last supported version for this will be 2.0.0 .

Returns:

a view of packet timestamps (see receive_timestamp()).

Eigen::Ref<Header<uint32_t>> status()

Access the per-timestamp status header (bit 0 = valid).

Returns:

a view of statuses. Length matches timestamp() (w for a LidarFrame, 1 for a CameraFrame).

Eigen::Ref<const Header<uint32_t>> status() const

Access the per-timestamp status header (bit 0 = valid).

Returns:

a view of statuses. Length matches timestamp() (w for a LidarFrame, 1 for a CameraFrame).

virtual uint64_t get_first_valid_receive_timestamp() const

Return the first valid packet timestamp.

The base implementation maps timestamps to packets using status() and receive_timestamp(). Derived types may override to combine additional streams (e.g. LidarFrame folds in IMU and zone packets).

Throws:

std::runtime_error – if no valid packets are available

Returns:

the first valid packet timestamp

virtual uint64_t get_last_valid_receive_timestamp() const

Return the last valid packet timestamp.

Throws:

std::runtime_error – if no valid packets are available

Returns:

the last valid packet timestamp

virtual uint64_t get_min_valid_receive_timestamp() const

Return the min valid packet timestamp.

Throws:

std::runtime_error – if no valid packets are available

Returns:

the min valid packet timestamp

virtual uint64_t get_max_valid_receive_timestamp() const

Return the max valid packet timestamp.

Throws:

std::runtime_error – if no valid packets are available

Returns:

the max valid packet timestamp

inline uint64_t get_first_valid_packet_timestamp() const

Deprecated:

Renamed to get_first_valid_receive_timestamp(); this alias forwards to it and will be removed in a future release.

Deprecated:

Use get_first_valid_receive_timestamp() instead. The last supported version for this will be 2.0.0 .

Returns:

the first valid packet timestamp

inline uint64_t get_last_valid_packet_timestamp() const

Deprecated:

Renamed to get_last_valid_receive_timestamp(); this alias forwards to it and will be removed in a future release.

Deprecated:

Use get_last_valid_receive_timestamp() instead. The last supported version for this will be 2.0.0 .

Returns:

the last valid packet timestamp

inline uint64_t get_min_valid_packet_timestamp() const

Deprecated:

Renamed to get_min_valid_receive_timestamp(); this alias forwards to it and will be removed in a future release.

Deprecated:

Use get_min_valid_receive_timestamp() instead. The last supported version for this will be 2.0.0 .

Returns:

the min valid packet timestamp

inline uint64_t get_max_valid_packet_timestamp() const

Deprecated:

Renamed to get_max_valid_receive_timestamp(); this alias forwards to it and will be removed in a future release.

Deprecated:

Use get_max_valid_receive_timestamp() instead. The last supported version for this will be 2.0.0 .

Returns:

the max valid packet timestamp

int get_first_valid_column() const

Return the first valid column index.

Scans the status() header (bit 0 = valid) for the first valid entry. Works for any Frame: a LidarFrame has one status per column, while a CameraFrame has a single status entry (index 0).

Throws:

std::runtime_error – if no valid columns are available

Returns:

the first valid column index

int get_last_valid_column() const

Return the last valid column index.

Scans the status() header (bit 0 = valid) for the last valid entry. Works for any Frame: a LidarFrame has one status per column, while a CameraFrame has a single status entry (index 0).

Throws:

std::runtime_error – if no valid columns are available

Returns:

the last valid column index

Field &body_to_world()

Access the array of body-to-world transforms (per each timestamp).

Cast to ArrayView3<double> in order to access as 3d.

Returns:

3d field of homogeneous pose matrices, shaped (N, 4, 4) where N is the number of timestamps (w for lidar, 1 for camera).

const Field &body_to_world() const

Access the array of body-to-world transforms (per each timestamp).

Cast to ArrayView3<double> in order to access as 3d.

Returns:

3d field of homogeneous pose matrices, shaped (N, 4, 4) where N is the number of timestamps (w for lidar, 1 for camera).

void set_column_pose(int index, const Matrix4dR &pose)

Set the pose at the given timestamp index.

Index is a column index for LidarFrame and 0 for CameraFrame. Bounds are the pose array’s first dimension, not Frame::w.

Parameters:
  • index[in] The timestamp index to set the pose for.

  • pose[in] The pose to set as a 4x4 matrix.

Throws:

std::out_of_range – if index is out of bounds

Matrix4dR get_column_pose(int index) const

Get the pose at the given timestamp index.

Index is a column index for LidarFrame and 0 for CameraFrame. Bounds are the pose array’s first dimension, not Frame::w.

Parameters:

index[in] The timestamp index to get the pose for.

Throws:

std::out_of_range – if index is out of bounds

Returns:

The pose as a 4x4 matrix.

LidarFrameFieldTypes field_types() const

Get the FieldType of all fields in the frame.

Returns:

The type associated with every field in the frame.

Public Members

size_t w = {0}

Frame horizontal resolution.

Warning

Members variables: use with caution, some of these will become private.

size_t h = {0}

Frame vertical resolution.

Warning

Members variables: use with caution, some of these will become private.

Friends

friend void assign_sensor_info(Frame &frame, std::shared_ptr<SensorInfo> info)

Grants impl::assign_sensor_info() write access to sensor_info_.

There is deliberately no setter here: a base Frame cannot verify the sensor kind at compile time, so metadata is assigned either through the typed TypedFrame::set_sensor_info() or, for genuinely generic code, through the runtime-checked impl::assign_sensor_info().

Parameters:
  • frame[inout] The frame to assign metadata to.

  • info[in] The metadata to assign.