iVS3D v2.0.0
Loading...
Searching...
No Matches
resolution.h
1#pragma once
2
3#include <QtGlobal>
4#include <QString>
5#include <QRectF>
6#include <QPoint>
7#include <opencv2/core.hpp>
8#include <opencv2/imgproc.hpp>
9
18private:
19 uint m_width;
20 uint m_height;
21
22public:
26 Resolution() : m_width(0), m_height(0) {}
27
33 Resolution(uint width, uint height) : m_width(width), m_height(height) {}
34
39 Resolution(const cv::Size &size) : m_width(size.width), m_height(size.height) {}
40
45 Resolution(const QSize &size) : m_width(size.width()), m_height(size.height()) {}
46
51 Resolution(const QPoint &size) : m_width(size.x()), m_height(size.y()) {}
52
57 Resolution(const cv::Mat &img) : m_width(img.cols), m_height(img.rows) {}
58
59 uint getWidth() const { return m_width; }
60 uint getHeight() const { return m_height; }
61
66 bool isValid() const { return m_width>0 && m_height>0; }
67
73 bool operator==(const Resolution& other) const { return m_width == other.m_width && m_height == other.m_height; }
74
75
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); }
79
85 void resize(const cv::Mat &src, cv::Mat &dest) const { cv::resize(src, dest, this->toCvSize(), 0, 0, cv::INTER_AREA); }
86
91 void resize(cv::Mat &img) const { resize(img,img); }
92
93 QString toString() const { return QString("%1 x %2").arg(m_width).arg(m_height); }
94
100 bool fromString(const QString& resolution);
101};
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