ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
instance_crop.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// Pinhole projection of a set of world-space points into a sensor frame, and
8// selection of the best view + 2D bounding box for cropping an instance out of
9// its color image (#373).
10//
11// The projection math mirrors what vision/project.cpp does with rtabmap
12// (world -> base via pose^-1, base -> camera via localTransform^-1, then a
13// pinhole divide), but is reimplemented here with plain Eigen so it is small,
14// dependency-light and directly unit-testable — no rtabmap CameraModel, no
15// z-buffer. We only need where the points land, not a full depth render.
16
17#include "reusex/core/SensorIntrinsics.hpp"
18
19#include <Eigen/Core>
20
21#include <array>
22#include <cstddef>
23#include <optional>
24#include <vector>
25
26namespace reusex::vision {
27
31 int x_min = 0, y_min = 0, x_max = 0, y_max = 0;
32 int in_bounds = 0;
33};
34
44std::optional<ProjectedBox>
45project_points_to_box(const std::vector<Eigen::Vector3f> &world_points,
46 const std::array<double, 16> &pose,
47 const core::SensorIntrinsics &intrinsics, int image_width,
48 int image_height);
49
50} // namespace reusex::vision
std::optional< ProjectedBox > project_points_to_box(const std::vector< Eigen::Vector3f > &world_points, const std::array< double, 16 > &pose, const core::SensorIntrinsics &intrinsics, int image_width, int image_height)
Project world_points into the camera described by pose (row-major 4x4 base-to-world) and intrinsics,...
Lightweight camera intrinsics replacing rtabmap::CameraModel in downstream code.
A projected 2D bounding box of an instance in one frame, with the count of points that landed inside ...
int in_bounds
Number of points projected inside the image.