ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
sam3_prompt.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// Backend-agnostic SAM3 prompt type shared between the vision library and
6// the GUI layer. No OpenCV, no backend headers — only the standard library.
7
8#pragma once
9
10#include <array>
11#include <string>
12#include <string_view>
13#include <utility>
14#include <vector>
15
16namespace reusex::vision {
17
20using SegmentBox = std::pair<std::string, std::array<float, 4>>;
21
27inline constexpr std::string_view kGeometryOnlyPromptText = "visual";
28
37inline int sam3_label_value(bool by_prompt_index, int prompt_index,
38 int cache_id) noexcept {
39 return by_prompt_index && prompt_index >= 0 ? prompt_index : cache_id;
40}
41
43using SegmentPoint = std::array<float, 2>;
44
47struct Sam3Prompt {
48 std::string text;
49 std::vector<SegmentBox> boxes;
54 std::vector<SegmentPoint> points;
56 float confidence = -1.0f;
57
58 explicit Sam3Prompt(std::string t, std::vector<SegmentBox> b = {},
59 float conf = -1.0f)
60 : text(std::move(t)), boxes(std::move(b)), confidence(conf) {}
61};
62
63} // namespace reusex::vision
constexpr std::string_view kGeometryOnlyPromptText
Text sent to SAM3 for a prompt that carries boxes but no class name.
int sam3_label_value(bool by_prompt_index, int prompt_index, int cache_id) noexcept
The value a backend writes into the label map for one prompt's detections.
std::array< float, 2 > SegmentPoint
A click-point prompt: pixel [x, y].
std::pair< std::string, std::array< float, 4 > > SegmentBox
A bounding-box prompt: label ("pos" or "neg") and pixel coords [x1,y1,x2,y2].
Sam3Prompt(std::string t, std::vector< SegmentBox > b={}, float conf=-1.0f)
std::vector< SegmentPoint > points
Positive click points.
std::vector< SegmentBox > boxes
float confidence
Per-prompt confidence override. Negative ⟹ use the global threshold.