ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
Sam3Type.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6#include <opencv2/opencv.hpp>
7
8#include <array>
9#include <string>
10#include <utility>
11#include <vector>
12
14
15// Define BoxPrompt: <Label("pos"/"neg"), {x1, y1, x2, y2}>
16using BoxPrompt = std::pair<std::string, std::array<float, 4>>;
17
18// Single prompt unit: contains a piece of text and an optional set of boxes
20 std::string text;
21 std::vector<BoxPrompt> boxes;
22 // Positive click points [x, y] in pixels (see vision::Sam3Prompt::points).
23 std::vector<std::array<float, 2>> points;
24 // Per-prompt detection confidence threshold. Negative => use the frame/global
25 // threshold (TensorRTData::confidence_threshold). Lets each concept be tuned
26 // independently (e.g. a low threshold for a hard-to-see "electrical outlet",
27 // a high one for a noisy "person").
28 float confidence = -1.0f;
29 Sam3PromptUnit() = default;
30 explicit Sam3PromptUnit(const std::string &t,
31 const std::vector<BoxPrompt> &b = {},
32 float conf = -1.0f)
33 : text(t), boxes(b), confidence(conf) {}
34};
35
36// Unified input struct
37struct Sam3Input {
39 cv::Mat image; // Required: input image
40 std::vector<Sam3PromptUnit>
41 prompts; // Required: all prompt words list corresponding to this image
42 Sam3Input() = default;
43 explicit Sam3Input(const cv::Mat &img) : image(img) {}
44 // Initialiser order follows declaration order (confidence_threshold first),
45 // which is the order the compiler actually uses regardless of what is
46 // written here.
47 Sam3Input(const cv::Mat &img, const std::vector<Sam3PromptUnit> &p,
48 float conf)
49 : confidence_threshold(conf), image(img), prompts(p) {}
50};
51} // namespace reusex::vision::tensor_rt
std::pair< std::string, std::array< float, 4 > > BoxPrompt
Definition Sam3Type.hpp:16
Sam3Input(const cv::Mat &img, const std::vector< Sam3PromptUnit > &p, float conf)
Definition Sam3Type.hpp:47
std::vector< Sam3PromptUnit > prompts
Definition Sam3Type.hpp:41
Sam3PromptUnit(const std::string &t, const std::vector< BoxPrompt > &b={}, float conf=-1.0f)
Definition Sam3Type.hpp:30
std::vector< std::array< float, 2 > > points
Definition Sam3Type.hpp:23