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 // Per-prompt detection confidence threshold. Negative => use the frame/global
23 // threshold (TensorRTData::confidence_threshold). Lets each concept be tuned
24 // independently (e.g. a low threshold for a hard-to-see "electrical outlet",
25 // a high one for a noisy "person").
26 float confidence = -1.0f;
27 Sam3PromptUnit() = default;
28 explicit Sam3PromptUnit(const std::string &t,
29 const std::vector<BoxPrompt> &b = {},
30 float conf = -1.0f)
31 : text(t), boxes(b), confidence(conf) {}
32};
33
34// Unified input struct
35struct Sam3Input {
37 cv::Mat image; // Required: input image
38 std::vector<Sam3PromptUnit>
39 prompts; // Required: all prompt words list corresponding to this image
40 Sam3Input() = default;
41 explicit Sam3Input(const cv::Mat &img) : image(img) {}
42 // Initialiser order follows declaration order (confidence_threshold first),
43 // which is the order the compiler actually uses regardless of what is
44 // written here.
45 Sam3Input(const cv::Mat &img, const std::vector<Sam3PromptUnit> &p,
46 float conf)
47 : confidence_threshold(conf), image(img), prompts(p) {}
48};
49} // 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:45
std::vector< Sam3PromptUnit > prompts
Definition Sam3Type.hpp:39
Sam3PromptUnit(const std::string &t, const std::vector< BoxPrompt > &b={}, float conf=-1.0f)
Definition Sam3Type.hpp:28