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

Archetype: Camera perspective projection (a.k.a. More...

#include <rerun/archetypes/pinhole.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

Pinhole with_resolution (float width, float height) &&
 Pixel resolution (usually integers) of child image space.
 
Pinhole with_resolution (int width, int height) &&
 Pixel resolution (usually integers) of child image space.
 
 Pinhole (Pinhole &&other)=default
 
 Pinhole (const Pinhole &other)=default
 
Pinholeoperator= (const Pinhole &other)=default
 
Pinholeoperator= (Pinhole &&other)=default
 
 Pinhole (rerun::components::PinholeProjection _image_from_camera)
 
Pinhole with_image_from_camera (const rerun::components::PinholeProjection &_image_from_camera) &&
 Camera projection, from image coordinates to view coordinates.
 
Pinhole with_many_image_from_camera (const Collection< rerun::components::PinholeProjection > &_image_from_camera) &&
 This method makes it possible to pack multiple image_from_camera in a single component batch.
 
Pinhole with_resolution (const rerun::components::Resolution &_resolution) &&
 Pixel resolution (usually integers) of child image space.
 
Pinhole with_many_resolution (const Collection< rerun::components::Resolution > &_resolution) &&
 This method makes it possible to pack multiple resolution in a single component batch.
 
Pinhole with_camera_xyz (const rerun::components::ViewCoordinates &_camera_xyz) &&
 Sets the view coordinates for the camera.
 
Pinhole with_many_camera_xyz (const Collection< rerun::components::ViewCoordinates > &_camera_xyz) &&
 This method makes it possible to pack multiple camera_xyz in a single component batch.
 
Pinhole with_image_plane_distance (const rerun::components::ImagePlaneDistance &_image_plane_distance) &&
 The distance from the camera origin to the image plane when the projection is shown in a 3D viewer.
 
Pinhole with_many_image_plane_distance (const Collection< rerun::components::ImagePlaneDistance > &_image_plane_distance) &&
 This method makes it possible to pack multiple image_plane_distance in a single component batch.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static Pinhole from_focal_length_and_resolution (const datatypes::Vec2D &focal_length, const datatypes::Vec2D &resolution)
 Creates a pinhole from the camera focal length and resolution, both specified in pixels.
 
static Pinhole from_focal_length_and_resolution (float focal_length, const datatypes::Vec2D &resolution)
 Creates a symmetric pinhole from the camera focal length and resolution, both specified in pixels.
 
static Pinhole from_fov_and_aspect_ratio (float fov_y, float aspect_ratio)
 Creates a pinhole from the camera vertical field of view (in radians) and aspect ratio (width/height).
 
static Pinhole update_fields ()
 Update only some specific fields of a Pinhole.
 
static Pinhole clear_fields ()
 Clear all the fields of a Pinhole.
 

Public Attributes

std::optional< ComponentBatchimage_from_camera
 Camera projection, from image coordinates to view coordinates.
 
std::optional< ComponentBatchresolution
 Pixel resolution (usually integers) of child image space.
 
std::optional< ComponentBatchcamera_xyz
 Sets the view coordinates for the camera.
 
std::optional< ComponentBatchimage_plane_distance
 The distance from the camera origin to the image plane when the projection is shown in a 3D viewer.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.PinholeIndicator"
 
static constexpr const char ArchetypeName [] = "rerun.archetypes.Pinhole"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_image_from_camera
 ComponentDescriptor for the image_from_camera field.
 
static constexpr auto Descriptor_resolution
 ComponentDescriptor for the resolution field.
 
static constexpr auto Descriptor_camera_xyz
 ComponentDescriptor for the camera_xyz field.
 
static constexpr auto Descriptor_image_plane_distance
 ComponentDescriptor for the image_plane_distance field.
 

Detailed Description

Archetype: Camera perspective projection (a.k.a.

intrinsics).

Examples

Simple pinhole camera

image

#include <rerun.hpp>
#include <algorithm> // std::generate
#include <cstdlib> // std::rand
#include <vector>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_pinhole");
rec.spawn().exit_on_failure();
rec.log("world/image", rerun::Pinhole::from_focal_length_and_resolution(3.0f, {3.0f, 3.0f}));
std::vector<uint8_t> random_data(3 * 3 * 3);
std::generate(random_data.begin(), random_data.end(), [] {
return static_cast<uint8_t>(std::rand());
});
rec.log("world/image", rerun::Image::from_rgb24(random_data, {3, 3}));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60

Perspective pinhole camera

image

#include <rerun.hpp>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_pinhole_perspective");
rec.spawn().exit_on_failure();
const float fov_y = 0.7853982f;
const float aspect_ratio = 1.7777778f;
rec.log(
"world/cam",
rerun::Pinhole::from_fov_and_aspect_ratio(fov_y, aspect_ratio)
);
rec.log(
"world/points",
rerun::Points3D({{0.0f, 0.0f, -0.5f}, {0.1f, 0.1f, -0.5f}, {-0.1f, -0.1f, -0.5f}}
).with_radii({0.025f})
);
}
Pinhole with_camera_xyz(const rerun::components::ViewCoordinates &_camera_xyz) &&
Sets the view coordinates for the camera.
Definition pinhole.hpp:305
Pinhole with_image_plane_distance(const rerun::components::ImagePlaneDistance &_image_plane_distance) &&
The distance from the camera origin to the image plane when the projection is shown in a 3D viewer.
Definition pinhole.hpp:326
Archetype: A 3D point cloud with positions and optional colors, radii, labels, etc.
Definition points3d.hpp:175
static RERUN_SDK_EXPORT const rerun::components::ViewCoordinates RUB
X=Right, Y=Up, Z=Back.
Definition view_coordinates.hpp:138

Member Function Documentation

◆ from_focal_length_and_resolution() [1/2]

static Pinhole rerun::archetypes::Pinhole::from_focal_length_and_resolution ( const datatypes::Vec2D focal_length,
const datatypes::Vec2D resolution 
)
static

Creates a pinhole from the camera focal length and resolution, both specified in pixels.

The focal length is the diagonal of the projection matrix. Set the same value for x & y value for symmetric cameras, or two values for anamorphic cameras.

Assumes the principal point to be in the middle of the sensor.

◆ from_focal_length_and_resolution() [2/2]

static Pinhole rerun::archetypes::Pinhole::from_focal_length_and_resolution ( float  focal_length,
const datatypes::Vec2D resolution 
)
inlinestatic

Creates a symmetric pinhole from the camera focal length and resolution, both specified in pixels.

The focal length is the diagonal of the projection matrix.

Assumes the principal point to be in the middle of the sensor.

◆ from_fov_and_aspect_ratio()

static Pinhole rerun::archetypes::Pinhole::from_fov_and_aspect_ratio ( float  fov_y,
float  aspect_ratio 
)
inlinestatic

Creates a pinhole from the camera vertical field of view (in radians) and aspect ratio (width/height).

Assumes the principal point to be in the middle of the sensor.

◆ with_resolution() [1/3]

Pinhole rerun::archetypes::Pinhole::with_resolution ( float  width,
float  height 
) &&
inline

Pixel resolution (usually integers) of child image space.

Width and height.

image_from_camera project onto the space spanned by (0,0) and resolution - 1.

◆ with_resolution() [2/3]

Pinhole rerun::archetypes::Pinhole::with_resolution ( int  width,
int  height 
) &&
inline

Pixel resolution (usually integers) of child image space.

Width and height.

image_from_camera project onto the space spanned by (0,0) and resolution - 1.

◆ with_many_image_from_camera()

Pinhole rerun::archetypes::Pinhole::with_many_image_from_camera ( const Collection< rerun::components::PinholeProjection > &  _image_from_camera) &&
inline

This method makes it possible to pack multiple image_from_camera in a single component batch.

This only makes sense when used in conjunction with columns. with_image_from_camera should be used when logging a single row's worth of data.

◆ with_resolution() [3/3]

Pinhole rerun::archetypes::Pinhole::with_resolution ( const rerun::components::Resolution _resolution) &&
inline

Pixel resolution (usually integers) of child image space.

Width and height.

Example:

[1920.0, 1440.0]

image_from_camera project onto the space spanned by (0,0) and resolution - 1.

◆ with_many_resolution()

Pinhole rerun::archetypes::Pinhole::with_many_resolution ( const Collection< rerun::components::Resolution > &  _resolution) &&
inline

This method makes it possible to pack multiple resolution in a single component batch.

This only makes sense when used in conjunction with columns. with_resolution should be used when logging a single row's worth of data.

◆ with_camera_xyz()

Pinhole rerun::archetypes::Pinhole::with_camera_xyz ( const rerun::components::ViewCoordinates _camera_xyz) &&
inline

Sets the view coordinates for the camera.

All common values are available as constants on the components::ViewCoordinates class.

The default is ViewCoordinates::RDF, i.e. X=Right, Y=Down, Z=Forward, and this is also the recommended setting. This means that the camera frustum will point along the positive Z axis of the parent space, and the cameras "up" direction will be along the negative Y axis of the parent space.

The camera frustum will point whichever axis is set to F (or the opposite of B). When logging a depth image under this entity, this is the direction the point cloud will be projected. With RDF, the default forward is +Z.

The frustum's "up" direction will be whichever axis is set to U (or the opposite of D). This will match the negative Y direction of pixel space (all images are assumed to have xyz=RDF). With RDF, the default is up is -Y.

The frustum's "right" direction will be whichever axis is set to R (or the opposite of L). This will match the positive X direction of pixel space (all images are assumed to have xyz=RDF). With RDF, the default right is +x.

Other common formats are RUB (X=Right, Y=Up, Z=Back) and FLU (X=Forward, Y=Left, Z=Up).

NOTE: setting this to something else than RDF (the default) will change the orientation of the camera frustum, and make the pinhole matrix not match up with the coordinate system of the pinhole entity.

The pinhole matrix (the image_from_camera argument) always project along the third (Z) axis, but will be re-oriented to project along the forward axis of the camera_xyz argument.

◆ with_many_camera_xyz()

Pinhole rerun::archetypes::Pinhole::with_many_camera_xyz ( const Collection< rerun::components::ViewCoordinates > &  _camera_xyz) &&
inline

This method makes it possible to pack multiple camera_xyz in a single component batch.

This only makes sense when used in conjunction with columns. with_camera_xyz should be used when logging a single row's worth of data.

◆ with_image_plane_distance()

Pinhole rerun::archetypes::Pinhole::with_image_plane_distance ( const rerun::components::ImagePlaneDistance _image_plane_distance) &&
inline

The distance from the camera origin to the image plane when the projection is shown in a 3D viewer.

This is only used for visualization purposes, and does not affect the projection itself.

◆ with_many_image_plane_distance()

Pinhole rerun::archetypes::Pinhole::with_many_image_plane_distance ( const Collection< rerun::components::ImagePlaneDistance > &  _image_plane_distance) &&
inline

This method makes it possible to pack multiple image_plane_distance in a single component batch.

This only makes sense when used in conjunction with columns. with_image_plane_distance should be used when logging a single row's worth of data.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::Pinhole::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::Pinhole::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ resolution

std::optional<ComponentBatch> rerun::archetypes::Pinhole::resolution

Pixel resolution (usually integers) of child image space.

Width and height.

Example:

[1920.0, 1440.0]

image_from_camera project onto the space spanned by (0,0) and resolution - 1.

◆ camera_xyz

std::optional<ComponentBatch> rerun::archetypes::Pinhole::camera_xyz

Sets the view coordinates for the camera.

All common values are available as constants on the components::ViewCoordinates class.

The default is ViewCoordinates::RDF, i.e. X=Right, Y=Down, Z=Forward, and this is also the recommended setting. This means that the camera frustum will point along the positive Z axis of the parent space, and the cameras "up" direction will be along the negative Y axis of the parent space.

The camera frustum will point whichever axis is set to F (or the opposite of B). When logging a depth image under this entity, this is the direction the point cloud will be projected. With RDF, the default forward is +Z.

The frustum's "up" direction will be whichever axis is set to U (or the opposite of D). This will match the negative Y direction of pixel space (all images are assumed to have xyz=RDF). With RDF, the default is up is -Y.

The frustum's "right" direction will be whichever axis is set to R (or the opposite of L). This will match the positive X direction of pixel space (all images are assumed to have xyz=RDF). With RDF, the default right is +x.

Other common formats are RUB (X=Right, Y=Up, Z=Back) and FLU (X=Forward, Y=Left, Z=Up).

NOTE: setting this to something else than RDF (the default) will change the orientation of the camera frustum, and make the pinhole matrix not match up with the coordinate system of the pinhole entity.

The pinhole matrix (the image_from_camera argument) always project along the third (Z) axis, but will be re-oriented to project along the forward axis of the camera_xyz argument.

◆ image_plane_distance

std::optional<ComponentBatch> rerun::archetypes::Pinhole::image_plane_distance

The distance from the camera origin to the image plane when the projection is shown in a 3D viewer.

This is only used for visualization purposes, and does not affect the projection itself.

◆ Descriptor_image_from_camera

constexpr auto rerun::archetypes::Pinhole::Descriptor_image_from_camera
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "image_from_camera",
Loggable<rerun::components::PinholeProjection>::Descriptor.component_name
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition pinhole.hpp:133

ComponentDescriptor for the image_from_camera field.

◆ Descriptor_resolution

constexpr auto rerun::archetypes::Pinhole::Descriptor_resolution
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "resolution",
Loggable<rerun::components::Resolution>::Descriptor.component_name
)

ComponentDescriptor for the resolution field.

◆ Descriptor_camera_xyz

constexpr auto rerun::archetypes::Pinhole::Descriptor_camera_xyz
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "camera_xyz",
Loggable<rerun::components::ViewCoordinates>::Descriptor.component_name
)

ComponentDescriptor for the camera_xyz field.

◆ Descriptor_image_plane_distance

constexpr auto rerun::archetypes::Pinhole::Descriptor_image_plane_distance
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "image_plane_distance",
Loggable<rerun::components::ImagePlaneDistance>::Descriptor.component_name
)

ComponentDescriptor for the image_plane_distance field.


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