Struct re_components::DecodedTensor
source · pub struct DecodedTensor(_);
Expand description
Implementations§
source§impl DecodedTensor
impl DecodedTensor
source§impl DecodedTensor
impl DecodedTensor
sourcepub fn from_image(
image: impl Into<DynamicImage>
) -> Result<DecodedTensor, TensorImageLoadError>
pub fn from_image( image: impl Into<DynamicImage> ) -> Result<DecodedTensor, TensorImageLoadError>
Construct a tensor from something that can be turned into a image::DynamicImage
.
Requires the image
feature.
sourcepub fn from_dynamic_image(
image: DynamicImage
) -> Result<DecodedTensor, TensorImageLoadError>
pub fn from_dynamic_image( image: DynamicImage ) -> Result<DecodedTensor, TensorImageLoadError>
Construct a tensor from image::DynamicImage
.
Requires the image
feature.
pub fn try_decode( maybe_encoded_tensor: Tensor ) -> Result<Self, TensorImageLoadError>
pub fn decode_jpeg_bytes( jpeg_bytes: &Buffer<u8>, [expected_height, expected_width, expected_channels]: [u64; 3] ) -> Result<DecodedTensor, TensorImageLoadError>
Methods from Deref<Target = Tensor>§
pub fn id(&self) -> TensorId
pub fn shape(&self) -> &[TensorDimension]
sourcepub fn shape_short(&self) -> &[TensorDimension]
pub fn shape_short(&self) -> &[TensorDimension]
Returns the shape of the tensor with all trailing dimensions of size 1 ignored.
If all dimension sizes are one, this returns only the first dimension.
pub fn num_dim(&self) -> usize
sourcepub fn image_height_width_channels(&self) -> Option<[u64; 3]>
pub fn image_height_width_channels(&self) -> Option<[u64; 3]>
If the tensor can be interpreted as an image, return the height, width, and channels/depth of it.
sourcepub fn is_shaped_like_an_image(&self) -> bool
pub fn is_shaped_like_an_image(&self) -> bool
Returns true if the tensor can be interpreted as an image.
sourcepub fn is_vector(&self) -> bool
pub fn is_vector(&self) -> bool
Returns true if either all dimensions have size 1 or only a single dimension has a size larger than 1.
Empty tensors return false.
pub fn meaning(&self) -> TensorDataMeaning
sourcepub fn get_with_image_coords(
&self,
x: u64,
y: u64,
channel: u64
) -> Option<TensorElement>
pub fn get_with_image_coords( &self, x: u64, y: u64, channel: u64 ) -> Option<TensorElement>
Query with x, y, channel indices.
Allows to query values for any image like tensor even if it has more or less dimensions than 3.
(useful for sampling e.g. N x M x C x 1
tensor which is a valid image)
pub fn get(&self, index: &[u64]) -> Option<TensorElement>
pub fn dtype(&self) -> TensorDataType
pub fn size_in_bytes(&self) -> usize
sourcepub fn could_be_dynamic_image(&self) -> bool
pub fn could_be_dynamic_image(&self) -> bool
Predicts if Self::to_dynamic_image
is likely to succeed, without doing anything expensive
sourcepub fn to_dynamic_image(&self) -> Result<DynamicImage, TensorImageSaveError>
pub fn to_dynamic_image(&self) -> Result<DynamicImage, TensorImageSaveError>
Try to convert an image-like tensor into an image::DynamicImage
.
Trait Implementations§
source§impl AsRef<Tensor> for DecodedTensor
impl AsRef<Tensor> for DecodedTensor
source§impl Borrow<Tensor> for DecodedTensor
impl Borrow<Tensor> for DecodedTensor
source§impl Clone for DecodedTensor
impl Clone for DecodedTensor
source§fn clone(&self) -> DecodedTensor
fn clone(&self) -> DecodedTensor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more