Skip to content

Commit 42bf99d

Browse files
Kumataroshyama7004
authored andcommitted
Merge pull request opencv#26590 from Kumataro:fix26589
Support C++20 standard opencv#26590 Close opencv#26589 Related opencv/opencv_contrib#3842 Related: opencv#20269 - do not arithmetic enums and ( different enums or floating numeric) - remove unused variable ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
1 parent d1da8df commit 42bf99d

File tree

27 files changed

+148
-183
lines changed

27 files changed

+148
-183
lines changed

modules/calib3d/src/fisheye.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ void cv::fisheye::initUndistortRectifyMap( InputArray K, InputArray D, InputArra
589589

590590
if( m1type == CV_16SC2 )
591591
{
592-
int iu = cv::saturate_cast<int>(u*cv::INTER_TAB_SIZE);
593-
int iv = cv::saturate_cast<int>(v*cv::INTER_TAB_SIZE);
592+
int iu = cv::saturate_cast<int>(u*static_cast<double>(cv::INTER_TAB_SIZE));
593+
int iv = cv::saturate_cast<int>(v*static_cast<double>(cv::INTER_TAB_SIZE));
594594
m1[j*2+0] = (short)(iu >> cv::INTER_BITS);
595595
m1[j*2+1] = (short)(iv >> cv::INTER_BITS);
596596
m2[j] = (ushort)((iv & (cv::INTER_TAB_SIZE-1))*cv::INTER_TAB_SIZE + (iu & (cv::INTER_TAB_SIZE-1)));

modules/calib3d/src/undistort.simd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ class initUndistortRectifyMapComputer : public ParallelLoopBody
259259
double v = fy*invProj*vecTilt(1) + v0;
260260
if( m1type == CV_16SC2 )
261261
{
262-
int iu = saturate_cast<int>(u*INTER_TAB_SIZE);
263-
int iv = saturate_cast<int>(v*INTER_TAB_SIZE);
262+
int iu = saturate_cast<int>(u*static_cast<double>(INTER_TAB_SIZE));
263+
int iv = saturate_cast<int>(v*static_cast<double>(INTER_TAB_SIZE));
264264
m1[j*2] = (short)(iu >> INTER_BITS);
265265
m1[j*2+1] = (short)(iv >> INTER_BITS);
266266
m2[j] = (ushort)((iv & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (iu & (INTER_TAB_SIZE-1)));

modules/calib3d/test/test_stereomatching.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ class CV_StereoBMTest : public CV_StereoMatchingTest
789789
calcROI = getValidDisparityROI(cROI, cROI, params.mindisp, params.ndisp, params.winSize);
790790

791791
bm->compute( leftImg, rightImg, tempDisp );
792-
tempDisp.convertTo(leftDisp, CV_32F, 1./StereoMatcher::DISP_SCALE);
792+
tempDisp.convertTo(leftDisp, CV_32F, 1./static_cast<double>(StereoMatcher::DISP_SCALE));
793793

794794
//check for fixed-type disparity data type
795795
Mat_<float> fixedFloatDisp;
@@ -802,7 +802,7 @@ class CV_StereoBMTest : public CV_StereoMatchingTest
802802
for (int x = 0; x < leftDisp.cols; x++)
803803
{
804804
if (leftDisp.at<float>(y, x) < params.mindisp)
805-
leftDisp.at<float>(y, x) = -1./StereoMatcher::DISP_SCALE; // treat disparity < mindisp as no disparity
805+
leftDisp.at<float>(y, x) = -1./static_cast<double>(StereoMatcher::DISP_SCALE); // treat disparity < mindisp as no disparity
806806
}
807807

808808
return params.winSize/2;

modules/core/include/opencv2/core/mat.inl.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ CV__DEBUG_NS_END
460460

461461
template<typename _Tp> inline
462462
Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
463-
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
463+
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
464464
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
465465
{
466466
if(vec.empty())
@@ -497,7 +497,7 @@ Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp
497497

498498
template<typename _Tp, std::size_t _Nm> inline
499499
Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
500-
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
500+
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
501501
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
502502
{
503503
if(arr.empty())
@@ -514,7 +514,7 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
514514

515515
template<typename _Tp, int n> inline
516516
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
517-
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
517+
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
518518
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
519519
{
520520
if( !copyData )
@@ -546,7 +546,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
546546

547547
template<typename _Tp> inline
548548
Mat::Mat(const Point_<_Tp>& pt, bool copyData)
549-
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
549+
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
550550
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
551551
{
552552
if( !copyData )
@@ -565,7 +565,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData)
565565

566566
template<typename _Tp> inline
567567
Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
568-
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
568+
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
569569
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
570570
{
571571
if( !copyData )
@@ -585,7 +585,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
585585

586586
template<typename _Tp> inline
587587
Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer)
588-
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
588+
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
589589
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
590590
{
591591
*this = commaInitializer.operator Mat_<_Tp>();
@@ -2090,7 +2090,7 @@ SparseMatConstIterator_<_Tp> SparseMat::end() const
20902090
template<typename _Tp> inline
20912091
SparseMat_<_Tp>::SparseMat_()
20922092
{
2093-
flags = MAGIC_VAL + traits::Type<_Tp>::value;
2093+
flags = +MAGIC_VAL + traits::Type<_Tp>::value;
20942094
}
20952095

20962096
template<typename _Tp> inline
@@ -3248,7 +3248,7 @@ const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b)
32483248

32493249
template<typename _Tp> inline
32503250
UMat::UMat(const std::vector<_Tp>& vec, bool copyData)
3251-
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
3251+
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
32523252
cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
32533253
{
32543254
if(vec.empty())

modules/core/src/matrix_sparse.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ void SparseMat::Hdr::clear()
171171
hashtab.clear();
172172
hashtab.resize(HASH_SIZE0);
173173
pool.clear();
174+
#if defined(__GNUC__) && (__GNUC__ == 13) && !defined(__clang__) && (__cplusplus >= 202002L)
175+
#pragma GCC diagnostic push
176+
#pragma GCC diagnostic ignored "-Wstringop-overflow"
177+
#endif
174178
pool.resize(nodeSize);
179+
#if defined(__GNUC__) && (__GNUC__ == 13) && !defined(__clang__) && (__cplusplus >= 202002L)
180+
#pragma GCC diagnostic pop
181+
#endif
175182
nodeCount = freeList = 0;
176183
}
177184

modules/features2d/test/test_matchers_algorithmic.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343

4444
namespace opencv_test { namespace {
4545

46-
const string FEATURES2D_DIR = "features2d";
47-
const string IMAGE_FILENAME = "tsukuba.png";
48-
4946
/****************************************************************************************\
5047
* Algorithmic tests for descriptor matchers *
5148
\****************************************************************************************/

modules/gapi/src/streaming/gstreamer/gstreamer_media_adapter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GStreamerMediaAdapter::GStreamerMediaAdapter(const cv::GFrameDesc& frameDesc,
2323
{
2424
#if GST_VERSION_MINOR >= 10
2525
// Check that GstBuffer has mono-view, so we can retrieve only one video-meta
26-
GAPI_Assert((gst_buffer_get_flags(m_buffer) & GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW) == 0);
26+
GAPI_Assert((gst_buffer_get_flags(m_buffer) & static_cast<GstBufferFlags>(GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW)) == 0);
2727
#endif // GST_VERSION_MINOR >= 10
2828

2929
GstVideoMeta* videoMeta = gst_buffer_get_video_meta(m_buffer);

modules/highgui/src/window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
219219
//change between fullscreen or not.
220220
case cv::WND_PROP_FULLSCREEN:
221221

222-
if (prop_value != cv::WINDOW_NORMAL && prop_value != cv::WINDOW_FULLSCREEN) // bad argument
222+
if ((int)prop_value != cv::WINDOW_NORMAL && (int)prop_value != cv::WINDOW_FULLSCREEN) // bad argument
223223
break;
224224

225225
#if defined (HAVE_QT)

modules/highgui/src/window_gtk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ class GTKWindow
21772177
switch (prop)
21782178
{
21792179
case cv::WND_PROP_FULLSCREEN:
2180-
if (value != cv::WINDOW_NORMAL && value != cv::WINDOW_FULLSCREEN) // bad arg
2180+
if ((int)value != cv::WINDOW_NORMAL && (int)value != cv::WINDOW_FULLSCREEN) // bad arg
21812181
break;
21822182
setModeWindow_(window, value);
21832183
return true;

modules/highgui/src/window_w32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ class Win32UIWindow
28052805
switch ((WindowPropertyFlags)prop)
28062806
{
28072807
case WND_PROP_FULLSCREEN:
2808-
if (value != WINDOW_NORMAL && value != WINDOW_FULLSCREEN) // bad arg
2808+
if ((int)value != WINDOW_NORMAL && (int)value != WINDOW_FULLSCREEN) // bad arg
28092809
break;
28102810
setModeWindow_(window, (int)value);
28112811
return true;

0 commit comments

Comments
 (0)