ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
reusex::vision Namespace Reference

Namespaces

namespace  common
namespace  libtorch
namespace  onnx
namespace  osd
namespace  tensor_rt
namespace  torchvision

Classes

struct  AnnotationConfig
 Configuration for ML annotation inference and data loading. More...
class  BackendFactory
class  Dataloader
struct  IData
class  IDataset
class  IMLBackend
class  IModel
class  IVideoModel
struct  SegmentPanoramaOptions
 Options controlling how a panorama is tiled and segmented. More...

Enumerations

enum class  Backend {
  opencv , tensor_rt , libtorch , dnn ,
  onnx_runtime , openvino , unknown
}
enum class  Model { yolo , sam3 , sam3p1 }

Functions

auto annotate (const std::filesystem::path &dbPath, const std::filesystem::path &modelPath, const AnnotationConfig &config=AnnotationConfig{}) -> int
 Run semantic annotation on sensor frames using ML models.
bool is_sequence_boundary (std::size_t index, int node_id, int prev_id)
 Whether the video tracker must reset before the frame at index.
std::unique_ptr< IModelcreate_model_from_path (const std::filesystem::path &modelPath, bool use_cuda)
 Detect the backend + model kind from modelPath and build the model.
torch::Tensor xyxy_to_xywh (const torch::Tensor &x)
 Convert bounding boxes from (x1,y1,x2,y2) to (cx,cy,w,h) format.
torch::Tensor xywh_to_xyxy (const torch::Tensor &x)
 Convert bounding boxes from (cx,cy,w,h) to (x1,y1,x2,y2) format.
torch::Tensor nms (const torch::Tensor &bboxes, const torch::Tensor &scores, float iou_threshold=0.45)
 Non-maximum suppression on bounding boxes.
torch::Tensor non_max_suppression (torch::Tensor predictions, float confThreshold=0.25, float iouThreshold=0.45, int maxDetections=300)
 YOLO-style non-maximum suppression with class-aware filtering.
auto project (const ProjectDB &db, CloudConstPtr cloud) -> CloudLPtr
 Project the labels stored in the database on tho the assebled point cloud.
cv::Mat segment_panorama (IModel &model, const cv::Mat &equirect_bgr, const SegmentPanoramaOptions &opts)
 Segment a 360 equirectangular panorama with a SAM3 model.
float generate_scale (const cv::Mat &image, const cv::Size &target_size, bool scale_up=false)
float letterbox (cv::Mat &input_image, cv::Mat &output_image, const cv::Size &target_size)
float cropbox (cv::Mat &input_image, cv::Mat &output_image, const cv::Size &target_size)

Variables

std::vector< std::string > Yolov8_className
 YOLO v8 class names for object detection.

Enumeration Type Documentation

◆ Backend

enum class reusex::vision::Backend
strong
Enumerator
opencv 
tensor_rt 
libtorch 
dnn 
onnx_runtime 
openvino 
unknown 

Definition at line 32 of file BackendFactory.hpp.

◆ Model

enum class reusex::vision::Model
strong
Enumerator
yolo 
sam3 
sam3p1 

Definition at line 15 of file IMLBackend.hpp.

Function Documentation

◆ annotate()

auto reusex::vision::annotate ( const std::filesystem::path & dbPath,
const std::filesystem::path & modelPath,
const AnnotationConfig & config = AnnotationConfig{} ) -> int

Run semantic annotation on sensor frames using ML models.

Parameters
dbPathPath to project database containing sensor frames
modelPathPath to ML model (.pt, .engine, .onnx)
configConfiguration for inference and data loading
Returns
0 on success, error code on failure

◆ create_model_from_path()

std::unique_ptr< IModel > reusex::vision::create_model_from_path ( const std::filesystem::path & modelPath,
bool use_cuda )

Detect the backend + model kind from modelPath and build the model.

Exceptions
std::runtime_errorif the required backend is not compiled in.

◆ cropbox()

float reusex::vision::cropbox ( cv::Mat & input_image,
cv::Mat & output_image,
const cv::Size & target_size )

◆ generate_scale()

float reusex::vision::generate_scale ( const cv::Mat & image,
const cv::Size & target_size,
bool scale_up = false )

◆ is_sequence_boundary()

bool reusex::vision::is_sequence_boundary ( std::size_t index,
int node_id,
int prev_id )
inline

Whether the video tracker must reset before the frame at index.

A stateful video model must start a fresh temporal memory at the beginning of every ordered sequence. Within one scan the sensor-frame node ids increase monotonically (small forward gaps from dropped frames are normal and must NOT trigger a reset), so a boundary is only the very first frame (index 0) or a point where the node id fails to increase — which happens when a dataset concatenates multiple sequences that restart their numbering.

Kept as a free function (independent of any tracker/dataset object) so the boundary logic can be unit-tested directly.

Parameters
indexPosition in the (possibly prefix-trimmed) ordered list.
node_idNode id of the frame at index.
prev_idNode id of the frame at index-1 (unused when index==0).
Returns
true if the tracker should reset before processing this frame.

Definition at line 63 of file annotate.hpp.

◆ letterbox()

float reusex::vision::letterbox ( cv::Mat & input_image,
cv::Mat & output_image,
const cv::Size & target_size )

◆ nms()

torch::Tensor reusex::vision::nms ( const torch::Tensor & bboxes,
const torch::Tensor & scores,
float iou_threshold = 0.45 )

Non-maximum suppression on bounding boxes.

The algorithm is torchvision's reference CPU kernel, vendored under BSD-3-Clause in vision/third_party/torchvision_nms_kernel.hpp (#141). This wrapper owns the ReUseX-facing contract: CPU, float32, empty input tolerated.

Boxes are suppressed when IoU is strictly greater than iou_threshold, so a threshold of 1.0 suppresses nothing and ties at the threshold survive. Equal scores are broken towards the lower index (the sort is stable).

Parameters
bboxesBounding boxes tensor [N, 4] in xyxy format. CPU, float32.
scoresConfidence scores tensor [N]. CPU, float32.
iou_thresholdIoU threshold for suppression.
Returns
Indices of kept boxes, in descending score order (int64).
Exceptions
c10::Errorif the tensors are not CPU float32, or are malformed.

◆ non_max_suppression()

torch::Tensor reusex::vision::non_max_suppression ( torch::Tensor predictions,
float confThreshold = 0.25,
float iouThreshold = 0.45,
int maxDetections = 300 )

YOLO-style non-maximum suppression with class-aware filtering.

Parameters
predictionsRaw model output [batch_size, 116, 8400].
confThresholdConfidence threshold for filtering.
iouThresholdIoU threshold for NMS.
maxDetectionsMaximum detections to keep per image.
Returns
Filtered detections [batch_size, maxDetections, 6+32].

◆ project()

auto reusex::vision::project ( const ProjectDB & db,
CloudConstPtr cloud ) -> CloudLPtr

Project the labels stored in the database on tho the assebled point cloud.

For each view in the database this constructs a croped point cloud, computes a z-buffer and the assigns the precomputed labels to the closses point in the point cloud.

◆ segment_panorama()

cv::Mat reusex::vision::segment_panorama ( IModel & model,
const cv::Mat & equirect_bgr,
const SegmentPanoramaOptions & opts )

Segment a 360 equirectangular panorama with a SAM3 model.

Parameters
modelSAM3 model handle (created via BackendFactory).
equirect_bgrEquirectangular panorama (BGR, CV_8UC3).
optsTiling / prompt / confidence options.
Returns
A CV_32S equirect label map the same size as equirect_bgr, with -1 for background. Class ids are stable across tiles because a single model instance assigns each prompt text a fixed class id.

◆ xywh_to_xyxy()

torch::Tensor reusex::vision::xywh_to_xyxy ( const torch::Tensor & x)

Convert bounding boxes from (cx,cy,w,h) to (x1,y1,x2,y2) format.

◆ xyxy_to_xywh()

torch::Tensor reusex::vision::xyxy_to_xywh ( const torch::Tensor & x)

Convert bounding boxes from (x1,y1,x2,y2) to (cx,cy,w,h) format.

Variable Documentation

◆ Yolov8_className

std::vector<std::string> reusex::vision::Yolov8_className
extern

YOLO v8 class names for object detection.

Contains the list of class names that can be detected by YOLO v8 model.