Backport some of C API removal in core module implementation.

This commit is contained in:
Alexander Smorkalov 2024-11-14 11:24:00 +03:00
parent e1d66643b3
commit 1ff16cb551
2 changed files with 21 additions and 21 deletions

View File

@ -696,7 +696,7 @@ void calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int
Mat mean;
ctype = std::max(std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), _mean.depth()), CV_32F);
if( (flags & CV_COVAR_USE_AVG) != 0 )
if( (flags & cv::COVAR_USE_AVG) != 0 )
{
CV_Assert( _mean.size() == size );
if( _mean.isContinuous() && _mean.type() == ctype )
@ -722,8 +722,8 @@ void calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int
}
}
calcCovarMatrix( _data, covar, mean, (flags & ~(CV_COVAR_ROWS|CV_COVAR_COLS)) | CV_COVAR_ROWS, ctype );
if( (flags & CV_COVAR_USE_AVG) == 0 )
calcCovarMatrix( _data, covar, mean, (flags & ~(cv::COVAR_ROWS|cv::COVAR_COLS)) | cv::COVAR_ROWS, ctype );
if( (flags & cv::COVAR_USE_AVG) == 0 )
_mean = mean.reshape(1, size.height);
}
@ -754,7 +754,7 @@ void calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mea
}
Mat mean;
if( (flags & CV_COVAR_USE_AVG) != 0 )
if( (flags & cv::COVAR_USE_AVG) != 0 )
{
CV_Assert( _mean.size() == size );
@ -770,9 +770,9 @@ void calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mea
mean = _mean.getMat().reshape(1, 1);
}
calcCovarMatrix( _data, _covar, mean, (flags & ~(CV_COVAR_ROWS|CV_COVAR_COLS)) | CV_COVAR_ROWS, ctype );
calcCovarMatrix( _data, _covar, mean, (flags & ~(cv::COVAR_ROWS|cv::COVAR_COLS)) | cv::COVAR_ROWS, ctype );
if( (flags & CV_COVAR_USE_AVG) == 0 )
if( (flags & cv::COVAR_USE_AVG) == 0 )
{
mean = mean.reshape(1, size.height);
mean.copyTo(_mean);
@ -781,14 +781,14 @@ void calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mea
}
Mat data = _src.getMat(), mean;
CV_Assert( ((flags & CV_COVAR_ROWS) != 0) ^ ((flags & CV_COVAR_COLS) != 0) );
bool takeRows = (flags & CV_COVAR_ROWS) != 0;
CV_Assert( ((flags & cv::COVAR_ROWS) != 0) ^ ((flags & cv::COVAR_COLS) != 0) );
bool takeRows = (flags & cv::COVAR_ROWS) != 0;
int type = data.type();
int nsamples = takeRows ? data.rows : data.cols;
CV_Assert( nsamples > 0 );
Size size = takeRows ? Size(data.cols, 1) : Size(1, data.rows);
if( (flags & CV_COVAR_USE_AVG) != 0 )
if( (flags & cv::COVAR_USE_AVG) != 0 )
{
mean = _mean.getMat();
ctype = std::max(std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), mean.depth()), CV_32F);
@ -808,8 +808,8 @@ void calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mea
mean = _mean.getMat();
}
mulTransposed( data, _covar, ((flags & CV_COVAR_NORMAL) == 0) ^ takeRows,
mean, (flags & CV_COVAR_SCALE) != 0 ? 1./nsamples : 1, ctype );
mulTransposed( data, _covar, ((flags & cv::COVAR_NORMAL) == 0) ^ takeRows,
mean, (flags & cv::COVAR_SCALE) != 0 ? 1./nsamples : 1, ctype );
}
@ -1171,7 +1171,7 @@ cvCalcCovarMatrix( const CvArr** vecarr, int count,
if( avgarr )
mean = mean0 = cv::cvarrToMat(avgarr);
if( (flags & CV_COVAR_COLS) != 0 || (flags & CV_COVAR_ROWS) != 0 )
if( (flags & cv::COVAR_COLS) != 0 || (flags & cv::COVAR_ROWS) != 0 )
{
cv::Mat data = cv::cvarrToMat(vecarr[0]);

View File

@ -554,7 +554,7 @@ void MatOp::matmul(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const
if( isT(e1) )
{
flags = CV_GEMM_A_T;
flags = cv::GEMM_1_T;
scale = e1.alpha;
m1 = e1.a;
}
@ -568,7 +568,7 @@ void MatOp::matmul(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const
if( isT(e2) )
{
flags |= CV_GEMM_B_T;
flags |= cv::GEMM_2_T;
scale *= e2.alpha;
m2 = e2.a;
}
@ -1574,10 +1574,10 @@ void MatOp_GEMM::add(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const
double alpha1 = i1 ? 1 : e1.alpha, alpha2 = i2 ? 1 : e2.alpha;
if( isMatProd(e1) && (i2 || isScaled(e2) || isT(e2)) )
MatOp_GEMM::makeExpr(res, (e1.flags & ~CV_GEMM_C_T)|(isT(e2) ? CV_GEMM_C_T : 0),
MatOp_GEMM::makeExpr(res, (e1.flags & ~cv::GEMM_3_T)|(isT(e2) ? cv::GEMM_3_T : 0),
e1.a, e1.b, alpha1, e2.a, alpha2);
else if( isMatProd(e2) && (i1 || isScaled(e1) || isT(e1)) )
MatOp_GEMM::makeExpr(res, (e2.flags & ~CV_GEMM_C_T)|(isT(e1) ? CV_GEMM_C_T : 0),
MatOp_GEMM::makeExpr(res, (e2.flags & ~cv::GEMM_3_T)|(isT(e1) ? cv::GEMM_3_T : 0),
e2.a, e2.b, alpha2, e1.a, alpha1);
else if( this == e2.op )
MatOp::add(e1, e2, res);
@ -1593,10 +1593,10 @@ void MatOp_GEMM::subtract(const MatExpr& e1, const MatExpr& e2, MatExpr& res) co
double alpha1 = i1 ? 1 : e1.alpha, alpha2 = i2 ? 1 : e2.alpha;
if( isMatProd(e1) && (i2 || isScaled(e2) || isT(e2)) )
MatOp_GEMM::makeExpr(res, (e1.flags & ~CV_GEMM_C_T)|(isT(e2) ? CV_GEMM_C_T : 0),
MatOp_GEMM::makeExpr(res, (e1.flags & ~cv::GEMM_3_T)|(isT(e2) ? cv::GEMM_3_T : 0),
e1.a, e1.b, alpha1, e2.a, -alpha2);
else if( isMatProd(e2) && (i1 || isScaled(e1) || isT(e1)) )
MatOp_GEMM::makeExpr(res, (e2.flags & ~CV_GEMM_C_T)|(isT(e1) ? CV_GEMM_C_T : 0),
MatOp_GEMM::makeExpr(res, (e2.flags & ~cv::GEMM_3_T)|(isT(e1) ? cv::GEMM_3_T : 0),
e2.a, e2.b, -alpha2, e1.a, alpha1);
else if( this == e2.op )
MatOp::subtract(e1, e2, res);
@ -1618,9 +1618,9 @@ void MatOp_GEMM::transpose(const MatExpr& e, MatExpr& res) const
CV_INSTRUMENT_REGION();
res = e;
res.flags = (!(e.flags & CV_GEMM_A_T) ? CV_GEMM_B_T : 0) |
(!(e.flags & CV_GEMM_B_T) ? CV_GEMM_A_T : 0) |
(!(e.flags & CV_GEMM_C_T) ? CV_GEMM_C_T : 0);
res.flags = (!(e.flags & cv::GEMM_1_T) ? cv::GEMM_2_T : 0) |
(!(e.flags & cv::GEMM_2_T) ? cv::GEMM_1_T : 0) |
(!(e.flags & cv::GEMM_3_T) ? cv::GEMM_3_T : 0);
swap(res.a, res.b);
}