Skip to content

Commit

Permalink
Add archetypes.ImageEncoded and hook up to spatial viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jul 13, 2024
1 parent 307a09d commit 462492a
Show file tree
Hide file tree
Showing 48 changed files with 1,422 additions and 30 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5297,6 +5297,7 @@ dependencies = [
"egui_tiles",
"glam",
"half 2.3.1",
"image",
"indexmap 2.1.0",
"itertools 0.13.0",
"linked-hash-map",
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/archetypes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include "./archetypes/boxes3d.fbs";
include "./archetypes/clear.fbs";
include "./archetypes/depth_image.fbs";
include "./archetypes/disconnected_space.fbs";
include "./archetypes/image_encoded.fbs";
include "./archetypes/image.fbs";
include "./archetypes/line_strips2d.fbs";
include "./archetypes/line_strips3d.fbs";
Expand Down
12 changes: 6 additions & 6 deletions crates/store/re_types/definitions/rerun/archetypes/image.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ namespace rerun.archetypes;
/// Leading and trailing unit-dimensions are ignored, so that
/// `1x480x640x3x1` is treated as a `480x640x3` RGB image.
///
/// Rerun also supports compressed image encoded as JPEG, N12, and YUY2.
/// Using these formats can save a lot of bandwidth and memory.
/// \py To compress an image, use [`rerun.Image.compress`][].
/// \py To pass in an already encoded image, use [`rerun.ImageEncoded`][].
/// \rs See [`crate::components::TensorData`] for more.
/// \cpp See [`rerun::datatypes::TensorBuffer`] for more.
/// Rerun also supports compressed images (JPEG, PNG, …), using [archetypes.ImageEncoded].
/// Compressing images can save a lot of bandwidth and memory.
///
/// \py You can compress an image using [`rerun.Image.compress`][].
///
/// See also [components.TensorData] and [datatypes.TensorBuffer].
///
/// \cpp Since the underlying `rerun::datatypes::TensorData` uses `rerun::Collection` internally,
/// \cpp data can be passed in without a copy from raw pointers or by reference from `std::vector`/`std::array`/c-arrays.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
include "fbs/attributes.fbs";

include "rerun/datatypes.fbs";
include "rerun/components.fbs";

namespace rerun.archetypes;


/// An image encoded as e.g. a JPEG or PNG.
///
/// Rerun also supports uncompressed images with the [archetypes.Image].
///
/// \py To compress an image, use [`rerun.Image.compress`][].
///
/// \example archetypes/image_encoded
table ImageEncoded (
"attr.cpp.no_field_ctors",
"attr.docs.category": "Image & tensor",
"attr.docs.unreleased",
"attr.docs.view_types": "Spatial2DView, Spatial3DView: if logged under a projection",
"attr.rust.derive": "PartialEq"
) {
// --- Required ---

/// The encoded content of some image file, e.g. a PNG or JPEG.
blob: rerun.components.Blob ("attr.rerun.component_required", order: 1000);

// --- Recommended ---

/// The Media Type of the asset.
///
/// Supported values:
/// * `image/jpeg`
/// * `image/png`
///
/// If omitted, the viewer will try to guess from the data blob.
/// If it cannot guess, it won't be able to render the asset.
media_type: rerun.components.MediaType ("attr.rerun.component_recommended", nullable, order: 2000);

// --- Optional ---

/// Opacity of the image, useful for layering several images.
///
/// Defaults to 1.0 (fully opaque).
opacity: rerun.components.Opacity ("attr.rerun.component_optional", nullable, order: 3000);

/// An optional floating point value that specifies the 2D drawing order.
///
/// Objects with higher values are drawn on top of those with lower values.
draw_order: rerun.components.DrawOrder ("attr.rerun.component_optional", nullable, order: 3100);
}
1 change: 1 addition & 0 deletions crates/store/re_types/src/archetypes/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions crates/store/re_types/src/archetypes/image.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

285 changes: 285 additions & 0 deletions crates/store/re_types/src/archetypes/image_encoded.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 462492a

Please sign in to comment.