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