Go to the documentation of this file.
15 #include <opencv2/opencv.hpp>
26 cv::Point_<T> tl1 = rect1.tl();
27 cv::Point_<T> br1 = rect1.br();
28 if (tl1.inside(rect2) && br1.inside(rect2)) {
32 cv::Point_<T> tl2 = rect2.tl();
33 cv::Point_<T> br2 = rect2.br();
34 if (tl2.inside(rect1) && br2.inside(rect1)) {
43 return cv::Point_<T>(rect.x + rect.width / 2.0, rect.y + rect.height / 2.0);
48 return sqrt(pow(point2.x - point.x, 2) + pow(point2.y - point.y, 2));
52 inline cv::Point_<T>
pointsCenter(
const cv::Point_<T> &point,
const cv::Point_<T> &point2) {
53 return cv::Point_<T>((point.x + point2.x) / 2.0, (point.y + point2.y) / 2.0);
60 T
distanceBetween(
const cv::Rect_<T> &rectangle1,
const cv::Rect_<T> &rectangle2) {
86 for (
auto rectangle : rectangles) {
89 width += rectangle.width;
90 height += rectangle.height;
93 x /= rectangles.size();
94 y /= rectangles.size();
95 width /= rectangles.size();
96 height /= rectangles.size();
98 return cv::Rect_<T>(x, y, width, height);
101 template <
typename T>
102 bool equals(
const cv::Size_<T> &size1,
const cv::Size_<T> &size2) {
103 return size1.width == size2.width && size1.height == size2.height;
109 void rotateMatrix(
const cv::Mat &src,
double angleDegrees, cv::Mat &target, cv::Scalar fillColor = cv::Scalar(255, 255, 255));
114 template <
typename T>
117 double adjacent = point2.x - point.x;
118 double angle = acos(adjacent / hypotenuse);
122 bool matIsEqual(
const cv::Mat &img1,
const cv::Mat &img2);
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:26470
double getIntersectionOverUnion(const cv::Rect2d &bb1, const cv::Rect2d &bb2)
Definition: geom_opencv.cpp:17
cv::Rect_< T > averageRectangle(const vector< cv::Rect_< T >> &rectangles)
Definition: geom_opencv.h:80
string rectToString(const cv::Rect_< T > &rect)
Definition: geom_opencv.h:65
double anglePointsInRad(const cv::Point_< T > &point, const cv::Point_< T > &point2)
Definition: geom_opencv.h:115
bool equals(const cv::Size_< T > &size1, const cv::Size_< T > &size2)
Definition: geom_opencv.h:102
cv::Point_< T > rectangleCenter(const cv::Rect_< T > &rect)
Definition: geom_opencv.h:42
string sizeToString(const cv::Size_< T > &size)
Definition: geom_opencv.h:75
string pointToString(const cv::Point_< T > &point)
Definition: geom_opencv.h:70
cv::Point_< T > pointsCenter(const cv::Point_< T > &point, const cv::Point_< T > &point2)
Definition: geom_opencv.h:52
bool isIncludedInOther(const cv::Rect_< T > &rect1, const cv::Rect_< T > &rect2)
Definition: geom_opencv.h:25
void rotateMatrix(const cv::Mat &src, double angleDegrees, cv::Mat &target, cv::Scalar fillColor)
Definition: geom_opencv.cpp:63
double distanceBetween(double x1, double y1, double x2, double y2)
Definition: geom.cpp:136
cv::Vec3f rotationMatrixToEulerAngles(const cv::Mat &R)
Definition: geom_opencv.cpp:74
bool matIsEqual(const cv::Mat &img1, const cv::Mat &img2)
Definition: geom_opencv.cpp:94
bool isRotationMatrix(const cv::Mat &R)
Definition: geom_opencv.cpp:54