Skip to content

Commit

Permalink
improve channel name comments and add overload for directly passing w…
Browse files Browse the repository at this point in the history
…idth/height/channel
  • Loading branch information
Wumpf committed Oct 18, 2023
1 parent 7a5605d commit 1a43cc5
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 72 deletions.
2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/image_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Image {
assign_if_none(&mut data.shape[non_empty_dim_inds[1]].name, "width");
}
3 => match data.shape[non_empty_dim_inds[2]].size {
1 | 3 | 4 => {
3 | 4 => {
assign_if_none(&mut data.shape[non_empty_dim_inds[0]].name, "height");
assign_if_none(&mut data.shape[non_empty_dim_inds[1]].name, "width");
assign_if_none(&mut data.shape[non_empty_dim_inds[2]].name, "depth");
Expand Down
2 changes: 1 addition & 1 deletion docs/code-examples/annotation_context_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ int main() {
std::fill_n(data.begin() + y * WIDTH + 6, 6, 2); // right half
}

rec.log("segmentation/image", rerun::SegmentationImage({HEIGHT, WIDTH}, std::move(data)));
rec.log("segmentation/image", rerun::SegmentationImage(WIDTH, HEIGHT, std::move(data)));
}
2 changes: 1 addition & 1 deletion docs/code-examples/depth_image_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ int main() {

rec.log(
"world/camera/depth",
rerun::DepthImage({HEIGHT, WIDTH}, std::move(data)).with_meter(10000.0)
rerun::DepthImage(WIDTH, HEIGHT, std::move(data)).with_meter(10000.0)
);
}
2 changes: 1 addition & 1 deletion docs/code-examples/depth_image_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ int main() {
std::fill_n(data.begin() + y * WIDTH + 6, 6, 45000); // right half
}

rec.log("depth", rerun::DepthImage({HEIGHT, WIDTH}, std::move(data)).with_meter(10000.0));
rec.log("depth", rerun::DepthImage(WIDTH, HEIGHT, std::move(data)).with_meter(10000.0));
}
2 changes: 1 addition & 1 deletion docs/code-examples/image_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ int main() {
}
}

rec.log("image", rerun::Image({HEIGHT, WIDTH, 3}, std::move(data)));
rec.log("image", rerun::Image(WIDTH, HEIGHT, 3, std::move(data)));
}
2 changes: 1 addition & 1 deletion rerun_cpp/src/rerun/archetypes/annotation_context.hpp

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

30 changes: 20 additions & 10 deletions rerun_cpp/src/rerun/archetypes/depth_image.hpp

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

31 changes: 21 additions & 10 deletions rerun_cpp/src/rerun/archetypes/depth_image_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,36 @@ namespace rerun {
#ifdef EDIT_EXTENSION
// [CODEGEN COPY TO HEADER START]

/// New DepthImage from dimensions and tensor buffer.
/// New depth image from width, height and tensor buffer.
///
/// Sets dimensions to width/height if they are not specified.
/// Calls Error::handle() if the shape is not rank 2.
/// Sets the dimension names to "width" and "height" if they are not specified.
DepthImage(
std::vector<rerun::datatypes::TensorDimension> shape,
rerun::datatypes::TensorBuffer buffer
datatypes::TensorDimension width,
datatypes::TensorDimension height,
datatypes::TensorBuffer buffer
)
: DepthImage(rerun::datatypes::TensorData(std::move(shape), std::move(buffer))) {}
: DepthImage(datatypes::TensorData({std::move(height), std::move(width)}, std::move(buffer))) {}

/// New depth image from height/width and tensor buffer.
///
/// Sets the dimension names to "height" and "width" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2.
DepthImage(
std::vector<datatypes::TensorDimension> shape,
datatypes::TensorBuffer buffer
)
: DepthImage(datatypes::TensorData(std::move(shape), std::move(buffer))) {}

/// New depth image from tensor data.
///
/// Sets dimensions to width/height if they are not specified.
/// Calls Error::handle() if the shape is not rank 2.
explicit DepthImage(rerun::components::TensorData _data);
/// Sets the dimension names to "height" and "width" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2.
explicit DepthImage(components::TensorData _data);

// [CODEGEN COPY TO HEADER END]
#endif

DepthImage::DepthImage(rerun::components::TensorData _data) : data(std::move(_data)) {
DepthImage::DepthImage(components::TensorData _data) : data(std::move(_data)) {
auto& shape = data.data.shape;
if (shape.size() != 2) {
Error(ErrorCode::InvalidTensorDimension, "Shape must be rank 2.").handle();
Expand Down
43 changes: 30 additions & 13 deletions rerun_cpp/src/rerun/archetypes/image.hpp

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

41 changes: 30 additions & 11 deletions rerun_cpp/src/rerun/archetypes/image_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,41 @@ namespace rerun {
#ifdef EDIT_EXTENSION
// [CODEGEN COPY TO HEADER START]

/// New image from dimensions and tensor buffer.
/// New Image from width, height and tensor buffer.
///
/// Sets dimensions to width/height/channel if they are not specified.
/// Calls Error::handle() if the shape is not rank 2 or 3 or
/// has neither 1, 3 or 4 channels.
/// Sets the dimension names to "width" and "height" if they are not specified.
Image(
std::vector<rerun::datatypes::TensorDimension> shape,
rerun::datatypes::TensorBuffer buffer
datatypes::TensorDimension width,
datatypes::TensorDimension height,
datatypes::TensorBuffer buffer
)
: Image(rerun::datatypes::TensorData(std::move(shape), std::move(buffer))) {}
: Image(datatypes::TensorData({std::move(height), std::move(width)}, std::move(buffer))) {}

/// New image from tensor data.
/// New Image from width, height, channels and tensor buffer.
///
/// Sets dimensions to width/height if they are not specified.
/// Calls Error::handle() if the shape is not rank 2 or 3 or
/// has neither 1, 3 or 4 channels.
/// Sets the dimension names to "width", "height" and "channel" if they are not specified.
Image(
datatypes::TensorDimension width,
datatypes::TensorDimension height,
datatypes::TensorDimension channels,
datatypes::TensorBuffer buffer
)
: Image(datatypes::TensorData({std::move(height), std::move(width), std::move(channels)}, std::move(buffer))) {}

/// New Image from height/width/channel and tensor buffer.
///
/// Sets the dimension names to "height", "width" and "channel" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2 or 3.
Image(
std::vector<datatypes::TensorDimension> shape,
datatypes::TensorBuffer buffer
)
: Image(datatypes::TensorData(std::move(shape), std::move(buffer))) {}

/// New depth image from tensor data.
///
/// Sets the dimension names to "height", "width" and "channel" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2 or 3.
explicit Image(rerun::components::TensorData _data);
// [CODEGEN COPY TO HEADER END]
#endif
Expand Down
30 changes: 19 additions & 11 deletions rerun_cpp/src/rerun/archetypes/segmentation_image.hpp

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

32 changes: 21 additions & 11 deletions rerun_cpp/src/rerun/archetypes/segmentation_image_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,36 @@ namespace rerun {
#ifdef EDIT_EXTENSION
// [CODEGEN COPY TO HEADER START]

/// New SegmentationImage from dimensions and tensor buffer.
/// New segmentation image from width, height and tensor buffer.
///
/// Sets dimensions to width/height if they are not specified.
/// Calls Error::handle() if the shape is not rank 2.
/// Sets the dimension names to "width" and "height" if they are not specified.
SegmentationImage(
std::vector<rerun::datatypes::TensorDimension> shape,
rerun::datatypes::TensorBuffer buffer
datatypes::TensorDimension width,
datatypes::TensorDimension height,
datatypes::TensorBuffer buffer
)
: SegmentationImage(rerun::datatypes::TensorData(std::move(shape), std::move(buffer))) {
}
: SegmentationImage(datatypes::TensorData({std::move(height), std::move(width)}, std::move(buffer))) {}

/// New segmentation image from height/width and tensor buffer.
///
/// Sets the dimension names to "height" and "width" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2.
SegmentationImage(
std::vector<datatypes::TensorDimension> shape,
datatypes::TensorBuffer buffer
)
: SegmentationImage(datatypes::TensorData(std::move(shape), std::move(buffer))) {}

/// New segmentation image from tensor data.
///
/// Sets dimensions to width/height if they are not specified.
/// Calls Error::handle() if the shape is not rank 2.
explicit SegmentationImage(rerun::components::TensorData _data);
/// Sets the dimension names to "height" and "width" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2.
explicit SegmentationImage(components::TensorData _data);

// [CODEGEN COPY TO HEADER END]
#endif

SegmentationImage::SegmentationImage(rerun::components::TensorData _data)
SegmentationImage::SegmentationImage(components::TensorData _data)
: data(std::move(_data)) {
auto& shape = data.data.shape;
if (shape.size() != 2) {
Expand Down

0 comments on commit 1a43cc5

Please sign in to comment.