Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::DepthImage Struct Reference

Archetype: A depth image. More...

#include <rerun/archetypes/depth_image.hpp>

Public Types

using IndicatorComponent = rerun::components::IndicatorComponent< IndicatorComponentName >
 Indicator component, used to identify the archetype when converting to a list of components.
 

Public Member Functions

 DepthImage (Collection< datatypes::TensorDimension > shape, datatypes::TensorBuffer buffer)
 New depth image from height/width and tensor buffer.
 
 DepthImage (components::TensorData data_)
 New depth image from tensor data.
 
template<typename TElement >
 DepthImage (Collection< datatypes::TensorDimension > shape, const TElement *data_)
 New depth image from dimensions and pointer to depth image data.
 
 DepthImage (DepthImage &&other)=default
 
DepthImage with_meter (rerun::components::DepthMeter _meter) &&
 An optional floating point value that specifies how long a meter is in the native depth units.
 
DepthImage with_colormap (rerun::components::Colormap _colormap) &&
 Colormap to use for rendering the depth image.
 
DepthImage with_point_fill_ratio (rerun::components::FillRatio _point_fill_ratio) &&
 Scale the radii of the points in the point cloud generated from this image.
 
DepthImage with_draw_order (rerun::components::DrawOrder _draw_order) &&
 An optional floating point value that specifies the 2D drawing order, used only if the depth image is shown as a 2D image.
 

Public Attributes

rerun::components::TensorData data
 The depth-image data. Should always be a 2-dimensional tensor.
 
std::optional< rerun::components::DepthMetermeter
 An optional floating point value that specifies how long a meter is in the native depth units.
 
std::optional< rerun::components::Colormapcolormap
 Colormap to use for rendering the depth image.
 
std::optional< rerun::components::FillRatiopoint_fill_ratio
 Scale the radii of the points in the point cloud generated from this image.
 
std::optional< rerun::components::DrawOrderdraw_order
 An optional floating point value that specifies the 2D drawing order, used only if the depth image is shown as a 2D image.
 

Static Public Attributes

static constexpr const char IndicatorComponentName []
 

Detailed Description

Archetype: A depth image.

The shape of the TensorData must be mappable to an HxW tensor. Each pixel corresponds to a depth value in units specified by meter.

Since the underlying rerun::datatypes::TensorData uses rerun::Collection internally, data can be passed in without a copy from raw pointers or by reference from std::vector/std::array/c-arrays. If needed, this "borrow-behavior" can be extended by defining your own rerun::CollectionAdapter.

Example

Depth to 3D example

image

#include <rerun.hpp>
#include <algorithm> // fill_n
#include <vector>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_depth_image_3d");
rec.spawn().exit_on_failure();
// Create a synthetic depth image.
const int HEIGHT = 200;
const int WIDTH = 300;
std::vector<uint16_t> data(WIDTH * HEIGHT, 65535);
for (auto y = 50; y <150; ++y) {
std::fill_n(data.begin() + y * WIDTH + 50, 100, static_cast<uint16_t>(20000));
}
for (auto y = 130; y <180; ++y) {
std::fill_n(data.begin() + y * WIDTH + 100, 180, static_cast<uint16_t>(45000));
}
// If we log a pinhole camera model, the depth gets automatically back-projected to 3D
rec.log(
"world/camera",
rerun::Pinhole::from_focal_length_and_resolution(
200.0f,
{static_cast<float>(WIDTH), static_cast<float>(HEIGHT)}
)
);
rec.log(
"world/camera/depth",
rerun::DepthImage({HEIGHT, WIDTH}, data)
.with_meter(10000.0)
);
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:57
@ Viridis
The Viridis colormap from Matplotlib.
Archetype: A depth image.
Definition depth_image.hpp:75
rerun::components::TensorData data
The depth-image data. Should always be a 2-dimensional tensor.
Definition depth_image.hpp:77
DepthImage with_colormap(rerun::components::Colormap _colormap) &&
Colormap to use for rendering the depth image.
Definition depth_image.hpp:168
DepthImage with_meter(rerun::components::DepthMeter _meter) &&
An optional floating point value that specifies how long a meter is in the native depth units.
Definition depth_image.hpp:159

Constructor & Destructor Documentation

◆ DepthImage() [1/3]

rerun::archetypes::DepthImage::DepthImage ( Collection< datatypes::TensorDimension shape,
datatypes::TensorBuffer  buffer 
)
inline

New depth image from height/width and tensor buffer.

Parameters
shapeShape of the image. Calls Error::handle() if the tensor is not 2-dimensional Sets the dimension names to "height" and "width" if they are not specified.
bufferThe tensor buffer containing the depth image data.

◆ DepthImage() [2/3]

rerun::archetypes::DepthImage::DepthImage ( components::TensorData  data_)
explicit

New depth image from tensor data.

Parameters
data_The tensor buffer containing the depth image data. Sets the dimension names to "height" and "width" if they are not specified. Calls Error::handle() if the tensor is not 2-dimensional

◆ DepthImage() [3/3]

template<typename TElement >
rerun::archetypes::DepthImage::DepthImage ( Collection< datatypes::TensorDimension shape,
const TElement *  data_ 
)
inlineexplicit

New depth image from dimensions and pointer to depth image data.

Type must be one of the types supported by rerun::datatypes::TensorData.

Parameters
shapeShape of the image. Calls Error::handle() if the tensor is not 2-dimensional Sets the dimension names to "height", "width" and "channel" if they are not specified. Determines the number of elements expected to be in data.
data_Target of the pointer must outlive the archetype.

Member Function Documentation

◆ with_meter()

DepthImage rerun::archetypes::DepthImage::with_meter ( rerun::components::DepthMeter  _meter) &&
inline

An optional floating point value that specifies how long a meter is in the native depth units.

For instance: with uint16, perhaps meter=1000 which would mean you have millimeter precision and a range of up to ~65 meters (2^16 / 1000).

Note that the only effect on 2D views is the physical depth values shown when hovering the image. In 3D views on the other hand, this affects where the points of the point cloud are placed.

◆ with_colormap()

DepthImage rerun::archetypes::DepthImage::with_colormap ( rerun::components::Colormap  _colormap) &&
inline

Colormap to use for rendering the depth image.

If not set, the depth image will be rendered using the Turbo colormap.

◆ with_point_fill_ratio()

DepthImage rerun::archetypes::DepthImage::with_point_fill_ratio ( rerun::components::FillRatio  _point_fill_ratio) &&
inline

Scale the radii of the points in the point cloud generated from this image.

A fill ratio of 1.0 (the default) means that each point is as big as to touch the center of its neighbor if it is at the same depth, leaving no gaps. A fill ratio of 0.5 means that each point touches the edge of its neighbor if it has the same depth.

TODO(#6744): This applies only to 3D views!

◆ with_draw_order()

DepthImage rerun::archetypes::DepthImage::with_draw_order ( rerun::components::DrawOrder  _draw_order) &&
inline

An optional floating point value that specifies the 2D drawing order, used only if the depth image is shown as a 2D image.

Objects with higher values are drawn on top of those with lower values.

Member Data Documentation

◆ meter

std::optional<rerun::components::DepthMeter> rerun::archetypes::DepthImage::meter

An optional floating point value that specifies how long a meter is in the native depth units.

For instance: with uint16, perhaps meter=1000 which would mean you have millimeter precision and a range of up to ~65 meters (2^16 / 1000).

Note that the only effect on 2D views is the physical depth values shown when hovering the image. In 3D views on the other hand, this affects where the points of the point cloud are placed.

◆ colormap

std::optional<rerun::components::Colormap> rerun::archetypes::DepthImage::colormap

Colormap to use for rendering the depth image.

If not set, the depth image will be rendered using the Turbo colormap.

◆ point_fill_ratio

std::optional<rerun::components::FillRatio> rerun::archetypes::DepthImage::point_fill_ratio

Scale the radii of the points in the point cloud generated from this image.

A fill ratio of 1.0 (the default) means that each point is as big as to touch the center of its neighbor if it is at the same depth, leaving no gaps. A fill ratio of 0.5 means that each point touches the edge of its neighbor if it has the same depth.

TODO(#6744): This applies only to 3D views!

◆ draw_order

std::optional<rerun::components::DrawOrder> rerun::archetypes::DepthImage::draw_order

An optional floating point value that specifies the 2D drawing order, used only if the depth image is shown as a 2D image.

Objects with higher values are drawn on top of those with lower values.

◆ IndicatorComponentName

constexpr const char rerun::archetypes::DepthImage::IndicatorComponentName[]
staticconstexpr
Initial value:
=
"rerun.components.DepthImageIndicator"

The documentation for this struct was generated from the following file: