Skip to content

Commit

Permalink
Fix depth point cloud not taking transformation at its path into acco…
Browse files Browse the repository at this point in the history
…unt (#3514)

### What

* Fixes #3296

Repro code:
```python
import numpy as np
import rerun as rr

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

rr.log(
    "world0/rgbd_camera",
    rr.TranslationAndMat3x3(translation=[10.0, 0.0, 0.0], matrix=np.eye(3)),
)
rr.log_pinhole("world0/rgbd_camera/image", height=480, width=640, focal_length_px=500.0)
rr.log("world0/rgbd_camera/image/depth", rr.DepthImage(np.random.rand(480, 640)))


rr.log(
    "world1/rgbd_camera",
    rr.TranslationAndMat3x3(translation=[10.0, 0.0, 0.0], matrix=np.eye(3)),
)
rr.log_pinhole("world1/rgbd_camera", height=480, width=640, focal_length_px=500.0)
rr.log("world1/rgbd_camera/depth", rr.DepthImage(np.random.rand(480, 640)))


rr.log(
    "world2/rgbd_camera",
    rr.TranslationAndMat3x3(translation=[10.0, 0.0, 0.0], matrix=np.eye(3)),
)
rr.log_pinhole("world2/rgbd_camera", height=480, width=640, focal_length_px=500.0)
rr.log("world2/rgbd_camera", rr.DepthImage(np.random.rand(480, 640)))
```

Before:
<img width="1089" alt="Screenshot 2023-09-28 at 12 02 06"
src="https://github.com/rerun-io/rerun/assets/1220815/fafa90e9-03e8-40ee-aec6-422fd5ad3dbd">

After:
<img width="1058" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/690d229f-2a61-4196-bdac-7bea7f8fb685">
  • Loading branch information
Wumpf authored Sep 28, 2023
1 parent 6de9058 commit 8cd24b2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions crates/re_space_view_spatial/src/parts/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,20 @@ impl ImagesPart {
) -> anyhow::Result<DepthCloud> {
re_tracing::profile_function!();

let store = &ctx.store_db.entity_db.data_store;

let Some(intrinsics) = query_pinhole(store, &ctx.current_query(), parent_pinhole_path)
else {
let Some(intrinsics) = query_pinhole(
ctx.store_db.store(),
&ctx.current_query(),
parent_pinhole_path,
) else {
anyhow::bail!("Couldn't fetch pinhole intrinsics at {parent_pinhole_path:?}");
};

// TODO(cmc): getting to those extrinsics is no easy task :|
let world_from_view = parent_pinhole_path
.parent()
.and_then(|ent_path| transforms.reference_from_entity(&ent_path));
// Place the cloud at the pinhole's location. Note that this means we ignore any 2D transforms that might be there.
let world_from_view = transforms.reference_from_entity_ignoring_pinhole(
parent_pinhole_path,
ctx.store_db.store(),
&ctx.current_query(),
);
let Some(world_from_view) = world_from_view else {
anyhow::bail!("Couldn't fetch pinhole extrinsics at {parent_pinhole_path:?}");
};
Expand Down

0 comments on commit 8cd24b2

Please sign in to comment.