Merge pull request #26590 from Kumataro:fix26589

Support C++20 standard #26590

Close https://github.com/opencv/opencv/issues/26589
Related https://github.com/opencv/opencv_contrib/pull/3842
Related: https://github.com/opencv/opencv/issues/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
pull/26633/head
Kumataro 4 months ago committed by GitHub
parent 1a1b1901e8
commit 260f511dfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      modules/calib3d/src/fisheye.cpp
  2. 4
      modules/calib3d/src/undistort.simd.hpp
  3. 4
      modules/calib3d/test/test_stereomatching.cpp
  4. 16
      modules/core/include/opencv2/core/mat.inl.hpp
  5. 7
      modules/core/src/matrix_sparse.cpp
  6. 3
      modules/features2d/test/test_matchers_algorithmic.cpp
  7. 2
      modules/gapi/src/streaming/gstreamer/gstreamer_media_adapter.cpp
  8. 2
      modules/highgui/src/window.cpp
  9. 2
      modules/highgui/src/window_gtk.cpp
  10. 2
      modules/highgui/src/window_w32.cpp
  11. 10
      modules/imgproc/include/opencv2/imgproc/imgproc_c.h
  12. 10
      modules/imgproc/src/color_lab.cpp
  13. 13
      modules/imgproc/src/drawing.cpp
  14. 6
      modules/imgproc/src/generalized_hough.cpp
  15. 2
      modules/imgproc/src/histogram.cpp
  16. 20
      modules/imgproc/src/imgwarp.cpp
  17. 10
      modules/imgproc/src/imgwarp.sse4_1.cpp
  18. 4
      modules/imgproc/src/templmatch.cpp
  19. 160
      modules/imgproc/test/test_filter.cpp
  20. 22
      modules/imgproc/test/test_imgwarp.cpp
  21. 2
      modules/imgproc/test/test_imgwarp_strict.cpp
  22. 2
      modules/ml/src/boost.cpp
  23. 2
      modules/ml/src/rtrees.cpp
  24. 2
      modules/photo/src/calibrate.cpp
  25. 2
      modules/photo/src/merge.cpp
  26. 16
      modules/videoio/include/opencv2/videoio.hpp
  27. 2
      modules/videoio/src/cap_gstreamer.cpp

@ -589,8 +589,8 @@ void cv::fisheye::initUndistortRectifyMap( InputArray K, InputArray D, InputArra
if( m1type == CV_16SC2 )
{
int iu = cv::saturate_cast<int>(u*cv::INTER_TAB_SIZE);
int iv = cv::saturate_cast<int>(v*cv::INTER_TAB_SIZE);
int iu = cv::saturate_cast<int>(u*static_cast<double>(cv::INTER_TAB_SIZE));
int iv = cv::saturate_cast<int>(v*static_cast<double>(cv::INTER_TAB_SIZE));
m1[j*2+0] = (short)(iu >> cv::INTER_BITS);
m1[j*2+1] = (short)(iv >> cv::INTER_BITS);
m2[j] = (ushort)((iv & (cv::INTER_TAB_SIZE-1))*cv::INTER_TAB_SIZE + (iu & (cv::INTER_TAB_SIZE-1)));

@ -259,8 +259,8 @@ public:
double v = fy*invProj*vecTilt(1) + v0;
if( m1type == CV_16SC2 )
{
int iu = saturate_cast<int>(u*INTER_TAB_SIZE);
int iv = saturate_cast<int>(v*INTER_TAB_SIZE);
int iu = saturate_cast<int>(u*static_cast<double>(INTER_TAB_SIZE));
int iv = saturate_cast<int>(v*static_cast<double>(INTER_TAB_SIZE));
m1[j*2] = (short)(iu >> INTER_BITS);
m1[j*2+1] = (short)(iv >> INTER_BITS);
m2[j] = (ushort)((iv & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (iu & (INTER_TAB_SIZE-1)));

@ -789,7 +789,7 @@ protected:
calcROI = getValidDisparityROI(cROI, cROI, params.mindisp, params.ndisp, params.winSize);
bm->compute( leftImg, rightImg, tempDisp );
tempDisp.convertTo(leftDisp, CV_32F, 1./StereoMatcher::DISP_SCALE);
tempDisp.convertTo(leftDisp, CV_32F, 1./static_cast<double>(StereoMatcher::DISP_SCALE));
//check for fixed-type disparity data type
Mat_<float> fixedFloatDisp;
@ -802,7 +802,7 @@ protected:
for (int x = 0; x < leftDisp.cols; x++)
{
if (leftDisp.at<float>(y, x) < params.mindisp)
leftDisp.at<float>(y, x) = -1./StereoMatcher::DISP_SCALE; // treat disparity < mindisp as no disparity
leftDisp.at<float>(y, x) = -1./static_cast<double>(StereoMatcher::DISP_SCALE); // treat disparity < mindisp as no disparity
}
return params.winSize/2;

@ -460,7 +460,7 @@ CV__DEBUG_NS_END
template<typename _Tp> inline
Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if(vec.empty())
@ -497,7 +497,7 @@ Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp
template<typename _Tp, std::size_t _Nm> inline
Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if(arr.empty())
@ -514,7 +514,7 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
template<typename _Tp, int n> inline
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if( !copyData )
@ -546,7 +546,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
template<typename _Tp> inline
Mat::Mat(const Point_<_Tp>& pt, bool copyData)
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if( !copyData )
@ -565,7 +565,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData)
template<typename _Tp> inline
Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if( !copyData )
@ -585,7 +585,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
template<typename _Tp> inline
Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer)
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
{
*this = commaInitializer.operator Mat_<_Tp>();
@ -2090,7 +2090,7 @@ SparseMatConstIterator_<_Tp> SparseMat::end() const
template<typename _Tp> inline
SparseMat_<_Tp>::SparseMat_()
{
flags = MAGIC_VAL + traits::Type<_Tp>::value;
flags = +MAGIC_VAL + traits::Type<_Tp>::value;
}
template<typename _Tp> inline
@ -3248,7 +3248,7 @@ const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b)
template<typename _Tp> inline
UMat::UMat(const std::vector<_Tp>& vec, bool copyData)
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
{
if(vec.empty())

@ -171,7 +171,14 @@ void SparseMat::Hdr::clear()
hashtab.clear();
hashtab.resize(HASH_SIZE0);
pool.clear();
#if defined(__GNUC__) && (__GNUC__ == 13) && !defined(__clang__) && (__cplusplus >= 202002L)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
pool.resize(nodeSize);
#if defined(__GNUC__) && (__GNUC__ == 13) && !defined(__clang__) && (__cplusplus >= 202002L)
#pragma GCC diagnostic pop
#endif
nodeCount = freeList = 0;
}

@ -43,9 +43,6 @@
namespace opencv_test { namespace {
const string FEATURES2D_DIR = "features2d";
const string IMAGE_FILENAME = "tsukuba.png";
/****************************************************************************************\
* Algorithmic tests for descriptor matchers *
\****************************************************************************************/

@ -23,7 +23,7 @@ GStreamerMediaAdapter::GStreamerMediaAdapter(const cv::GFrameDesc& frameDesc,
{
#if GST_VERSION_MINOR >= 10
// Check that GstBuffer has mono-view, so we can retrieve only one video-meta
GAPI_Assert((gst_buffer_get_flags(m_buffer) & GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW) == 0);
GAPI_Assert((gst_buffer_get_flags(m_buffer) & static_cast<GstBufferFlags>(GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW)) == 0);
#endif // GST_VERSION_MINOR >= 10
GstVideoMeta* videoMeta = gst_buffer_get_video_meta(m_buffer);

@ -219,7 +219,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
//change between fullscreen or not.
case cv::WND_PROP_FULLSCREEN:
if (prop_value != cv::WINDOW_NORMAL && prop_value != cv::WINDOW_FULLSCREEN) // bad argument
if ((int)prop_value != cv::WINDOW_NORMAL && (int)prop_value != cv::WINDOW_FULLSCREEN) // bad argument
break;
#if defined (HAVE_QT)

@ -2177,7 +2177,7 @@ public:
switch (prop)
{
case cv::WND_PROP_FULLSCREEN:
if (value != cv::WINDOW_NORMAL && value != cv::WINDOW_FULLSCREEN) // bad arg
if ((int)value != cv::WINDOW_NORMAL && (int)value != cv::WINDOW_FULLSCREEN) // bad arg
break;
setModeWindow_(window, value);
return true;

@ -2805,7 +2805,7 @@ public:
switch ((WindowPropertyFlags)prop)
{
case WND_PROP_FULLSCREEN:
if (value != WINDOW_NORMAL && value != WINDOW_FULLSCREEN) // bad arg
if ((int)value != WINDOW_NORMAL && (int)value != WINDOW_FULLSCREEN) // bad arg
break;
setModeWindow_(window, (int)value);
return true;

@ -219,7 +219,7 @@ replication border mode.
@see cv::warpAffine
*/
CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
/** @brief Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2)
@ -239,7 +239,7 @@ CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle,
@see cv::warpPerspective
*/
CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
/** @brief Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3)
@ -254,7 +254,7 @@ CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
*/
CVAPI(void) cvRemap( const CvArr* src, CvArr* dst,
const CvArr* mapx, const CvArr* mapy,
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
/** @brief Converts mapx & mapy from floating-point to integer formats for cvRemap
@ -268,14 +268,14 @@ CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
*/
CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst,
CvPoint2D32f center, double M,
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
/** Performs forward or inverse linear-polar image transform
@see cv::warpPolar
*/
CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst,
CvPoint2D32f center, double maxRadius,
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
#ifdef _MSC_VER
#pragma warning( pop )

@ -1982,7 +1982,7 @@ struct RGB2Lab_f
clipv(bvec0); clipv(bvec1);
#undef clipv
/* int iR = R*LAB_BASE, iG = G*LAB_BASE, iB = B*LAB_BASE, iL, ia, ib; */
v_float32 basef = vx_setall_f32(LAB_BASE);
v_float32 basef = vx_setall_f32(static_cast<float>(LAB_BASE));
rvec0 = v_mul(rvec0, basef), gvec0 = v_mul(gvec0, basef), bvec0 = v_mul(bvec0, basef);
rvec1 = v_mul(rvec1, basef), gvec1 = v_mul(gvec1, basef), bvec1 = v_mul(bvec1, basef);
@ -2013,14 +2013,14 @@ struct RGB2Lab_f
b_vec0 = v_cvt_f32(i_bvec0); b_vec1 = v_cvt_f32(i_bvec1);
/* dst[i] = L*100.0f */
v_float32 v100dBase = vx_setall_f32(100.0f/LAB_BASE);
v_float32 v100dBase = vx_setall_f32(100.0f / static_cast<float>(LAB_BASE));
l_vec0 = v_mul(l_vec0, v100dBase);
l_vec1 = v_mul(l_vec1, v100dBase);
/*
dst[i + 1] = a*256.0f - 128.0f;
dst[i + 2] = b*256.0f - 128.0f;
*/
v_float32 v256dBase = vx_setall_f32(256.0f/LAB_BASE), vm128 = vx_setall_f32(-128.f);
v_float32 v256dBase = vx_setall_f32(256.0f / static_cast<float>(LAB_BASE)), vm128 = vx_setall_f32(-128.f);
a_vec0 = v_fma(a_vec0, v256dBase, vm128);
a_vec1 = v_fma(a_vec1, v256dBase, vm128);
b_vec0 = v_fma(b_vec0, v256dBase, vm128);
@ -2038,10 +2038,10 @@ struct RGB2Lab_f
float G = clip(src[1]);
float B = clip(src[bIdx^2]);
int iR = cvRound(R*LAB_BASE), iG = cvRound(G*LAB_BASE), iB = cvRound(B*LAB_BASE);
int iR = cvRound(R*static_cast<float>(LAB_BASE)), iG = cvRound(G*static_cast<float>(LAB_BASE)), iB = cvRound(B*static_cast<float>(LAB_BASE));
int iL, ia, ib;
trilinearInterpolate(iR, iG, iB, LABLUVLUTs16.RGB2LabLUT_s16, iL, ia, ib);
float L = iL*1.0f/LAB_BASE, a = ia*1.0f/LAB_BASE, b = ib*1.0f/LAB_BASE;
float L = iL*1.0f/static_cast<float>(LAB_BASE), a = ia*1.0f/static_cast<float>(LAB_BASE), b = ib*1.0f/static_cast<float>(LAB_BASE);
dst[i] = L*100.0f;
dst[i + 1] = a*256.0f - 128.0f;

@ -43,7 +43,6 @@ using namespace cv;
namespace cv
{
enum { XY_SHIFT = 16, XY_ONE = 1 << XY_SHIFT, DRAWING_STORAGE_BLOCK = (1<<12) - 256 };
static const int MAX_THICKNESS = 32767;
@ -1027,8 +1026,8 @@ EllipseEx( Mat& img, Point2l center, Size2l axes,
for (unsigned int i = 0; i < _v.size(); ++i)
{
Point2l pt;
pt.x = (int64)cvRound(_v[i].x / XY_ONE) << XY_SHIFT;
pt.y = (int64)cvRound(_v[i].y / XY_ONE) << XY_SHIFT;
pt.x = (int64)cvRound(_v[i].x / static_cast<double>(XY_ONE)) << XY_SHIFT;
pt.y = (int64)cvRound(_v[i].y / static_cast<double>(XY_ONE)) << XY_SHIFT;
pt.x += cvRound(_v[i].x - pt.x);
pt.y += cvRound(_v[i].y - pt.y);
if (pt != prevPt) {
@ -1645,7 +1644,7 @@ static void
ThickLine( Mat& img, Point2l p0, Point2l p1, const void* color,
int thickness, int line_type, int flags, int shift )
{
static const double INV_XY_ONE = 1./XY_ONE;
static const double INV_XY_ONE = 1./static_cast<double>(XY_ONE);
p0.x <<= XY_SHIFT - shift;
p0.y <<= XY_SHIFT - shift;
@ -1981,8 +1980,8 @@ void ellipse(InputOutputArray _img, const RotatedRect& box, const Scalar& color,
int _angle = cvRound(box.angle);
Point2l center(cvRound(box.center.x),
cvRound(box.center.y));
center.x = (center.x << XY_SHIFT) + cvRound((box.center.x - center.x)*XY_ONE);
center.y = (center.y << XY_SHIFT) + cvRound((box.center.y - center.y)*XY_ONE);
center.x = (center.x << XY_SHIFT) + cvRound((box.center.x - center.x)*static_cast<float>(XY_ONE));
center.y = (center.y << XY_SHIFT) + cvRound((box.center.y - center.y)*static_cast<float>(XY_ONE));
Size2l axes(cvRound(box.size.width),
cvRound(box.size.height));
axes.width = (axes.width << (XY_SHIFT - 1)) + cvRound((box.size.width - axes.width)*(XY_ONE>>1));
@ -2303,7 +2302,7 @@ void putText( InputOutputArray _img, const String& text, Point org,
scalarToRawData(color, buf, img.type(), 0);
int base_line = -(ascii[0] & 15);
int hscale = cvRound(fontScale*XY_ONE), vscale = hscale;
int hscale = cvRound(fontScale * static_cast<double>(XY_ONE)), vscale = hscale;
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;

@ -692,7 +692,11 @@ namespace
getContourPoints(edges, dx, dy, points);
features.resize(levels_ + 1);
std::for_each(features.begin(), features.end(), [=](std::vector<Feature>& e) { e.clear(); e.reserve(maxBufferSize_); });
const size_t maxBufferSize = maxBufferSize_;
std::for_each(features.begin(), features.end(), [maxBufferSize](std::vector<Feature>& e) {
e.clear();
e.reserve(maxBufferSize);
});
for (size_t i = 0; i < points.size(); ++i)
{

@ -1283,7 +1283,7 @@ void cv::calcHist( InputArrayOfArrays images, const std::vector<int>& channels,
CV_OCL_RUN(images.total() == 1 && channels.size() == 1 && images.channels(0) == 1 &&
channels[0] == 0 && images.isUMatVector() && mask.empty() && !accumulate &&
histSize.size() == 1 && histSize[0] == BINS && ranges.size() == 2 &&
ranges[0] == 0 && ranges[1] == BINS,
ranges[0] == 0 && ranges[1] == static_cast<float>(BINS),
ocl_calcHist(images, hist))
int i, dims = (int)histSize.size(), rsz = (int)ranges.size(), csz = (int)channels.size();

@ -1274,8 +1274,8 @@ public:
#endif
for( ; x1 < bcols; x1++ )
{
int sx = cvRound(sX[x1]*INTER_TAB_SIZE);
int sy = cvRound(sY[x1]*INTER_TAB_SIZE);
int sx = cvRound(sX[x1]*static_cast<float>(INTER_TAB_SIZE));
int sy = cvRound(sY[x1]*static_cast<float>(INTER_TAB_SIZE));
int v = (sy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (sx & (INTER_TAB_SIZE-1));
XY[x1*2] = saturate_cast<short>(sx >> INTER_BITS);
XY[x1*2+1] = saturate_cast<short>(sy >> INTER_BITS);
@ -1314,8 +1314,8 @@ public:
for( ; x1 < bcols; x1++ )
{
int sx = cvRound(sXY[x1*2]*INTER_TAB_SIZE);
int sy = cvRound(sXY[x1*2+1]*INTER_TAB_SIZE);
int sx = cvRound(sXY[x1*2]*static_cast<float>(INTER_TAB_SIZE));
int sy = cvRound(sXY[x1*2+1]*static_cast<float>(INTER_TAB_SIZE));
int v = (sy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (sx & (INTER_TAB_SIZE-1));
XY[x1*2] = saturate_cast<short>(sx >> INTER_BITS);
XY[x1*2+1] = saturate_cast<short>(sy >> INTER_BITS);
@ -1991,7 +1991,7 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
bool useSSE4_1 = CV_CPU_HAS_SUPPORT_SSE4_1;
#endif
const float scale = 1.f/INTER_TAB_SIZE;
const float scale = 1.f/static_cast<float>(INTER_TAB_SIZE);
int x, y;
for( y = 0; y < size.height; y++ )
{
@ -2071,8 +2071,8 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
#endif
for( ; x < size.width; x++ )
{
int ix = saturate_cast<int>(src1f[x]*INTER_TAB_SIZE);
int iy = saturate_cast<int>(src2f[x]*INTER_TAB_SIZE);
int ix = saturate_cast<int>(src1f[x]*static_cast<float>(INTER_TAB_SIZE));
int iy = saturate_cast<int>(src2f[x]*static_cast<float>(INTER_TAB_SIZE));
dst1[x*2] = saturate_cast<short>(ix >> INTER_BITS);
dst1[x*2+1] = saturate_cast<short>(iy >> INTER_BITS);
dst2[x] = (ushort)((iy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE-1)));
@ -2117,8 +2117,8 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
#endif
for( ; x < size.width; x++ )
{
int ix = saturate_cast<int>(src1f[x*2]*INTER_TAB_SIZE);
int iy = saturate_cast<int>(src1f[x*2+1]*INTER_TAB_SIZE);
int ix = saturate_cast<int>(src1f[x*2]*static_cast<float>(INTER_TAB_SIZE));
int iy = saturate_cast<int>(src1f[x*2+1]*static_cast<float>(INTER_TAB_SIZE));
dst1[x*2] = saturate_cast<short>(ix >> INTER_BITS);
dst1[x*2+1] = saturate_cast<short>(iy >> INTER_BITS);
dst2[x] = (ushort)((iy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE-1)));
@ -3143,7 +3143,7 @@ void WarpPerspectiveLine_Process_CV_SIMD(const double *M, short* xy, short* alph
for( ; x1 < bw; x1++ )
{
double W = W0 + M[6]*x1;
W = W ? INTER_TAB_SIZE/W : 0;
W = W ? static_cast<double>(INTER_TAB_SIZE)/W : 0;
double fX = std::max((double)INT_MIN, std::min((double)INT_MAX, (X0 + M[0]*x1)*W));
double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3]*x1)*W));
int X = saturate_cast<int>(fX);

@ -132,8 +132,8 @@ void convertMaps_32f1c16s_SSE41(const float* src1f, const float* src2f, short* d
}
for (; x < width; x++)
{
int ix = saturate_cast<int>(src1f[x] * INTER_TAB_SIZE);
int iy = saturate_cast<int>(src2f[x] * INTER_TAB_SIZE);
int ix = saturate_cast<int>(src1f[x] * static_cast<float>(INTER_TAB_SIZE));
int iy = saturate_cast<int>(src2f[x] * static_cast<float>(INTER_TAB_SIZE));
dst1[x * 2] = saturate_cast<short>(ix >> INTER_BITS);
dst1[x * 2 + 1] = saturate_cast<short>(iy >> INTER_BITS);
dst2[x] = (ushort)((iy & (INTER_TAB_SIZE - 1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE - 1)));
@ -165,8 +165,8 @@ void convertMaps_32f2c16s_SSE41(const float* src1f, short* dst1, ushort* dst2, i
}
for (; x < width; x++)
{
int ix = saturate_cast<int>(src1f[x * 2] * INTER_TAB_SIZE);
int iy = saturate_cast<int>(src1f[x * 2 + 1] * INTER_TAB_SIZE);
int ix = saturate_cast<int>(src1f[x * 2] * static_cast<float>(INTER_TAB_SIZE));
int iy = saturate_cast<int>(src1f[x * 2 + 1] * static_cast<float>(INTER_TAB_SIZE));
dst1[x * 2] = saturate_cast<short>(ix >> INTER_BITS);
dst1[x * 2 + 1] = saturate_cast<short>(iy >> INTER_BITS);
dst2[x] = (ushort)((iy & (INTER_TAB_SIZE - 1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE - 1)));
@ -444,7 +444,7 @@ public:
for (; x1 < bw; x1++)
{
double W = W0 + M[6] * x1;
W = W ? INTER_TAB_SIZE / W : 0;
W = W ? static_cast<double>(INTER_TAB_SIZE) / W : 0;
double fX = std::max((double)INT_MIN, std::min((double)INT_MAX, (X0 + M[0] * x1)*W));
double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3] * x1)*W));
int X = saturate_cast<int>(fX);

@ -1056,7 +1056,7 @@ static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst, bool normed)
if (ippiCrossCorrNorm==0)
return false;
IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiROIValid);
IppEnum funCfg = (IppEnum)(+ippAlgAuto | ippiROIValid);
if(normed)
funCfg |= ippiNorm;
else
@ -1093,7 +1093,7 @@ static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst)
if (ippiSqrDistanceNorm==0)
return false;
IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiROIValid | ippiNormNone);
IppEnum funCfg = (IppEnum)(+ippAlgAuto | ippiROIValid | ippiNormNone);
status = ippiSqrDistanceNormGetBufferSize(srcRoiSize, tplRoiSize, funCfg, &bufSize);
if ( status < 0 )
return false;

@ -1865,107 +1865,65 @@ TEST(Imgproc_PreCornerDetect, accuracy) { CV_PreCornerDetectTest test; test.safe
TEST(Imgproc_Integral, accuracy) { CV_IntegralTest test; test.safe_run(); }
//////////////////////////////////////////////////////////////////////////////////
class CV_FilterSupportedFormatsTest : public cvtest::BaseTest
{
public:
CV_FilterSupportedFormatsTest() {}
~CV_FilterSupportedFormatsTest() {}
protected:
void run(int)
{
const int depths[][2] =
{
{CV_8U, CV_8U},
{CV_8U, CV_16U},
{CV_8U, CV_16S},
{CV_8U, CV_32F},
{CV_8U, CV_64F},
{CV_16U, CV_16U},
{CV_16U, CV_32F},
{CV_16U, CV_64F},
{CV_16S, CV_16S},
{CV_16S, CV_32F},
{CV_16S, CV_64F},
{CV_32F, CV_32F},
{CV_64F, CV_64F},
{-1, -1}
};
int i = 0;
volatile int fidx = -1;
try
{
// use some "odd" size to do yet another smoke
// testing of the non-SIMD loop tails
Size sz(163, 117);
Mat small_kernel(5, 5, CV_32F), big_kernel(21, 21, CV_32F);
Mat kernelX(11, 1, CV_32F), kernelY(7, 1, CV_32F);
Mat symkernelX(11, 1, CV_32F), symkernelY(7, 1, CV_32F);
randu(small_kernel, -10, 10);
randu(big_kernel, -1, 1);
randu(kernelX, -1, 1);
randu(kernelY, -1, 1);
flip(kernelX, symkernelX, 0);
symkernelX += kernelX;
flip(kernelY, symkernelY, 0);
symkernelY += kernelY;
Mat elem_ellipse = getStructuringElement(MORPH_ELLIPSE, Size(7, 7));
Mat elem_rect = getStructuringElement(MORPH_RECT, Size(7, 7));
for( i = 0; depths[i][0] >= 0; i++ )
{
int sdepth = depths[i][0];
int ddepth = depths[i][1];
Mat src(sz, CV_MAKETYPE(sdepth, 5)), dst;
randu(src, 0, 100);
// non-separable filtering with a small kernel
fidx = 0;
cv::filter2D(src, dst, ddepth, small_kernel);
fidx++;
cv::filter2D(src, dst, ddepth, big_kernel);
fidx++;
cv::sepFilter2D(src, dst, ddepth, kernelX, kernelY);
fidx++;
cv::sepFilter2D(src, dst, ddepth, symkernelX, symkernelY);
fidx++;
cv::Sobel(src, dst, ddepth, 2, 0, 5);
fidx++;
cv::Scharr(src, dst, ddepth, 0, 1);
if( sdepth != ddepth )
continue;
fidx++;
cv::GaussianBlur(src, dst, Size(5, 5), 1.2, 1.2);
fidx++;
cv::blur(src, dst, Size(11, 11));
fidx++;
cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_ellipse);
fidx++;
cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_rect);
}
}
catch(...)
{
ts->printf(cvtest::TS::LOG, "Combination of depths %d => %d in %s is not supported (yet it should be)",
depths[i][0], depths[i][1],
fidx == 0 ? "filter2D (small kernel)" :
fidx == 1 ? "filter2D (large kernel)" :
fidx == 2 ? "sepFilter2D" :
fidx == 3 ? "sepFilter2D (symmetrical/asymmetrical kernel)" :
fidx == 4 ? "Sobel" :
fidx == 5 ? "Scharr" :
fidx == 6 ? "GaussianBlur" :
fidx == 7 ? "blur" :
fidx == 8 || fidx == 9 ? "morphologyEx" :
"unknown???");
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
}
}
};
TEST(Imgproc_Filtering, supportedFormats) { CV_FilterSupportedFormatsTest test; test.safe_run(); }
typedef std::pair<perf::MatDepth, perf::MatDepth> Imgproc_DepthAndDepth;
typedef testing::TestWithParam< Imgproc_DepthAndDepth> Imgproc_FilterSupportedFormats;
TEST_P(Imgproc_FilterSupportedFormats, normal)
{
// use some "odd" size to do yet another smoke
// testing of the non-SIMD loop tails
Size sz(163, 117);
Mat small_kernel(5, 5, CV_32F), big_kernel(21, 21, CV_32F);
Mat kernelX(11, 1, CV_32F), kernelY(7, 1, CV_32F);
Mat symkernelX(11, 1, CV_32F), symkernelY(7, 1, CV_32F);
randu(small_kernel, -10, 10);
randu(big_kernel, -1, 1);
randu(kernelX, -1, 1);
randu(kernelY, -1, 1);
flip(kernelX, symkernelX, 0);
symkernelX += kernelX;
flip(kernelY, symkernelY, 0);
symkernelY += kernelY;
Mat elem_ellipse = getStructuringElement(MORPH_ELLIPSE, Size(7, 7));
Mat elem_rect = getStructuringElement(MORPH_RECT, Size(7, 7));
int sdepth = std::get<0>(GetParam());
int ddepth = std::get<1>(GetParam());
Mat src(sz, CV_MAKETYPE(sdepth, 5)), dst;
randu(src, 0, 100);
// non-separable filtering with a small kernel
EXPECT_NO_THROW(cv::filter2D(src, dst, ddepth, small_kernel));
EXPECT_NO_THROW(cv::filter2D(src, dst, ddepth, big_kernel));
EXPECT_NO_THROW(cv::sepFilter2D(src, dst, ddepth, kernelX, kernelY));
EXPECT_NO_THROW(cv::sepFilter2D(src, dst, ddepth, symkernelX, symkernelY));
EXPECT_NO_THROW(cv::Sobel(src, dst, ddepth, 2, 0, 5));
EXPECT_NO_THROW(cv::Scharr(src, dst, ddepth, 0, 1));
if( sdepth != ddepth )
return;
EXPECT_NO_THROW(cv::GaussianBlur(src, dst, Size(5, 5), 1.2, 1.2));
EXPECT_NO_THROW(cv::blur(src, dst, Size(11, 11)));
EXPECT_NO_THROW(cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_ellipse));
EXPECT_NO_THROW(cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_rect));
}
INSTANTIATE_TEST_CASE_P(/**/, Imgproc_FilterSupportedFormats,
testing::Values(
make_pair( CV_8U, CV_8U ),
make_pair( CV_8U, CV_16U ),
make_pair( CV_8U, CV_16S ),
make_pair( CV_8U, CV_32F),
make_pair( CV_8U, CV_64F),
make_pair( CV_16U, CV_16U),
make_pair( CV_16U, CV_32F),
make_pair( CV_16U, CV_64F),
make_pair( CV_16S, CV_16S),
make_pair( CV_16S, CV_32F),
make_pair( CV_16S, CV_64F),
make_pair( CV_32F, CV_32F),
make_pair( CV_64F, CV_64F)
)
);
TEST(Imgproc_Blur, borderTypes)
{

@ -282,7 +282,7 @@ void CV_ResizeTest::prepare_to_validation( int /*test_case_idx*/ )
int elem_size = CV_ELEM_SIZE(src->type);
int drows = dst->rows, dcols = dst->cols;
if( interpolation == CV_INTER_NN )
if( interpolation == cv::INTER_NEAREST )
{
for( j = 0; j < dcols; j++ )
{
@ -373,7 +373,7 @@ void CV_ResizeExactTest::get_test_array_types_and_sizes(int test_case_idx, vecto
/////////////////////////
static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& mapy,
Mat* mask=0, int interpolation=CV_INTER_LINEAR )
Mat* mask=0, int interpolation=cv::INTER_LINEAR )
{
int x, y, k;
int drows = dst.rows, dcols = dst.cols;
@ -384,7 +384,7 @@ static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& ma
int step = (int)(src.step / CV_ELEM_SIZE(depth));
int delta;
if( interpolation != CV_INTER_CUBIC )
if( interpolation != cv::INTER_CUBIC )
{
delta = 0;
scols -= 1; srows -= 1;
@ -762,7 +762,7 @@ void CV_RemapTest::get_test_array_types_and_sizes( int test_case_idx, vector<vec
{
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
types[INPUT][1] = types[INPUT][2] = CV_32FC1;
interpolation = CV_INTER_LINEAR;
interpolation = cv::INTER_LINEAR;
}
@ -917,7 +917,7 @@ void CV_GetRectSubPixTest::get_test_array_types_and_sizes( int test_case_idx, ve
center.x = (float)(cvtest::randReal(rng)*src_size.width);
center.y = (float)(cvtest::randReal(rng)*src_size.height);
interpolation = CV_INTER_LINEAR;
interpolation = cv::INTER_LINEAR;
test_cpp = (cvtest::randInt(rng) & 256) == 0;
}
@ -1595,7 +1595,7 @@ TEST(Imgproc_Remap, DISABLED_memleak)
putchar('.');
fflush(stdout);
}
remap(src, dst, map_x, map_y, CV_INTER_LINEAR);
remap(src, dst, map_x, map_y, cv::INTER_LINEAR);
}
}
@ -1617,11 +1617,11 @@ TEST(Imgproc_linearPolar, identity)
{
linearPolar(src, dst,
Point2f((N-1) * 0.5f, (N-1) * 0.5f), N * 0.5f,
cv::WARP_FILL_OUTLIERS | CV_INTER_LINEAR | cv::WARP_INVERSE_MAP);
cv::WARP_FILL_OUTLIERS | cv::INTER_LINEAR | cv::WARP_INVERSE_MAP);
linearPolar(dst, src,
Point2f((N-1) * 0.5f, (N-1) * 0.5f), N * 0.5f,
cv::WARP_FILL_OUTLIERS | CV_INTER_LINEAR);
cv::WARP_FILL_OUTLIERS | cv::INTER_LINEAR);
double psnr = cvtest::PSNR(in(roi), src(roi));
EXPECT_LE(25, psnr) << "iteration=" << i;
@ -1658,11 +1658,11 @@ TEST(Imgproc_logPolar, identity)
{
logPolar(src, dst,
Point2f((N-1) * 0.5f, (N-1) * 0.5f), M,
cv::WARP_FILL_OUTLIERS | CV_INTER_LINEAR | cv::WARP_INVERSE_MAP);
cv::WARP_FILL_OUTLIERS | cv::INTER_LINEAR | cv::WARP_INVERSE_MAP);
logPolar(dst, src,
Point2f((N-1) * 0.5f, (N-1) * 0.5f), M,
cv::WARP_FILL_OUTLIERS | CV_INTER_LINEAR);
cv::WARP_FILL_OUTLIERS | cv::INTER_LINEAR);
double psnr = cvtest::PSNR(in(roi), src(roi));
EXPECT_LE(25, psnr) << "iteration=" << i;
@ -1694,7 +1694,7 @@ TEST(Imgproc_warpPolar, identity)
Rect roi = Rect(0, 0, in.cols - ((N + 19) / 20), in.rows);
Point2f center = Point2f((N - 1) * 0.5f, (N - 1) * 0.5f);
double radius = N * 0.5;
int flags = cv::WARP_FILL_OUTLIERS | CV_INTER_LINEAR;
int flags = cv::WARP_FILL_OUTLIERS | cv::INTER_LINEAR;
// test linearPolar
for (int ki = 1; ki <= 5; ki++)
{

@ -1269,7 +1269,7 @@ void CV_WarpPerspective_Test::warpPerspective(const Mat& _src, Mat& _dst)
continue;
}
den *= INTER_TAB_SIZE;
den *= static_cast<double>(INTER_TAB_SIZE);
int v0 = saturate_cast<int>((tM[0] * dx + tM[1] * dy + tM[2]) * den);
int v1 = saturate_cast<int>((tM[3] * dx + tM[4] * dy + tM[5]) * den);

@ -210,7 +210,7 @@ public:
double* result = buf.data();
float* sbuf = (float*)(result + n);
Mat sample(1, nvars, CV_32F, sbuf);
int predictFlags = bparams.boostType == Boost::DISCRETE ? (PREDICT_MAX_VOTE | RAW_OUTPUT) : PREDICT_SUM;
int predictFlags = bparams.boostType == Boost::DISCRETE ? (+PREDICT_MAX_VOTE | RAW_OUTPUT) : PREDICT_SUM;
predictFlags |= COMPRESSED_INPUT;
for( i = 0; i < n; i++ )

@ -158,7 +158,7 @@ public:
float* psamples = samples.ptr<float>();
size_t sstep0 = samples.step1(), sstep1 = 1;
Mat sample0, sample(nallvars, 1, CV_32F, &samplebuf[0]);
int predictFlags = _isClassifier ? (PREDICT_MAX_VOTE + RAW_OUTPUT) : PREDICT_SUM;
int predictFlags = _isClassifier ? (+PREDICT_MAX_VOTE + RAW_OUTPUT) : PREDICT_SUM;
bool calcOOBError = eps > 0 || rparams.calcVarImportance;
double max_response = 0.;

@ -228,7 +228,7 @@ public:
dst.create(LDR_SIZE, 1, CV_32FCC);
Mat response = dst.getMat();
response = linearResponse(3) / (LDR_SIZE / 2.0f);
response = linearResponse(3) / (static_cast<float>(LDR_SIZE) / 2.0f);
Mat card = Mat::zeros(LDR_SIZE, 1, CV_32FCC);
for(size_t i = 0; i < images.size(); i++) {

@ -338,7 +338,7 @@ public:
Mat response = input_response.getMat();
if(response.empty()) {
float middle = LDR_SIZE / 2.0f;
float middle = static_cast<float>(LDR_SIZE) / 2.0f;
response = linearResponse(channels) / middle;
}
CV_Assert(response.rows == LDR_SIZE && response.cols == 1 &&

@ -323,14 +323,14 @@ enum { CAP_PROP_OPENNI_OUTPUT_MODE = 100,
#pragma warning( disable: 5054 )
#endif
//! OpenNI shortcuts
enum { CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT,
CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE,
CAP_OPENNI_DEPTH_GENERATOR_PRESENT = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT,
CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE,
CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH,
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION,
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION,
CAP_OPENNI_IR_GENERATOR_PRESENT = CAP_OPENNI_IR_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT,
enum { CAP_OPENNI_IMAGE_GENERATOR_PRESENT = +CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT,
CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = +CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE,
CAP_OPENNI_DEPTH_GENERATOR_PRESENT = +CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT,
CAP_OPENNI_DEPTH_GENERATOR_BASELINE = +CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE,
CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = +CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH,
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = +CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION,
CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION,
CAP_OPENNI_IR_GENERATOR_PRESENT = +CAP_OPENNI_IR_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT
};
#ifdef _MSC_VER
#pragma warning( pop )

@ -961,7 +961,7 @@ bool GStreamerCapture::retrieveVideoFrame(int, OutputArray dst)
// regular strides/offsets if no meta is present.
GstVideoFrame frame = {};
#if FULL_GST_VERSION >= VERSION_NUM(1,6,0)
GstMapFlags flags = static_cast<GstMapFlags>(GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF);
GstMapFlags flags = static_cast<GstMapFlags>(+GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF);
#else
GstMapFlags flags = static_cast<GstMapFlags>(GST_MAP_READ);
#endif

Loading…
Cancel
Save