7#include <opencv2/core.hpp>
8#include <opencv2/imgproc.hpp>
33 Resolution(uint width, uint height) : m_width(width), m_height(height) {}
39 Resolution(
const cv::Size &size) : m_width(size.width), m_height(size.height) {}
45 Resolution(
const QSize &size) : m_width(size.width()), m_height(size.height()) {}
51 Resolution(
const QPoint &size) : m_width(size.x()), m_height(size.y()) {}
57 Resolution(
const cv::Mat &img) : m_width(img.cols), m_height(img.rows) {}
59 uint getWidth()
const {
return m_width; }
60 uint getHeight()
const {
return m_height; }
66 bool isValid()
const {
return m_width>0 && m_height>0; }
73 bool operator==(
const Resolution& other)
const {
return m_width == other.m_width && m_height == other.m_height; }
76 cv::Size toCvSize()
const {
return cv::Size(m_width, m_height); }
77 QSize toQSize()
const {
return QSize(m_width, m_height); }
78 QPoint toQPoint()
const {
return QPoint(m_width, m_height); }
85 void resize(
const cv::Mat &src, cv::Mat &dest)
const { cv::resize(src, dest, this->toCvSize(), 0, 0, cv::INTER_AREA); }
93 QString toString()
const {
return QString(
"%1 x %2").arg(m_width).arg(m_height); }
The Resolution class encapsulates an image resolution (width and height). It provides functionality f...
Definition resolution.h:17
Resolution(const QSize &size)
Constructs a Resolution object from a QSize object.
Definition resolution.h:45
Resolution(const cv::Mat &img)
Constructs a Resolution object from an OpenCV Mat object.
Definition resolution.h:57
void resize(cv::Mat &img) const
Resizes an OpenCV Mat image in-place.
Definition resolution.h:91
Resolution(uint width, uint height)
Constructs a Resolution object with specified width and height.
Definition resolution.h:33
Resolution()
Default constructor initializing width and height to zero. This resolution is not valid,...
Definition resolution.h:26
bool operator==(const Resolution &other) const
Equality operator to compare two Resolution objects.
Definition resolution.h:73
bool isValid() const
Checks whether the resolution is valid (i.e., width and height are greater than zero).
Definition resolution.h:66
Resolution(const cv::Size &size)
Constructs a Resolution object from an OpenCV Size object.
Definition resolution.h:39
void resize(const cv::Mat &src, cv::Mat &dest) const
Resizes an OpenCV Mat image to the resolution defined in this object.
Definition resolution.h:85
bool fromString(const QString &resolution)
Parses resolution from a string format.
Definition resolution.cpp:4
Resolution(const QPoint &size)
Constructs a Resolution object from a QPoint object.
Definition resolution.h:51