ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
instance_evidence.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7// Evidence for a scanned instance: where it is (centroid), which sensor
8// frames see it (photo counts for every survey part in one pass), and which
9// 360° panoramas were taken near it (with the equirect pixel it lands on).
10//
11// Lives in `core` next to `frame_visibility` for the same reason that does:
12// the GUI read endpoints (`ruxd_api_lib`) link `reusex_core` only. Core does
13// not link `reusex_geometry_common`, so the equirect bearing convention of
14// `geometry/EquirectProjection.hpp` is restated here (`equirect_uv`) and
15// pinned by a test against the frontend's `bearingToUv`.
16
17#include "reusex/core/frame_visibility.hpp"
18
19#include <Eigen/Core>
20
21#include <cstddef>
22#include <cstdint>
23#include <map>
24#include <optional>
25#include <stdexcept>
26#include <string>
27#include <string_view>
28#include <vector>
29
30namespace reusex {
31class ProjectDB;
32}
33
34namespace reusex::core {
35
40class CloudMisalignedError : public std::runtime_error {
41 public:
42 using std::runtime_error::runtime_error;
43};
44
46 Eigen::Vector3d centroid = Eigen::Vector3d::Zero();
47 std::size_t point_count = 0;
48};
49
62std::map<std::uint32_t, InstanceCentroid>
63instance_centroids(const ProjectDB &db, std::string_view label_cloud,
64 std::string_view positions_cloud = "cloud");
65
76
80 std::vector<Eigen::Vector3d> samples;
81 [[nodiscard]] VisibilityProbe probe() const {
82 return {centroid.centroid, samples};
83 }
84};
85
93std::map<std::uint32_t, InstanceProbe>
94instance_probes(const ProjectDB &db, std::string_view label_cloud,
95 std::string_view positions_cloud = "cloud",
96 std::size_t samples = PhotoQuery{}.samples_per_instance);
97
99struct PartPhotos {
100 std::size_t count = 0;
101 std::optional<int> best_frame_id;
102};
103
108 std::vector<FrameVisibility> frames;
109 [[nodiscard]] PartPhotos photos() const {
110 PartPhotos p;
111 p.count = frames.size();
112 if (!frames.empty())
113 p.best_frame_id = frames.front().frame_id;
114 return p;
115 }
116};
117
128std::map<std::uint32_t, InstanceEvidence>
129instance_evidence(const ProjectDB &db, std::string_view label_cloud,
130 const PhotoQuery &query = {},
131 std::string_view positions_cloud = "cloud",
132 const std::atomic<bool> *cancel = nullptr);
133
135std::map<std::uint32_t, PartPhotos>
136instance_photos(const ProjectDB &db, std::string_view label_cloud,
137 const PhotoQuery &query = {},
138 std::string_view positions_cloud = "cloud");
139
144 double max_distance = 15.0;
145};
146
153
156 int panorama_id = 0;
157 int node_id = -1;
158 double distance = 0;
159 double u = 0;
160 double v = 0;
162};
163
174Eigen::Vector2d equirect_uv(const Eigen::Vector3d &bearing);
175
190std::vector<PanoramaSighting>
191panoramas_for_point(const ProjectDB &db, const Eigen::Vector3d &world_point,
192 const PanoramaQuery &query = {});
193
194} // namespace reusex::core
Mean position of one instance's points.
Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs...
std::map< std::uint32_t, InstanceProbe > instance_probes(const ProjectDB &db, std::string_view label_cloud, std::string_view positions_cloud="cloud", std::size_t samples=PhotoQuery{}.samples_per_instance)
instance_centroids() plus up to samples points per instance, taken at evenly spaced positions in the ...
std::map< std::uint32_t, InstanceEvidence > instance_evidence(const ProjectDB &db, std::string_view label_cloud, const PhotoQuery &query={}, std::string_view positions_cloud="cloud", const std::atomic< bool > *cancel=nullptr)
The ranked, occlusion-aware frames of every instance of label_cloud that has points: visible_frames_o...
std::vector< PanoramaSighting > panoramas_for_point(const ProjectDB &db, const Eigen::Vector3d &world_point, const PanoramaQuery &query={})
Panoramas that can be placed in the world, nearest first, with where world_point appears in each.
PanoramaHeading
Where a panorama's orientation comes from (mirrors the frontend's PanoramaHeading in viewport/panoram...
@ resected
rux align 360 pose: position and heading measured.
@ levelled
Matched frame's position, heading unknown (LEVELLED basis).
Eigen::Vector2d equirect_uv(const Eigen::Vector3d &bearing)
Normalised equirect coordinates of a bearing in the panorama frame.
std::map< std::uint32_t, PartPhotos > instance_photos(const ProjectDB &db, std::string_view label_cloud, const PhotoQuery &query={}, std::string_view positions_cloud="cloud")
instance_evidence() reduced to count + best frame per instance.
std::map< std::uint32_t, InstanceCentroid > instance_centroids(const ProjectDB &db, std::string_view label_cloud, std::string_view positions_cloud="cloud")
Centroid of every instance id in an instance-label cloud.
std::size_t point_count
Finite points averaged.
Everything the photo evidence knows about one instance: where it is and the frames that see it,...
std::vector< FrameVisibility > frames
An instance's centroid plus evenly spread samples of its points.
std::vector< Eigen::Vector3d > samples
VisibilityProbe probe() const
Tunables for visible_frames_occluded().
Tunables for panoramas_for_point().
double max_distance
Drop panoramas whose centre is farther than this from the point, in metres.
One panorama near a world point.
double u
Equirect column of the point, 0..1 (left to right).
int node_id
Matched sensor frame, -1 if none.
double v
Equirect row of the point, 0..1 (0 = north pole).
double distance
Panorama centre to the point, metres.
The photo evidence of one survey part.
std::size_t count
Sensor frames that see the instance.
std::optional< int > best_frame_id
Most central of them, if any.
Tunables for the photo evidence of an instance.
OcclusionQuery occlusion
How a frame decides it sees the instance (depth tolerance etc.).
std::size_t samples_per_instance
Surface points per instance tested besides the centroid (spread evenly over the instance's points).
What visible_frames_occluded() tests for one object: an anchor that decides the frustum test and the ...