1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2024-08-27 18:31:36 +03:00
108 changed files with 1241 additions and 646 deletions
@@ -135,6 +135,9 @@ CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckCon
/// Example: depth == CV_32F || depth == CV_64F
#define CV_CheckDepth(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatDepth, t, (test_expr), #t, #test_expr, msg)
/// Example: channel == 1 || channel == 3
#define CV_CheckChannels(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatChannels, t, (test_expr), #t, #test_expr, msg)
/// Example: v == A || v == B
#define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
+28 -4
View File
@@ -478,7 +478,14 @@ public:
template<typename _Tp2> operator Rect_<_Tp2>() const;
//! checks whether the rectangle contains the point
bool contains(const Point_<_Tp>& pt) const;
/*! @warning After OpenCV 4.11.0, when calling Rect.contains() with cv::Point2f / cv::Point2d point, point should not convert/round to int.
* ```
* Rect_<int> r(0,0,500,500); Point_<float> pt(250.0f, 499.9f);
* r.contains(pt) returns false.(OpenCV 4.10.0 or before)
* r.contains(pt) returns true. (OpenCV 4.11.0 or later)
* ```
*/
template<typename _Tp2> inline bool contains(const Point_<_Tp2>& pt) const;
_Tp x; //!< x coordinate of the top-left corner
_Tp y; //!< y coordinate of the top-left corner
@@ -1861,12 +1868,29 @@ Rect_<_Tp>::operator Rect_<_Tp2>() const
return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height));
}
template<typename _Tp> inline
bool Rect_<_Tp>::contains(const Point_<_Tp>& pt) const
template<typename _Tp> template<typename _Tp2> inline
bool Rect_<_Tp>::contains(const Point_<_Tp2>& pt) const
{
return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height;
}
// See https://github.com/opencv/opencv/issues/26016
template<> template<> inline
bool Rect_<int>::contains(const Point_<double>& pt) const
{
// std::numeric_limits<int>::digits is 31.
// std::numeric_limits<double>::digits is 53.
// So conversion int->double does not lead to accuracy errors.
const Rect_<double> _rect(static_cast<double>(x), static_cast<double>(y), static_cast<double>(width), static_cast<double>(height));
return _rect.contains(pt);
}
template<> template<> inline
bool Rect_<int>::contains(const Point_<float>& _pt) const
{
// std::numeric_limits<float>::digits is 24.
// std::numeric_limits<double>::digits is 53.
// So conversion float->double does not lead to accuracy errors.
return contains(Point_<double>(static_cast<double>(_pt.x), static_cast<double>(_pt.y)));
}
template<typename _Tp> static inline
Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Point_<_Tp>& b )
@@ -13,7 +13,7 @@
/* not supported */
# elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || \
defined __FreeBSD__ || defined __bsdi__ || defined __HAIKU__ || \
defined __GNU__
defined __GNU__ || defined __QNX__
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 1
# elif defined(__APPLE__)
# include <TargetConditionals.h>