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

Add a simple example to display Open Photogrammetry Format datasets #2512

Merged
merged 19 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**/target_wasm

# Python virtual environment:
**/venv
**/venv*

# Python build artifacts:
__pycache__
Expand Down
1 change: 1 addition & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ First, a local virtual environment must be created and the necessary dependencie

```sh
just py-dev-env
source venv/bin/activate
```

Then, the SDK can be compiled and installed in the virtual environment using the following command:
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl SpatialSpaceViewState {
if properties.pinhole_image_plane_distance.is_auto() {
let scene_size = self.scene_bbox_accum.size().length();
let default_image_plane_distance = if scene_size.is_finite() && scene_size > 0.0 {
scene_size * 0.05
scene_size * 0.02 // Works pretty well for `examples/python/open_photogrammetry_format/main.py --no-frames`
} else {
1.0
};
Expand Down
1 change: 1 addition & 0 deletions crates/re_viewer/src/app_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl<'a> AppBlueprint<'a> {
}

fn load_panel_state(path: &EntityPath, blueprint_db: &re_data_store::StoreDb) -> Option<bool> {
re_tracing::profile_function!();
blueprint_db
.store()
.query_timeless_component::<PanelState>(path)
Expand Down
2 changes: 0 additions & 2 deletions crates/re_viewer/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ impl AppState {
egui::CentralPanel::default()
.frame(central_panel_frame)
.show_inside(ui, |ui| {
re_tracing::profile_function!();

let spaces_info = SpaceInfoCollection::new(&ctx.store_db.entity_db);

blueprint.viewport.on_frame_start(&mut ctx, &spaces_info);
Expand Down
39 changes: 37 additions & 2 deletions crates/re_viewport/src/auto_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ use std::collections::BTreeMap;

use itertools::Itertools as _;

use re_viewer_context::SpaceViewId;
use re_viewer_context::{SpaceViewClassName, SpaceViewId};

use super::space_view::SpaceViewBlueprint;

#[derive(Clone, Debug)]
struct SpaceMakeInfo {
id: SpaceViewId,
class_name: SpaceViewClassName,
layout_priority: re_viewer_context::SpaceViewClassLayoutPriority,
}

Expand All @@ -35,11 +36,13 @@ pub(crate) fn tree_from_space_views(
)
})
.map(|(space_view_id, space_view)| {
let class_name = *space_view.class_name();
let layout_priority = space_view
.class(space_view_class_registry)
.layout_priority();
SpaceMakeInfo {
id: *space_view_id,
class_name,
layout_priority,
}
})
Expand All @@ -59,13 +62,45 @@ pub(crate) fn tree_from_space_views(
],
&mut tiles,
)
} else {
} else if space_make_infos.len() < 12 {
// Arrange it all in a grid that is responsive to changes in viewport size:
let child_tile_ids = space_make_infos
.into_iter()
.map(|smi| tiles.insert_pane(smi.id))
.collect_vec();
tiles.insert_grid_tile(child_tile_ids)
} else {
// So many space views - lets group by class and put the members of each group into tabs:
let mut grouped_by_class: BTreeMap<SpaceViewClassName, Vec<SpaceMakeInfo>> =
Default::default();
for smi in space_make_infos {
grouped_by_class
.entry(smi.class_name)
.or_default()
.push(smi);
}

let groups = grouped_by_class
.values()
.cloned()
.sorted_by_key(|group| -(group[0].layout_priority as isize));

let tabs = groups
.into_iter()
.map(|group| {
let children = group
.into_iter()
.map(|smi| tiles.insert_pane(smi.id))
.collect_vec();
tiles.insert_tab_tile(children)
})
.collect_vec();

if tabs.len() == 1 {
tabs[0]
} else {
tiles.insert_grid_tile(tabs)
}
};

egui_tiles::Tree::new(root, tiles)
Expand Down
4 changes: 4 additions & 0 deletions crates/re_viewport/src/viewport_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub struct ViewportBlueprint<'a> {

impl<'a> ViewportBlueprint<'a> {
pub fn from_db(blueprint_db: &'a re_data_store::StoreDb) -> Self {
re_tracing::profile_function!();

let space_views: HashMap<SpaceViewId, SpaceViewBlueprint> = if let Some(space_views) =
blueprint_db
.entity_db
Expand Down Expand Up @@ -128,6 +130,7 @@ fn load_space_view(
path: &EntityPath,
blueprint_db: &re_data_store::StoreDb,
) -> Option<SpaceViewBlueprint> {
re_tracing::profile_function!();
blueprint_db
.store()
.query_timeless_component::<SpaceViewComponent>(path)
Expand All @@ -138,6 +141,7 @@ fn load_viewport(
blueprint_db: &re_data_store::StoreDb,
space_views: HashMap<SpaceViewId, SpaceViewBlueprint>,
) -> Viewport {
re_tracing::profile_function!();
let auto_space_views = blueprint_db
.store()
.query_timeless_component::<AutoSpaceViews>(&VIEWPORT_PATH.into())
Expand Down
25 changes: 25 additions & 0 deletions examples/python/open_photogrammetry_format/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Open Photogrammetry Format
python: https://github.com/rerun-io/rerun/tree/latest/examples/python/open_photogrammetry_format/main.py
tags: [2d, 3d, camera, photogrammetry]
thumbnail: https://static.rerun.io/20716c6a10ffaa3960a212673adcbfff36da682e_open_photogrammetry_format_480w.png
---

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/20716c6a10ffaa3960a212673adcbfff36da682e_open_photogrammetry_format_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/ed4a35b86775020956963cd464a0b32278761345_open_photogrammetry_format_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/832c4fe63b6abe665c5723e5664d80bf19e9c6e1_open_photogrammetry_format_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/3bb25c43fa2a4c367d036c27943812ebfe3e4d42_open_photogrammetry_format_1200w.png">
<img src="https://static.rerun.io/603d5605f9670889bc8bce3365f16b831fce1eb1_open_photogrammetry_format_full.png" alt="">
</picture>


Use [pyopf](https://github.com/Pix4D/pyopf) to load and display a photogrammetrically reconstructed 3D point cloud in the Open Photogrammetry Format (OPF).


```bash
pip install -r examples/python/open_photogrammetry_format/requirements.txt
python examples/python/open_photogrammetry_format/main.py
```

Requires Python 3.10 or higher because of [pyopf](https://pypi.org/project/pyopf/).
Loading