Struct rerun::DepthImage
source · pub struct DepthImage {
pub data: TensorData,
pub meter: Option<DepthMeter>,
pub draw_order: Option<DrawOrder>,
}
Expand 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
.
§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 mut image = Array::<u16, _>::from_elem((200, 300).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.clone())?.with_meter(10000.0);
// 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],
[image.shape()[1] as f32, image.shape()[0] as f32],
),
)?;
rec.log("world/camera/depth", &depth_image)?;
Ok(())
}
Fields§
§data: TensorData
The depth-image data. Should always be a rank-2 tensor.
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).
draw_order: Option<DrawOrder>
An optional floating point value that specifies the 2D drawing order.
Objects with higher values are drawn on top of those with lower values.
Implementations§
source§impl DepthImage
impl DepthImage
sourcepub const NUM_COMPONENTS: usize = 4usize
pub const NUM_COMPONENTS: usize = 4usize
The total number of components in the archetype: 1 required, 1 recommended, 2 optional
source§impl DepthImage
impl DepthImage
sourcepub fn new(data: impl Into<TensorData>) -> DepthImage
pub fn new(data: impl Into<TensorData>) -> 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).
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.
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 an 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 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 moresource§impl ToArchetype<DepthImage> for LatestAtResults
impl ToArchetype<DepthImage> for LatestAtResults
source§fn to_archetype(
&self,
resolver: &PromiseResolver
) -> PromiseResult<Result<DepthImage, QueryError>>
fn to_archetype( &self, resolver: &PromiseResolver ) -> PromiseResult<Result<DepthImage, QueryError>>
re_types_core::Archetype
. Read moreimpl 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>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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 more