Struct re_sdk::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").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: TensorDataThe 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
pub const NUM_COMPONENTS: usize = 5usize
source§impl DepthImage
impl DepthImage
pub fn new(data: impl Into<TensorData>) -> DepthImage
pub fn with_meter(self, meter: impl Into<DepthMeter>) -> DepthImage
pub fn with_draw_order(self, draw_order: impl Into<DrawOrder>) -> DepthImage
source§impl DepthImage
impl DepthImage
sourcepub fn try_from<T>(data: T) -> Result<DepthImage, ImageConstructionError<T>>where
T: TryInto<TensorData>,
<T as TryInto<TensorData>>::Error: Error,
pub fn try_from<T>(data: T) -> Result<DepthImage, ImageConstructionError<T>>where T: TryInto<TensorData>, <T as TryInto<TensorData>>::Error: Error,
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(
arrow_data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<DepthImage, DeserializationError>
fn from_arrow( arrow_data: impl IntoIterator<Item = (Field, Box<dyn Array>)> ) -> Result<DepthImage, DeserializationError>
source§impl AsComponents for DepthImage
impl AsComponents for DepthImage
source§fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
ComponentBatchs. Read moresource§fn num_instances(&self) -> usize
fn num_instances(&self) -> usize
source§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 ==.