ReUseX  0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
utils.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
7#include <torch/torch.h>
8
9#include <opencv2/core/mat.hpp>
10#include <opencv2/core/types.hpp>
11
12namespace ReUseX::vision {
13float generate_scale(cv::Mat &image, const cv::Size &target_size,
14 bool scale_up = false);
15float letterbox(cv::Mat &input_image, cv::Mat &output_image,
16 const cv::Size &target_size);
17float cropbox(cv::Mat &input_image, cv::Mat &output_image,
18 const cv::Size &target_size);
19
20torch::Tensor xyxy_to_xywh(const torch::Tensor &x);
21torch::Tensor xywh_to_xyxy(const torch::Tensor &x);
22torch::Tensor nms(const torch::Tensor &bboces, const torch::Tensor &scores,
23 float iou_threshold = 0.45);
24
25torch::Tensor non_max_suppression(torch::Tensor &predictions,
26 float confThreshold = 0.25,
27 float iouThreshold = 0.45,
28 int maxDetections = 300);
29
30// Deprecated aliases for backward compatibility
31[[deprecated("Use xyxy_to_xywh instead")]] inline torch::Tensor
32xyxy2xywh(const torch::Tensor &x) {
33 return xyxy_to_xywh(x);
34}
35[[deprecated("Use xywh_to_xyxy instead")]] inline torch::Tensor
36xywh2xyxy(const torch::Tensor &x) {
37 return xywh_to_xyxy(x);
38}
39} // namespace ReUseX::vision
float letterbox(cv::Mat &input_image, cv::Mat &output_image, const cv::Size &target_size)
torch::Tensor nms(const torch::Tensor &bboces, const torch::Tensor &scores, float iou_threshold=0.45)
torch::Tensor xywh2xyxy(const torch::Tensor &x)
Definition utils.hpp:36
float cropbox(cv::Mat &input_image, cv::Mat &output_image, const cv::Size &target_size)
torch::Tensor xywh_to_xyxy(const torch::Tensor &x)
float generate_scale(cv::Mat &image, const cv::Size &target_size, bool scale_up=false)
torch::Tensor xyxy2xywh(const torch::Tensor &x)
Definition utils.hpp:32
torch::Tensor non_max_suppression(torch::Tensor &predictions, float confThreshold=0.25, float iouThreshold=0.45, int maxDetections=300)
torch::Tensor xyxy_to_xywh(const torch::Tensor &x)