ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
sam3_geometry.hpp File Reference
#include "reusex/vision/sam3_prompt.hpp"
#include <array>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
Include dependency graph for sam3_geometry.hpp:

Go to the source code of this file.

Classes

class  reusex::vision::Sam3GeometryFailures
 When a request's geometry path fails at run time (encode_boxes / decode with a geometry slot), the request is re-run text-only. More...

Namespaces

namespace  reusex
namespace  reusex::vision

Functions

std::array< float, 4 > reusex::vision::sam3_box_cxcywh (const std::array< float, 4 > &xyxy, int image_w, int image_h)
 Pixel box [x1, y1, x2, y2] (corners in any order) -> the normalised [cx, cy, w, h] the SAM3 geometry encoder takes, clamped to the image_w x image_h image.
std::int64_t reusex::vision::sam3_box_label (std::string_view polarity) noexcept
 SAM3 box label: 1 for a positive ("pos") box, 0 for a negative one.
int reusex::vision::sam3_geometry_slot_len (int max_boxes) noexcept
 Geometry tokens one prompt slot holds when the largest prompt in a decoder batch has max_boxes boxes: the geometry encoder emits one token per box plus a CLS token, so max_boxes + 1, or 0 when no prompt has a box.
std::vector< std::uint8_t > reusex::vision::sam3_geometry_slot_mask (int n_boxes, int slot_len)
 Validity of one prompt's geometry slot of slot_len tokens holding n_boxes encoded boxes: 1 == a token the decoder attends to, 0 == padding.
std::optional< bool > reusex::vision::sam3_mask_true_is_valid (const std::vector< std::uint8_t > &mask, int real_tokens)
 Which way an export's bool token masks point, read off the text encoder's own output for an input whose first real_tokens tokens are real and the rest padding.
constexpr bool reusex::vision::sam3_mask_value (bool valid, bool true_is_valid) noexcept
 The bool an engine mask holds for a token that is valid, under the polarity sam3_mask_true_is_valid() found.
int reusex::vision::sam3_geometry_box_count (std::size_t requested, int capacity) noexcept
 Boxes actually fed for a prompt with requested boxes when the model accepts at most capacity (0 = geometry disabled).
int reusex::vision::sam3_geometry_capacity (int model_cap, int encoder_min_boxes, int encoder_max_boxes, int text_len, int decoder_max_len) noexcept
 Most boxes per prompt the engines can take, or 0 when geometry prompting is unusable.
bool reusex::vision::sam3_detection_selected (const std::array< float, 4 > &det_xyxy, const std::vector< SegmentBox > &boxes, const std::vector< std::array< float, 2 > > &points={}, const std::function< bool(float, float)> &covers={})
 Does a detection with pixel box det_xyxy belong to a box-prompted selection?
const std::vector< float > & reusex::vision::sam3_point_exemplar_fracs ()
 Exemplar box half-sizes, as fractions of the image's shorter side, a click point is tried at.
std::array< float, 4 > reusex::vision::sam3_point_exemplar_box (const std::array< float, 2 > &point, int image_w, int image_h, float frac)
 The exemplar box [x1, y1, x2, y2] for a click point: half-size frac of the image's shorter side, clamped to the image.
std::vector< std::size_t > reusex::vision::sam3_best_detection_per_point (const std::vector< float > &scores, const std::vector< std::vector< bool > > &covers)
 Which detections a click selects: for each point, the single highest- scoring detection that covers it (covers[d][p]: detection d covers point p).
std::vector< std::size_t > reusex::vision::sam3_point_prompt_selection (const std::vector< float > &scores, const std::vector< std::vector< bool > > &covers, const std::vector< bool > &box_selected)
 The detections a prompt with click points keeps: the UNION of.