35 #include <opencv2/core/mat.hpp>
36 #include <opencv2/core/types.hpp>
45 static inline cv::Point2d pointPixelToRoiNormalized(
const cv::Point2d& pixel_point,
46 const cv::Rect2d& roi) {
47 const double x_norm = (pixel_point.x - roi.x) / roi.width;
48 const double y_norm = (pixel_point.y - roi.y) / roi.height;
49 return cv::Point2d(x_norm, y_norm);
58 static inline cv::Point2d sizePixelToRoiNormalized(
const cv::Size& size,
const cv::Rect& roi) {
59 const double width_norm =
static_cast<double>(size.width) / roi.width;
60 const double height_norm =
static_cast<double>(size.height) / roi.height;
61 return cv::Point2d(width_norm, height_norm);
70 static inline cv::Point pointRoiNormalizedToPixel(
const cv::Point2d& normalized_point,
71 const cv::Rect& roi) {
72 const int x_pixel =
static_cast<int>(std::round(normalized_point.x * roi.width + roi.x));
73 const int y_pixel =
static_cast<int>(std::round(normalized_point.y * roi.height + roi.y));
75 return cv::Point(x_pixel, y_pixel);
84 static inline cv::Size sizeRoiNormalizedToPixel(
const cv::Size2d& size,
const cv::Rect& roi) {
85 const int width_pixel =
static_cast<int>(size.width * roi.width);
86 const int height_pixel =
static_cast<int>(size.height * roi.height);
87 return cv::Size(width_pixel, height_pixel);