Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize code examples and their screenshots #3954

Merged
merged 8 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/re_types/definitions/rerun/archetypes/boxes3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace rerun.archetypes;
/// 3D boxes with half-extents and optional center, rotations, rotations, colors etc.
///
/// \example box3d_simple !api title="Simple 3D boxes" image="https://static.rerun.io/box3d_simple/d6a3f38d2e3360fbacac52bb43e44762635be9c8/1200w.png"
/// \example box3d_batch title="Batch of 3D boxes" image="https://static.rerun.io/box3d_batch/28368d2872b2c98186a49fbd063b433e324a88ba/1200w.png"
/// \example box3d_batch title="Batch of 3D boxes" image="https://static.rerun.io/box3d_batch/6d3e453c3a0201ae42bbae9de941198513535f1d/1200w.png"
table Boxes3D (
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
Expand Down
6 changes: 3 additions & 3 deletions crates/re_types/src/archetypes/annotation_context.rs

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

10 changes: 5 additions & 5 deletions crates/re_types/src/archetypes/boxes3d.rs

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

8 changes: 4 additions & 4 deletions crates/re_types/src/archetypes/depth_image.rs

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

6 changes: 3 additions & 3 deletions crates/re_types/src/archetypes/image.rs

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

12 changes: 6 additions & 6 deletions docs/code-examples/annotation_context_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ int main() {
);

// create a segmentation image
const int HEIGHT = 8;
const int WIDTH = 12;
const int HEIGHT = 200;
const int WIDTH = 300;
std::vector<uint8_t> data(WIDTH * HEIGHT, 0);
for (auto y = 0; y < 4; ++y) { // top half
std::fill_n(data.begin() + y * WIDTH, 6, 1); // left half
for (auto y = 50; y < 100; ++y) {
std::fill_n(data.begin() + y * WIDTH + 50, 70, 1);
}
for (auto y = 4; y < 8; ++y) { // bottom half
std::fill_n(data.begin() + y * WIDTH + 6, 6, 2); // right half
for (auto y = 100; y < 180; ++y) {
std::fill_n(data.begin() + y * WIDTH + 130, 150, 2);
}

rec.log("segmentation/image", rerun::SegmentationImage({HEIGHT, WIDTH}, std::move(data)));
Expand Down
6 changes: 3 additions & 3 deletions docs/code-examples/annotation_context_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
rr.init("rerun_example_annotation_context_segmentation", spawn=True)

# Create a simple segmentation image
image = np.zeros((8, 12), dtype=np.uint8)
image[0:4, 0:6] = 1
image[4:8, 6:12] = 2
image = np.zeros((200, 300), dtype=np.uint8)
image[50:100, 50:120] = 1
image[100:180, 130:280] = 2

# Log an annotation context to assign a label and color to each class
rr.log("segmentation", rr.AnnotationContext([(1, "red", (255, 0, 0)), (2, "green", (0, 255, 0))]), timeless=True)
Expand Down
6 changes: 3 additions & 3 deletions docs/code-examples/annotation_context_segmentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)?;

// create a segmentation image
let mut data = Array::<u8, _>::zeros((8, 12).f());
data.slice_mut(s![0..4, 0..6]).fill(1);
data.slice_mut(s![4..8, 6..12]).fill(2);
let mut data = Array::<u8, _>::zeros((200, 300).f());
data.slice_mut(s![50..100, 50..120]).fill(1);
data.slice_mut(s![100..180, 130..280]).fill(2);

rec.log(
"segmentation/image",
Expand Down
14 changes: 7 additions & 7 deletions docs/code-examples/depth_image_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ int main() {
rec.connect().throw_on_failure();

// Create a synthetic depth image.
const int HEIGHT = 8;
const int WIDTH = 12;
const int HEIGHT = 200;
const int WIDTH = 300;
std::vector<uint16_t> data(WIDTH * HEIGHT, 65535);
for (auto y = 0; y < 4; ++y) { // top half
std::fill_n(data.begin() + y * WIDTH, 6, 20000); // left half
for (auto y = 50; y < 150; ++y) {
std::fill_n(data.begin() + y * WIDTH + 50, 100, 20000);
}
for (auto y = 4; y < 8; ++y) { // bottom half
std::fill_n(data.begin() + y * WIDTH + 6, 6, 45000); // right half
for (auto y = 130; y < 180; ++y) {
std::fill_n(data.begin() + y * WIDTH + 100, 180, 45000);
}

// If we log a pinhole camera model, the depth gets automatically back-projected to 3D
rec.log(
"world/camera",
rerun::Pinhole::focal_length_and_resolution(
{20.0f, 20.0f},
{200.0f, 200.0f},
{static_cast<float>(WIDTH), static_cast<float>(HEIGHT)}
)
);
Expand Down
8 changes: 4 additions & 4 deletions docs/code-examples/depth_image_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import numpy as np
import rerun as rr

depth_image = 65535 * np.ones((8, 12), dtype=np.uint16)
depth_image[0:4, 0:6] = 20000
depth_image[4:8, 6:12] = 45000
depth_image = 65535 * np.ones((200, 300), dtype=np.uint16)
depth_image[50:150, 50:150] = 20000
depth_image[130:180, 100:280] = 45000

rr.init("rerun_example_depth_image", spawn=True)

Expand All @@ -15,7 +15,7 @@
rr.Pinhole(
width=depth_image.shape[1],
height=depth_image.shape[0],
focal_length=20,
focal_length=200,
),
)

Expand Down
8 changes: 4 additions & 4 deletions docs/code-examples/depth_image_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (rec, storage) =
rerun::RecordingStreamBuilder::new("rerun_example_depth_image").memory()?;

let mut image = Array::<u16, _>::from_elem((8, 12).f(), 65535);
image.slice_mut(s![0..4, 0..6]).fill(20000);
image.slice_mut(s![4..8, 6..12]).fill(45000);
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(
[20.0, 20.0],
[200.0, 200.0],
[image.shape()[1] as f32, image.shape()[0] as f32],
),
)?;
Expand Down
12 changes: 6 additions & 6 deletions docs/code-examples/depth_image_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ int main() {
rec.connect().throw_on_failure();

// create a synthetic depth image.
const int HEIGHT = 8;
const int WIDTH = 12;
const int HEIGHT = 200;
const int WIDTH = 300;
std::vector<uint16_t> data(WIDTH * HEIGHT, 65535);
for (auto y = 0; y < 4; ++y) { // top half
std::fill_n(data.begin() + y * WIDTH, 6, 20000); // left half
for (auto y = 50; y < 150; ++y) {
std::fill_n(data.begin() + y * WIDTH + 50, 100, 20000);
}
for (auto y = 4; y < 8; ++y) { // bottom half
std::fill_n(data.begin() + y * WIDTH + 6, 6, 45000); // right half
for (auto y = 130; y < 180; ++y) {
std::fill_n(data.begin() + y * WIDTH + 100, 180, 45000);
}

rec.log("depth", rerun::DepthImage({HEIGHT, WIDTH}, std::move(data)).with_meter(10000.0));
Expand Down
6 changes: 3 additions & 3 deletions docs/code-examples/depth_image_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import numpy as np
import rerun as rr

depth_image = 65535 * np.ones((8, 12), dtype=np.uint16)
depth_image[0:4, 0:6] = 20000
depth_image[4:8, 6:12] = 45000
depth_image = 65535 * np.ones((200, 300), dtype=np.uint16)
depth_image[50:150, 50:150] = 20000
depth_image[130:180, 100:280] = 45000

rr.init("rerun_example_depth_image", spawn=True)

Expand Down
6 changes: 3 additions & 3 deletions docs/code-examples/depth_image_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (rec, storage) =
rerun::RecordingStreamBuilder::new("rerun_example_depth_image").memory()?;

let mut image = Array::<u16, _>::from_elem((8, 12).f(), 65535);
image.slice_mut(s![0..4, 0..6]).fill(20000);
image.slice_mut(s![4..8, 6..12]).fill(45000);
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)?.with_meter(10_000.0);

Expand Down
14 changes: 7 additions & 7 deletions docs/code-examples/image_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ int main() {
rec.connect().throw_on_failure();

// Create a synthetic image.
const int HEIGHT = 8;
const int WIDTH = 12;
const int HEIGHT = 200;
const int WIDTH = 300;
std::vector<uint8_t> data(WIDTH * HEIGHT * 3, 0);
for (size_t i = 0; i < data.size(); i += 3) {
data[i] = 255;
}
for (auto y = 0; y < 4; ++y) { // top half
auto row = data.begin() + y * WIDTH * 3;
for (auto i = 0; i < 6 * 3; i += 3) { // left half
row[i] = 0;
row[i + 1] = 255;
for (size_t y = 50; y < 150; ++y) {
for (size_t x = 50; x < 150; ++x) {
data[(y * WIDTH + x) * 3 + 0] = 0;
data[(y * WIDTH + x) * 3 + 1] = 255;
data[(y * WIDTH + x) * 3 + 2] = 0;
}
}

Expand Down
4 changes: 2 additions & 2 deletions docs/code-examples/image_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import rerun as rr

# Create an image with numpy
image = np.zeros((8, 12, 3), dtype=np.uint8)
image = np.zeros((200, 300, 3), dtype=np.uint8)
image[:, :, 0] = 255
image[0:4, 0:6] = (0, 255, 0)
image[50:150, 50:150] = (0, 255, 0)

rr.init("rerun_example_image_simple", spawn=True)

Expand Down
6 changes: 3 additions & 3 deletions docs/code-examples/image_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (rec, storage) =
rerun::RecordingStreamBuilder::new("rerun_example_image_simple").memory()?;

let mut image = Array::<u8, _>::zeros((8, 12, 3).f());
let mut image = Array::<u8, _>::zeros((200, 300, 3).f());
image.slice_mut(s![.., .., 0]).fill(255);
image.slice_mut(s![0..4, 0..6, 0]).fill(0);
image.slice_mut(s![0..4, 0..6, 1]).fill(255);
image.slice_mut(s![50..150, 50..150, 0]).fill(0);
image.slice_mut(s![50..150, 50..150, 1]).fill(255);

rec.log("image", &rerun::Image::try_from(image)?)?;

Expand Down
10 changes: 5 additions & 5 deletions docs/content/reference/types/archetypes/boxes3d.md

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

12 changes: 6 additions & 6 deletions 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.

14 changes: 7 additions & 7 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.

14 changes: 7 additions & 7 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.

6 changes: 3 additions & 3 deletions rerun_py/rerun_sdk/rerun/archetypes/annotation_context.py

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

Loading
Loading