Struct rerun::archetypes::DepthImage
source · pub struct DepthImage {
pub buffer: ImageBuffer,
pub format: ImageFormat,
pub meter: Option<DepthMeter>,
pub colormap: Option<Colormap>,
pub depth_range: Option<ValueRange>,
pub point_fill_ratio: Option<FillRatio>,
pub draw_order: Option<DrawOrder>,
}
Expand description
Archetype: A depth image, i.e. as captured by a depth camera.
Each pixel corresponds to a depth value in units specified by components::DepthMeter
.
§Example
§Depth to 3D example
use ndarray::{s, Array, ShapeBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_depth_image_3d").spawn()?;
let width = 300;
let height = 200;
let mut image = Array::<u16, _>::from_elem((height, width).f(), 65535);
image.slice_mut(s![50..150, 50..150]).fill(20000);
image.slice_mut(s![130..180, 100..280]).fill(45000);
let depth_image = rerun::DepthImage::try_from(image)?
.with_meter(10000.0)
.with_colormap(rerun::components::Colormap::Viridis);
// 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.0, 200.0],
[width as f32, height as f32],
),
)?;
rec.log("world/camera/depth", &depth_image)?;
Ok(())
}
Fields§
§buffer: ImageBuffer
The raw depth image data.
format: ImageFormat
The format of the image.
meter: Option<DepthMeter>
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: Option<Colormap>
Colormap to use for rendering the depth image.
If not set, the depth image will be rendered using the Turbo colormap.
depth_range: Option<ValueRange>
The expected range of depth values.
This is typically the expected range of valid values. Everything outside of the range is clamped to the range for the purpose of colormpaping. Note that point clouds generated from this image will still display all points, regardless of this range.
If not specified, the range will be automatically estimated from the data. Note that the Viewer may try to guess a wider range than the minimum/maximum of values in the contents of the depth image. E.g. if all values are positive, some bigger than 1.0 and all smaller than 255.0, the Viewer will guess that the data likely came from an 8bit image, thus assuming a range of 0-255.
point_fill_ratio: Option<FillRatio>
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: Option<DrawOrder>
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.
Implementations§
source§impl DepthImage
impl DepthImage
sourcepub const NUM_COMPONENTS: usize = 8usize
pub const NUM_COMPONENTS: usize = 8usize
The total number of components in the archetype: 2 required, 1 recommended, 5 optional
source§impl DepthImage
impl DepthImage
sourcepub fn new(
buffer: impl Into<ImageBuffer>,
format: impl Into<ImageFormat>
) -> DepthImage
pub fn new( buffer: impl Into<ImageBuffer>, format: impl Into<ImageFormat> ) -> DepthImage
Create a new DepthImage
.
sourcepub fn with_meter(self, meter: impl Into<DepthMeter>) -> DepthImage
pub fn with_meter(self, meter: impl Into<DepthMeter>) -> DepthImage
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.
sourcepub fn with_colormap(self, colormap: impl Into<Colormap>) -> DepthImage
pub fn with_colormap(self, colormap: impl Into<Colormap>) -> DepthImage
Colormap to use for rendering the depth image.
If not set, the depth image will be rendered using the Turbo colormap.
sourcepub fn with_depth_range(self, depth_range: impl Into<ValueRange>) -> DepthImage
pub fn with_depth_range(self, depth_range: impl Into<ValueRange>) -> DepthImage
The expected range of depth values.
This is typically the expected range of valid values. Everything outside of the range is clamped to the range for the purpose of colormpaping. Note that point clouds generated from this image will still display all points, regardless of this range.
If not specified, the range will be automatically estimated from the data. Note that the Viewer may try to guess a wider range than the minimum/maximum of values in the contents of the depth image. E.g. if all values are positive, some bigger than 1.0 and all smaller than 255.0, the Viewer will guess that the data likely came from an 8bit image, thus assuming a range of 0-255.
sourcepub fn with_point_fill_ratio(
self,
point_fill_ratio: impl Into<FillRatio>
) -> DepthImage
pub fn with_point_fill_ratio( self, point_fill_ratio: impl Into<FillRatio> ) -> DepthImage
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!
sourcepub fn with_draw_order(self, draw_order: impl Into<DrawOrder>) -> DepthImage
pub fn with_draw_order(self, draw_order: impl Into<DrawOrder>) -> DepthImage
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.
source§impl DepthImage
impl DepthImage
sourcepub fn try_from<T>(data: T) -> Result<DepthImage, ImageConstructionError<T>>
pub fn try_from<T>(data: T) -> Result<DepthImage, ImageConstructionError<T>>
Try to construct a DepthImage
from anything that can be converted into TensorData
Will return an ImageConstructionError
if the shape of the tensor data is invalid
for treating as an image.
This is useful for constructing a DepthImage
from an ndarray.
Trait Implementations§
source§impl Archetype for DepthImage
impl Archetype for DepthImage
§type Indicator = GenericIndicatorComponent<DepthImage>
type Indicator = GenericIndicatorComponent<DepthImage>
source§fn name() -> ArchetypeName
fn name() -> ArchetypeName
rerun.archetypes.Points2D
.source§fn display_name() -> &'static str
fn display_name() -> &'static str
source§fn indicator() -> MaybeOwnedComponentBatch<'static>
fn indicator() -> MaybeOwnedComponentBatch<'static>
source§fn required_components() -> Cow<'static, [ComponentName]>
fn required_components() -> Cow<'static, [ComponentName]>
source§fn recommended_components() -> Cow<'static, [ComponentName]>
fn recommended_components() -> Cow<'static, [ComponentName]>
source§fn optional_components() -> Cow<'static, [ComponentName]>
fn optional_components() -> Cow<'static, [ComponentName]>
source§fn all_components() -> Cow<'static, [ComponentName]>
fn all_components() -> Cow<'static, [ComponentName]>
source§fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)>
) -> Result<DepthImage, DeserializationError>
fn from_arrow_components( arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)> ) -> Result<DepthImage, DeserializationError>
ComponentNames
, deserializes them
into this archetype. Read moresource§fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
source§impl AsComponents for DepthImage
impl AsComponents for DepthImage
source§fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
ComponentBatch
s. Read moresource§impl Clone for DepthImage
impl Clone for DepthImage
source§fn clone(&self) -> DepthImage
fn clone(&self) -> DepthImage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DepthImage
impl Debug for DepthImage
source§impl PartialEq for DepthImage
impl PartialEq for DepthImage
source§fn eq(&self, other: &DepthImage) -> bool
fn eq(&self, other: &DepthImage) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl SizeBytes for DepthImage
impl SizeBytes for DepthImage
source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
self
on the heap, in bytes.source§fn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
self
in bytes, accounting for both stack and heap space.source§fn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
self
on the stack, in bytes. Read moreimpl ArchetypeReflectionMarker for DepthImage
impl StructuralPartialEq for DepthImage
Auto Trait Implementations§
impl Freeze for DepthImage
impl RefUnwindSafe for DepthImage
impl Send for DepthImage
impl Sync for DepthImage
impl Unpin for DepthImage
impl UnwindSafe for DepthImage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request