8000 fix legacy constants by sturkmen72 · Pull Request #21378 · opencv/opencv · GitHub
[go: up one dir, main page]

Skip to content

fix legacy constants #21378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/core/perf/perf_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceR,
int reduceOp = get<2>(GetParam());

int ddepth = -1;
if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG) )
if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG) )
ddepth = CV_32S;

Mat src(sz, matType);
Expand Down Expand Up @@ -51,7 +51,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceC,
int reduceOp = get<2>(GetParam());

int ddepth = -1;
if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG) )
if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG) )
ddepth = CV_32S;

Mat src(sz, matType);
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/matmul.dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ void calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mea
else
{
ctype = std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), CV_32F);
reduce( _src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype );
reduce( _src, _mean, takeRows ? 0 : 1, REDUCE_AVG, ctype );
mean = _mean.getMat();
}

Expand Down
40 changes: 20 additions & 20 deletions modules/core/src/matrix_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst,
if (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F))
return false;

if (op == CV_REDUCE_AVG)
if (op == REDUCE_AVG)
{
if (sdepth < CV_32S && ddepth < CV_32S)
ddepth = CV_32S;
Expand Down Expand Up @@ -654,7 +654,7 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst,
_dst.create(dsize, dtype);
UMat dst = _dst.getUMat();

if (op0 == CV_REDUCE_AVG)
if (op0 == REDUCE_AVG)
k.args(ocl::KernelArg::ReadOnly(src),
ocl::KernelArg::WriteOnlyNoSize(dst), 1.0f / src.cols);
else
Expand Down Expand Up @@ -690,7 +690,7 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst,
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnly(src),
temparg = ocl::KernelArg::WriteOnlyNoSize(dst);

if (op0 == CV_REDUCE_AVG)
if (op0 == REDUCE_AVG)
k.args(srcarg, temparg, 1.0f / (dim == 0 ? src.rows : src.cols));
else
k.args(srcarg, temparg);
Expand All @@ -717,8 +717,8 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
int ddepth = CV_MAT_DEPTH(dtype);

CV_Assert( cn == CV_MAT_CN(dtype) );
CV_Assert( op == CV_REDUCE_SUM || op == CV_REDUCE_MAX ||
op == CV_REDUCE_MIN || op == CV_REDUCE_AVG );
CV_Assert( op == REDUCE_SUM || op == REDUCE_MAX ||
op == REDUCE_MIN || op == REDUCE_AVG );

CV_OCL_RUN(_dst.isUMat(),
ocl_reduce(_src, _dst, dim, op, op0, stype, dtype))
Expand All @@ -732,9 +732,9 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
_dst.create(dim == 0 ? 1 : src.rows, dim == 0 ? src.cols : 1, dtype);
Mat dst = _dst.getMat(), temp = dst;

if( op == CV_REDUCE_AVG )
if( op == REDUCE_AVG )
{
op = CV_REDUCE_SUM;
op = REDUCE_SUM;
if( sdepth < CV_32S && ddepth < CV_32S )
{
temp.create(dst.rows, dst.cols, CV_32SC(cn));
Expand All @@ -745,7 +745,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
ReduceFunc func = 0;
if( dim == 0 )
{
if( op == CV_REDUCE_SUM )
if( op == REDUCE_SUM )
{
if(sdepth == CV_8U && ddepth == CV_32S)
func = GET_OPTIMIZED(reduceSumR8u32s);
Expand All @@ -768,7 +768,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
else if(sdepth == CV_64F && ddepth == CV_64F)
func = reduceSumR64f64f;
}
else if(op == CV_REDUCE_MAX)
else if(op == REDUCE_MAX)
{
if(sdepth == CV_8U && ddepth == CV_8U)
func = GET_OPTIMIZED(reduceMaxR8u);
Expand All @@ -781,7 +781,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
else if(sdepth == CV_64F && ddepth == CV_64F)
func = reduceMaxR64f;
}
else if(op == CV_REDUCE_MIN)
else if(op == REDUCE_MIN)
{
if(sdepth == CV_8U && ddepth == CV_8U)
func = GET_OPTIMIZED(reduceMinR8u);
Expand All @@ -797,7 +797,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
}
else
{
if(op == CV_REDUCE_SUM)
if(op == REDUCE_SUM)
{
if(sdepth == CV_8U && ddepth == CV_32S)
func = GET_OPTIMIZED(reduceSumC8u32s);
Expand All @@ -820,7 +820,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
else if(sdepth == CV_64F && ddepth == CV_64F)
func = reduceSumC64f64f;
}
else if(op == CV_REDUCE_MAX)
else if(op == REDUCE_MAX)
{
if(sdepth == CV_8U && ddepth == CV_8U)
func = GET_OPTIMIZED(reduceMaxC8u);
Expand All @@ -833,7 +833,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
else if(sdepth == CV_64F && ddepth == CV_64F)
func = reduceMaxC64f;
}
else if(op == CV_REDUCE_MIN)
else if(op == REDUCE_MIN)
{
if(sdepth == CV_8U && ddepth == CV_8U)
func = GET_OPTIMIZED(reduceMinC8u);
Expand All @@ -854,7 +854,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)

func( src, temp );

if( op0 == CV_REDUCE_AVG )
if( op0 == REDUCE_AVG )
temp.convertTo(dst, dst.type(), 1./(dim == 0 ? src.rows : src.cols));
}

Expand All @@ -868,9 +868,9 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
{
AutoBuffer<T> buf;
int n, len;
bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW;
bool sortRows = (flags & 1) == SORT_EVERY_ROW;
bool inplace = src.data == dst.data;
bool sortDescending = (flags & CV_SORT_DESCENDING) != 0;
bool sortDescending = (flags & SORT_DESCENDING) != 0;

if( sortRows )
n = src.rows, len = src.cols;
Expand 9E12 Down Expand Up @@ -940,8 +940,8 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags)
{
CV_INSTRUMENT_REGION_IPP();

bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW;
bool sortDescending = (flags & CV_SORT_DESCENDING) != 0;
bool sortRows = (flags & 1) == SORT_EVERY_ROW;
bool sortDescending = (flags & SORT_DESCENDING) != 0;
bool inplace = (src.data == dst.data);
int depth = src.depth();
IppDataType type = ippiGetDataType(depth);
Expand Down Expand Up @@ -1013,8 +1013,8 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
{
AutoBuffer<T> buf;
AutoBuffer<int> ibuf;
bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW;
bool sortDescending = (flags & CV_SORT_DESCENDING) != 0;
bool sortRows = (flags & 1) == SORT_EVERY_ROW;
bool sortDescending = (flags & SORT_DESCENDING) != 0;

CV_Assert( src.data != dst.data );

Expand Down
16 changes: 8 additions & 8 deletions modules/core/test/ocl/test_arithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,8 +1819,8 @@ OCL_TEST_P(ReduceSum, Mat)
{
generateTestData();

OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_SUM, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_SUM, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_SUM, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_SUM, dtype));

double eps = ddepth <= CV_32S ? 1 : 7e-4;
OCL_EXPECT_MATS_NEAR(dst, eps);
Expand All @@ -1835,8 +1835,8 @@ OCL_TEST_P(ReduceMax, Mat)
{
generateTestData();

OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MAX, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MAX, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_MAX, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_MAX, dtype));

OCL_EXPECT_MATS_NEAR(dst, 0);
}
Expand All @@ -1850,8 +1850,8 @@ OCL_TEST_P(ReduceMin, Mat)
{
generateTestData();

OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_MIN, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MIN, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_MIN, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_MIN, dtype));

OCL_EXPECT_MATS_NEAR(dst, 0);
}
Expand All @@ -1865,8 +1865,8 @@ OCL_TEST_P(ReduceAvg, Mat)
{
generateTestData();

OCL_OFF(cv::reduce(src_roi, dst_roi, dim, CV_REDUCE_AVG, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_AVG, dtype));
OCL_OFF(cv::reduce(src_roi, dst_roi, dim, REDUCE_AVG, dtype));
OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, REDUCE_AVG, dtype));

double eps = ddepth <= CV_32S ? 1 : 6e-6;
OCL_EXPECT_MATS_NEAR(dst, eps);
Expand Down
34 changes: 17 additions & 17 deletions modules/core/test/test_mat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
{
int srcType = src.type();
bool support = false;
if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG )
if( opType == REDUCE_SUM || opType == REDUCE_AVG )
{
if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) )
support = true;
Expand All @@ -106,7 +106,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
if( srcType == CV_64F && dstType == CV_64F)
support = true;
}
else if( opType == CV_REDUCE_MAX )
else if( opType == REDUCE_MAX )
{
if( srcType == CV_8U && dstType == CV_8U )
support = true;
Expand All @@ -115,7 +115,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
if( srcType == CV_64F && dstType == CV_64F )
support = true;
}
else if( opType == CV_REDUCE_MIN )
else if( opType == REDUCE_MIN )
{
if( srcType == CV_8U && dstType == CV_8U)
support = true;
Expand All @@ -128,7 +128,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
return cvtest::TS::OK;

double eps = 0.0;
if ( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG )
if ( opType == REDUCE_SUM || opType == REDUCE_AVG )
{
if ( dstType == CV_32F )
eps = 1.e-5;
Expand All @@ -152,10 +152,10 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
if( check )
{
char msg[100];
const char* opTypeStr = opType == CV_REDUCE_SUM ? "CV_REDUCE_SUM" :
opType == CV_REDUCE_AVG ? "CV_REDUCE_AVG" :
opType == CV_REDUCE_MAX ? "CV_REDUCE_MAX" :
opType == CV_REDUCE_MIN ? "CV_REDUCE_MIN" : "unknown operation type";
const char* opTypeStr = opType == REDUCE_SUM ? "REDUCE_SUM" :
opType == REDUCE_AVG ? "REDUCE_AVG" :
opType == REDUCE_MAX ? "REDUCE_MAX" :
opType == REDUCE_MIN ? "REDUCE_MIN" : "unknown operation type";
string srcTypeStr, dstTypeStr;
getMatTypeStr( src.type(), srcTypeStr );
getMatTypeStr( dstType, dstTypeStr );
Expand Down Expand Up @@ -195,19 +195,19 @@ int Core_ReduceTest::checkCase( int srcType, int dstType, int dim, Size sz )
CV_Assert( 0 );

// 1. sum
tempCode = checkOp( src, dstType, CV_REDUCE_SUM, sum, dim );
tempCode = checkOp( src, dstType, REDUCE_SUM, sum, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;

// 2. avg
tempCode = checkOp( src, dstType, CV_REDUCE_AVG, avg, dim );
tempCode = checkOp( src, dstType, REDUCE_AVG, avg, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;

// 3. max
tempCode = checkOp( src, dstType, CV_REDUCE_MAX, max, dim );
tempCode = checkOp( src, dstType, REDUCE_MAX, max, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;

// 4. min
tempCode = checkOp( src, dstType, CV_REDUCE_MIN, min, dim );
tempCode = checkOp( src, dstType, REDUCE_MIN, min, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;

return code;
Expand Down Expand Up @@ -315,7 +315,7 @@ TEST(Core_PCA, accuracy)
Mat rBackPrjTestPoints = rPCA.backProject( rPrjTestPoints );

Mat avg(1, sz.width, CV_32FC1 );
cv::reduce( rPoints, avg, 0, CV_REDUCE_AVG );
cv::reduce( rPoints, avg, 0, REDUCE_AVG );
Mat Q = rPoints - repeat( avg, rPoints.rows, 1 ), Qt = Q.t(), eval, evec;
Q = Qt * Q;
Q = Q /(float)rPoints.rows;
Expand Down Expand Up @@ -1559,10 +1559,10 @@ TEST(Reduce, regression_should_fail_bug_4594)
cv::Mat src = cv::Mat::eye(4, 4, CV_8U);
std::vector<int> dst;

EXPECT_THROW(cv::reduce(src, dst, 0, CV_REDUCE_MIN, CV_32S), cv::Exception);
EXPECT_THROW(cv::reduce(src, dst, 0, CV_REDUCE_MAX, CV_32S), cv::Exception);
EXPECT_NO_THROW(cv::reduce(src, dst, 0, CV_REDUCE_SUM, CV_32S));
EXPECT_NO_THROW(cv::reduce(src, dst, 0, CV_REDUCE_AVG, CV_32S));
EXPECT_THROW(cv::reduce(src, dst, 0, REDUCE_MIN, CV_32S), cv::Exception);
EXPECT_THROW(cv::reduce(src, dst, 0, REDUCE_MAX, CV_32S), cv::Exception);
EXPECT_NO_THROW(cv::reduce(src, dst, 0, REDUCE_SUM, CV_32S));
EXPECT_NO_THROW(cv::reduce(src, dst, 0, REDUCE_AVG, CV_32S));
}

TEST(Mat, push_back_vector)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/test/test_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3018,7 +3018,7 @@ TEST(CovariationMatrixVectorOfMatWithMean, accuracy)
cv::randu(src,cv::Scalar(-128), cv::Scalar(128));
cv::Mat goldMean;

cv::reduce(src,goldMean,0 ,CV_REDUCE_AVG, CV_32F);
cv::reduce(src,goldMean,0 ,REDUCE_AVG, CV_32F);

cv::calcCovarMatrix(src,gold,goldMean,singleMatFlags,CV_32F);

Expand Down
3 changes: 0 additions & 3 deletions modules/core/test/test_precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

#include "opencv2/ts.hpp"
#include "opencv2/ts/ocl_test.hpp"
#include "opencv2/core/core_c.h"

#include "opencv2/core/cvdef.h"
#include "opencv2/core/private.hpp"
#include "opencv2/core/hal/hal.hpp"

Expand Down
4 changes: 2 additions & 2 deletions modules/core/test/test_umat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,8 +1398,8 @@ TEST(UMat, testTempObjects_Mat_issue_8693)
randu(srcUMat, -1.f, 1.f);
srcUMat.copyTo(srcMat);

reduce(srcUMat, srcUMat, 0, CV_REDUCE_SUM);
reduce(srcMat, srcMat, 0, CV_REDUCE_SUM);
reduce(srcUMat, srcUMat, 0, REDUCE_SUM);
reduce(srcMat, srcMat, 0, REDUCE_SUM);

srcUMat.convertTo(srcUMat, CV_64FC1);< 1241 /span>
srcMat.convertTo(srcMat, CV_64FC1);
Expand Down
2 changes: 1 addition & 1 deletion modules/imgcodecs/src/grfmt_exr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ bool ExrEncoder::write( const Mat& img, const std::vector<int>& params )

for( size_t i = 0; i < params.size(); i += 2 )
{
if( params[i] == CV_IMWRITE_EXR_TYPE )
if( params[i] == IMWRITE_EXR_TYPE )
{
switch( params[i+1] )
{
Expand Down
Loading
0