diff --git a/apps/interactive-calibration/calibController.cpp b/apps/interactive-calibration/calibController.cpp index f0aa6df36e91..bb6004d24008 100644 --- a/apps/interactive-calibration/calibController.cpp +++ b/apps/interactive-calibration/calibController.cpp @@ -221,7 +221,7 @@ void calib::calibDataController::filterFrames() mCalibData->allCharucoIds.erase(mCalibData->allCharucoIds.begin() + worstElemIndex); } - cv::Mat newErrorsVec = cv::Mat((int)numberOfFrames - 1, 1, CV_64F); + cv::Mat newErrorsVec = cv::Mat((int)numberOfFrames - 1, 1, CV_64FC1); std::copy(mCalibData->perViewErrors.ptr(0), mCalibData->perViewErrors.ptr((int)worstElemIndex), newErrorsVec.ptr(0)); if((int)worstElemIndex < (int)numberOfFrames-1) { diff --git a/apps/interactive-calibration/frameProcessor.cpp b/apps/interactive-calibration/frameProcessor.cpp index 9d7827143854..d063ff9436f5 100644 --- a/apps/interactive-calibration/frameProcessor.cpp +++ b/apps/interactive-calibration/frameProcessor.cpp @@ -212,7 +212,7 @@ bool CalibProcessor::checkLastFrame() const double badAngleThresh = 40; if(!mCalibData->cameraMatrix.total()) { - tmpCamMatrix = cv::Mat::eye(3, 3, CV_64F); + tmpCamMatrix = cv::Mat::eye(3, 3, CV_64FC1); tmpCamMatrix.at(0,0) = 20000; tmpCamMatrix.at(1,1) = 20000; tmpCamMatrix.at(0,2) = mCalibData->imageSize.height/2; diff --git a/apps/interactive-calibration/rotationConverters.cpp b/apps/interactive-calibration/rotationConverters.cpp index 421d15a924d2..5a0edac0e132 100644 --- a/apps/interactive-calibration/rotationConverters.cpp +++ b/apps/interactive-calibration/rotationConverters.cpp @@ -17,7 +17,7 @@ void calib::Euler(const cv::Mat& src, cv::Mat& dst, int argType) if((src.rows == 3) && (src.cols == 3)) { //convert rotation matrix to 3 angles (pitch, yaw, roll) - dst = cv::Mat(3, 1, CV_64F); + dst = cv::Mat(3, 1, CV_64FC1); double pitch, yaw, roll; if(src.at(0,2) < -0.998) @@ -78,9 +78,9 @@ void calib::Euler(const cv::Mat& src, cv::Mat& dst, int argType) else if(argType != CALIB_RADIANS) CV_Error(cv::Error::StsBadFlag, "Invalid argument type"); - dst = cv::Mat(3, 3, CV_64F); - cv::Mat M(3, 3, CV_64F); - cv::Mat i = cv::Mat::eye(3, 3, CV_64F); + dst = cv::Mat(3, 3, CV_64FC1); + cv::Mat M(3, 3, CV_64FC1); + cv::Mat i = cv::Mat::eye(3, 3, CV_64FC1); i.copyTo(dst); i.copyTo(M); diff --git a/apps/traincascade/HOGfeatures.cpp b/apps/traincascade/HOGfeatures.cpp index 0707f936d5e7..39b33145caae 100644 --- a/apps/traincascade/HOGfeatures.cpp +++ b/apps/traincascade/HOGfeatures.cpp @@ -156,13 +156,13 @@ void CvHOGEvaluator::Feature::write(FileStorage &fs, int featComponentIdx) const void CvHOGEvaluator::integralHistogram(const Mat &img, vector &histogram, Mat &norm, int nbins) const { - CV_Assert( img.type() == CV_8U || img.type() == CV_8UC3 ); + CV_Assert( img.type() == CV_8UC1 || img.type() == CV_8UC3 ); int x, y, binIdx; Size gradSize(img.size()); Size histSize(histogram[0].size()); - Mat grad(gradSize, CV_32F); - Mat qangle(gradSize, CV_8U); + Mat grad(gradSize, CV_32FC1); + Mat qangle(gradSize, CV_8UC1); AutoBuffer mapbuf(gradSize.width + gradSize.height + 4); int* xmap = mapbuf.data() + 1; @@ -178,10 +178,10 @@ void CvHOGEvaluator::integralHistogram(const Mat &img, vector &histogram, M int width = gradSize.width; AutoBuffer _dbuf(width*4); float* dbuf = _dbuf.data(); - Mat Dx(1, width, CV_32F, dbuf); - Mat Dy(1, width, CV_32F, dbuf + width); - Mat Mag(1, width, CV_32F, dbuf + width*2); - Mat Angle(1, width, CV_32F, dbuf + width*3); + Mat Dx(1, width, CV_32FC1, dbuf); + Mat Dy(1, width, CV_32FC1, dbuf + width); + Mat Mag(1, width, CV_32FC1, dbuf + width*2); + Mat Angle(1, width, CV_32FC1, dbuf + width*3); float angleScale = (float)(nbins/CV_PI); diff --git a/apps/traincascade/boost.cpp b/apps/traincascade/boost.cpp index ee0486ec9088..60a05e02fd5c 100644 --- a/apps/traincascade/boost.cpp +++ b/apps/traincascade/boost.cpp @@ -80,7 +80,8 @@ static CvMat* cvPreprocessIndexArray( const CvMat* idx_arr, int data_arr_size, b __CV_BEGIN__; - int i, idx_total, idx_selected = 0, step, type, prev = INT_MIN, is_sorted = 1; + int i, idx_total, idx_selected = 0, step, prev = INT_MIN, is_sorted = 1; + ElemType type; uchar* srcb = 0; int* srci = 0; int* dsti; @@ -658,7 +659,7 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat (MAX(0,max_c_count - 33)/32)*sizeof(int),sizeof(void*)); split_heap = cvCreateSet( 0, sizeof(*split_heap), maxSplitSize, tree_storage ); - priors = cvCreateMat( 1, get_num_classes(), CV_64F ); + priors = cvCreateMat( 1, get_num_classes(), CV_64FC1); cvSet(priors, cvScalar(1)); priors_mult = cvCloneMat( priors ); counts = cvCreateMat( 1, get_num_classes(), CV_32SC1 ); @@ -1423,11 +1424,11 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree ) cvReleaseMat( &subsample_mask ); cvReleaseMat( &weights ); - orig_response = cvCreateMat( 1, n, CV_32S ); - weak_eval = cvCreateMat( 1, n, CV_64F ); - subsample_mask = cvCreateMat( 1, n, CV_8U ); - weights = cvCreateMat( 1, n, CV_64F ); - subtree_weights = cvCreateMat( 1, n + 2, CV_64F ); + orig_response = cvCreateMat( 1, n, CV_32SC1); + weak_eval = cvCreateMat( 1, n, CV_64FC1); + subsample_mask = cvCreateMat( 1, n, CV_8UC1); + weights = cvCreateMat( 1, n, CV_64FC1); + subtree_weights = cvCreateMat( 1, n + 2, CV_64FC1); if (data->is_buf_16u) { @@ -1464,7 +1465,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree ) if( params.boost_type == LOGIT ) { - sum_response = cvCreateMat( 1, n, CV_64F ); + sum_response = cvCreateMat( 1, n, CV_64FC1); for( int i = 0; i < n; i++ ) { diff --git a/apps/traincascade/old_ml_boost.cpp b/apps/traincascade/old_ml_boost.cpp index a937ea670c9a..c5aa8b68da74 100644 --- a/apps/traincascade/old_ml_boost.cpp +++ b/apps/traincascade/old_ml_boost.cpp @@ -1179,11 +1179,11 @@ CvBoost::update_weights( CvBoostTree* tree ) cvReleaseMat( &weights ); cvReleaseMat( &subtree_weights ); - CV_CALL( orig_response = cvCreateMat( 1, n, CV_32S )); - CV_CALL( weak_eval = cvCreateMat( 1, n, CV_64F )); - CV_CALL( subsample_mask = cvCreateMat( 1, n, CV_8U )); - CV_CALL( weights = cvCreateMat( 1, n, CV_64F )); - CV_CALL( subtree_weights = cvCreateMat( 1, n + 2, CV_64F )); + CV_CALL( orig_response = cvCreateMat( 1, n, CV_32SC1)); + CV_CALL( weak_eval = cvCreateMat( 1, n, CV_64FC1)); + CV_CALL( subsample_mask = cvCreateMat( 1, n, CV_8UC1)); + CV_CALL( weights = cvCreateMat( 1, n, CV_64FC1)); + CV_CALL( subtree_weights = cvCreateMat( 1, n + 2, CV_64FC1)); if( data->have_priors ) { @@ -1237,7 +1237,7 @@ CvBoost::update_weights( CvBoostTree* tree ) if( params.boost_type == LOGIT ) { - CV_CALL( sum_response = cvCreateMat( 1, n, CV_64F )); + CV_CALL( sum_response = cvCreateMat( 1, n, CV_64FC1)); for( i = 0; i < n; i++ ) { @@ -1274,8 +1274,8 @@ CvBoost::update_weights( CvBoostTree* tree ) cvXorS( subsample_mask, cvScalar(1.), subsample_mask ); data->get_vectors( subsample_mask, values, missing, 0 ); - _sample = cvMat( 1, data->var_count, CV_32F ); - _mask = cvMat( 1, data->var_count, CV_8U ); + _sample = cvMat( 1, data->var_count, CV_32FC1); + _mask = cvMat( 1, data->var_count, CV_8UC1); // run tree through all the non-processed samples for( i = 0; i < n; i++ ) @@ -1492,8 +1492,8 @@ CvBoost::get_active_vars( bool absolute_idx ) const CvDTreeNode* node; assert(!active_vars && !active_vars_abs); - mask = cvCreateMat( 1, data->var_count, CV_8U ); - inv_map = cvCreateMat( 1, data->var_count, CV_32S ); + mask = cvCreateMat( 1, data->var_count, CV_8UC1); + inv_map = cvCreateMat( 1, data->var_count, CV_32SC1); cvZero( mask ); cvSet( inv_map, cvScalar(-1) ); @@ -1533,8 +1533,8 @@ CvBoost::get_active_vars( bool absolute_idx ) //if ( nactive_vars > 0 ) { - active_vars = cvCreateMat( 1, nactive_vars, CV_32S ); - active_vars_abs = cvCreateMat( 1, nactive_vars, CV_32S ); + active_vars = cvCreateMat( 1, nactive_vars, CV_32SC1); + active_vars_abs = cvCreateMat( 1, nactive_vars, CV_32SC1); have_active_cat_vars = false; diff --git a/apps/traincascade/old_ml_data.cpp b/apps/traincascade/old_ml_data.cpp index d221dcbf0f7b..3019741296e1 100644 --- a/apps/traincascade/old_ml_data.cpp +++ b/apps/traincascade/old_ml_data.cpp @@ -213,7 +213,7 @@ int CvMLData::read_csv(const char* filename) storage = cvCreateMemStorage(); seq = cvCreateSeq( 0, sizeof(*seq), cols_count*sizeof(float), storage ); - var_types = cvCreateMat( 1, cols_count, CV_8U ); + var_types = cvCreateMat( 1, cols_count, CV_8UC1); cvZero( var_types ); var_types_ptr = var_types->data.ptr; @@ -245,7 +245,7 @@ int CvMLData::read_csv(const char* filename) fclose(file); values = cvCreateMat( seq->total, cols_count, CV_32FC1 ); - missing = cvCreateMat( seq->total, cols_count, CV_8U ); + missing = cvCreateMat( seq->total, cols_count, CV_8UC1); var_idx_mask = cvCreateMat( 1, values->cols, CV_8UC1 ); cvSet( var_idx_mask, cvRealScalar(1) ); train_sample_count = seq->total; diff --git a/apps/traincascade/old_ml_inner_functions.cpp b/apps/traincascade/old_ml_inner_functions.cpp index 5858a4014a90..f9b3d45c9066 100644 --- a/apps/traincascade/old_ml_inner_functions.cpp +++ b/apps/traincascade/old_ml_inner_functions.cpp @@ -206,7 +206,8 @@ cvPreprocessIndexArray( const CvMat* idx_arr, int data_arr_size, bool check_for_ __BEGIN__; - int i, idx_total, idx_selected = 0, step, type, prev = INT_MIN, is_sorted = 1; + int i, idx_total, idx_selected = 0, step, prev = INT_MIN, is_sorted = 1; + ElemType type; uchar* srcb = 0; int* srci = 0; int* dsti; @@ -1062,7 +1063,7 @@ cvPreparePredictData( const CvArr* _sample, int dims_all, static void -icvConvertDataToSparse( const uchar* src, int src_step, int src_type, +icvConvertDataToSparse(const uchar* src, int src_step, int src_type, uchar* dst, int dst_step, int dst_type, CvSize size, int* idx ) { diff --git a/apps/traincascade/old_ml_tree.cpp b/apps/traincascade/old_ml_tree.cpp index cfba9ec9523b..d4950252a1a4 100644 --- a/apps/traincascade/old_ml_tree.cpp +++ b/apps/traincascade/old_ml_tree.cpp @@ -647,7 +647,7 @@ void CvDTreeTrainData::set_data( const CvMat* _train_data, int _tflag, { int m = get_num_classes(); double sum = 0; - CV_CALL( priors = cvCreateMat( 1, m, CV_64F )); + CV_CALL( priors = cvCreateMat( 1, m, CV_64FC1)); for( i = 0; i < m; i++ ) { double val = have_priors ? params.priors[i] : 1.; @@ -3390,7 +3390,7 @@ void CvDTree::prune_cv() double min_err = 0, min_err_se = 0; int min_idx = -1; - CV_CALL( ab = cvCreateMat( 1, 256, CV_64F )); + CV_CALL( ab = cvCreateMat( 1, 256, CV_64FC1)); // build the main tree sequence, calculate alpha's for(;;tree_count++) @@ -3401,7 +3401,7 @@ void CvDTree::prune_cv() if( ab->cols <= tree_count ) { - CV_CALL( temp = cvCreateMat( 1, ab->cols*3/2, CV_64F )); + CV_CALL( temp = cvCreateMat( 1, ab->cols*3/2, CV_64FC1)); for( ti = 0; ti < ab->cols; ti++ ) temp->data.db[ti] = ab->data.db[ti]; cvReleaseMat( &ab ); @@ -3420,7 +3420,7 @@ void CvDTree::prune_cv() ab->data.db[ti] = sqrt(ab->data.db[ti]*ab->data.db[ti+1]); ab->data.db[tree_count-1] = DBL_MAX*0.5; - CV_CALL( err_jk = cvCreateMat( cv_n, tree_count, CV_64F )); + CV_CALL( err_jk = cvCreateMat( cv_n, tree_count, CV_64FC1)); err = err_jk->data.db; for( j = 0; j < cv_n; j++ ) @@ -3744,7 +3744,7 @@ const CvMat* CvDTree::get_var_importance() double* importance; if( !node ) return 0; - var_importance = cvCreateMat( 1, data->var_count, CV_64F ); + var_importance = cvCreateMat( 1, data->var_count, CV_64FC1); cvZero( var_importance ); importance = var_importance->data.db; diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 28d6862e5951..6577508127e8 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -1613,7 +1613,7 @@ points1 and points2 are the same input for findEssentialMat. : } // cametra matrix with both focal lengths = 1, and principal point = (0, 0) - Mat cameraMatrix = Mat::eye(3, 3, CV_64F); + Mat cameraMatrix = Mat::eye(3, 3, CV_64FC1); Mat E, R, t, mask; @@ -1799,7 +1799,7 @@ perspectiveTransform . CV_EXPORTS_W void reprojectImageTo3D( InputArray disparity, OutputArray _3dImage, InputArray Q, bool handleMissingValues = false, - int ddepth = -1 ); + ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Calculates the Sampson Distance between two points. @@ -2310,7 +2310,7 @@ namespace fisheye @param map2 The second output map. */ CV_EXPORTS_W void initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P, - const cv::Size& size, int m1type, OutputArray map1, OutputArray map2); + const cv::Size& size, ElemType m1type, OutputArray map1, OutputArray map2); /** @brief Transforms an image to compensate for fisheye lens distortion. diff --git a/modules/calib3d/perf/perf_affine2d.cpp b/modules/calib3d/perf/perf_affine2d.cpp index d9854fe74de1..a8f661f5ee6d 100644 --- a/modules/calib3d/perf/perf_affine2d.cpp +++ b/modules/calib3d/perf/perf_affine2d.cpp @@ -61,7 +61,7 @@ static Mat rngPartialAffMat() { double ty = rngIn(-2, 2); double aff[2*3] = { std::cos(theta) * scale, -std::sin(theta) * scale, tx, std::sin(theta) * scale, std::cos(theta) * scale, ty }; - return Mat(2, 3, CV_64F, aff).clone(); + return Mat(2, 3, CV_64FC1, aff).clone(); } PERF_TEST_P( EstimateAffine, EstimateAffine2D, ESTIMATE_PARAMS ) @@ -72,7 +72,7 @@ PERF_TEST_P( EstimateAffine, EstimateAffine2D, ESTIMATE_PARAMS ) const int method = get<2>(params); const size_t refining = get<3>(params); - Mat aff(2, 3, CV_64F); + Mat aff(2, 3, CV_64FC1); cv::randu(aff, -2., 2.); // LMEDS can't handle more than 50% outliers (by design) diff --git a/modules/calib3d/perf/perf_pnp.cpp b/modules/calib3d/perf/perf_pnp.cpp index 7c7254a0df3c..7fc21382a7df 100644 --- a/modules/calib3d/perf/perf_pnp.cpp +++ b/modules/calib3d/perf/perf_pnp.cpp @@ -85,7 +85,7 @@ PERF_TEST_P(PointsNum_Algo, solvePnPSmallPoints, warmup(tvec, WARMUP_RNG); // normalize Rodrigues vector - Mat rvec_tmp = Mat::eye(3, 3, CV_32F); + Mat rvec_tmp = Mat::eye(3, 3, CV_32FC1); cv::Rodrigues(rvec, rvec_tmp); cv::Rodrigues(rvec_tmp, rvec); @@ -122,7 +122,7 @@ PERF_TEST_P(PointsNum, DISABLED_SolvePnPRansac, testing::Values(5, 3*9, 7*13)) camera_mat.at(2, 0) = 0.f; camera_mat.at(2, 1) = 0.f; - Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); + Mat dist_coef(1, 8, CV_32FC1, cv::Scalar::all(0)); vector image_vec; diff --git a/modules/calib3d/perf/perf_stereosgbm.cpp b/modules/calib3d/perf/perf_stereosgbm.cpp index 2947938d4029..3b4a38d74e2b 100644 --- a/modules/calib3d/perf/perf_stereosgbm.cpp +++ b/modules/calib3d/perf/perf_stereosgbm.cpp @@ -63,7 +63,7 @@ PERF_TEST_P( TestStereoCorresp, DISABLED_TooLongInDebug_SGBM, Combine(Values(Siz Mat src_left(sz, CV_8UC3); Mat src_right(sz, CV_8UC3); - Mat dst(sz, CV_16S); + Mat dst(sz, CV_16SC1); MakeArtificialExample(rng,src_left,src_right); diff --git a/modules/calib3d/src/ap3p.cpp b/modules/calib3d/src/ap3p.cpp index 7b86834db85a..0adea9dfbb20 100644 --- a/modules/calib3d/src/ap3p.cpp +++ b/modules/calib3d/src/ap3p.cpp @@ -315,8 +315,8 @@ bool ap3p::solve(cv::Mat &R, cv::Mat &tvec, const cv::Mat &opoints, const cv::Ma points[6], points[7], points[8], points[9], points[10], points[11], points[12], points[13], points[14], points[15], points[16], points[17], points[18], points[19]); - cv::Mat(3, 1, CV_64F, translation).copyTo(tvec); - cv::Mat(3, 3, CV_64F, rotation_matrix).copyTo(R); + cv::Mat(3, 1, CV_64FC1, translation).copyTo(tvec); + cv::Mat(3, 3, CV_64FC1, rotation_matrix).copyTo(R); return result; } @@ -342,8 +342,8 @@ int ap3p::solve(std::vector &Rs, std::vector &tvecs, const cv: for (int i = 0; i < solutions; i++) { cv::Mat R, tvec; - cv::Mat(3, 1, CV_64F, translation[i]).copyTo(tvec); - cv::Mat(3, 3, CV_64F, rotation_matrix[i]).copyTo(R); + cv::Mat(3, 1, CV_64FC1, translation[i]).copyTo(tvec); + cv::Mat(3, 3, CV_64FC1, rotation_matrix[i]).copyTo(R); Rs.push_back(R); tvecs.push_back(tvec); diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp index 3180dc881164..907fc07b531b 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -65,7 +65,7 @@ CV_IMPL void cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, Cv CV_Assert( CV_IS_MAT(A) && CV_IS_MAT(B) ); CV_Assert( CV_ARE_TYPES_EQ(A, B) && - (CV_MAT_TYPE(A->type) == CV_32F || CV_MAT_TYPE(A->type) == CV_64F) ); + (CV_MAT_TYPE(A->type) == CV_32FC1 || CV_MAT_TYPE(A->type) == CV_64FC1)); CV_Assert( A->cols == B->rows ); M = A->rows; @@ -85,7 +85,7 @@ CV_IMPL void cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, Cv dABdB->rows == A->rows*B->cols && dABdB->cols == B->rows*B->cols ); } - if( CV_MAT_TYPE(A->type) == CV_32F ) + if (CV_MAT_TYPE(A->type) == CV_32FC1) { for( i = 0; i < M*N; i++ ) { @@ -156,14 +156,14 @@ CV_IMPL void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1, { double _r1[3], _r2[3]; double _R1[9], _d1[9*3], _R2[9], _d2[9*3]; - CvMat r1 = cvMat(3,1,CV_64F,_r1), r2 = cvMat(3,1,CV_64F,_r2); - CvMat R1 = cvMat(3,3,CV_64F,_R1), R2 = cvMat(3,3,CV_64F,_R2); - CvMat dR1dr1 = cvMat(9,3,CV_64F,_d1), dR2dr2 = cvMat(9,3,CV_64F,_d2); + CvMat r1 = cvMat(3,1,CV_64FC1,_r1), r2 = cvMat(3,1,CV_64FC1,_r2); + CvMat R1 = cvMat(3,3,CV_64FC1,_R1), R2 = cvMat(3,3,CV_64FC1,_R2); + CvMat dR1dr1 = cvMat(9,3,CV_64FC1,_d1), dR2dr2 = cvMat(9,3,CV_64FC1,_d2); CV_Assert( CV_IS_MAT(_rvec1) && CV_IS_MAT(_rvec2) ); - CV_Assert( CV_MAT_TYPE(_rvec1->type) == CV_32F || - CV_MAT_TYPE(_rvec1->type) == CV_64F ); + CV_Assert(CV_MAT_TYPE(_rvec1->type) == CV_32FC1 || + CV_MAT_TYPE(_rvec1->type) == CV_64FC1 ); CV_Assert( _rvec1->rows == 3 && _rvec1->cols == 1 && CV_ARE_SIZES_EQ(_rvec1, _rvec2) ); @@ -177,10 +177,10 @@ CV_IMPL void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1, { double _r3[3], _R3[9], _dR3dR1[9*9], _dR3dR2[9*9], _dr3dR3[9*3]; double _W1[9*3], _W2[3*3]; - CvMat r3 = cvMat(3,1,CV_64F,_r3), R3 = cvMat(3,3,CV_64F,_R3); - CvMat dR3dR1 = cvMat(9,9,CV_64F,_dR3dR1), dR3dR2 = cvMat(9,9,CV_64F,_dR3dR2); - CvMat dr3dR3 = cvMat(3,9,CV_64F,_dr3dR3); - CvMat W1 = cvMat(3,9,CV_64F,_W1), W2 = cvMat(3,3,CV_64F,_W2); + CvMat r3 = cvMat(3,1,CV_64FC1,_r3), R3 = cvMat(3,3,CV_64FC1,_R3); + CvMat dR3dR1 = cvMat(9,9,CV_64FC1,_dR3dR1), dR3dR2 = cvMat(9,9,CV_64FC1,_dR3dR2); + CvMat dr3dR3 = cvMat(3,9,CV_64FC1,_dr3dR3); + CvMat W1 = cvMat(3,9,CV_64FC1,_W1), W2 = cvMat(3,3,CV_64FC1,_W2); cvMatMul( &R2, &R1, &R3 ); cvCalcMatMulDeriv( &R2, &R1, &dR3dR2, &dR3dR1 ); @@ -213,11 +213,11 @@ CV_IMPL void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1, if( _tvec3 || dt3dr2 || dt3dt1 ) { double _t1[3], _t2[3], _t3[3], _dxdR2[3*9], _dxdt1[3*3], _W3[3*3]; - CvMat t1 = cvMat(3,1,CV_64F,_t1), t2 = cvMat(3,1,CV_64F,_t2); - CvMat t3 = cvMat(3,1,CV_64F,_t3); - CvMat dxdR2 = cvMat(3, 9, CV_64F, _dxdR2); - CvMat dxdt1 = cvMat(3, 3, CV_64F, _dxdt1); - CvMat W3 = cvMat(3, 3, CV_64F, _W3); + CvMat t1 = cvMat(3,1,CV_64FC1,_t1), t2 = cvMat(3,1,CV_64FC1,_t2); + CvMat t3 = cvMat(3,1,CV_64FC1,_t3); + CvMat dxdR2 = cvMat(3, 9, CV_64FC1, _dxdR2); + CvMat dxdt1 = cvMat(3, 3, CV_64FC1, _dxdt1); + CvMat W3 = cvMat(3, 3, CV_64FC1, _W3); CV_Assert( CV_IS_MAT(_tvec1) && CV_IS_MAT(_tvec2) ); CV_Assert( CV_ARE_SIZES_EQ(_tvec1, _tvec2) && CV_ARE_SIZES_EQ(_tvec1, _rvec1) ); @@ -338,7 +338,7 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian ) // R = cos(theta)*I + (1 - cos(theta))*r*rT + sin(theta)*[r_x] Matx33d R = c*Matx33d::eye() + c1*rrt + s*r_x; - Mat(R).convertTo(cvarrToMat(dst), dst->type); + Mat(R).convertTo(cvarrToMat(dst), CV_MAT_DEPTH(dst->type)); if( jacobian ) { @@ -1305,7 +1305,7 @@ static double cvCalibrateCamera2Internal( const CvMat* objectPoints, Matx33d A; double k[14] = {0}; - CvMat matA = cvMat(3, 3, CV_64F, A.val), _k; + CvMat matA = cvMat(3, 3, CV_64FC1, A.val), _k; int i, nimages, maxPoints = 0, ni = 0, pos, total = 0, nparams, npstep, cn; double aspectRatio = 0.; @@ -1646,7 +1646,7 @@ static double cvCalibrateCamera2Internal( const CvMat* objectPoints, Mat mask = cvarrToMat(solver.mask); int nparams_nz = countNonZero(mask); Mat JtJinv, JtJN; - JtJN.create(nparams_nz, nparams_nz, CV_64F); + JtJN.create(nparams_nz, nparams_nz, CV_64FC1); subMatrix(cvarrToMat(_JtJ), JtJN, mask, mask); completeSymm(JtJN, false); cv::invert(JtJN, JtJinv, DECOMP_SVD); @@ -1770,7 +1770,7 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i double A[2][9], dk[2][14]={{0}}, rlr[9]; CvMat K[2], Dist[2], om_LR, T_LR; - CvMat R_LR = cvMat(3, 3, CV_64F, rlr); + CvMat R_LR = cvMat(3, 3, CV_64FC1, rlr); int i, k, p, ni = 0, ofs, nimages, pointsTotal, maxPoints = 0; int nparams; bool recomputeIntrinsics = false; @@ -1813,8 +1813,8 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i ((_imagePoints1->rows == pointsTotal && _imagePoints1->cols*cn == 2) || (_imagePoints1->rows == 1 && _imagePoints1->cols == pointsTotal && cn == 2)) ); - K[k] = cvMat(3,3,CV_64F,A[k]); - Dist[k] = cvMat(1,14,CV_64F,dk[k]); + K[k] = cvMat(3,3,CV_64FC1,A[k]); + Dist[k] = cvMat(1,14,CV_64FC1,dk[k]); imagePoints[k].reset(cvCreateMat( points->rows, points->cols, CV_64FC(CV_MAT_CN(points->type)))); cvConvert( points, imagePoints[k] ); @@ -1854,10 +1854,10 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i recomputeIntrinsics = (flags & CALIB_FIX_INTRINSIC) == 0; - Mat err( maxPoints*2, 1, CV_64F ); - Mat Je( maxPoints*2, 6, CV_64F ); - Mat J_LR( maxPoints*2, 6, CV_64F ); - Mat Ji( maxPoints*2, NINTRINSIC, CV_64F, Scalar(0) ); + Mat err(maxPoints * 2, 1, CV_64FC1); + Mat Je(maxPoints * 2, 6, CV_64FC1); + Mat J_LR(maxPoints * 2, 6, CV_64FC1); + Mat Ji(maxPoints * 2, NINTRINSIC, CV_64FC1, Scalar(0)); // we optimize for the inter-camera R(3),t(3), then, optionally, // for intrinisic parameters of each camera ((fx,fy,cx,cy,k1,k2,p1,p2) ~ 8 parameters). @@ -1936,9 +1936,9 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i for( k = 0; k < 2; k++ ) { imgpt_i[k] = cvMat(1, ni, CV_64FC2, imagePoints[k]->data.db + ofs*2); - om[k] = cvMat(3, 1, CV_64F, _om[k]); - R[k] = cvMat(3, 3, CV_64F, r[k]); - T[k] = cvMat(3, 1, CV_64F, t[k]); + om[k] = cvMat(3, 1, CV_64FC1, _om[k]); + R[k] = cvMat(3, 3, CV_64FC1, r[k]); + T[k] = cvMat(3, 1, CV_64FC1, t[k]); cvFindExtrinsicCameraParams2( &objpt_i, &imgpt_i[k], &K[k], &Dist[k], &om[k], &T[k] ); cvRodrigues2( &om[k], &R[k] ); @@ -2010,8 +2010,8 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i iparam[17] = dk[k][13]; } - om_LR = cvMat(3, 1, CV_64F, solver.param->data.db); - T_LR = cvMat(3, 1, CV_64F, solver.param->data.db + 3); + om_LR = cvMat(3, 1, CV_64FC1, solver.param->data.db); + T_LR = cvMat(3, 1, CV_64FC1, solver.param->data.db + 3); for(;;) { @@ -2020,12 +2020,12 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i double *_errNorm = 0; double _omR[3], _tR[3]; double _dr3dr1[9], _dr3dr2[9], /*_dt3dr1[9],*/ _dt3dr2[9], _dt3dt1[9], _dt3dt2[9]; - CvMat dr3dr1 = cvMat(3, 3, CV_64F, _dr3dr1); - CvMat dr3dr2 = cvMat(3, 3, CV_64F, _dr3dr2); - //CvMat dt3dr1 = cvMat(3, 3, CV_64F, _dt3dr1); - CvMat dt3dr2 = cvMat(3, 3, CV_64F, _dt3dr2); - CvMat dt3dt1 = cvMat(3, 3, CV_64F, _dt3dt1); - CvMat dt3dt2 = cvMat(3, 3, CV_64F, _dt3dt2); + CvMat dr3dr1 = cvMat(3, 3, CV_64FC1, _dr3dr1); + CvMat dr3dr2 = cvMat(3, 3, CV_64FC1, _dr3dr2); + //CvMat dt3dr1 = cvMat(3, 3, CV_64FC1, _dt3dr1); + CvMat dt3dr2 = cvMat(3, 3, CV_64FC1, _dt3dr2); + CvMat dt3dt1 = cvMat(3, 3, CV_64FC1, _dt3dt1); + CvMat dt3dt2 = cvMat(3, 3, CV_64FC1, _dt3dt2); CvMat om[2], T[2], imgpt_i[2]; if( !solver.updateAlt( param, JtJ, JtErr, _errNorm )) @@ -2033,8 +2033,8 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i reprojErr = 0; cvRodrigues2( &om_LR, &R_LR ); - om[1] = cvMat(3,1,CV_64F,_omR); - T[1] = cvMat(3,1,CV_64F,_tR); + om[1] = cvMat(3,1,CV_64FC1,_omR); + T[1] = cvMat(3,1,CV_64FC1,_tR); if( recomputeIntrinsics ) { @@ -2083,8 +2083,8 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i ni = npoints->data.i[i]; CvMat objpt_i; - om[0] = cvMat(3,1,CV_64F,solver.param->data.db+(i+1)*6); - T[0] = cvMat(3,1,CV_64F,solver.param->data.db+(i+1)*6+3); + om[0] = cvMat(3,1,CV_64FC1,solver.param->data.db+(i+1)*6); + T[0] = cvMat(3,1,CV_64FC1,solver.param->data.db+(i+1)*6+3); if( JtJ || JtErr ) cvComposeRT( &om[0], &T[0], &om_LR, &T_LR, &om[1], &T[1], &dr3dr1, 0, @@ -2209,17 +2209,17 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i t[2], 0, -t[0], -t[1], t[0], 0 }; - CvMat Tx = cvMat(3, 3, CV_64F, tx); + CvMat Tx = cvMat(3, 3, CV_64FC1, tx); double e[9], f[9]; - CvMat E = cvMat(3, 3, CV_64F, e); - CvMat F = cvMat(3, 3, CV_64F, f); + CvMat E = cvMat(3, 3, CV_64FC1, e); + CvMat F = cvMat(3, 3, CV_64FC1, f); cvMatMul( &Tx, &R_LR, &E ); if( matE ) cvConvert( &E, matE ); if( matF ) { double ik[9]; - CvMat iK = cvMat(3, 3, CV_64F, ik); + CvMat iK = cvMat(3, 3, CV_64FC1, ik); cvInvert(&K[1], &iK); cvGEMM( &iK, &E, 1, 0, 0, &E, CV_GEMM_A_T ); cvInvert(&K[0], &iK); @@ -2299,16 +2299,16 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, double _ww[3], _wr[3][3], _z[3] = {0,0,0}, _ri[3][3], _w3[3]; cv::Rect_ inner1, inner2, outer1, outer2; - CvMat om = cvMat(3, 1, CV_64F, _om); - CvMat t = cvMat(3, 1, CV_64F, _t); - CvMat uu = cvMat(3, 1, CV_64F, _uu); - CvMat r_r = cvMat(3, 3, CV_64F, _r_r); - CvMat pp = cvMat(3, 4, CV_64F, _pp); - CvMat ww = cvMat(3, 1, CV_64F, _ww); // temps - CvMat w3 = cvMat(3, 1, CV_64F, _w3); // temps - CvMat wR = cvMat(3, 3, CV_64F, _wr); - CvMat Z = cvMat(3, 1, CV_64F, _z); - CvMat Ri = cvMat(3, 3, CV_64F, _ri); + CvMat om = cvMat(3, 1, CV_64FC1, _om); + CvMat t = cvMat(3, 1, CV_64FC1, _t); + CvMat uu = cvMat(3, 1, CV_64FC1, _uu); + CvMat r_r = cvMat(3, 3, CV_64FC1, _r_r); + CvMat pp = cvMat(3, 4, CV_64FC1, _pp); + CvMat ww = cvMat(3, 1, CV_64FC1, _ww); // temps + CvMat w3 = cvMat(3, 1, CV_64FC1, _w3); // temps + CvMat wR = cvMat(3, 3, CV_64FC1, _wr); + CvMat Z = cvMat(3, 1, CV_64FC1, _z); + CvMat Ri = cvMat(3, 3, CV_64FC1, _ri); double nx = imageSize.width, ny = imageSize.height; int i, k; double nt, nw; @@ -2391,7 +2391,7 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, //Change camera matrix to have cc=[0,0] and fc = fc_new double _a_tmp[3][3]; - CvMat A_tmp = cvMat(3, 3, CV_64F, _a_tmp); + CvMat A_tmp = cvMat(3, 3, CV_64FC1, _a_tmp); _a_tmp[0][0]=fc_new; _a_tmp[1][1]=fc_new; _a_tmp[0][2]=0.0; @@ -2514,7 +2514,7 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, 0, 0, -1./_t[idx], (idx == 0 ? cc_new[0].x - cc_new[1].x : cc_new[0].y - cc_new[1].y)/_t[idx] }; - CvMat Q = cvMat(4, 4, CV_64F, q); + CvMat Q = cvMat(4, 4, CV_64FC1, q); cvConvert( &Q, matQ ); } } @@ -2529,7 +2529,7 @@ void cvGetOptimalNewCameraMatrix( const CvMat* cameraMatrix, const CvMat* distCo newImgSize = newImgSize.width*newImgSize.height != 0 ? newImgSize : imgSize; double M[3][3]; - CvMat matM = cvMat(3, 3, CV_64F, M); + CvMat matM = cvMat(3, 3, CV_64FC1, M); cvConvert(cameraMatrix, &matM); if( centerPrincipalPoint ) @@ -2697,7 +2697,7 @@ CV_IMPL int cvStereoRectifyUncalibrated( 0, 1, -cy, 0, 0, 1 }; - CvMat T = cvMat(3, 3, CV_64F, t); + CvMat T = cvMat(3, 3, CV_64FC1, t); cvMatMul( &T, &E2, &E2 ); int mirror = e2[0] < 0; @@ -2710,7 +2710,7 @@ CV_IMPL int cvStereoRectifyUncalibrated( -beta, alpha, 0, 0, 0, 1 }; - CvMat R = cvMat(3, 3, CV_64F, r); + CvMat R = cvMat(3, 3, CV_64FC1, r); cvMatMul( &R, &T, &T ); cvMatMul( &R, &E2, &E2 ); double invf = fabs(e2[2]) < 1e-6*fabs(e2[0]) ? 0 : -e2[2]/e2[0]; @@ -2720,7 +2720,7 @@ CV_IMPL int cvStereoRectifyUncalibrated( 0, 1, 0, invf, 0, 1 }; - CvMat K = cvMat(3, 3, CV_64F, k); + CvMat K = cvMat(3, 3, CV_64FC1, k); cvMatMul( &K, &T, &H2 ); cvMatMul( &K, &E2, &E2 ); @@ -2748,11 +2748,11 @@ CV_IMPL int cvStereoRectifyUncalibrated( e2[1], e2[1], e2[1], e2[2], e2[2], e2[2], }; - CvMat E2_x = cvMat(3, 3, CV_64F, e2_x); - CvMat E2_111 = cvMat(3, 3, CV_64F, e2_111); + CvMat E2_x = cvMat(3, 3, CV_64FC1, e2_x); + CvMat E2_111 = cvMat(3, 3, CV_64FC1, e2_111); cvMatMulAdd(&E2_x, &F, &E2_111, &H0 ); cvMatMul(&H2, &H0, &H0); - CvMat E1=cvMat(3, 1, CV_64F, V.data.db+6); + CvMat E1=cvMat(3, 1, CV_64FC1, V.data.db+6); cvMatMul(&H0, &E1, &E1); cvPerspectiveTransform( _m1, _m1, &H0 ); @@ -2772,14 +2772,14 @@ CV_IMPL int cvStereoRectifyUncalibrated( 0, 1, 0, 0, 0, 1 }; - CvMat Ha = cvMat(3, 3, CV_64F, ha); + CvMat Ha = cvMat(3, 3, CV_64FC1, ha); cvMatMul( &Ha, &H0, &H1 ); cvPerspectiveTransform( _m1, _m1, &Ha ); if( mirror ) { double mm[] = { -1, 0, cx*2, 0, -1, cy*2, 0, 0, 1 }; - CvMat MM = cvMat(3, 3, CV_64F, mm); + CvMat MM = cvMat(3, 3, CV_64FC1, mm); cvMatMul( &MM, &H1, &H1 ); cvMatMul( &MM, &H2, &H2 ); } @@ -2793,7 +2793,7 @@ CV_IMPL int cvStereoRectifyUncalibrated( void cv::reprojectImageTo3D( InputArray _disparity, OutputArray __3dImage, InputArray _Qmat, - bool handleMissingValues, int dtype ) + bool handleMissingValues, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); @@ -2804,15 +2804,11 @@ void cv::reprojectImageTo3D( InputArray _disparity, stype == CV_32SC1 || stype == CV_32FC1 ); CV_Assert( Q.size() == Size(4,4) ); - if( dtype < 0 ) - dtype = CV_32FC3; - else - { - dtype = CV_MAKETYPE(CV_MAT_DEPTH(dtype), 3); - CV_Assert( dtype == CV_16SC3 || dtype == CV_32SC3 || dtype == CV_32FC3 ); - } + if (ddepth == CV_DEPTH_AUTO) + ddepth = CV_32F; + CV_Assert(ddepth == CV_16S || ddepth == CV_32S || ddepth == CV_32F); - __3dImage.create(disparity.size(), CV_MAKETYPE(dtype, 3)); + __3dImage.create(disparity.size(), CV_MAKETYPE(ddepth, 3)); Mat _3dImage = __3dImage.getMat(); const float bigZ = 10000.f; @@ -2859,7 +2855,7 @@ void cv::reprojectImageTo3D( InputArray _disparity, else sptr = disparity.ptr(y); - if( dtype == CV_32FC3 ) + if (ddepth == CV_32F) dptr = _3dImage.ptr(y); for( x = 0; x < cols; x++) @@ -2873,7 +2869,7 @@ void cv::reprojectImageTo3D( InputArray _disparity, dptr[x][2] = bigZ; } - if( dtype == CV_16SC3 ) + if (ddepth == CV_16S) { Vec3s* dptr0 = _3dImage.ptr(y); for( x = 0; x < cols; x++ ) @@ -2881,7 +2877,7 @@ void cv::reprojectImageTo3D( InputArray _disparity, dptr0[x] = dptr[x]; } } - else if( dtype == CV_32SC3 ) + else if (ddepth == CV_32S) { Vec3i* dptr0 = _3dImage.ptr(y); for( x = 0; x < cols; x++ ) @@ -2901,10 +2897,10 @@ void cvReprojectImageTo3D( const CvArr* disparityImage, cv::Mat _3dimg = cv::cvarrToMat(_3dImage); cv::Mat mq = cv::cvarrToMat(matQ); CV_Assert( disp.size() == _3dimg.size() ); - int dtype = _3dimg.type(); - CV_Assert( dtype == CV_16SC3 || dtype == CV_32SC3 || dtype == CV_32FC3 ); + ElemDepth ddepth = _3dimg.depth(); + CV_Assert(ddepth == CV_16S || ddepth == CV_32S || ddepth == CV_32F); - cv::reprojectImageTo3D(disp, _3dimg, mq, handleMissingValues != 0, dtype ); + cv::reprojectImageTo3D(disp, _3dimg, mq, handleMissingValues != 0, ddepth); } @@ -2914,9 +2910,9 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ, CvPoint3D64f *eulerAngles) { double matM[3][3], matR[3][3], matQ[3][3]; - CvMat M = cvMat(3, 3, CV_64F, matM); - CvMat R = cvMat(3, 3, CV_64F, matR); - CvMat Q = cvMat(3, 3, CV_64F, matQ); + CvMat M = cvMat(3, 3, CV_64FC1, matM); + CvMat R = cvMat(3, 3, CV_64FC1, matR); + CvMat Q = cvMat(3, 3, CV_64FC1, matQ); double z, c, s; /* Validate parameters. */ @@ -2939,7 +2935,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ, s *= z; double _Qx[3][3] = { {1, 0, 0}, {0, c, s}, {0, -s, c} }; - CvMat Qx = cvMat(3, 3, CV_64F, _Qx); + CvMat Qx = cvMat(3, 3, CV_64FC1, _Qx); cvMatMul(&M, &Qx, &R); assert(fabs(matR[2][1]) < FLT_EPSILON); @@ -2958,7 +2954,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ, s *= z; double _Qy[3][3] = { {c, 0, -s}, {0, 1, 0}, {s, 0, c} }; - CvMat Qy = cvMat(3, 3, CV_64F, _Qy); + CvMat Qy = cvMat(3, 3, CV_64FC1, _Qy); cvMatMul(&R, &Qy, &M); assert(fabs(matM[2][0]) < FLT_EPSILON); @@ -2978,7 +2974,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ, s *= z; double _Qz[3][3] = { {c, s, 0}, {-s, c, 0}, {0, 0, 1} }; - CvMat Qz = cvMat(3, 3, CV_64F, _Qz); + CvMat Qz = cvMat(3, 3, CV_64FC1, _Qz); cvMatMul(&M, &Qz, &R); assert(fabs(matR[1][0]) < FLT_EPSILON); @@ -3081,9 +3077,9 @@ cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr, CvMat *rotMatrZ, CvPoint3D64f *eulerAngles) { double tmpProjMatrData[16], tmpMatrixDData[16], tmpMatrixVData[16]; - CvMat tmpProjMatr = cvMat(4, 4, CV_64F, tmpProjMatrData); - CvMat tmpMatrixD = cvMat(4, 4, CV_64F, tmpMatrixDData); - CvMat tmpMatrixV = cvMat(4, 4, CV_64F, tmpMatrixVData); + CvMat tmpProjMatr = cvMat(4, 4, CV_64FC1, tmpProjMatrData); + CvMat tmpMatrixD = cvMat(4, 4, CV_64FC1, tmpMatrixDData); + CvMat tmpMatrixV = cvMat(4, 4, CV_64FC1, tmpMatrixVData); CvMat tmpMatrixM; /* Validate parameters. */ @@ -3152,7 +3148,7 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints, total += ni; } - npoints.create(1, (int)nimages, CV_32S); + npoints.create(1, (int)nimages, CV_32SC1); objPtMat.create(1, (int)total, CV_32FC3); imgPtMat1.create(1, (int)total, CV_32FC2); Point2f* imgPtData2 = 0; @@ -3191,15 +3187,15 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints, } } -static Mat prepareCameraMatrix(Mat& cameraMatrix0, int rtype) +static Mat prepareCameraMatrix(Mat& cameraMatrix0, ElemType rtype) { Mat cameraMatrix = Mat::eye(3, 3, rtype); if( cameraMatrix0.size() == cameraMatrix.size() ) - cameraMatrix0.convertTo(cameraMatrix, rtype); + cameraMatrix0.convertTo(cameraMatrix, CV_MAT_DEPTH(rtype)); return cameraMatrix; } -static Mat prepareDistCoeffs(Mat& distCoeffs0, int rtype, int outputSize = 14) +static Mat prepareDistCoeffs(Mat& distCoeffs0, ElemType rtype, int outputSize = 14) { CV_Assert((int)distCoeffs0.total() <= outputSize); Mat distCoeffs = Mat::zeros(distCoeffs0.cols == 1 ? Size(1, outputSize) : Size(outputSize, 1), rtype); @@ -3215,7 +3211,7 @@ static Mat prepareDistCoeffs(Mat& distCoeffs0, int rtype, int outputSize = 14) distCoeffs0.size() == Size(14, 1) ) { Mat dstCoeffs(distCoeffs, Rect(0, 0, distCoeffs0.cols, distCoeffs0.rows)); - distCoeffs0.convertTo(dstCoeffs, rtype); + distCoeffs0.convertTo(dstCoeffs, CV_MAT_DEPTH(rtype)); } return distCoeffs; } @@ -3229,12 +3225,12 @@ void cv::Rodrigues(InputArray _src, OutputArray _dst, OutputArray _jacobian) Mat src = _src.getMat(); bool v2m = src.cols == 1 || src.rows == 1; - _dst.create(3, v2m ? 3 : 1, src.depth()); + _dst.create(3, v2m ? 3 : 1, CV_MAKETYPE(src.depth(), 1)); Mat dst = _dst.getMat(); CvMat _csrc = cvMat(src), _cdst = cvMat(dst), _cjacobian; if( _jacobian.needed() ) { - _jacobian.create(v2m ? Size(9, 3) : Size(3, 9), src.depth()); + _jacobian.create(v2m ? Size(9, 3) : Size(3, 9), CV_MAKETYPE(src.depth(), 1)); _cjacobian = cvMat(_jacobian.getMat()); } bool ok = cvRodrigues2(&_csrc, &_cdst, _jacobian.needed() ? &_cjacobian : 0) > 0; @@ -3266,7 +3262,7 @@ void cv::composeRT( InputArray _rvec1, InputArray _tvec1, { Mat rvec1 = _rvec1.getMat(), tvec1 = _tvec1.getMat(); Mat rvec2 = _rvec2.getMat(), tvec2 = _tvec2.getMat(); - int rtype = rvec1.type(); + ElemType rtype = rvec1.type(); _rvec3.create(rvec1.size(), rtype); _tvec3.create(tvec1.size(), rtype); Mat rvec3 = _rvec3.getMat(), tvec3 = _tvec3.getMat(); @@ -3323,7 +3319,7 @@ void cv::projectPoints( InputArray _opoints, CvMat c_rvec = cvMat(rvec), c_tvec = cvMat(tvec); double dc0buf[5]={0}; - Mat dc0(5,1,CV_64F,dc0buf); + Mat dc0(5,1,CV_64FC1,dc0buf); Mat distCoeffs = _distCoeffs.getMat(); if( distCoeffs.empty() ) distCoeffs = dc0; @@ -3333,7 +3329,7 @@ void cv::projectPoints( InputArray _opoints, Mat jacobian; if( _jacobian.needed() ) { - _jacobian.create(npoints*2, 3+3+2+2+ndistCoeffs, CV_64F); + _jacobian.create(npoints*2, 3+3+2+2+ndistCoeffs, CV_64FC1); jacobian = _jacobian.getMat(); pdpdrot = &(dpdrot = cvMat(jacobian.colRange(0, 3))); pdpdt = &(dpdt = cvMat(jacobian.colRange(3, 6))); @@ -3352,7 +3348,7 @@ cv::Mat cv::initCameraMatrix2D( InputArrayOfArrays objectPoints, { CV_INSTRUMENT_REGION(); - Mat objPt, imgPt, npoints, cameraMatrix(3, 3, CV_64F); + Mat objPt, imgPt, npoints, cameraMatrix(3, 3, CV_64FC1); collectCalibrationData( objectPoints, imagePoints, noArray(), objPt, imgPt, 0, npoints ); CvMat _objPt = cvMat(objPt), _imgPt = cvMat(imgPt), _npoints = cvMat(npoints), _cameraMatrix = cvMat(cameraMatrix); @@ -3384,7 +3380,7 @@ double cv::calibrateCamera(InputArrayOfArrays _objectPoints, { CV_INSTRUMENT_REGION(); - int rtype = CV_64F; + ElemType rtype = CV_64FC1; Mat cameraMatrix = _cameraMatrix.getMat(); cameraMatrix = prepareCameraMatrix(cameraMatrix, rtype); Mat distCoeffs = _distCoeffs.getMat(); @@ -3411,7 +3407,7 @@ double cv::calibrateCamera(InputArrayOfArrays _objectPoints, _rvecs.create(nimages, 1, CV_64FC3); if(rvecs_mat_vec) - rvecM.create(nimages, 3, CV_64F); + rvecM.create(nimages, 3, CV_64FC1); else rvecM = _rvecs.getMat(); } @@ -3421,7 +3417,7 @@ double cv::calibrateCamera(InputArrayOfArrays _objectPoints, _tvecs.create(nimages, 1, CV_64FC3); if(tvecs_mat_vec) - tvecM.create(nimages, 3, CV_64F); + tvecM.create(nimages, 3, CV_64FC1); else tvecM = _tvecs.getMat(); } @@ -3429,12 +3425,12 @@ double cv::calibrateCamera(InputArrayOfArrays _objectPoints, bool stddev_any_needed = stddev_needed || stddev_ext_needed; if( stddev_any_needed ) { - stdDeviationsM.create(nimages*6 + CV_CALIB_NINTRINSIC, 1, CV_64F); + stdDeviationsM.create(nimages * 6 + CV_CALIB_NINTRINSIC, 1, CV_64FC1); } if( errors_needed ) { - _perViewErrors.create(nimages, 1, CV_64F); + _perViewErrors.create(nimages, 1, CV_64FC1); errorsM = _perViewErrors.getMat(); } @@ -3453,7 +3449,7 @@ double cv::calibrateCamera(InputArrayOfArrays _objectPoints, if( stddev_needed ) { - stdDeviationsIntrinsics.create(CV_CALIB_NINTRINSIC, 1, CV_64F); + stdDeviationsIntrinsics.create(CV_CALIB_NINTRINSIC, 1, CV_64FC1); Mat stdDeviationsIntrinsicsMat = stdDeviationsIntrinsics.getMat(); std::memcpy(stdDeviationsIntrinsicsMat.ptr(), stdDeviationsM.ptr(), CV_CALIB_NINTRINSIC*sizeof(double)); @@ -3461,7 +3457,7 @@ double cv::calibrateCamera(InputArrayOfArrays _objectPoints, if ( stddev_ext_needed ) { - stdDeviationsExtrinsics.create(nimages*6, 1, CV_64F); + stdDeviationsExtrinsics.create(nimages * 6, 1, CV_64FC1); Mat stdDeviationsExtrinsicsMat = stdDeviationsExtrinsics.getMat(); std::memcpy(stdDeviationsExtrinsicsMat.ptr(), stdDeviationsM.ptr() + CV_CALIB_NINTRINSIC*sizeof(double), @@ -3473,13 +3469,13 @@ double cv::calibrateCamera(InputArrayOfArrays _objectPoints, { if( rvecs_needed && rvecs_mat_vec) { - _rvecs.create(3, 1, CV_64F, i, true); + _rvecs.create(3, 1, CV_64FC1, i, true); Mat rv = _rvecs.getMat(i); memcpy(rv.ptr(), rvecM.ptr(i), 3*sizeof(double)); } if( tvecs_needed && tvecs_mat_vec) { - _tvecs.create(3, 1, CV_64F, i, true); + _tvecs.create(3, 1, CV_64FC1, i, true); Mat tv = _tvecs.getMat(i); memcpy(tv.ptr(), tvecM.ptr(i), 3*sizeof(double)); } @@ -3560,7 +3556,7 @@ double cv::stereoCalibrate( InputArrayOfArrays _objectPoints, OutputArray _perViewErrors, int flags , TermCriteria criteria) { - int rtype = CV_64F; + ElemType rtype = CV_64FC1; Mat cameraMatrix1 = _cameraMatrix1.getMat(); Mat cameraMatrix2 = _cameraMatrix2.getMat(); Mat distCoeffs1 = _distCoeffs1.getMat(); @@ -3613,7 +3609,7 @@ double cv::stereoCalibrate( InputArrayOfArrays _objectPoints, if( errors_needed ) { int nimages = int(_objectPoints.total()); - _perViewErrors.create(nimages, 2, CV_64F); + _perViewErrors.create(nimages, 2, CV_64FC1); matErr_ = _perViewErrors.getMat(); c_matErr = cvMat(matErr_); } @@ -3650,7 +3646,7 @@ void cv::stereoRectify( InputArray _cameraMatrix1, InputArray _distCoeffs1, CvMat c_distCoeffs2 = cvMat(distCoeffs2); CvMat c_R = cvMat(Rmat), c_T = cvMat(Tmat); - int rtype = CV_64F; + ElemType rtype = CV_64FC1; _Rmat1.create(3, 3, rtype); _Rmat2.create(3, 3, rtype); _Pmat1.create(3, 4, rtype); @@ -3678,7 +3674,7 @@ bool cv::stereoRectifyUncalibrated( InputArray _points1, InputArray _points2, { CV_INSTRUMENT_REGION(); - int rtype = CV_64F; + ElemType rtype = CV_64FC1; _Hmat1.create(3, 3, rtype); _Hmat2.create(3, 3, rtype); Mat F = _Fmat.getMat(); @@ -3755,7 +3751,7 @@ void cv::decomposeProjectionMatrix( InputArray _projMatrix, OutputArray _cameraM CV_INSTRUMENT_REGION(); Mat projMatrix = _projMatrix.getMat(); - int type = projMatrix.type(); + ElemType type = projMatrix.type(); _cameraMatrix.create(3, 3, type); _rotMatrix.create(3, 3, type); _transVect.create(4, 1, type); @@ -3783,7 +3779,7 @@ void cv::decomposeProjectionMatrix( InputArray _projMatrix, OutputArray _cameraM if( _eulerAngles.needed() ) { - _eulerAngles.create(3, 1, CV_64F, -1, true); + _eulerAngles.create(3, 1, CV_64FC1, -1, true); p_eulerAngles = _eulerAngles.getMat().ptr(); } @@ -3868,8 +3864,8 @@ float cv::rectify3Collinear( InputArray _cameraMatrix1, InputArray _distCoeffs1, Mat R12 = _Rmat12.getMat(), R13 = _Rmat13.getMat(), T12 = _Tmat12.getMat(), T13 = _Tmat13.getMat(); - _Rmat3.create(3, 3, CV_64F); - _Pmat3.create(3, 4, CV_64F); + _Rmat3.create(3, 3, CV_64FC1); + _Pmat3.create(3, 4, CV_64FC1); Mat P1 = _Pmat1.getMat(), P2 = _Pmat2.getMat(); Mat R3 = _Rmat3.getMat(), P3 = _Pmat3.getMat(); diff --git a/modules/calib3d/src/chessboard.cpp b/modules/calib3d/src/chessboard.cpp index 08e47d1fe89f..5fce5965253a 100644 --- a/modules/calib3d/src/chessboard.cpp +++ b/modules/calib3d/src/chessboard.cpp @@ -187,7 +187,7 @@ void polyfit(const Mat& src_x, const Mat& src_y, Mat& dst, int order) } cv::Mat w; solve(A,srcY,w,DECOMP_SVD); - w.convertTo(dst,std::max(std::max(src_x.depth(), src_y.depth()), CV_32F)); + w.convertTo(dst, CV_MAX_DEPTH(src_x.depth(), src_y.depth(), CV_32F)); } float calcSignedDistance(const cv::Vec2f &n,const cv::Point2f &a,const cv::Point2f &pt) @@ -1196,7 +1196,7 @@ void Chessboard::Board::draw(cv::InputArray m,cv::OutputArray out,cv::InputArray double maxVal,minVal; cv::minMaxLoc(image, &minVal, &maxVal); double scale = 255.0/(maxVal-minVal); - image.convertTo(image,CV_8UC1,scale,-scale*minVal); + image.convertTo(image,CV_8U,scale,-scale*minVal); cv::applyColorMap(image,image,cv::COLORMAP_JET); } diff --git a/modules/calib3d/src/chessboard.hpp b/modules/calib3d/src/chessboard.hpp index 7453355ee582..2460a18e9d6f 100644 --- a/modules/calib3d/src/chessboard.hpp +++ b/modules/calib3d/src/chessboard.hpp @@ -75,7 +75,7 @@ class FastX : public cv::Feature2D std::vector &keypoints)const; // define pure virtual methods virtual int descriptorSize()const override{return 0;}; - virtual int descriptorType()const override{return 0;}; + virtual ElemType descriptorType() const override { return CV_8UC1; }; virtual void operator()( cv::InputArray image, cv::InputArray mask, std::vector& keypoints, cv::OutputArray descriptors, bool useProvidedKeypoints=false )const { descriptors.clear(); @@ -723,7 +723,7 @@ class Chessboard: public cv::Feature2D // define pure virtual methods virtual int descriptorSize()const override{return 0;}; - virtual int descriptorType()const override{return 0;}; + virtual ElemType descriptorType() const override { return CV_8UC1; }; virtual void operator()( cv::InputArray image, cv::InputArray mask, std::vector& keypoints, cv::OutputArray descriptors, bool useProvidedKeypoints=false )const { descriptors.clear(); diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index 0b647951de30..fc04c07eee85 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -409,12 +409,12 @@ void CirclesGridClusterFinder::parsePatternPoints(const std::vector else idealPt = Point2f(j*squareSize, i*squareSize); - Mat query(1, 2, CV_32F, &idealPt); + Mat query(1, 2, CV_32FC1, &idealPt); const int knn = 1; int indicesbuf[knn] = {0}; float distsbuf[knn] = {0.f}; - Mat indices(1, knn, CV_32S, &indicesbuf); - Mat dists(1, knn, CV_32F, &distsbuf); + Mat indices(1, knn, CV_32SC1, &indicesbuf); + Mat dists(1, knn, CV_32FC1, &distsbuf); flannIndex.knnSearch(query, indices, dists, knn, flann::SearchParams()); centers.push_back(patternPoints.at(indicesbuf[0])); diff --git a/modules/calib3d/src/compat_ptsetreg.cpp b/modules/calib3d/src/compat_ptsetreg.cpp index 6e67000b3bd1..0958f12859b8 100644 --- a/modules/calib3d/src/compat_ptsetreg.cpp +++ b/modules/calib3d/src/compat_ptsetreg.cpp @@ -360,7 +360,7 @@ CV_IMPL int cvFindHomography( const CvMat* _src, const CvMat* _dst, CvMat* __H, Hz.setTo(cv::Scalar::all(0)); return 0; } - H0.convertTo(H, H.type()); + H0.convertTo(H, H.depth()); return 1; } @@ -389,7 +389,7 @@ CV_IMPL int cvFindFundamentalMat( const CvMat* points1, const CvMat* points2, CV_Assert( FM0.cols == 3 && FM0.rows % 3 == 0 && FM.cols == 3 && FM.rows % 3 == 0 && FM.channels() == 1 ); cv::Mat FM1 = FM.rowRange(0, MIN(FM0.rows, FM.rows)); - FM0.rowRange(0, FM1.rows).convertTo(FM1, FM1.type()); + FM0.rowRange(0, FM1.rows).convertTo(FM1, FM1.depth()); return FM1.rows / 3; } @@ -417,14 +417,14 @@ CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID, else { transpose( lines, lines ); - lines.convertTo( lines0, lines0.type() ); + lines.convertTo( lines0, lines0.depth() ); } } else { CV_Assert( lines.size() == lines0.size() ); if( lines.data != lines0.data ) - lines.convertTo(lines0, lines0.type()); + lines.convertTo(lines0, lines0.depth()); } } @@ -459,13 +459,13 @@ CV_IMPL void cvConvertPointsHomogeneous( const CvMat* _src, CvMat* _dst ) else { transpose( dst, dst ); - dst.convertTo( dst0, dst0.type() ); + dst.convertTo(dst0, dst0.depth()); } } else { CV_Assert( dst.size() == dst0.size() ); if( dst.data != dst0.data ) - dst.convertTo(dst0, dst0.type()); + dst.convertTo(dst0, dst0.depth()); } } diff --git a/modules/calib3d/src/dls.cpp b/modules/calib3d/src/dls.cpp index 93c409b03035..ca9bcd159bd8 100644 --- a/modules/calib3d/src/dls.cpp +++ b/modules/calib3d/src/dls.cpp @@ -27,9 +27,9 @@ dls::dls(const cv::Mat& opoints, const cv::Mat& ipoints) { N = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F)); - p = cv::Mat(3, N, CV_64F); - z = cv::Mat(3, N, CV_64F); - mn = cv::Mat::zeros(3, 1, CV_64F); + p = cv::Mat(3, N, CV_64FC1); + z = cv::Mat(3, N, CV_64FC1); + mn = cv::Mat::zeros(3, 1, CV_64FC1); cost__ = 9999; @@ -101,8 +101,8 @@ bool dls::compute_pose(cv::Mat& R, cv::Mat& t) void dls::run_kernel(const cv::Mat& pp) { - cv::Mat Mtilde(27, 27, CV_64F); - cv::Mat D = cv::Mat::zeros(9, 9, CV_64F); + cv::Mat Mtilde(27, 27, CV_64FC1); + cv::Mat D = cv::Mat::zeros(9, 9, CV_64FC1); build_coeff_matrix(pp, Mtilde, D); cv::Mat eigenval_r, eigenval_i, eigenvec_r, eigenvec_i; @@ -115,14 +115,14 @@ void dls::run_kernel(const cv::Mat& pp) // extract the optimal solutions from the eigen decomposition of the // Multiplication matrix - cv::Mat sols = cv::Mat::zeros(3, 27, CV_64F); + cv::Mat sols = cv::Mat::zeros(3, 27, CV_64FC1); std::vector cost; int count = 0; for (int k = 0; k < 27; ++k) { // V(:,k) = V(:,k)/V(1,k); cv::Mat V_kA = eigenvec_r.col(k); // 27x1 - cv::Mat V_kB = cv::Mat(1, 1, z.depth(), V_kA.at(0)); // 1x1 + cv::Mat V_kB = cv::Mat(1, 1, CV_MAKETYPE(z.depth(), 1), V_kA.at(0)); // 1x1 cv::Mat V_k; cv::solve(V_kB.t(), V_kA.t(), V_k); // A/B = B'\A' cv::Mat( V_k.t()).copyTo( eigenvec_r.col(k) ); @@ -147,7 +147,7 @@ void dls::run_kernel(const cv::Mat& pp) { // sols(:,i) = stmp; - cv::Mat stmp_mat(3, 1, CV_64F, &stmp); + cv::Mat stmp_mat(3, 1, CV_64FC1, &stmp); stmp_mat.copyTo( sols.col(count) ); @@ -177,11 +177,11 @@ void dls::run_kernel(const cv::Mat& pp) cv::Mat C_est_j = cayley2rotbar(sols_j).mul(sols_mult); C_est.push_back( C_est_j ); - cv::Mat A2 = cv::Mat::zeros(3, 3, CV_64F); - cv::Mat b2 = cv::Mat::zeros(3, 1, CV_64F); + cv::Mat A2 = cv::Mat::zeros(3, 3, CV_64FC1); + cv::Mat b2 = cv::Mat::zeros(3, 1, CV_64FC1); for (int i = 0; i < N; ++i) { - cv::Mat eye = cv::Mat::eye(3, 3, CV_64F); + cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1); cv::Mat z_mul = z.col(i)*z.col(i).t(); A2 += eye - z_mul; @@ -216,17 +216,17 @@ void dls::run_kernel(const cv::Mat& pp) void dls::build_coeff_matrix(const cv::Mat& pp, cv::Mat& Mtilde, cv::Mat& D) { CV_Assert(!pp.empty() && N > 0); - cv::Mat eye = cv::Mat::eye(3, 3, CV_64F); + cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1); // build coeff matrix // An intermediate matrix, the inverse of what is called "H" in the paper // (see eq. 25) - cv::Mat H = cv::Mat::zeros(3, 3, CV_64F); - cv::Mat A = cv::Mat::zeros(3, 9, CV_64F); - cv::Mat pp_i(3, 1, CV_64F); + cv::Mat H = cv::Mat::zeros(3, 3, CV_64FC1); + cv::Mat A = cv::Mat::zeros(3, 9, CV_64FC1); + cv::Mat pp_i(3, 1, CV_64FC1); - cv::Mat z_i(3, 1, CV_64F); + cv::Mat z_i(3, 1, CV_64FC1); for (int i = 0; i < N; ++i) { z.col(i).copyTo(z_i); @@ -239,7 +239,7 @@ void dls::build_coeff_matrix(const cv::Mat& pp, cv::Mat& Mtilde, cv::Mat& D) cv::solve(H, A, A, cv::DECOMP_NORMAL); H.release(); - cv::Mat ppi_A(3, 1, CV_64F); + cv::Mat ppi_A(3, 1, CV_64FC1); for (int i = 0; i < N; ++i) { z.col(i).copyTo(z_i); @@ -279,7 +279,7 @@ void dls::compute_eigenvec(const cv::Mat& Mtilde, cv::Mat& eigenval_real, cv::Ma #ifdef HAVE_EIGEN Eigen::MatrixXd Mtilde_eig, zeros_eig; cv::cv2eigen(Mtilde, Mtilde_eig); - cv::cv2eigen(cv::Mat::zeros(27, 27, CV_64F), zeros_eig); + cv::cv2eigen(cv::Mat::zeros(27, 27, CV_64FC1), zeros_eig); Eigen::MatrixXcd Mtilde_eig_cmplx(27, 27); Mtilde_eig_cmplx.real() = Mtilde_eig; @@ -396,7 +396,7 @@ void dls::fill_coeff(const cv::Mat * D_mat) cv::Mat dls::LeftMultVec(const cv::Mat& v) { - cv::Mat mat_ = cv::Mat::zeros(3, 9, CV_64F); + cv::Mat mat_ = cv::Mat::zeros(3, 9, CV_64FC1); for (int i = 0; i < 3; ++i) { @@ -412,7 +412,7 @@ cv::Mat dls::cayley_LS_M(const std::vector& a, const std::vector // TODO: input matrix pointer // TODO: shift coefficients one position to left - cv::Mat M = cv::Mat::zeros(120, 120, CV_64F); + cv::Mat M = cv::Mat::zeros(120, 120, CV_64FC1); M.at(0,0)=u[1]; M.at(0,35)=a[1]; M.at(0,83)=b[1]; M.at(0,118)=c[1]; M.at(1,0)=u[4]; M.at(1,1)=u[1]; M.at(1,34)=a[1]; M.at(1,35)=a[10]; M.at(1,54)=b[1]; M.at(1,83)=b[10]; M.at(1,99)=c[1]; M.at(1,118)=c[10]; @@ -577,18 +577,18 @@ cv::Mat dls::Hessian(const double s[]) Hs3[14]=0; Hs3[15]=3*s[2]*s[2]; Hs3[16]=s[0]*s[1]; Hs3[17]=0; Hs3[18]=s[0]*s[0]; Hs3[19]=0; // fill Hessian matrix - cv::Mat H(3, 3, CV_64F); - H.at(0,0) = cv::Mat(cv::Mat(f1coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs1)).at(0,0); - H.at(0,1) = cv::Mat(cv::Mat(f1coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs2)).at(0,0); - H.at(0,2) = cv::Mat(cv::Mat(f1coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs3)).at(0,0); + cv::Mat H(3, 3, CV_64FC1); + H.at(0,0) = cv::Mat(cv::Mat(f1coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs1)).at(0,0); + H.at(0,1) = cv::Mat(cv::Mat(f1coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs2)).at(0,0); + H.at(0,2) = cv::Mat(cv::Mat(f1coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs3)).at(0,0); - H.at(1,0) = cv::Mat(cv::Mat(f2coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs1)).at(0,0); - H.at(1,1) = cv::Mat(cv::Mat(f2coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs2)).at(0,0); - H.at(1,2) = cv::Mat(cv::Mat(f2coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs3)).at(0,0); + H.at(1,0) = cv::Mat(cv::Mat(f2coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs1)).at(0,0); + H.at(1,1) = cv::Mat(cv::Mat(f2coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs2)).at(0,0); + H.at(1,2) = cv::Mat(cv::Mat(f2coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs3)).at(0,0); - H.at(2,0) = cv::Mat(cv::Mat(f3coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs1)).at(0,0); - H.at(2,1) = cv::Mat(cv::Mat(f3coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs2)).at(0,0); - H.at(2,2) = cv::Mat(cv::Mat(f3coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64F, &Hs3)).at(0,0); + H.at(2,0) = cv::Mat(cv::Mat(f3coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs1)).at(0,0); + H.at(2,1) = cv::Mat(cv::Mat(f3coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs2)).at(0,0); + H.at(2,2) = cv::Mat(cv::Mat(f3coeff).rowRange(1,21).t()*cv::Mat(20, 1, CV_64FC1, &Hs3)).at(0,0); return H; } @@ -597,7 +597,7 @@ cv::Mat dls::cayley2rotbar(const cv::Mat& s) { double s_mul1 = cv::Mat(s.t()*s).at(0,0); cv::Mat s_mul2 = s*s.t(); - cv::Mat eye = cv::Mat::eye(3, 3, CV_64F); + cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1); return cv::Mat( eye.mul(1.-s_mul1) + skewsymm(&s).mul(2.) + s_mul2.mul(2.) ).t(); } @@ -636,7 +636,7 @@ cv::Mat dls::rotz(const double t) cv::Mat dls::mean(const cv::Mat& M) { - cv::Mat m = cv::Mat::zeros(3, 1, CV_64F); + cv::Mat m = cv::Mat::zeros(3, 1, CV_64FC1); for (int i = 0; i < M.cols; ++i) m += M.col(i); return m.mul(1./(double)M.cols); } diff --git a/modules/calib3d/src/dls.h b/modules/calib3d/src/dls.h index f03bee49d740..60db2d062252 100644 --- a/modules/calib3d/src/dls.h +++ b/modules/calib3d/src/dls.h @@ -744,7 +744,7 @@ class EigenvalueDecomposition { // Convert the given input matrix to double. Is there any way to // prevent allocating the temporary memory? Only used for copying // into working memory and deallocated after. - src.getMat().convertTo(tmp, CV_64FC1); + src.getMat().convertTo(tmp, CV_64F); // Get dimension of the matrix. this->n = tmp.cols; // Allocate the matrix data to work on. diff --git a/modules/calib3d/src/epnp.cpp b/modules/calib3d/src/epnp.cpp index a173b8808717..ca0f5e96c1ae 100644 --- a/modules/calib3d/src/epnp.cpp +++ b/modules/calib3d/src/epnp.cpp @@ -61,9 +61,9 @@ void epnp::choose_control_points(void) CvMat * PW0 = cvCreateMat(number_of_correspondences, 3, CV_64F); double pw0tpw0[3 * 3], dc[3] = {0}, uct[3 * 3] = {0}; - CvMat PW0tPW0 = cvMat(3, 3, CV_64F, pw0tpw0); - CvMat DC = cvMat(3, 1, CV_64F, dc); - CvMat UCt = cvMat(3, 3, CV_64F, uct); + CvMat PW0tPW0 = cvMat(3, 3, CV_64FC1, pw0tpw0); + CvMat DC = cvMat(3, 1, CV_64FC1, dc); + CvMat UCt = cvMat(3, 3, CV_64FC1, uct); for(int i = 0; i < number_of_correspondences; i++) for(int j = 0; j < 3; j++) @@ -84,8 +84,8 @@ void epnp::choose_control_points(void) void epnp::compute_barycentric_coordinates(void) { double cc[3 * 3], cc_inv[3 * 3]; - CvMat CC = cvMat(3, 3, CV_64F, cc); - CvMat CC_inv = cvMat(3, 3, CV_64F, cc_inv); + CvMat CC = cvMat(3, 3, CV_64FC1, cc); + CvMat CC_inv = cvMat(3, 3, CV_64FC1, cc_inv); for(int i = 0; i < 3; i++) for(int j = 1; j < 4; j++) @@ -158,17 +158,17 @@ void epnp::compute_pose(Mat& R, Mat& t) fill_M(M, 2 * i, &alphas[0] + 4 * i, us[2 * i], us[2 * i + 1]); double mtm[12 * 12], d[12], ut[12 * 12]; - CvMat MtM = cvMat(12, 12, CV_64F, mtm); - CvMat D = cvMat(12, 1, CV_64F, d); - CvMat Ut = cvMat(12, 12, CV_64F, ut); + CvMat MtM = cvMat(12, 12, CV_64FC1, mtm); + CvMat D = cvMat(12, 1, CV_64FC1, d); + CvMat Ut = cvMat(12, 12, CV_64FC1, ut); cvMulTransposed(M, &MtM, 1); cvSVD(&MtM, &D, &Ut, 0, CV_SVD_MODIFY_A | CV_SVD_U_T); cvReleaseMat(&M); double l_6x10[6 * 10], rho[6]; - CvMat L_6x10 = cvMat(6, 10, CV_64F, l_6x10); - CvMat Rho = cvMat(6, 1, CV_64F, rho); + CvMat L_6x10 = cvMat(6, 10, CV_64FC1, l_6x10); + CvMat Rho = cvMat(6, 1, CV_64FC1, rho); compute_L_6x10(ut, l_6x10); compute_rho(rho); @@ -192,8 +192,8 @@ void epnp::compute_pose(Mat& R, Mat& t) if (rep_errors[2] < rep_errors[1]) N = 2; if (rep_errors[3] < rep_errors[N]) N = 3; - Mat(3, 1, CV_64F, ts[N]).copyTo(t); - Mat(3, 3, CV_64F, Rs[N]).copyTo(R); + Mat(3, 1, CV_64FC1, ts[N]).copyTo(t); + Mat(3, 3, CV_64FC1, Rs[N]).copyTo(R); } void epnp::copy_R_and_t(const double R_src[3][3], const double t_src[3], @@ -241,10 +241,10 @@ void epnp::estimate_R_and_t(double R[3][3], double t[3]) } double abt[3 * 3] = {0}, abt_d[3], abt_u[3 * 3], abt_v[3 * 3]; - CvMat ABt = cvMat(3, 3, CV_64F, abt); - CvMat ABt_D = cvMat(3, 1, CV_64F, abt_d); - CvMat ABt_U = cvMat(3, 3, CV_64F, abt_u); - CvMat ABt_V = cvMat(3, 3, CV_64F, abt_v); + CvMat ABt = cvMat(3, 3, CV_64FC1, abt); + CvMat ABt_D = cvMat(3, 1, CV_64FC1, abt_d); + CvMat ABt_U = cvMat(3, 3, CV_64FC1, abt_u); + CvMat ABt_V = cvMat(3, 3, CV_64FC1, abt_v); cvSetZero(&ABt); for(int i = 0; i < number_of_correspondences; i++) { @@ -333,8 +333,8 @@ void epnp::find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho, double * betas) { double l_6x4[6 * 4], b4[4] = {0}; - CvMat L_6x4 = cvMat(6, 4, CV_64F, l_6x4); - CvMat B4 = cvMat(4, 1, CV_64F, b4); + CvMat L_6x4 = cvMat(6, 4, CV_64FC1, l_6x4); + CvMat B4 = cvMat(4, 1, CV_64FC1, b4); for(int i = 0; i < 6; i++) { cvmSet(&L_6x4, i, 0, cvmGet(L_6x10, i, 0)); @@ -365,8 +365,8 @@ void epnp::find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho, double * betas) { double l_6x3[6 * 3], b3[3] = {0}; - CvMat L_6x3 = cvMat(6, 3, CV_64F, l_6x3); - CvMat B3 = cvMat(3, 1, CV_64F, b3); + CvMat L_6x3 = cvMat(6, 3, CV_64FC1, l_6x3); + CvMat B3 = cvMat(3, 1, CV_64FC1, b3); for(int i = 0; i < 6; i++) { cvmSet(&L_6x3, i, 0, cvmGet(L_6x10, i, 0)); @@ -397,8 +397,8 @@ void epnp::find_betas_approx_3(const CvMat * L_6x10, const CvMat * Rho, double * betas) { double l_6x5[6 * 5], b5[5] = {0}; - CvMat L_6x5 = cvMat(6, 5, CV_64F, l_6x5); - CvMat B5 = cvMat(5, 1, CV_64F, b5); + CvMat L_6x5 = cvMat(6, 5, CV_64FC1, l_6x5); + CvMat B5 = cvMat(5, 1, CV_64FC1, b5); for(int i = 0; i < 6; i++) { cvmSet(&L_6x5, i, 0, cvmGet(L_6x10, i, 0)); @@ -507,9 +507,9 @@ void epnp::gauss_newton(const CvMat * L_6x10, const CvMat * Rho, double betas[4] const int iterations_number = 5; double a[6*4], b[6], x[4] = {0}; - CvMat A = cvMat(6, 4, CV_64F, a); - CvMat B = cvMat(6, 1, CV_64F, b); - CvMat X = cvMat(4, 1, CV_64F, x); + CvMat A = cvMat(6, 4, CV_64FC1, a); + CvMat B = cvMat(6, 1, CV_64FC1, b); + CvMat X = cvMat(4, 1, CV_64FC1, x); for(int k = 0; k < iterations_number; k++) { diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp index fdd8aad18ff4..f2619570e0b7 100644 --- a/modules/calib3d/src/fisheye.cpp +++ b/modules/calib3d/src/fisheye.cpp @@ -85,7 +85,7 @@ void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints Vec3d om = _rvec.depth() == CV_32F ? (Vec3d)*_rvec.getMat().ptr() : *_rvec.getMat().ptr(); Vec3d T = _tvec.depth() == CV_32F ? (Vec3d)*_tvec.getMat().ptr() : *_tvec.getMat().ptr(); - CV_Assert(_K.size() == Size(3,3) && (_K.type() == CV_32F || _K.type() == CV_64F) && _D.type() == _K.type() && _D.total() == 4); + CV_Assert(_K.size() == Size(3, 3) && (_K.type() == CV_32FC1 || _K.type() == CV_64FC1) && _D.type() == _K.type() && _D.total() == 4); cv::Vec2d f, c; if (_K.depth() == CV_32F) @@ -108,7 +108,7 @@ void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints if (jacobian.needed()) { int nvars = 2 + 2 + 1 + 4 + 3 + 3; // f, c, alpha, k, om, T, - jacobian.create(2*(int)n, nvars, CV_64F); + jacobian.create(2 * (int)n, nvars, CV_64FC1); Jn = jacobian.getMat().ptr(0); } @@ -262,7 +262,7 @@ void cv::fisheye::distortPoints(InputArray undistorted, OutputArray distorted, I distorted.create(undistorted.size(), undistorted.type()); size_t n = undistorted.total(); - CV_Assert(K.size() == Size(3,3) && (K.type() == CV_32F || K.type() == CV_64F) && D.total() == 4); + CV_Assert(K.size() == Size(3, 3) && (K.type() == CV_32FC1 || K.type() == CV_64FC1) && D.total() == 4); cv::Vec2d f, c; if (K.depth() == CV_32F) @@ -423,13 +423,13 @@ void cv::fisheye::undistortPoints( InputArray distorted, OutputArray undistorted /// cv::fisheye::undistortPoints void cv::fisheye::initUndistortRectifyMap( InputArray K, InputArray D, InputArray R, InputArray P, - const cv::Size& size, int m1type, OutputArray map1, OutputArray map2 ) + const cv::Size& size, ElemType m1type, OutputArray map1, OutputArray map2 ) { CV_INSTRUMENT_REGION(); - CV_Assert( m1type == CV_16SC2 || m1type == CV_32F || m1type <=0 ); - map1.create( size, m1type <= 0 ? CV_16SC2 : m1type ); - map2.create( size, map1.type() == CV_16SC2 ? CV_16UC1 : CV_32F ); + CV_Assert(m1type == CV_16SC2 || m1type == CV_32FC1 || m1type == CV_TYPE_AUTO); + map1.create( size, m1type <= CV_8UC1 ? CV_16SC2 : m1type ); + map2.create( size, map1.type() == CV_16SC2 ? CV_16UC1 : CV_32FC1 ); CV_Assert((K.depth() == CV_32F || K.depth() == CV_64F) && (D.depth() == CV_32F || D.depth() == CV_64F)); CV_Assert((P.empty() || P.depth() == CV_32F || P.depth() == CV_64F) && (R.empty() || R.depth() == CV_32F || R.depth() == CV_64F)); @@ -612,7 +612,7 @@ void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, Input Mat(Matx33d(new_f[0], 0, new_c[0], 0, new_f[1], new_c[1], - 0, 0, 1)).convertTo(P, P.empty() ? K.type() : P.type()); + 0, 0, 1)).convertTo(P, P.empty() ? K.depth() : P.depth()); } @@ -664,9 +664,9 @@ void cv::fisheye::stereoRectify( InputArray K1, InputArray D1, InputArray K2, In // apply to both views Matx33d ri1 = wr * r_r.t(); - Mat(ri1, false).convertTo(R1, R1.empty() ? CV_64F : R1.type()); + Mat(ri1, false).convertTo(R1, R1.empty() ? CV_64F : R1.depth()); Matx33d ri2 = wr * r_r; - Mat(ri2, false).convertTo(R2, R2.empty() ? CV_64F : R2.type()); + Mat(ri2, false).convertTo(R2, R2.empty() ? CV_64F : R2.depth()); Vec3d tnew = ri2 * tvec; // calculate projection/camera matrices. these contain the relevant rectified image internal params (fx, fy=fx, cx, cy) @@ -687,11 +687,11 @@ void cv::fisheye::stereoRectify( InputArray K1, InputArray D1, InputArray K2, In Mat(Matx34d(fc_new, 0, cc_new[0].x, 0, 0, fc_new, cc_new[0].y, 0, - 0, 0, 1, 0), false).convertTo(P1, P1.empty() ? CV_64F : P1.type()); + 0, 0, 1, 0), false).convertTo(P1, P1.empty() ? CV_64F : P1.depth()); Mat(Matx34d(fc_new, 0, cc_new[1].x, tnew[0]*fc_new, // baseline * focal length;, 0, fc_new, cc_new[1].y, 0, - 0, 0, 1, 0), false).convertTo(P2, P2.empty() ? CV_64F : P2.type()); + 0, 0, 1, 0), false).convertTo(P2, P2.empty() ? CV_64F : P2.depth()); if (Q.needed()) Mat(Matx44d(1, 0, 0, -cc_new[0].x, @@ -747,8 +747,8 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray Vec4d _D; if (flags & CALIB_USE_INTRINSIC_GUESS) { - K.getMat().convertTo(_K, CV_64FC1); - D.getMat().convertTo(_D, CV_64FC1); + K.getMat().convertTo(_K, CV_64F); + D.getMat().convertTo(_D, CV_64F); finalParam.Init(Vec2d(_K(0,0), _K(1, 1)), Vec2d(_K(0,2), _K(1, 2)), Vec4d(flags & CALIB_FIX_K1 ? 0 : _D[0], @@ -810,8 +810,8 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray 0, finalParam.f[1], finalParam.c[1], 0, 0, 1); - if (K.needed()) cv::Mat(_K).convertTo(K, K.empty() ? CV_64FC1 : K.type()); - if (D.needed()) cv::Mat(finalParam.k).convertTo(D, D.empty() ? CV_64FC1 : D.type()); + if (K.needed()) cv::Mat(_K).convertTo(K, K.empty() ? CV_64F : K.depth()); + if (D.needed()) cv::Mat(finalParam.k).convertTo(D, D.empty() ? CV_64F : D.depth()); if (rvecs.isMatVector()) { int N = (int)objectPoints.total(); @@ -824,16 +824,16 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray for(int i = 0; i < N; i++ ) { - rvecs.create(3, 1, CV_64F, i, true); - tvecs.create(3, 1, CV_64F, i, true); + rvecs.create(3, 1, CV_64FC1, i, true); + tvecs.create(3, 1, CV_64FC1, i, true); memcpy(rvecs.getMat(i).ptr(), omc[i].val, sizeof(Vec3d)); memcpy(tvecs.getMat(i).ptr(), Tc[i].val, sizeof(Vec3d)); } } else { - if (rvecs.needed()) cv::Mat(omc).convertTo(rvecs, rvecs.empty() ? CV_64FC3 : rvecs.type()); - if (tvecs.needed()) cv::Mat(Tc).convertTo(tvecs, tvecs.empty() ? CV_64FC3 : tvecs.type()); + if (rvecs.needed()) cv::Mat(omc).convertTo(rvecs, rvecs.empty() ? CV_64F : rvecs.depth()); + if (tvecs.needed()) cv::Mat(Tc).convertTo(tvecs, tvecs.empty() ? CV_64F : tvecs.depth()); } return rms; @@ -880,10 +880,10 @@ double cv::fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO Matx33d _K1, _K2; Vec4d _D1, _D2; - if (!K1.empty()) K1.getMat().convertTo(_K1, CV_64FC1); - if (!D1.empty()) D1.getMat().convertTo(_D1, CV_64FC1); - if (!K2.empty()) K2.getMat().convertTo(_K2, CV_64FC1); - if (!D2.empty()) D2.getMat().convertTo(_D2, CV_64FC1); + if (!K1.empty()) K1.getMat().convertTo(_K1, CV_64F); + if (!D1.empty()) D1.getMat().convertTo(_D1, CV_64F); + if (!K2.empty()) K2.getMat().convertTo(_K2, CV_64F); + if (!D2.empty()) D2.getMat().convertTo(_D2, CV_64F); std::vector rvecs1(n_images), tvecs1(n_images), rvecs2(n_images), tvecs2(n_images); @@ -1070,12 +1070,12 @@ double cv::fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO Mat _R; Rodrigues(omcur, _R); - if (K1.needed()) cv::Mat(_K1).convertTo(K1, K1.empty() ? CV_64FC1 : K1.type()); - if (K2.needed()) cv::Mat(_K2).convertTo(K2, K2.empty() ? CV_64FC1 : K2.type()); - if (D1.needed()) cv::Mat(intrinsicLeft.k).convertTo(D1, D1.empty() ? CV_64FC1 : D1.type()); - if (D2.needed()) cv::Mat(intrinsicRight.k).convertTo(D2, D2.empty() ? CV_64FC1 : D2.type()); - if (R.needed()) _R.convertTo(R, R.empty() ? CV_64FC1 : R.type()); - if (T.needed()) cv::Mat(Tcur).convertTo(T, T.empty() ? CV_64FC1 : T.type()); + if (K1.needed()) cv::Mat(_K1).convertTo(K1, K1.empty() ? CV_64F : K1.depth()); + if (K2.needed()) cv::Mat(_K2).convertTo(K2, K2.empty() ? CV_64F : K2.depth()); + if (D1.needed()) cv::Mat(intrinsicLeft.k).convertTo(D1, D1.empty() ? CV_64F : D1.depth()); + if (D2.needed()) cv::Mat(intrinsicRight.k).convertTo(D2, D2.empty() ? CV_64F : D2.depth()); + if (R.needed()) _R.convertTo(R, R.empty() ? CV_64F : R.depth()); + if (T.needed()) cv::Mat(Tcur).convertTo(T, T.empty() ? CV_64F : T.depth()); return rms; } @@ -1086,7 +1086,7 @@ void subMatrix(const Mat& src, Mat& dst, const std::vector& cols, const s CV_Assert(src.channels() == 1); int nonzeros_cols = cv::countNonZero(cols); - Mat tmp(src.rows, nonzeros_cols, CV_64F); + Mat tmp(src.rows, nonzeros_cols, CV_64FC1); for (int i = 0, j = 0; i < (int)cols.size(); i++) { @@ -1097,7 +1097,7 @@ void subMatrix(const Mat& src, Mat& dst, const std::vector& cols, const s } int nonzeros_rows = cv::countNonZero(rows); - dst.create(nonzeros_rows, nonzeros_cols, CV_64F); + dst.create(nonzeros_rows, nonzeros_cols, CV_64FC1); for (int i = 0, j = 0; i < (int)rows.size(); i++) { if (rows[i]) @@ -1404,8 +1404,8 @@ void cv::internal::CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArr Mat omckk, Tckk, JJ_kk; Mat image, object; - objectPoints.getMat(image_idx).convertTo(object, CV_64FC3); - imagePoints.getMat (image_idx).convertTo(image, CV_64FC2); + objectPoints.getMat(image_idx).convertTo(object, CV_64F); + imagePoints.getMat (image_idx).convertTo(image, CV_64F); bool imT = image.rows < image.cols; bool obT = object.rows < object.cols; @@ -1442,8 +1442,8 @@ void cv::internal::ComputeJacobians(InputArrayOfArrays objectPoints, InputArrayO for (int image_idx = 0; image_idx < n; ++image_idx) { Mat image, object; - objectPoints.getMat(image_idx).convertTo(object, CV_64FC3); - imagePoints.getMat (image_idx).convertTo(image, CV_64FC2); + objectPoints.getMat(image_idx).convertTo(object, CV_64F); + imagePoints.getMat (image_idx).convertTo(image, CV_64F); bool imT = image.rows < image.cols; Mat om(omc.getMat().col(image_idx)), T(Tc.getMat().col(image_idx)); @@ -1507,8 +1507,8 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA for (int image_idx = 0; image_idx < (int)objectPoints.total(); ++image_idx) { Mat image, object; - objectPoints.getMat(image_idx).convertTo(object, CV_64FC3); - imagePoints.getMat (image_idx).convertTo(image, CV_64FC2); + objectPoints.getMat(image_idx).convertTo(object, CV_64F); + imagePoints.getMat (image_idx).convertTo(image, CV_64F); bool imT = image.rows < image.cols; diff --git a/modules/calib3d/src/five-point.cpp b/modules/calib3d/src/five-point.cpp index 0cefe8df4c9c..65fdcf86115b 100644 --- a/modules/calib3d/src/five-point.cpp +++ b/modules/calib3d/src/five-point.cpp @@ -44,7 +44,7 @@ class EMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback Mat Q2 = q2.reshape(1, (int)q2.total()); int n = Q1.rows; - Mat Q(n, 9, CV_64F); + Mat Q(n, 9, CV_64FC1); Q.col(0) = Q1.col(0).mul( Q2.col(0) ); Q.col(1) = Q1.col(1).mul( Q2.col(0) ); Q.col(2) = Q2.col(0) * 1.0; @@ -59,7 +59,7 @@ class EMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback SVD::compute(Q, W, U, Vt, SVD::MODIFY_A | SVD::FULL_UV); Mat EE = Mat(Vt.t()).colRange(5, 9) * 1.0; - Mat A(10, 20, CV_64F); + Mat A(10, 20, CV_64FC1); EE = EE.t(); getCoeffMat(EE.ptr(), A.ptr()); EE = EE.t(); @@ -67,13 +67,13 @@ class EMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback A = A.colRange(0, 10).inv() * A.colRange(10, 20); double b[3 * 13]; - Mat B(3, 13, CV_64F, b); + Mat B(3, 13, CV_64FC1, b); for (int i = 0; i < 3; i++) { Mat arow1 = A.row(i * 2 + 4) * 1.0; Mat arow2 = A.row(i * 2 + 5) * 1.0; - Mat row1(1, 13, CV_64F, Scalar(0.0)); - Mat row2(1, 13, CV_64F, Scalar(0.0)); + Mat row1(1, 13, CV_64FC1, Scalar(0.0)); + Mat row2(1, 13, CV_64FC1, Scalar(0.0)); row1.colRange(1, 4) = arow1.colRange(0, 3) * 1.0; row1.colRange(5, 8) = arow1.colRange(3, 6) * 1.0; @@ -87,7 +87,7 @@ class EMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback } double c[11]; - Mat coeffs(1, 11, CV_64F, c); + Mat coeffs(1, 11, CV_64FC1, c); c[10] = (b[0]*b[17]*b[34]+b[26]*b[4]*b[21]-b[26]*b[17]*b[8]-b[13]*b[4]*b[34]-b[0]*b[21]*b[30]+b[13]*b[30]*b[8]); c[9] = (b[26]*b[4]*b[22]+b[14]*b[30]*b[8]+b[13]*b[31]*b[8]+b[1]*b[17]*b[34]-b[13]*b[5]*b[34]+b[26]*b[5]*b[21]-b[0]*b[21]*b[31]-b[26]*b[17]*b[9]-b[1]*b[21]*b[30]+b[27]*b[4]*b[21]+b[0]*b[17]*b[35]-b[0]*b[22]*b[30]+b[13]*b[30]*b[9]+b[0]*b[18]*b[34]-b[27]*b[17]*b[8]-b[14]*b[4]*b[34]-b[13]*b[4]*b[35]-b[26]*b[18]*b[8]); c[8] = (b[14]*b[30]*b[9]+b[14]*b[31]*b[8]+b[13]*b[31]*b[9]-b[13]*b[4]*b[36]-b[13]*b[5]*b[35]+b[15]*b[30]*b[8]-b[13]*b[6]*b[34]+b[13]*b[30]*b[10]+b[13]*b[32]*b[8]-b[14]*b[4]*b[35]-b[14]*b[5]*b[34]+b[26]*b[4]*b[23]+b[26]*b[5]*b[22]+b[26]*b[6]*b[21]-b[26]*b[17]*b[10]-b[15]*b[4]*b[34]-b[26]*b[18]*b[9]-b[26]*b[19]*b[8]+b[27]*b[4]*b[22]+b[27]*b[5]*b[21]-b[27]*b[17]*b[9]-b[27]*b[18]*b[8]-b[1]*b[21]*b[31]-b[0]*b[23]*b[30]-b[0]*b[21]*b[32]+b[28]*b[4]*b[21]-b[28]*b[17]*b[8]+b[2]*b[17]*b[34]+b[0]*b[18]*b[35]-b[0]*b[22]*b[31]+b[0]*b[17]*b[36]+b[0]*b[19]*b[34]-b[1]*b[22]*b[30]+b[1]*b[18]*b[34]+b[1]*b[17]*b[35]-b[2]*b[21]*b[30]); @@ -106,7 +106,7 @@ class EMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback std::vector xs, ys, zs; int count = 0; - Mat ematrix(10*3, 3, CV_64F); + Mat ematrix(10*3, 3, CV_64FC1); double* e = ematrix.ptr(); for (size_t i = 0; i < roots.size(); i++) { @@ -125,7 +125,7 @@ class EMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback bz[j][2] = br[8] * z4 + br[9] * z3 + br[10] * z2 + br[11] * z1 + br[12]; } - Mat Bz(3, 3, CV_64F, bz); + Mat Bz(3, 3, CV_64FC1, bz); cv::Mat xy1; SVD::solveZ(Bz, xy1); @@ -378,7 +378,7 @@ class EMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback int n = X1.checkVector(2); Matx33d E(model.ptr()); - _err.create(n, 1, CV_32F); + _err.create(n, 1, CV_32FC1); Mat err = _err.getMat(); for (int i = 0; i < n; i++) @@ -579,7 +579,7 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, } if (_mask.empty() && _mask.needed()) { - _mask.create(mask1.size(), CV_8U); + _mask.create(mask1.size(), CV_8UC1); } CV_Assert(_R.needed() && _t.needed()); @@ -654,7 +654,7 @@ void cv::decomposeEssentialMat( InputArray _E, OutputArray _R1, OutputArray _R2, if (determinant(Vt) < 0) Vt *= -1.; Mat W = (Mat_(3, 3) << 0, 1, 0, -1, 0, 0, 0, 0, 1); - W.convertTo(W, E.type()); + W.convertTo(W, E.depth()); Mat R1, R2, t; R1 = U * W * Vt; diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp index e0693497ad16..16bb24b8f06b 100644 --- a/modules/calib3d/src/fundam.cpp +++ b/modules/calib3d/src/fundam.cpp @@ -121,11 +121,11 @@ class HomographyEstimatorCallback CV_FINAL : public PointSetRegistrator::Callbac const Point2f* m = m2.ptr(); double LtL[9][9], W[9][1], V[9][9]; - Mat _LtL( 9, 9, CV_64F, &LtL[0][0] ); - Mat matW( 9, 1, CV_64F, W ); - Mat matV( 9, 9, CV_64F, V ); - Mat _H0( 3, 3, CV_64F, V[8] ); - Mat _Htemp( 3, 3, CV_64F, V[7] ); + Mat _LtL(9, 9, CV_64FC1, &LtL[0][0]); + Mat matW(9, 1, CV_64FC1, W); + Mat matV(9, 9, CV_64FC1, V); + Mat _H0(3, 3, CV_64FC1, V[8]); + Mat _Htemp(3, 3, CV_64FC1, V[7]); Point2d cM(0,0), cm(0,0), sM(0,0), sm(0,0); for( i = 0; i < count; i++ ) @@ -175,7 +175,7 @@ class HomographyEstimatorCallback CV_FINAL : public PointSetRegistrator::Callbac eigen( _LtL, matW, matV ); _Htemp = _invHnorm*_H0; _H0 = _Htemp*_Hnorm2; - _H0.convertTo(_model, _H0.type(), 1./_H0.at(2,2) ); + _H0.convertTo(_model, _H0.depth(), 1./_H0.at(2,2) ); return 1; } @@ -197,7 +197,7 @@ class HomographyEstimatorCallback CV_FINAL : public PointSetRegistrator::Callbac const double* H = model.ptr(); float Hf[] = { (float)H[0], (float)H[1], (float)H[2], (float)H[3], (float)H[4], (float)H[5], (float)H[6], (float)H[7] }; - _err.create(count, 1, CV_32F); + _err.create(count, 1, CV_32FC1); float* err = _err.getMat().ptr(); for( i = 0; i < count; i++ ) @@ -224,11 +224,11 @@ class HomographyRefineCallback CV_FINAL : public LMSolver::Callback { int i, count = src.checkVector(2); Mat param = _param.getMat(); - _err.create(count*2, 1, CV_64F); + _err.create(count * 2, 1, CV_64FC1); Mat err = _err.getMat(), J; if( _Jac.needed()) { - _Jac.create(count*2, param.rows, CV_64F); + _Jac.create(count * 2, param.rows, CV_64FC1); J = _Jac.getMat(); CV_Assert( J.isContinuous() && J.cols == 8 ); } @@ -288,7 +288,7 @@ static bool createAndRunRHORegistrator(double confidence, Mat tmpH = Mat(3, 3, CV_32FC1); /* Create output mask. */ - tempMask = Mat(npoints, 1, CV_8U); + tempMask = Mat(npoints, 1, CV_8UC1); /** * Make use of the RHO estimator API. @@ -334,7 +334,7 @@ static bool createAndRunRHORegistrator(double confidence, (float*)tmpH.data); /* Convert float homography to double precision. */ - tmpH.convertTo(_H, CV_64FC1); + tmpH.convertTo(_H, CV_64F); /* Maps non-zero mask elements to 1, for the sake of the test case. */ for(int k=0;krunKernel(src, dst, H) > 0; } else if( method == RANSAC ) @@ -410,7 +410,7 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2, dst = dst1; if( method == RANSAC || method == LMEDS ) cb->runKernel( src, dst, H ); - Mat H8(8, 1, CV_64F, H.ptr()); + Mat H8(8, 1, CV_64FC1, H.ptr()); createLMSolver(makePtr(src, dst), 10)->run(H8); } } @@ -424,7 +424,7 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2, { H.release(); if(_mask.needed() ) { - tempMask = Mat::zeros(npoints >= 0 ? npoints : 0, 1, CV_8U); + tempMask = Mat::zeros(npoints >= 0 ? npoints : 0, 1, CV_8UC1); tempMask.copyTo(_mask); } } @@ -479,12 +479,12 @@ static int run7Point( const Mat& _m1, const Mat& _m2, Mat& _fmatrix ) double a[7*9], w[7], u[9*9], v[9*9], c[4], r[3] = {0}; double* f1, *f2; double t0, t1, t2; - Mat A( 7, 9, CV_64F, a ); - Mat U( 7, 9, CV_64F, u ); - Mat Vt( 9, 9, CV_64F, v ); - Mat W( 7, 1, CV_64F, w ); - Mat coeffs( 1, 4, CV_64F, c ); - Mat roots( 1, 3, CV_64F, r ); + Mat A(7, 9, CV_64FC1, a); + Mat U(7, 9, CV_64FC1, u); + Mat Vt(9, 9, CV_64FC1, v); + Mat W(7, 1, CV_64FC1, w); + Mat coeffs(1, 4, CV_64FC1, c); + Mat roots(1, 3, CV_64FC1, r); const Point2f* m1 = _m1.ptr(); const Point2f* m2 = _m2.ptr(); double* fmatrix = _fmatrix.ptr(); @@ -714,7 +714,7 @@ class FMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback double f[9*3]; Mat m1 = _m1.getMat(), m2 = _m2.getMat(); int count = m1.checkVector(2); - Mat F(count == 7 ? 9 : 3, 3, CV_64F, f); + Mat F(count == 7 ? 9 : 3, 3, CV_64FC1, f); int n = count == 7 ? run7Point(m1, m2, F) : run8Point(m1, m2, F); if( n == 0 ) @@ -732,7 +732,7 @@ class FMEstimatorCallback CV_FINAL : public PointSetRegistrator::Callback const Point2f* m1 = __m1.ptr(); const Point2f* m2 = __m2.ptr(); const double* F = __model.ptr(); - _err.create(count, 1, CV_32F); + _err.create(count, 1, CV_32FC1); float* err = _err.getMat().ptr(); for( i = 0; i < count; i++ ) @@ -774,10 +774,10 @@ cv::Mat cv::findFundamentalMat( InputArray _points1, InputArray _points2, { Mat& p = i == 1 ? points1 : points2; Mat& m = i == 1 ? m1 : m2; - npoints = p.checkVector(2, -1, false); + npoints = p.checkVector(2, CV_DEPTH_AUTO, false); if( npoints < 0 ) { - npoints = p.checkVector(3, -1, false); + npoints = p.checkVector(3, CV_DEPTH_AUTO, false); if( npoints < 0 ) CV_Error(Error::StsBadArg, "The input arrays should be 2D or 3D point sets"); if( npoints == 0 ) @@ -800,7 +800,7 @@ cv::Mat cv::findFundamentalMat( InputArray _points1, InputArray _points2, result = cb->runKernel(m1, m2, F); if( _mask.needed() ) { - _mask.create(npoints, 1, CV_8U, -1, true); + _mask.create(npoints, 1, CV_8UC1, -1, true); Mat mask = _mask.getMat(); CV_Assert( (mask.cols == 1 || mask.rows == 1) && (int)mask.total() == npoints ); mask.setTo(Scalar::all(1)); @@ -839,7 +839,7 @@ void cv::computeCorrespondEpilines( InputArray _points, int whichImage, CV_INSTRUMENT_REGION(); double f[9] = {0}; - Mat tempF(3, 3, CV_64F, f); + Mat tempF(3, 3, CV_64FC1, f); Mat points = _points.getMat(), F = _Fmat.getMat(); if( !points.isContinuous() ) @@ -863,7 +863,7 @@ void cv::computeCorrespondEpilines( InputArray _points, int whichImage, if( whichImage == 2 ) transpose(tempF, tempF); - int ltype = CV_MAKETYPE(MAX(depth, CV_32F), 3); + ElemType ltype = CV_MAKETYPE(CV_MAX_DEPTH(depth, CV_32F), 3); _lines.create(npoints, 1, ltype); Mat lines = _lines.getMat(); if( !lines.isContinuous() ) @@ -916,7 +916,9 @@ void cv::convertPointsFromHomogeneous( InputArray _src, OutputArray _dst ) Mat src = _src.getMat(); if( !src.isContinuous() ) src = src.clone(); - int i, npoints = src.checkVector(3), depth = src.depth(), cn = 3; + int i, npoints = src.checkVector(3); + ElemDepth depth = src.depth(); + int cn = 3; if( npoints < 0 ) { npoints = src.checkVector(4); @@ -925,7 +927,7 @@ void cv::convertPointsFromHomogeneous( InputArray _src, OutputArray _dst ) } CV_Assert( npoints >= 0 && (depth == CV_32S || depth == CV_32F || depth == CV_64F)); - int dtype = CV_MAKETYPE(depth <= CV_32F ? CV_32F : CV_64F, cn-1); + ElemType dtype = CV_MAKETYPE(depth <= CV_32F ? CV_32F : CV_64F, cn-1); _dst.create(npoints, 1, dtype); Mat dst = _dst.getMat(); if( !dst.isContinuous() ) @@ -1026,7 +1028,7 @@ void cv::convertPointsToHomogeneous( InputArray _src, OutputArray _dst ) } CV_Assert( npoints >= 0 && (depth == CV_32S || depth == CV_32F || depth == CV_64F)); - int dtype = CV_MAKETYPE(depth, cn+1); + ElemType dtype = CV_MAKETYPE(depth, cn + 1); _dst.create(npoints, 1, dtype); Mat dst = _dst.getMat(); if( !dst.isContinuous() ) @@ -1110,7 +1112,7 @@ double cv::sampsonDistance(InputArray _pt1, InputArray _pt2, InputArray _F) { CV_INSTRUMENT_REGION(); - CV_Assert(_pt1.type() == CV_64F && _pt2.type() == CV_64F && _F.type() == CV_64F); + CV_Assert(_pt1.type() == CV_64FC1 && _pt2.type() == CV_64FC1 && _F.type() == CV_64FC1); CV_DbgAssert(_pt1.rows() == 3 && _F.size() == Size(3, 3) && _pt1.rows() == _pt2.rows()); Mat pt1(_pt1.getMat()); diff --git a/modules/calib3d/src/homography_decomp.cpp b/modules/calib3d/src/homography_decomp.cpp index fea8882c5ae9..454bf634d6cf 100644 --- a/modules/calib3d/src/homography_decomp.cpp +++ b/modules/calib3d/src/homography_decomp.cpp @@ -465,24 +465,24 @@ int decomposeHomographyMat(InputArray _H, hdecomp->decomposeHomography(H, K, motions); int nsols = static_cast(motions.size()); - int depth = CV_64F; //double precision matrices used in CameraMotion struct + ElemDepth depth = CV_64F; //double precision matrices used in CameraMotion struct if (_rotations.needed()) { - _rotations.create(nsols, 1, depth); + _rotations.create(nsols, 1, CV_MAKETYPE(depth, 1)); for (int k = 0; k < nsols; ++k ) { _rotations.getMatRef(k) = Mat(motions[k].R); } } if (_translations.needed()) { - _translations.create(nsols, 1, depth); + _translations.create(nsols, 1, CV_MAKETYPE(depth, 1)); for (int k = 0; k < nsols; ++k ) { _translations.getMatRef(k) = Mat(motions[k].t); } } if (_normals.needed()) { - _normals.create(nsols, 1, depth); + _normals.create(nsols, 1, CV_MAKETYPE(depth, 1)); for (int k = 0; k < nsols; ++k ) { _normals.getMatRef(k) = Mat(motions[k].n); } @@ -499,7 +499,7 @@ void filterHomographyDecompByVisibleRefpoints(InputArrayOfArrays _rotations, InputArray _pointsMask) { CV_Assert(_beforeRectifiedPoints.type() == CV_32FC2 && _afterRectifiedPoints.type() == CV_32FC2); - CV_Assert(_pointsMask.empty() || _pointsMask.type() == CV_8U); + CV_Assert(_pointsMask.empty() || _pointsMask.type() == CV_8UC1); Mat beforeRectifiedPoints = _beforeRectifiedPoints.getMat(); Mat afterRectifiedPoints = _afterRectifiedPoints.getMat(); diff --git a/modules/calib3d/src/levmarq.cpp b/modules/calib3d/src/levmarq.cpp index 0bec8680c605..511252a82018 100644 --- a/modules/calib3d/src/levmarq.cpp +++ b/modules/calib3d/src/levmarq.cpp @@ -92,9 +92,9 @@ class LMSolverImpl CV_FINAL : public LMSolver int run(InputOutputArray _param0) const CV_OVERRIDE { Mat param0 = _param0.getMat(), x, xd, r, rd, J, A, Ap, v, temp_d, d; - int ptype = param0.type(); + ElemType ptype = param0.type(); - CV_Assert( (param0.cols == 1 || param0.rows == 1) && (ptype == CV_32F || ptype == CV_64F)); + CV_Assert((param0.cols == 1 || param0.rows == 1) && (ptype == CV_32FC1 || ptype == CV_64FC1)); CV_Assert( cb ); int lx = param0.rows + param0.cols - 1; @@ -126,7 +126,7 @@ class LMSolverImpl CV_FINAL : public LMSolver for( ;; ) { - CV_Assert( A.type() == CV_64F && A.rows == lx ); + CV_Assert(A.type() == CV_64FC1 && A.rows == lx); A.copyTo(Ap); for( i = 0; i < lx; i++ ) Ap.at(i, i) += lambda*D.at(i); @@ -191,7 +191,7 @@ class LMSolverImpl CV_FINAL : public LMSolver if( param0.size != x.size ) transpose(x, x); - x.convertTo(param0, ptype); + x.convertTo(param0, CV_MAT_DEPTH(ptype)); if( iter == maxIters ) iter = -iter; diff --git a/modules/calib3d/src/p3p.cpp b/modules/calib3d/src/p3p.cpp index 7521e6b16700..735dc435bc86 100644 --- a/modules/calib3d/src/p3p.cpp +++ b/modules/calib3d/src/p3p.cpp @@ -52,8 +52,8 @@ bool p3p::solve(cv::Mat& R, cv::Mat& tvec, const cv::Mat& opoints, const cv::Mat bool result = solve(rotation_matrix, translation, points[0], points[1], points[2], points[3], points[4], points[5], points[6], points[7], points[8], points[9], points[10], points[11], points[12], points[13], points[14], points[15], points[16], points[17], points[18], points[19]); - cv::Mat(3, 1, CV_64F, translation).copyTo(tvec); - cv::Mat(3, 3, CV_64F, rotation_matrix).copyTo(R); + cv::Mat(3, 1, CV_64FC1, translation).copyTo(tvec); + cv::Mat(3, 3, CV_64FC1, rotation_matrix).copyTo(R); return result; } @@ -82,8 +82,8 @@ int p3p::solve(std::vector& Rs, std::vector& tvecs, const cv:: for (int i = 0; i < solutions; i++) { cv::Mat R, tvec; - cv::Mat(3, 1, CV_64F, translation[i]).copyTo(tvec); - cv::Mat(3, 3, CV_64F, rotation_matrix[i]).copyTo(R); + cv::Mat(3, 1, CV_64FC1, translation[i]).copyTo(tvec); + cv::Mat(3, 3, CV_64FC1, rotation_matrix[i]).copyTo(R); Rs.push_back(R); tvecs.push_back(tvec); diff --git a/modules/calib3d/src/ptsetreg.cpp b/modules/calib3d/src/ptsetreg.cpp index 4d2e9135d25d..f496a1affeb6 100644 --- a/modules/calib3d/src/ptsetreg.cpp +++ b/modules/calib3d/src/ptsetreg.cpp @@ -83,9 +83,9 @@ class RANSACPointSetRegistrator : public PointSetRegistrator int findInliers( const Mat& m1, const Mat& m2, const Mat& model, Mat& err, Mat& mask, double thresh ) const { cb->computeError( m1, m2, model, err ); - mask.create(err.size(), CV_8U); + mask.create(err.size(), CV_8UC1); - CV_Assert( err.isContinuous() && err.type() == CV_32F && mask.isContinuous() && mask.type() == CV_8U); + CV_Assert(err.isContinuous() && err.type() == CV_32FC1 && mask.isContinuous() && mask.type() == CV_8UC1); const float* errptr = err.ptr(); uchar* maskptr = mask.ptr(); float t = (float)(thresh*thresh); @@ -174,13 +174,13 @@ class RANSACPointSetRegistrator : public PointSetRegistrator if( _mask.needed() ) { - _mask.create(count, 1, CV_8U, -1, true); + _mask.create(count, 1, CV_8UC1, -1, true); bestMask0 = bestMask = _mask.getMat(); CV_Assert( (bestMask.cols == 1 || bestMask.rows == 1) && (int)bestMask.total() == count ); } else { - bestMask.create(count, 1, CV_8U); + bestMask.create(count, 1, CV_8UC1); bestMask0 = bestMask; } @@ -285,7 +285,7 @@ class LMeDSPointSetRegistrator : public RANSACPointSetRegistrator if( _mask.needed() ) { - _mask.create(count, 1, CV_8U, -1, true); + _mask.create(count, 1, CV_8UC1, -1, true); mask0 = mask = _mask.getMat(); CV_Assert( (mask.cols == 1 || mask.rows == 1) && (int)mask.total() == count ); } @@ -331,7 +331,7 @@ class LMeDSPointSetRegistrator : public RANSACPointSetRegistrator err.convertTo(errf, CV_32F); else errf = err; - CV_Assert( errf.isContinuous() && errf.type() == CV_32F && (int)errf.total() == count ); + CV_Assert(errf.isContinuous() && errf.type() == CV_32FC1 && (int)errf.total() == count); std::nth_element(errf.ptr(), errf.ptr() + count/2, errf.ptr() + count); double median = errf.at(count/2); @@ -408,9 +408,9 @@ class Affine3DEstimatorCallback : public PointSetRegistrator::Callback const int N = 12; double buf[N*N + N + N]; - Mat A(N, N, CV_64F, &buf[0]); - Mat B(N, 1, CV_64F, &buf[0] + N*N); - Mat X(N, 1, CV_64F, &buf[0] + N*N + N); + Mat A(N, N, CV_64FC1, &buf[0]); + Mat B(N, 1, CV_64FC1, &buf[0] + N*N); + Mat X(N, 1, CV_64FC1, &buf[0] + N*N + N); double* Adata = A.ptr(); double* Bdata = B.ptr(); A = Scalar::all(0); @@ -448,7 +448,7 @@ class Affine3DEstimatorCallback : public PointSetRegistrator::Callback int count = m1.checkVector(3); CV_Assert( count > 0 ); - _err.create(count, 1, CV_32F); + _err.create(count, 1, CV_32FC1); Mat err = _err.getMat(); float* errptr = err.ptr(); @@ -520,7 +520,7 @@ class Affine2DEstimatorCallback : public PointSetRegistrator::Callback Mat m1 = _m1.getMat(), m2 = _m2.getMat(); const Point2f* from = m1.ptr(); const Point2f* to = m2.ptr(); - _model.create(2, 3, CV_64F); + _model.create(2, 3, CV_64FC1); Mat M_mat = _model.getMat(); double *M = M_mat.ptr(); @@ -585,7 +585,7 @@ class Affine2DEstimatorCallback : public PointSetRegistrator::Callback int count = m1.checkVector(2); CV_Assert( count > 0 ); - _err.create(count, 1, CV_32F); + _err.create(count, 1, CV_32FC1); Mat err = _err.getMat(); float* errptr = err.ptr(); // transform matrix to floats @@ -633,7 +633,7 @@ class AffinePartial2DEstimatorCallback : public Affine2DEstimatorCallback Mat m1 = _m1.getMat(), m2 = _m2.getMat(); const Point2f* from = m1.ptr(); const Point2f* to = m2.ptr(); - _model.create(2, 3, CV_64F); + _model.create(2, 3, CV_64FC1); Mat M_mat = _model.getMat(); double *M = M_mat.ptr(); @@ -688,11 +688,11 @@ class Affine2DRefineCallback : public LMSolver::Callback { int i, count = src.checkVector(2); Mat param = _param.getMat(); - _err.create(count*2, 1, CV_64F); + _err.create(count * 2, 1, CV_64FC1); Mat err = _err.getMat(), J; if( _Jac.needed()) { - _Jac.create(count*2, param.rows, CV_64F); + _Jac.create(count * 2, param.rows, CV_64FC1); J = _Jac.getMat(); CV_Assert( J.isContinuous() && J.cols == 6 ); } @@ -746,11 +746,11 @@ class AffinePartial2DRefineCallback : public LMSolver::Callback { int i, count = src.checkVector(2); Mat param = _param.getMat(); - _err.create(count*2, 1, CV_64F); + _err.create(count * 2, 1, CV_64FC1); Mat err = _err.getMat(), J; if( _Jac.needed()) { - _Jac.create(count*2, param.rows, CV_64F); + _Jac.create(count * 2, param.rows, CV_64FC1); J = _Jac.getMat(); CV_Assert( J.isContinuous() && J.cols == 4 ); } @@ -828,9 +828,9 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers, if (from.type() != CV_32FC2 || to.type() != CV_32FC2) { Mat tmp1, tmp2; - from.convertTo(tmp1, CV_32FC2); + from.convertTo(tmp1, CV_32F); from = tmp1; - to.convertTo(tmp2, CV_32FC2); + to.convertTo(tmp2, CV_32F); to = tmp2; } // convert to N x 1 vectors @@ -840,7 +840,7 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers, Mat inliers; if(_inliers.needed()) { - _inliers.create(count, 1, CV_8U, -1, true); + _inliers.create(count, 1, CV_8UC1, -1, true); inliers = _inliers.getMat(); } @@ -872,7 +872,7 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers, H.release(); if(_inliers.needed()) { - inliers = Mat::zeros(count, 1, CV_8U); + inliers = Mat::zeros(count, 1, CV_8UC1); inliers.copyTo(_inliers); } } @@ -895,9 +895,9 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie if (from.type() != CV_32FC2 || to.type() != CV_32FC2) { Mat tmp1, tmp2; - from.convertTo(tmp1, CV_32FC2); + from.convertTo(tmp1, CV_32F); from = tmp1; - to.convertTo(tmp2, CV_32FC2); + to.convertTo(tmp2, CV_32F); to = tmp2; } // convert to N x 1 vectors @@ -907,7 +907,7 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie Mat inliers; if(_inliers.needed()) { - _inliers.create(count, 1, CV_8U, -1, true); + _inliers.create(count, 1, CV_8UC1, -1, true); inliers = _inliers.getMat(); } @@ -936,7 +936,7 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie // (a, b, tx, ty) double *Hptr = H.ptr(); double Hvec_buf[4] = {Hptr[0], Hptr[3], Hptr[2], Hptr[5]}; - Mat Hvec (4, 1, CV_64F, Hvec_buf); + Mat Hvec(4, 1, CV_64FC1, Hvec_buf); createLMSolver(makePtr(src, dst), static_cast(refineIters))->run(Hvec); // update H with refined parameters Hptr[0] = Hptr[4] = Hvec_buf[0]; @@ -952,7 +952,7 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie H.release(); if(_inliers.needed()) { - inliers = Mat::zeros(count, 1, CV_8U); + inliers = Mat::zeros(count, 1, CV_8UC1); inliers.copyTo(_inliers); } } diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index c26bca10da08..75c2a77e04d4 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -72,18 +72,18 @@ bool solvePnP( InputArray _opoints, InputArray _ipoints, { int rtype = _rvec.type(), ttype = _tvec.type(); Size rsize = _rvec.size(), tsize = _tvec.size(); - CV_Assert( (rtype == CV_32F || rtype == CV_64F) && - (ttype == CV_32F || ttype == CV_64F) ); + CV_Assert( (rtype == CV_32F || rtype == CV_64FC1) && + (ttype == CV_32F || ttype == CV_64FC1) ); CV_Assert( (rsize == Size(1, 3) || rsize == Size(3, 1)) && (tsize == Size(1, 3) || tsize == Size(3, 1)) ); } else { - int mtype = CV_64F; + ElemType mtype = CV_64FC1; // use CV_32F if all PnP inputs are CV_32F and outputs are empty if (_ipoints.depth() == _cameraMatrix.depth() && _ipoints.depth() == _opoints.depth() && _rvec.empty() && _tvec.empty()) - mtype = _opoints.depth(); + mtype = CV_MAKETYPE(_opoints.depth(), 1); _rvec.create(3, 1, mtype); _tvec.create(3, 1, mtype); @@ -174,7 +174,7 @@ class PnPRansacCallback CV_FINAL : public PointSetRegistrator::Callback public: - PnPRansacCallback(Mat _cameraMatrix=Mat(3,3,CV_64F), Mat _distCoeffs=Mat(4,1,CV_64F), int _flags=SOLVEPNP_ITERATIVE, + PnPRansacCallback(Mat _cameraMatrix=Mat(3,3,CV_64FC1), Mat _distCoeffs=Mat(4,1,CV_64FC1), int _flags=SOLVEPNP_ITERATIVE, bool _useExtrinsicGuess=false, Mat _rvec=Mat(), Mat _tvec=Mat() ) : cameraMatrix(_cameraMatrix), distCoeffs(_distCoeffs), flags(_flags), useExtrinsicGuess(_useExtrinsicGuess), rvec(_rvec), tvec(_tvec) {} @@ -294,7 +294,7 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints, if(_inliers.needed()) { - _inliers.create(npoints, 1, CV_32S); + _inliers.create(npoints, 1, CV_32SC1); Mat _local_inliers = _inliers.getMat(); for(int i = 0; i < npoints; i++) { @@ -412,11 +412,11 @@ int solveP3P( InputArray _opoints, InputArray _ipoints, } if (_rvecs.needed()) { - _rvecs.create(solutions, 1, CV_64F); + _rvecs.create(solutions, 1, CV_64FC1); } if (_tvecs.needed()) { - _tvecs.create(solutions, 1, CV_64F); + _tvecs.create(solutions, 1, CV_64FC1); } for (int i = 0; i < solutions; i++) { diff --git a/modules/calib3d/src/stereobm.cpp b/modules/calib3d/src/stereobm.cpp index 1b74e9f877d8..ac559840f471 100644 --- a/modules/calib3d/src/stereobm.cpp +++ b/modules/calib3d/src/stereobm.cpp @@ -69,7 +69,7 @@ struct StereoBMParams speckleRange = speckleWindowSize = 0; roi1 = roi2 = Rect(0,0,0,0); disp12MaxDiff = -1; - dispType = CV_16S; + dispType = CV_16SC1; } int preFilterType; @@ -84,7 +84,7 @@ struct StereoBMParams int speckleWindowSize; Rect roi1, roi2; int disp12MaxDiff; - int dispType; + ElemType dispType; }; #ifdef HAVE_OPENCL @@ -965,7 +965,7 @@ static bool ocl_stereobm( InputArray _left, InputArray _right, UMat left = _left.getUMat(), right = _right.getUMat(); int cols = left.cols, rows = left.rows; - _disp.create(_left.size(), CV_16S); + _disp.create(_left.size(), CV_16SC1); _disp.setTo((mindisp - 1) << 4); Rect roi = Rect(Point(wsz2 + mindisp + ndisp - 1, wsz2), Point(cols-wsz2-mindisp, rows-wsz2) ); UMat disp = (_disp.getUMat())(roi); @@ -995,7 +995,7 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody bool _useShorts, Rect _validDisparityRect, Mat& _slidingSumBuf, Mat& _cost ) { - CV_Assert( _disp.type() == CV_16S || _disp.type() == CV_32S ); + CV_Assert(_disp.type() == CV_16SC1 || _disp.type() == CV_32SC1); left = &_left; right = &_right; disp = &_disp; state = _state; nstripes = _nstripes; stripeBufSize = _stripeBufSize; @@ -1015,8 +1015,8 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody int _row1 = std::min(cvRound(range.end * rows / nstripes), rows); uchar *ptr = slidingSumBuf->ptr() + range.start * stripeBufSize; - int dispShift = disp->type() == CV_16S ? DISPARITY_SHIFT_16S : - DISPARITY_SHIFT_32S; + int dispShift = disp->type() == CV_16SC1 ? DISPARITY_SHIFT_16S : + DISPARITY_SHIFT_32S; int FILTERED = (state->minDisparity - 1) << dispShift; Rect roi = validDisparityRect & Rect(0, _row0, cols, _row1 - _row0); @@ -1045,7 +1045,7 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody #if CV_SIMD128 if( useSIMD && useShorts ) { - if( disp_i.type() == CV_16S) + if (disp_i.type() == CV_16SC1) findStereoCorrespondenceBM_SIMD( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 ); else findStereoCorrespondenceBM_SIMD( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1); @@ -1053,7 +1053,7 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody else #endif { - if( disp_i.type() == CV_16S ) + if (disp_i.type() == CV_16SC1) findStereoCorrespondenceBM( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 ); else findStereoCorrespondenceBM( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 ); @@ -1103,7 +1103,7 @@ class StereoBMImpl CV_FINAL : public StereoBM { CV_INSTRUMENT_REGION(); - int dtype = disparr.fixedType() ? disparr.type() : params.dispType; + ElemType dtype = disparr.fixedType() ? disparr.type() : params.dispType; Size leftsize = leftarr.size(); if (leftarr.size() != rightarr.size()) @@ -1159,8 +1159,8 @@ class StereoBMImpl CV_FINAL : public StereoBM if( params.speckleRange >= 0 && params.speckleWindowSize > 0 ) filterSpeckles(disparr.getMat(), FILTERED, params.speckleWindowSize, params.speckleRange, slidingSumBuf); - if (dtype == CV_32F) - disparr.getUMat().convertTo(disparr, CV_32FC1, 1./(1 << disp_shift), 0); + if (dtype == CV_32FC1) + disparr.getUMat().convertTo(disparr, CV_32F, 1./(1 << disp_shift), 0); CV_IMPL_ADD(CV_IMPL_OCL); return; } @@ -1172,9 +1172,9 @@ class StereoBMImpl CV_FINAL : public StereoBM disparr.create(left0.size(), dtype); Mat disp0 = disparr.getMat(); - preFilteredImg0.create( left0.size(), CV_8U ); - preFilteredImg1.create( left0.size(), CV_8U ); - cost.create( left0.size(), CV_16S ); + preFilteredImg0.create(left0.size(), CV_8UC1); + preFilteredImg1.create(left0.size(), CV_8UC1); + cost.create(left0.size(), CV_16SC1); Mat left = preFilteredImg0, right = preFilteredImg1; @@ -1189,14 +1189,14 @@ class StereoBMImpl CV_FINAL : public StereoBM if( lofs >= width || rofs >= width || width1 < 1 ) { - disp0 = Scalar::all( FILTERED * ( disp0.type() < CV_32F ? 1 : 1./(1 << disp_shift) ) ); + disp0 = Scalar::all(FILTERED * (disp0.type() < CV_32FC1 ? 1 : 1. / (1 << disp_shift))); return; } Mat disp = disp0; - if( dtype == CV_32F ) + if (dtype == CV_32FC1) { - dispbuf.create(disp0.size(), CV_32S); + dispbuf.create(disp0.size(), CV_32SC1); disp = dispbuf; } @@ -1219,7 +1219,7 @@ class StereoBMImpl CV_FINAL : public StereoBM int bufSize = std::max(bufSize0 * nstripes, std::max(bufSize1 * 2, bufSize2)); if( slidingSumBuf.cols < bufSize ) - slidingSumBuf.create( 1, bufSize, CV_8U ); + slidingSumBuf.create(1, bufSize, CV_8UC1); uchar *_buf = slidingSumBuf.ptr(); @@ -1240,7 +1240,7 @@ class StereoBMImpl CV_FINAL : public StereoBM filterSpeckles(disp, FILTERED, params.speckleWindowSize, params.speckleRange, slidingSumBuf); if (disp0.data != disp.data) - disp.convertTo(disp0, disp0.type(), 1./(1 << disp_shift), 0); + disp.convertTo(disp0, disp0.depth(), 1./(1 << disp_shift), 0); } int getMinDisparity() const CV_OVERRIDE { return params.minDisparity; } diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index cd198885f008..bd2565d8691f 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -882,7 +882,7 @@ struct CalcVerticalSums: public ParallelLoopBody size_t auxBufsSize = pixDiffSize*sizeof(CostType) + //pixdiff size width*16*img1.channels()*sizeof(PixType) + 32; //tempBuf Mat auxBuff; - auxBuff.create(1, (int)auxBufsSize, CV_8U); + auxBuff.create(1, (int)auxBufsSize, CV_8UC1); CostType* pixDiff = (CostType*)alignPtr(auxBuff.ptr(), ALIGN); PixType* tempBuf = (PixType*)(pixDiff + pixDiffSize); @@ -1158,7 +1158,7 @@ struct CalcHorizontalSums: public ParallelLoopBody size_t auxBufsSize = LrSize * sizeof(CostType) + width*(sizeof(CostType) + sizeof(DispType)) + 32; Mat auxBuff; - auxBuff.create(1, (int)auxBufsSize, CV_8U); + auxBuff.create(1, (int)auxBufsSize, CV_8UC1); CostType *Lr = ((CostType*)alignPtr(auxBuff.ptr(), ALIGN)) + 8; CostType* disp2cost = Lr + LrSize; DispType* disp2ptr = (DispType*)(disp2cost + width); @@ -2112,7 +2112,7 @@ static void computeDisparity3WaySGBM( const Mat& img1, const Mat& img2, int stripe_overlap = (params.SADWindowSize/2+1) + (int)ceil(0.1*stripe_sz); Mat* dst_disp = new Mat[nstripes]; for(int i=0;i 0 && disp.type() == CV_16S && - (costType == CV_16S || costType == CV_32S) && + CV_Assert(numberOfDisparities > 0 && disp.type() == CV_16SC1 && + (costType == CV_16S || costType == CV_32SC1) && disp.size() == cost.size() ); for( int y = 0; y < rows; y++ ) diff --git a/modules/calib3d/src/upnp.cpp b/modules/calib3d/src/upnp.cpp index a674df543f08..63a23c165531 100644 --- a/modules/calib3d/src/upnp.cpp +++ b/modules/calib3d/src/upnp.cpp @@ -97,7 +97,7 @@ double upnp::compute_pose(Mat& R, Mat& t) choose_control_points(); compute_alphas(); - Mat * M = new Mat(2 * number_of_correspondences, 12, CV_64F); + Mat * M = new Mat(2 * number_of_correspondences, 12, CV_64FC1); for(int i = 0; i < number_of_correspondences; i++) { @@ -105,10 +105,10 @@ double upnp::compute_pose(Mat& R, Mat& t) } double mtm[12 * 12], d[12], ut[12 * 12], vt[12 * 12]; - Mat MtM = Mat(12, 12, CV_64F, mtm); - Mat D = Mat(12, 1, CV_64F, d); - Mat Ut = Mat(12, 12, CV_64F, ut); - Mat Vt = Mat(12, 12, CV_64F, vt); + Mat MtM = Mat(12, 12, CV_64FC1, mtm); + Mat D = Mat(12, 1, CV_64FC1, d); + Mat Ut = Mat(12, 12, CV_64FC1, ut); + Mat Vt = Mat(12, 12, CV_64FC1, vt); MtM = M->t() * (*M); SVD::compute(MtM, D, Ut, Vt, SVD::MODIFY_A | SVD::FULL_UV); @@ -117,8 +117,8 @@ double upnp::compute_pose(Mat& R, Mat& t) delete M; double l_6x12[6 * 12], rho[6]; - Mat L_6x12 = Mat(6, 12, CV_64F, l_6x12); - Mat Rho = Mat(6, 1, CV_64F, rho); + Mat L_6x12 = Mat(6, 12, CV_64FC1, l_6x12); + Mat Rho = Mat(6, 1, CV_64FC1, rho); compute_L_6x12(ut, l_6x12); compute_rho(rho); @@ -137,8 +137,8 @@ double upnp::compute_pose(Mat& R, Mat& t) int N = 1; if (rep_errors[2] < rep_errors[1]) N = 2; - Mat(3, 1, CV_64F, ts[N]).copyTo(t); - Mat(3, 3, CV_64F, Rs[N]).copyTo(R); + Mat(3, 1, CV_64FC1, ts[N]).copyTo(t); + Mat(3, 3, CV_64FC1, Rs[N]).copyTo(R); fu = fv = Efs[N][0]; return fu; @@ -176,10 +176,10 @@ void upnp::estimate_R_and_t(double R[3][3], double t[3]) } double abt[3 * 3] = {0}, abt_d[3], abt_u[3 * 3], abt_v[3 * 3]; - Mat ABt = Mat(3, 3, CV_64F, abt); - Mat ABt_D = Mat(3, 1, CV_64F, abt_d); - Mat ABt_U = Mat(3, 3, CV_64F, abt_u); - Mat ABt_V = Mat(3, 3, CV_64F, abt_v); + Mat ABt = Mat(3, 3, CV_64FC1, abt); + Mat ABt_D = Mat(3, 1, CV_64FC1, abt_d); + Mat ABt_U = Mat(3, 3, CV_64FC1, abt_u); + Mat ABt_V = Mat(3, 3, CV_64FC1, abt_v); ABt.setTo(0.0); for(int i = 0; i < number_of_correspondences; i++) { @@ -271,15 +271,15 @@ void upnp::choose_control_points() void upnp::compute_alphas() { - Mat CC = Mat(4, 3, CV_64F, &cws); - Mat PC = Mat(number_of_correspondences, 3, CV_64F, &pws[0]); - Mat ALPHAS = Mat(number_of_correspondences, 4, CV_64F, &alphas[0]); + Mat CC = Mat(4, 3, CV_64FC1, &cws); + Mat PC = Mat(number_of_correspondences, 3, CV_64FC1, &pws[0]); + Mat ALPHAS = Mat(number_of_correspondences, 4, CV_64FC1, &alphas[0]); Mat CC_ = CC.clone().t(); Mat PC_ = PC.clone().t(); - Mat row14 = Mat::ones(1, 4, CV_64F); - Mat row1n = Mat::ones(1, number_of_correspondences, CV_64F); + Mat row14 = Mat::ones(1, 4, CV_64FC1); + Mat row1n = Mat::ones(1, number_of_correspondences, CV_64FC1); CC_.push_back(row14); PC_.push_back(row1n); @@ -332,8 +332,8 @@ void upnp::compute_pcs(void) void upnp::find_betas_and_focal_approx_1(Mat * Ut, Mat * Rho, double * betas, double * efs) { - Mat Kmf1 = Mat(12, 1, CV_64F, Ut->ptr(11)); - Mat dsq = Mat(6, 1, CV_64F, Rho->ptr(0)); + Mat Kmf1 = Mat(12, 1, CV_64FC1, Ut->ptr(11)); + Mat dsq = Mat(6, 1, CV_64FC1, Rho->ptr(0)); Mat D = compute_constraint_distance_2param_6eq_2unk_f_unk( Kmf1 ); Mat Dt = D.t(); @@ -341,7 +341,7 @@ void upnp::find_betas_and_focal_approx_1(Mat * Ut, Mat * Rho, double * betas, do Mat A = Dt * D; Mat b = Dt * dsq; - Mat x = Mat(2, 1, CV_64F); + Mat x = Mat(2, 1, CV_64FC1); solve(A, b, x); betas[0] = sqrt( abs( x.at(0) ) ); @@ -353,12 +353,12 @@ void upnp::find_betas_and_focal_approx_1(Mat * Ut, Mat * Rho, double * betas, do void upnp::find_betas_and_focal_approx_2(Mat * Ut, Mat * Rho, double * betas, double * efs) { double u[12*12]; - Mat U = Mat(12, 12, CV_64F, u); + Mat U = Mat(12, 12, CV_64FC1, u); Ut->copyTo(U); - Mat Kmf1 = Mat(12, 1, CV_64F, Ut->ptr(10)); - Mat Kmf2 = Mat(12, 1, CV_64F, Ut->ptr(11)); - Mat dsq = Mat(6, 1, CV_64F, Rho->ptr(0)); + Mat Kmf1 = Mat(12, 1, CV_64FC1, Ut->ptr(10)); + Mat Kmf2 = Mat(12, 1, CV_64FC1, Ut->ptr(11)); + Mat dsq = Mat(6, 1, CV_64FC1, Rho->ptr(0)); Mat D = compute_constraint_distance_3param_6eq_6unk_f_unk( Kmf1, Kmf2 ); @@ -366,7 +366,7 @@ void upnp::find_betas_and_focal_approx_2(Mat * Ut, Mat * Rho, double * betas, do Mat b = dsq; double x[6]; - Mat X = Mat(6, 1, CV_64F, x); + Mat X = Mat(6, 1, CV_64FC1, x); solve(A, b, X, DECOMP_QR); @@ -402,7 +402,7 @@ void upnp::find_betas_and_focal_approx_2(Mat * Ut, Mat * Rho, double * betas, do Mat upnp::compute_constraint_distance_2param_6eq_2unk_f_unk(const Mat& M1) { - Mat P = Mat(6, 2, CV_64F); + Mat P = Mat(6, 2, CV_64FC1); double m[13]; for (int i = 1; i < 13; ++i) m[i] = *M1.ptr(i-1); @@ -438,7 +438,7 @@ Mat upnp::compute_constraint_distance_2param_6eq_2unk_f_unk(const Mat& M1) Mat upnp::compute_constraint_distance_3param_6eq_6unk_f_unk(const Mat& M1, const Mat& M2) { - Mat P = Mat(6, 6, CV_64F); + Mat P = Mat(6, 6, CV_64FC1); double m[3][13]; for (int i = 1; i < 13; ++i) @@ -553,9 +553,9 @@ void upnp::generate_all_possible_solutions_for_f_unk(const double betas[5], doub for (int i = 0; i < 18; ++i) { double matrix[9], independent_term[3]; - Mat M = Mat(3, 3, CV_64F, matrix); - Mat I = Mat(3, 1, CV_64F, independent_term); - Mat S = Mat(1, 3, CV_64F); + Mat M = Mat(3, 3, CV_64FC1, matrix); + Mat I = Mat(3, 1, CV_64FC1, independent_term); + Mat S = Mat(1, 3, CV_64FC1); for (int j = 0; j < 9; ++j) matrix[j] = (double)matrix_to_resolve[i][j]; @@ -576,9 +576,9 @@ void upnp::gauss_newton(const Mat * L_6x12, const Mat * Rho, double betas[4], do const int iterations_number = 50; double a[6*4], b[6], x[4] = {0}; - Mat * A = new Mat(6, 4, CV_64F, a); - Mat * B = new Mat(6, 1, CV_64F, b); - Mat * X = new Mat(4, 1, CV_64F, x); + Mat * A = new Mat(6, 4, CV_64FC1, a); + Mat * B = new Mat(6, 1, CV_64FC1, b); + Mat * X = new Mat(4, 1, CV_64FC1, x); for(int k = 0; k < iterations_number; k++) { diff --git a/modules/calib3d/test/test_affine2d_estimator.cpp b/modules/calib3d/test/test_affine2d_estimator.cpp index b636f2685b10..48078418ec01 100644 --- a/modules/calib3d/test/test_affine2d_estimator.cpp +++ b/modules/calib3d/test/test_affine2d_estimator.cpp @@ -53,7 +53,7 @@ TEST_P(EstimateAffine2D, test3Points) // try more transformations for (size_t i = 0; i < 500; ++i) { - Mat aff(2, 3, CV_64F); + Mat aff(2, 3, CV_64FC1); cv::randu(aff, 1., 3.); Mat fpts(1, 3, CV_32FC2); @@ -81,7 +81,7 @@ TEST_P(EstimateAffine2D, testNPoints) // try more transformations for (size_t i = 0; i < 500; ++i) { - Mat aff(2, 3, CV_64F); + Mat aff(2, 3, CV_64FC1); cv::randu(aff, -2., 2.); const int method = GetParam(); const int n = 100; @@ -125,7 +125,7 @@ TEST_P(EstimateAffine2D, testNPoints) // test conversion from other datatypes than float TEST_P(EstimateAffine2D, testConversion) { - Mat aff(2, 3, CV_32S); + Mat aff(2, 3, CV_32SC1); cv::randu(aff, 1., 3.); std::vector fpts(3); diff --git a/modules/calib3d/test/test_affine3d_estimator.cpp b/modules/calib3d/test/test_affine3d_estimator.cpp index 42e10a0e77af..851f2673c6cc 100644 --- a/modules/calib3d/test/test_affine3d_estimator.cpp +++ b/modules/calib3d/test/test_affine3d_estimator.cpp @@ -79,7 +79,7 @@ struct WrapAff bool CV_Affine3D_EstTest::test4Points() { - Mat aff(3, 4, CV_64F); + Mat aff(3, 4, CV_64FC1); cv::randu(aff, Scalar(1), Scalar(3)); // setting points that are no in the same line @@ -121,7 +121,7 @@ struct Noise bool CV_Affine3D_EstTest::testNPoints() { - Mat aff(3, 4, CV_64F); + Mat aff(3, 4, CV_64FC1); cv::randu(aff, Scalar(-2), Scalar(2)); // setting points that are no in the same line diff --git a/modules/calib3d/test/test_affine_partial2d_estimator.cpp b/modules/calib3d/test/test_affine_partial2d_estimator.cpp index 1bb85a4136a7..2910faa72ec2 100644 --- a/modules/calib3d/test/test_affine_partial2d_estimator.cpp +++ b/modules/calib3d/test/test_affine_partial2d_estimator.cpp @@ -57,7 +57,7 @@ static Mat rngPartialAffMat() { double ty = rngIn(-2, 2); double aff[2*3] = { std::cos(theta) * scale, -std::sin(theta) * scale, tx, std::sin(theta) * scale, std::cos(theta) * scale, ty }; - return Mat(2, 3, CV_64F, aff).clone(); + return Mat(2, 3, CV_64FC1, aff).clone(); } TEST_P(EstimateAffinePartial2D, test2Points) diff --git a/modules/calib3d/test/test_cameracalibration.cpp b/modules/calib3d/test/test_cameracalibration.cpp index f20edfea2783..5ebb53d572da 100644 --- a/modules/calib3d/test/test_cameracalibration.cpp +++ b/modules/calib3d/test/test_cameracalibration.cpp @@ -51,13 +51,13 @@ class CV_ProjectPointsTest : public cvtest::ArrayTest CV_ProjectPointsTest(); protected: - int read_params( CvFileStorage* fs ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); - int prepare_test_case( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + int read_params( CvFileStorage* fs ) CV_OVERRIDE; + void fill_array( int test_case_idx, int i, int j, Mat& arr ) CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; bool calc_jacobians; }; @@ -91,7 +91,7 @@ int CV_ProjectPointsTest::read_params( CvFileStorage* fs ) void CV_ProjectPointsTest::get_test_array_types_and_sizes( - int /*test_case_idx*/, vector >& sizes, vector >& types ) + int /*test_case_idx*/, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F; @@ -749,8 +749,8 @@ void CV_CameraCalibrationTest_C::calibrate(int imageCount, int* pointCounts, CvMat _objectPoints = cvMat(1, total, CV_64FC3, objectPoints); CvMat _imagePoints = cvMat(1, total, CV_64FC2, imagePoints); CvMat _pointCounts = cvMat(1, imageCount, CV_32S, pointCounts); - CvMat _cameraMatrix = cvMat(3, 3, CV_64F, cameraMatrix); - CvMat _distCoeffs = cvMat(4, 1, CV_64F, distortionCoeffs); + CvMat _cameraMatrix = cvMat(3, 3, CV_64FC1, cameraMatrix); + CvMat _distCoeffs = cvMat(4, 1, CV_64FC1, distortionCoeffs); CvMat _rotationMatrices = cvMat(imageCount, 9, CV_64F, rotationMatrices); CvMat _translationVectors = cvMat(imageCount, 3, CV_64F, translationVectors); @@ -764,10 +764,10 @@ void CV_CameraCalibrationTest_C::project( int pointCount, CvPoint3D64f* objectPo { CvMat _objectPoints = cvMat(1, pointCount, CV_64FC3, objectPoints); CvMat _imagePoints = cvMat(1, pointCount, CV_64FC2, imagePoints); - CvMat _cameraMatrix = cvMat(3, 3, CV_64F, cameraMatrix); - CvMat _distCoeffs = cvMat(4, 1, CV_64F, distortion); - CvMat _rotationMatrix = cvMat(3, 3, CV_64F, rotationMatrix); - CvMat _translationVector = cvMat(1, 3, CV_64F, translationVector); + CvMat _cameraMatrix = cvMat(3, 3, CV_64FC1, cameraMatrix); + CvMat _distCoeffs = cvMat(4, 1, CV_64FC1, distortion); + CvMat _rotationMatrix = cvMat(3, 3, CV_64FC1, rotationMatrix); + CvMat _translationVector = cvMat(1, 3, CV_64FC1, translationVector); cvProjectPoints2(&_objectPoints, &_rotationMatrix, &_translationVector, &_cameraMatrix, &_distCoeffs, &_imagePoints); } @@ -796,7 +796,7 @@ void CV_CameraCalibrationTest_CPP::calibrate(int imageCount, int* pointCounts, vector > objectPoints( imageCount ); vector > imagePoints( imageCount ); Size imageSize = _imageSize; - Mat cameraMatrix, distCoeffs(1,4,CV_64F,Scalar::all(0)); + Mat cameraMatrix, distCoeffs(1, 4, CV_64FC1, Scalar::all(0)); vector rvecs, tvecs; Mat stdDevsMatInt, stdDevsMatExt; Mat perViewErrorsMat; @@ -831,15 +831,15 @@ void CV_CameraCalibrationTest_CPP::calibrate(int imageCount, int* pointCounts, perViewErrorsMat, flags ); - assert( stdDevsMatInt.type() == CV_64F ); + assert( stdDevsMatInt.type() == CV_64FC1 ); assert( stdDevsMatInt.total() == static_cast(CV_CALIB_NINTRINSIC) ); memcpy( stdDevs, stdDevsMatInt.ptr(), CV_CALIB_NINTRINSIC*sizeof(double) ); - assert( stdDevsMatExt.type() == CV_64F ); + assert( stdDevsMatExt.type() == CV_64FC1 ); assert( stdDevsMatExt.total() == static_cast(6*imageCount) ); memcpy( stdDevs + CV_CALIB_NINTRINSIC, stdDevsMatExt.ptr(), 6*imageCount*sizeof(double) ); - assert( perViewErrorsMat.type() == CV_64F); + assert( perViewErrorsMat.type() == CV_64FC1); assert( perViewErrorsMat.total() == static_cast(imageCount) ); memcpy( perViewErrors, perViewErrorsMat.ptr(), imageCount*sizeof(double) ); @@ -877,7 +877,7 @@ void CV_CameraCalibrationTest_CPP::project( int pointCount, CvPoint3D64f* _objec vector imagePoints; cvtest::Rodrigues( rmat, rvec ); - objectPoints.convertTo( objectPoints, CV_32FC1 ); + objectPoints.convertTo( objectPoints, CV_32F ); projectPoints( objectPoints, rvec, tvec, cameraMatrix, distCoeffs, imagePoints ); vector::const_iterator it = imagePoints.begin(); @@ -1299,11 +1299,11 @@ void CV_ProjectPointsTest_C::project( const Mat& opoints, const Mat& rvec, const { int npoints = opoints.cols*opoints.rows*opoints.channels()/3; ipoints.resize(npoints); - dpdrot.create(npoints*2, 3, CV_64F); - dpdt.create(npoints*2, 3, CV_64F); - dpdf.create(npoints*2, 2, CV_64F); - dpdc.create(npoints*2, 2, CV_64F); - dpddist.create(npoints*2, distCoeffs.rows + distCoeffs.cols - 1, CV_64F); + dpdrot.create(npoints * 2, 3, CV_64FC1); + dpdt.create(npoints * 2, 3, CV_64FC1); + dpdf.create(npoints * 2, 2, CV_64FC1); + dpdc.create(npoints * 2, 2, CV_64FC1); + dpddist.create(npoints * 2, distCoeffs.rows + distCoeffs.cols - 1, CV_64FC1); Mat imagePoints(ipoints); CvMat _objectPoints = cvMat(opoints), _imagePoints = cvMat(imagePoints); CvMat _rvec = cvMat(rvec), _tvec = cvMat(tvec), _cameraMatrix = cvMat(cameraMatrix), _distCoeffs = cvMat(distCoeffs); @@ -1525,7 +1525,7 @@ bool CV_StereoCalibrationTest::checkPandROI( int test_case_idx, const Mat& M, co } // step 2. check that all the points inside ROI belong to the original source image - Mat temp(imgsize, CV_8U), utemp, map1, map2; + Mat temp(imgsize, CV_8UC1), utemp, map1, map2; temp = Scalar::all(1); initUndistortRectifyMap(M, D, R, P, imgsize, CV_16SC2, map1, map2); remap(temp, utemp, map1, map2, INTER_LINEAR); @@ -1630,7 +1630,7 @@ void CV_StereoCalibrationTest::run( int ) } // rectify (calibrated) - Mat M1 = Mat::eye(3,3,CV_64F), M2 = Mat::eye(3,3,CV_64F), D1(5,1,CV_64F), D2(5,1,CV_64F), R, T, E, F; + Mat M1 = Mat::eye(3, 3, CV_64FC1), M2 = Mat::eye(3, 3, CV_64FC1), D1(5, 1, CV_64FC1), D2(5, 1, CV_64FC1), R, T, E, F; M1.at(0,2) = M2.at(0,2)=(imgsize.width-1)*0.5; M1.at(1,2) = M2.at(1,2)=(imgsize.height-1)*0.5; D1 = Scalar::all(0); @@ -1655,7 +1655,7 @@ void CV_StereoCalibrationTest::run( int ) Mat R1, R2, P1, P2, Q; Rect roi1, roi2; rectify(M1, D1, M2, D2, imgsize, R, T, R1, R2, P1, P2, Q, 1, imgsize, &roi1, &roi2, 0); - Mat eye33 = Mat::eye(3,3,CV_64F); + Mat eye33 = Mat::eye(3, 3, CV_64FC1); Mat R1t = R1.t(), R2t = R2.t(); if( cvtest::norm(R1t*R1 - eye33, NORM_L2) > 0.01 || @@ -1774,7 +1774,7 @@ void CV_StereoCalibrationTest::run( int ) newHomogeneousPoints1 = newHomogeneousPoints1.reshape(1); newHomogeneousPoints2 = newHomogeneousPoints2.reshape(1); Mat typedF; - F.convertTo(typedF, newHomogeneousPoints1.type()); + F.convertTo(typedF, newHomogeneousPoints1.depth()); for (int i = 0; i < newHomogeneousPoints1.rows; ++i) { Mat error = newHomogeneousPoints2.row(i) * typedF * newHomogeneousPoints1.row(i).t(); @@ -1894,14 +1894,14 @@ double CV_StereoCalibrationTest_C::calibrateStereoCamera( const vector::value ), imgPt( 1, total, traits::Type::value ), imgPt2( 1, total, traits::Type::value ); @@ -1942,7 +1942,7 @@ void CV_StereoCalibrationTest_C::rectify( const Mat& cameraMatrix1, const Mat& d double alpha, Size newImageSize, Rect* validPixROI1, Rect* validPixROI2, int flags ) { - int rtype = CV_64F; + ElemType rtype = CV_64FC1; R1.create(3, 3, rtype); R2.create(3, 3, rtype); P1.create(3, 4, rtype); @@ -1959,8 +1959,8 @@ void CV_StereoCalibrationTest_C::rectify( const Mat& cameraMatrix1, const Mat& d bool CV_StereoCalibrationTest_C::rectifyUncalibrated( const Mat& points1, const Mat& points2, const Mat& F, Size imgSize, Mat& H1, Mat& H2, double threshold ) { - H1.create(3, 3, CV_64F); - H2.create(3, 3, CV_64F); + H1.create(3, 3, CV_64FC1); + H2.create(3, 3, CV_64FC1); CvMat _pt1 = cvMat(points1), _pt2 = cvMat(points2), matF, *pF=0, _H1 = cvMat(H1), _H2 = cvMat(H2); if( F.size() == Size(3, 3) ) pF = &(matF = cvMat(F)); @@ -2161,14 +2161,14 @@ TEST(Calib3d_Triangulate, accuracy) { double P1data[] = { 250, 0, 200, 0, 0, 250, 150, 0, 0, 0, 1, 0 }; double P2data[] = { 250, 0, 200, -250, 0, 250, 150, 0, 0, 0, 1, 0 }; - Mat P1(3, 4, CV_64F, P1data), P2(3, 4, CV_64F, P2data); + Mat P1(3, 4, CV_64FC1, P1data), P2(3, 4, CV_64FC1, P2data); float x1data[] = { 200.f, 0.f }; float x2data[] = { 170.f, 1.f }; float Xdata[] = { 0.f, -5.f, 25/3.f }; - Mat x1(2, 1, CV_32F, x1data); - Mat x2(2, 1, CV_32F, x2data); - Mat res0(1, 3, CV_32F, Xdata); + Mat x1(2, 1, CV_32FC1, x1data); + Mat x2(2, 1, CV_32FC1, x2data); + Mat res0(1, 3, CV_32FC1, Xdata); Mat res_, res; triangulatePoints(P1, P2, x1, x2, res_); @@ -2206,9 +2206,9 @@ TEST(Calib3d_Triangulate, accuracy) float x1data[] = { 438.f, 19.f }; float x2data[] = { 452.363600f, 16.452225f }; float Xdata[] = { -81.049530f, -215.702804f, 2401.645449f }; - Mat x1(2, 1, CV_32F, x1data); - Mat x2(2, 1, CV_32F, x2data); - Mat res0(1, 3, CV_32F, Xdata); + Mat x1(2, 1, CV_32FC1, x1data); + Mat x2(2, 1, CV_32FC1, x2data); + Mat res0(1, 3, CV_32FC1, Xdata); Mat res_, res; triangulatePoints(P1, P2, x1, x2, res_); diff --git a/modules/calib3d/test/test_cameracalibration_artificial.cpp b/modules/calib3d/test/test_cameracalibration_artificial.cpp index 165a66a7b179..4d502d992942 100644 --- a/modules/calib3d/test/test_cameracalibration_artificial.cpp +++ b/modules/calib3d/test/test_cameracalibration_artificial.cpp @@ -63,7 +63,7 @@ Mat calcRvec(const vector& points, const Size& cornerSize) Vec3d ey(p01.x - p00.x, p01.y - p00.y, p01.z - p00.z); Vec3d ez = ex.cross(ey); - Mat rot(3, 3, CV_64F); + Mat rot(3, 3, CV_64FC1); *rot.ptr(0) = ex; *rot.ptr(1) = ey; *rot.ptr(2) = ez * (1.0/cv::norm(ez)); // TODO cvtest @@ -219,8 +219,8 @@ class CV_CalibrateCameraArtificialTest : public cvtest::BaseTest double reprojectErrorWithoutIntrinsics(const vector& cb3d, const vector& _rvecs_exp, const vector& _tvecs_exp, const vector& rvecs_est, const vector& tvecs_est) { - const static Mat eye33 = Mat::eye(3, 3, CV_64F); - const static Mat zero15 = Mat::zeros(1, 5, CV_64F); + const static Mat eye33 = Mat::eye(3, 3, CV_64FC1); + const static Mat zero15 = Mat::zeros(1, 5, CV_64FC1); Mat _chessboard3D(cb3d); vector uv_exp, uv_est; double res = 0; @@ -277,7 +277,7 @@ class CV_CalibrateCameraArtificialTest : public cvtest::BaseTest imagePoints_art.push_back(corners_art); imagePoints_findCb.push_back(corners_fcb); - tvecs_exp[i].create(1, 3, CV_64F); + tvecs_exp[i].create(1, 3, CV_64FC1); *tvecs_exp[i].ptr() = cbg.corners3d[0]; rvecs_exp[i] = calcRvec(cbg.corners3d, cbg.cornersSize()); } @@ -319,7 +319,7 @@ class CV_CalibrateCameraArtificialTest : public cvtest::BaseTest throw std::exception(); } - Mat camMat_est = Mat::eye(3, 3, CV_64F), distCoeffs_est = Mat::zeros(1, 5, CV_64F); + Mat camMat_est = Mat::eye(3, 3, CV_64FC1), distCoeffs_est = Mat::zeros(1, 5, CV_64FC1); vector rvecs_est, tvecs_est; int flags = /*CALIB_FIX_K3|*/CALIB_FIX_K4|CALIB_FIX_K5|CALIB_FIX_K6; //CALIB_FIX_K3; //CALIB_FIX_ASPECT_RATIO | | CALIB_ZERO_TANGENT_DIST; diff --git a/modules/calib3d/test/test_cameracalibration_badarg.cpp b/modules/calib3d/test/test_cameracalibration_badarg.cpp index c367432f40a8..a35161ccaf53 100644 --- a/modules/calib3d/test/test_cameracalibration_badarg.cpp +++ b/modules/calib3d/test/test_cameracalibration_badarg.cpp @@ -93,11 +93,11 @@ void CV_CameraCalibrationBadArgTest::run( int /* start_from */ ) ChessBoardGenerator cbg(Size(8,6)); corSize = cbg.cornersSize(); vector exp_corn; - chessBoard = cbg(Mat(imgSize, CV_8U, Scalar(0)), camMat, distCoeffs0, exp_corn); + chessBoard = cbg(Mat(imgSize, CV_8UC1, Scalar(0)), camMat, distCoeffs0, exp_corn); Mat_(corSize.height, corSize.width, (Point2f*)&exp_corn[0]).copyTo(corners); CvMat objPts, imgPts, npoints, cameraMatrix, distCoeffs, rvecs, tvecs; - Mat zeros(1, sizeof(CvMat), CV_8U, Scalar(0)); + Mat zeros(1, sizeof(CvMat), CV_8UC1, Scalar(0)); C_Caller caller, bad_caller; caller.imageSize = imgSize; @@ -126,8 +126,8 @@ void CV_CameraCalibrationBadArgTest::run( int /* start_from */ ) imgPts_cpp = corners.clone().reshape(2, 1); npoints_cpp = Mat_(M, 1, corSize.width * corSize.height); - cameraMatrix_cpp.create(3, 3, CV_32F); - distCoeffs_cpp.create(5, 1, CV_32F); + cameraMatrix_cpp.create(3, 3, CV_32FC1); + distCoeffs_cpp.create(5, 1, CV_32FC1); rvecs_cpp.create(M, 1, CV_32FC3); tvecs_cpp.create(M, 1, CV_32FC3); @@ -221,9 +221,9 @@ void CV_CameraCalibrationBadArgTest::run( int /* start_from */ ) bad_caller.tvecs = &bad_tvecs_c2; errors += run_test_case( CV_StsBadArg, "Bad tvecs header", bad_caller ); - Mat bad_cameraMatrix_cpp1(3, 3, CV_32S); CvMat bad_cameraMatrix_c1 = cvMat(bad_cameraMatrix_cpp1); - Mat bad_cameraMatrix_cpp2(2, 3, CV_32F); CvMat bad_cameraMatrix_c2 = cvMat(bad_cameraMatrix_cpp2); - Mat bad_cameraMatrix_cpp3(3, 2, CV_64F); CvMat bad_cameraMatrix_c3 = cvMat(bad_cameraMatrix_cpp3); + Mat bad_cameraMatrix_cpp1(3, 3, CV_32SC1); CvMat bad_cameraMatrix_c1 = cvMat(bad_cameraMatrix_cpp1); + Mat bad_cameraMatrix_cpp2(2, 3, CV_32FC1); CvMat bad_cameraMatrix_c2 = cvMat(bad_cameraMatrix_cpp2); + Mat bad_cameraMatrix_cpp3(3, 2, CV_64FC1); CvMat bad_cameraMatrix_c3 = cvMat(bad_cameraMatrix_cpp3); @@ -239,9 +239,9 @@ void CV_CameraCalibrationBadArgTest::run( int /* start_from */ ) bad_caller.cameraMatrix = &bad_cameraMatrix_c3; errors += run_test_case( CV_StsBadArg, "Bad camearaMatrix header", bad_caller ); - Mat bad_distCoeffs_cpp1(1, 5, CV_32S); CvMat bad_distCoeffs_c1 = cvMat(bad_distCoeffs_cpp1); - Mat bad_distCoeffs_cpp2(2, 2, CV_64F); CvMat bad_distCoeffs_c2 = cvMat(bad_distCoeffs_cpp2); - Mat bad_distCoeffs_cpp3(1, 6, CV_64F); CvMat bad_distCoeffs_c3 = cvMat(bad_distCoeffs_cpp3); + Mat bad_distCoeffs_cpp1(1, 5, CV_32SC1); CvMat bad_distCoeffs_c1 = cvMat(bad_distCoeffs_cpp1); + Mat bad_distCoeffs_cpp2(2, 2, CV_64FC1); CvMat bad_distCoeffs_c2 = cvMat(bad_distCoeffs_cpp2); + Mat bad_distCoeffs_cpp3(1, 6, CV_64FC1); CvMat bad_distCoeffs_c3 = cvMat(bad_distCoeffs_cpp3); @@ -259,7 +259,7 @@ void CV_CameraCalibrationBadArgTest::run( int /* start_from */ ) errors += run_test_case( CV_StsBadArg, "Bad distCoeffs header", bad_caller ); double CM[] = {0, 0, 0, /**/0, 0, 0, /**/0, 0, 0}; - Mat bad_cameraMatrix_cpp4(3, 3, CV_64F, CM); CvMat bad_cameraMatrix_c4 = cvMat(bad_cameraMatrix_cpp4); + Mat bad_cameraMatrix_cpp4(3, 3, CV_64FC1, CM); CvMat bad_cameraMatrix_c4 = cvMat(bad_cameraMatrix_cpp4); bad_caller = caller; bad_caller.flags |= CV_CALIB_USE_INTRINSIC_GUESS; @@ -344,12 +344,12 @@ class CV_Rodrigues2BadArgTest : public cvtest::BadArgTest void run(int /* start_from */ ) { - Mat zeros(1, sizeof(CvMat), CV_8U, Scalar(0)); + Mat zeros(1, sizeof(CvMat), CV_8UC1, Scalar(0)); CvMat src_c, dst_c, jacobian_c; - Mat src_cpp(3, 1, CV_32F); src_c = cvMat(src_cpp); - Mat dst_cpp(3, 3, CV_32F); dst_c = cvMat(dst_cpp); - Mat jacobian_cpp(3, 9, CV_32F); jacobian_c = cvMat(jacobian_cpp); + Mat src_cpp(3, 1, CV_32FC1); src_c = cvMat(src_cpp); + Mat dst_cpp(3, 3, CV_32FC1); dst_c = cvMat(dst_cpp); + Mat jacobian_cpp(3, 9, CV_32FC1); jacobian_c = cvMat(jacobian_cpp); C_Caller caller, bad_caller; caller.src = &src_c; @@ -373,11 +373,11 @@ class CV_Rodrigues2BadArgTest : public cvtest::BadArgTest bad_caller.dst = 0; errors += run_test_case( CV_StsNullPtr, "Dst is zero pointer", bad_caller ); - Mat bad_src_cpp1(3, 1, CV_8U); CvMat bad_src_c1 = cvMat(bad_src_cpp1); - Mat bad_dst_cpp1(3, 1, CV_8U); CvMat bad_dst_c1 = cvMat(bad_dst_cpp1); - Mat bad_jac_cpp1(3, 1, CV_8U); CvMat bad_jac_c1 = cvMat(bad_jac_cpp1); + Mat bad_src_cpp1(3, 1, CV_8UC1); CvMat bad_src_c1 = cvMat(bad_src_cpp1); + Mat bad_dst_cpp1(3, 1, CV_8UC1); CvMat bad_dst_c1 = cvMat(bad_dst_cpp1); + Mat bad_jac_cpp1(3, 1, CV_8UC1); CvMat bad_jac_c1 = cvMat(bad_jac_cpp1); Mat bad_jac_cpp2(3, 1, CV_32FC2); CvMat bad_jac_c2 = cvMat(bad_jac_cpp2); - Mat bad_jac_cpp3(3, 1, CV_32F); CvMat bad_jac_c3 = cvMat(bad_jac_cpp3); + Mat bad_jac_cpp3(3, 1, CV_32FC1); CvMat bad_jac_c3 = cvMat(bad_jac_cpp3); bad_caller = caller; bad_caller.src = &bad_src_c1; @@ -403,14 +403,14 @@ class CV_Rodrigues2BadArgTest : public cvtest::BadArgTest bad_caller.jacobian = &bad_jac_c3; errors += run_test_case( CV_StsBadSize, "Bad jacobian format", bad_caller ); - Mat bad_src_cpp2(1, 1, CV_32F); CvMat bad_src_c2 = cvMat(bad_src_cpp2); + Mat bad_src_cpp2(1, 1, CV_32FC1); CvMat bad_src_c2 = cvMat(bad_src_cpp2); bad_caller = caller; bad_caller.src = &bad_src_c2; errors += run_test_case( CV_StsBadSize, "Bad src format", bad_caller ); - Mat bad_dst_cpp2(2, 1, CV_32F); CvMat bad_dst_c2 = cvMat(bad_dst_cpp2); - Mat bad_dst_cpp3(3, 2, CV_32F); CvMat bad_dst_c3 = cvMat(bad_dst_cpp3); + Mat bad_dst_cpp2(2, 1, CV_32FC1); CvMat bad_dst_c2 = cvMat(bad_dst_cpp2); + Mat bad_dst_cpp3(3, 2, CV_32FC1); CvMat bad_dst_c3 = cvMat(bad_dst_cpp3); Mat bad_dst_cpp4(3, 3, CV_32FC2); CvMat bad_dst_c4 = cvMat(bad_dst_cpp4); bad_caller = caller; @@ -427,11 +427,11 @@ class CV_Rodrigues2BadArgTest : public cvtest::BadArgTest /********/ - src_cpp.create(3, 3, CV_32F); src_c = cvMat(src_cpp); - dst_cpp.create(3, 1, CV_32F); dst_c = cvMat(dst_cpp); + src_cpp.create(3, 3, CV_32FC1); src_c = cvMat(src_cpp); + dst_cpp.create(3, 1, CV_32FC1); dst_c = cvMat(dst_cpp); - Mat bad_dst_cpp5(5, 5, CV_32F); CvMat bad_dst_c5 = cvMat(bad_dst_cpp5); + Mat bad_dst_cpp5(5, 5, CV_32FC1); CvMat bad_dst_c5 = cvMat(bad_dst_cpp5); bad_caller = caller; bad_caller.dst = &bad_dst_c5; @@ -502,18 +502,18 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest randu(objectPoints_cpp, Scalar::all(1), Scalar::all(10)); objectPoints_c = cvMat(objectPoints_cpp); - Mat t_vec_cpp(Mat::zeros(1, 3, CV_32F)); t_vec_c = cvMat(t_vec_cpp); - Mat r_vec_cpp(3, 1, CV_32F); - cvtest::Rodrigues(Mat::eye(3, 3, CV_32F), r_vec_cpp); r_vec_c = cvMat(r_vec_cpp); + Mat t_vec_cpp(Mat::zeros(1, 3, CV_32FC1)); t_vec_c = cvMat(t_vec_cpp); + Mat r_vec_cpp(3, 1, CV_32FC1); + cvtest::Rodrigues(Mat::eye(3, 3, CV_32FC1), r_vec_cpp); r_vec_c = cvMat(r_vec_cpp); Mat A_cpp = camMat.clone(); A_c = cvMat(A_cpp); Mat distCoeffs_cpp = distCoeffs.clone(); distCoeffs_c = cvMat(distCoeffs_cpp); - Mat dpdr_cpp(2*n, 3, CV_32F); dpdr_c = cvMat(dpdr_cpp); - Mat dpdt_cpp(2*n, 3, CV_32F); dpdt_c = cvMat(dpdt_cpp); - Mat dpdf_cpp(2*n, 2, CV_32F); dpdf_c = cvMat(dpdf_cpp); - Mat dpdc_cpp(2*n, 2, CV_32F); dpdc_c = cvMat(dpdc_cpp); - Mat dpdk_cpp(2*n, 4, CV_32F); dpdk_c = cvMat(dpdk_cpp); + Mat dpdr_cpp(2 * n, 3, CV_32FC1); dpdr_c = cvMat(dpdr_cpp); + Mat dpdt_cpp(2 * n, 3, CV_32FC1); dpdt_c = cvMat(dpdt_cpp); + Mat dpdf_cpp(2 * n, 2, CV_32FC1); dpdf_c = cvMat(dpdf_cpp); + Mat dpdc_cpp(2 * n, 2, CV_32FC1); dpdc_c = cvMat(dpdc_cpp); + Mat dpdk_cpp(2 * n, 4, CV_32FC1); dpdk_c = cvMat(dpdk_cpp); caller.aspectRatio = 1.0; caller.objectPoints = &objectPoints_c; @@ -553,8 +553,8 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest errors += run_test_case( CV_StsBadArg, "Zero imagePoints", bad_caller ); /****************************/ - Mat bad_r_vec_cpp1(r_vec_cpp.size(), CV_32S); CvMat bad_r_vec_c1 = cvMat(bad_r_vec_cpp1); - Mat bad_r_vec_cpp2(2, 2, CV_32F); CvMat bad_r_vec_c2 = cvMat(bad_r_vec_cpp2); + Mat bad_r_vec_cpp1(r_vec_cpp.size(), CV_32SC1); CvMat bad_r_vec_c1 = cvMat(bad_r_vec_cpp1); + Mat bad_r_vec_cpp2(2, 2, CV_32FC1); CvMat bad_r_vec_c2 = cvMat(bad_r_vec_cpp2); Mat bad_r_vec_cpp3(r_vec_cpp.size(), CV_32FC2); CvMat bad_r_vec_c3 = cvMat(bad_r_vec_cpp3); bad_caller = caller; @@ -570,8 +570,8 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest errors += run_test_case( CV_StsBadArg, "Bad rvec format", bad_caller ); /****************************/ - Mat bad_t_vec_cpp1(t_vec_cpp.size(), CV_32S); CvMat bad_t_vec_c1 = cvMat(bad_t_vec_cpp1); - Mat bad_t_vec_cpp2(2, 2, CV_32F); CvMat bad_t_vec_c2 = cvMat(bad_t_vec_cpp2); + Mat bad_t_vec_cpp1(t_vec_cpp.size(), CV_32SC1); CvMat bad_t_vec_c1 = cvMat(bad_t_vec_cpp1); + Mat bad_t_vec_cpp2(2, 2, CV_32FC1); CvMat bad_t_vec_c2 = cvMat(bad_t_vec_cpp2); Mat bad_t_vec_cpp3(1, 1, CV_32FC2); CvMat bad_t_vec_c3 = cvMat(bad_t_vec_cpp3); bad_caller = caller; @@ -587,8 +587,8 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest errors += run_test_case( CV_StsBadArg, "Bad tvec format", bad_caller ); /****************************/ - Mat bad_A_cpp1(A_cpp.size(), CV_32S); CvMat bad_A_c1 = cvMat(bad_A_cpp1); - Mat bad_A_cpp2(2, 2, CV_32F); CvMat bad_A_c2 = cvMat(bad_A_cpp2); + Mat bad_A_cpp1(A_cpp.size(), CV_32SC1); CvMat bad_A_c1 = cvMat(bad_A_cpp1); + Mat bad_A_cpp2(2, 2, CV_32FC1); CvMat bad_A_c2 = cvMat(bad_A_cpp2); bad_caller = caller; bad_caller.A = &bad_A_c1; @@ -599,9 +599,9 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest errors += run_test_case( CV_StsBadArg, "Bad A format", bad_caller ); /****************************/ - Mat bad_distCoeffs_cpp1(distCoeffs_cpp.size(), CV_32S); CvMat bad_distCoeffs_c1 = cvMat(bad_distCoeffs_cpp1); - Mat bad_distCoeffs_cpp2(2, 2, CV_32F); CvMat bad_distCoeffs_c2 = cvMat(bad_distCoeffs_cpp2); - Mat bad_distCoeffs_cpp3(1, 7, CV_32F); CvMat bad_distCoeffs_c3 = cvMat(bad_distCoeffs_cpp3); + Mat bad_distCoeffs_cpp1(distCoeffs_cpp.size(), CV_32SC1); CvMat bad_distCoeffs_c1 = cvMat(bad_distCoeffs_cpp1); + Mat bad_distCoeffs_cpp2(2, 2, CV_32FC1); CvMat bad_distCoeffs_c2 = cvMat(bad_distCoeffs_cpp2); + Mat bad_distCoeffs_cpp3(1, 7, CV_32FC1); CvMat bad_distCoeffs_c3 = cvMat(bad_distCoeffs_cpp3); bad_caller = caller; bad_caller.distCoeffs = &zeros; @@ -621,9 +621,9 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest /****************************/ - Mat bad_dpdr_cpp1(dpdr_cpp.size(), CV_32S); CvMat bad_dpdr_c1 = cvMat(bad_dpdr_cpp1); - Mat bad_dpdr_cpp2(dpdr_cpp.cols+1, 3, CV_32F); CvMat bad_dpdr_c2 = cvMat(bad_dpdr_cpp2); - Mat bad_dpdr_cpp3(dpdr_cpp.cols, 7, CV_32F); CvMat bad_dpdr_c3 = cvMat(bad_dpdr_cpp3); + Mat bad_dpdr_cpp1(dpdr_cpp.size(), CV_32SC1); CvMat bad_dpdr_c1 = cvMat(bad_dpdr_cpp1); + Mat bad_dpdr_cpp2(dpdr_cpp.cols + 1, 3, CV_32FC1); CvMat bad_dpdr_c2 = cvMat(bad_dpdr_cpp2); + Mat bad_dpdr_cpp3(dpdr_cpp.cols, 7, CV_32FC1); CvMat bad_dpdr_c3 = cvMat(bad_dpdr_cpp3); bad_caller = caller; bad_caller.dpdr = &zeros; @@ -661,7 +661,7 @@ class CV_ProjectPoints2BadArgTest : public cvtest::BadArgTest /****************************/ - Mat bad_dpdf_cpp2(dpdr_cpp.cols+1, 2, CV_32F); CvMat bad_dpdf_c2 = cvMat(bad_dpdf_cpp2); + Mat bad_dpdf_cpp2(dpdr_cpp.cols + 1, 2, CV_32FC1); CvMat bad_dpdf_c2 = cvMat(bad_dpdf_cpp2); bad_caller = caller; bad_caller.dpdf = &zeros; diff --git a/modules/calib3d/test/test_cameracalibration_tilt.cpp b/modules/calib3d/test/test_cameracalibration_tilt.cpp index 5ac5dd985d08..99bdade4e37f 100644 --- a/modules/calib3d/test/test_cameracalibration_tilt.cpp +++ b/modules/calib3d/test/test_cameracalibration_tilt.cpp @@ -616,7 +616,7 @@ TEST_F(cameraCalibrationTiltTest, calibrateCamera) // Output std::vector outRvecs, outTvecs; - cv::Mat outCameraMatrix(3, 3, CV_64F, cv::Scalar::all(1)), outDistCoeff; + cv::Mat outCameraMatrix(3, 3, CV_64FC1, cv::Scalar::all(1)), outDistCoeff; // Stopping criteria cv::TermCriteria stop( diff --git a/modules/calib3d/test/test_chessboardgenerator.cpp b/modules/calib3d/test/test_chessboardgenerator.cpp index 3a8c17345fb8..59d4466f61f8 100644 --- a/modules/calib3d/test/test_chessboardgenerator.cpp +++ b/modules/calib3d/test/test_chessboardgenerator.cpp @@ -47,10 +47,10 @@ namespace cv { ChessBoardGenerator::ChessBoardGenerator(const Size& _patternSize) : sensorWidth(32), sensorHeight(24), squareEdgePointsNum(200), min_cos(std::sqrt(3.f)*0.5f), cov(0.5), - patternSize(_patternSize), rendererResolutionMultiplier(4), tvec(Mat::zeros(1, 3, CV_32F)) + patternSize(_patternSize), rendererResolutionMultiplier(4), tvec(Mat::zeros(1, 3, CV_32FC1)) { - rvec.create(3, 1, CV_32F); - cvtest::Rodrigues(Mat::eye(3, 3, CV_32F), rvec); + rvec.create(3, 1, CV_32FC1); + cvtest::Rodrigues(Mat::eye(3, 3, CV_32FC1), rvec); } void ChessBoardGenerator::generateEdge(const Point3f& p1, const Point3f& p2, vector& out) const diff --git a/modules/calib3d/test/test_chesscorners_badarg.cpp b/modules/calib3d/test/test_chesscorners_badarg.cpp index 422e364d46ac..9c949e16a3a4 100644 --- a/modules/calib3d/test/test_chesscorners_badarg.cpp +++ b/modules/calib3d/test/test_chesscorners_badarg.cpp @@ -98,7 +98,7 @@ CV_ChessboardDetectorBadArgTest::CV_ChessboardDetectorBadArgTest() /* ///////////////////// chess_corner_test ///////////////////////// */ void CV_ChessboardDetectorBadArgTest::run( int /*start_from */) { - Mat bg(800, 600, CV_8U, Scalar(0)); + Mat bg(800, 600, CV_8UC1, Scalar(0)); Mat_ camMat(3, 3); camMat << 300.f, 0.f, bg.cols/2.f, 0, 300.f, bg.rows/2.f, 0.f, 0.f, 1.f; Mat_ distCoeffs(1, 5); diff --git a/modules/calib3d/test/test_filter_homography_decomp.cpp b/modules/calib3d/test/test_filter_homography_decomp.cpp index 533d9ddf5616..7b89f9d1aca2 100644 --- a/modules/calib3d/test/test_filter_homography_decomp.cpp +++ b/modules/calib3d/test/test_filter_homography_decomp.cpp @@ -556,7 +556,7 @@ class CV_FilterHomographyDecompTest : public cvtest::BaseTest { _rotations.swap(rotations); _normals.swap(normals); - _mask = Mat(514, 1, CV_8U, maskArray).clone(); + _mask = Mat(514, 1, CV_8UC1, maskArray).clone(); } bool isValidResult(const vector& solutions) diff --git a/modules/calib3d/test/test_fisheye.cpp b/modules/calib3d/test/test_fisheye.cpp index b535a0080253..aeea689b04c1 100644 --- a/modules/calib3d/test/test_fisheye.cpp +++ b/modules/calib3d/test/test_fisheye.cpp @@ -145,9 +145,9 @@ TEST_F(fisheyeTest, jacobians) { int n = 10; cv::Mat X(1, n, CV_64FC3); - cv::Mat om(3, 1, CV_64F), theT(3, 1, CV_64F); - cv::Mat f(2, 1, CV_64F), c(2, 1, CV_64F); - cv::Mat k(4, 1, CV_64F); + cv::Mat om(3, 1, CV_64FC1), theT(3, 1, CV_64FC1); + cv::Mat f(2, 1, CV_64FC1), c(2, 1, CV_64FC1); + cv::Mat k(4, 1, CV_64FC1); double alpha; cv::RNG r; @@ -452,8 +452,8 @@ TEST_F(fisheyeTest, stereoRectify) #if 1 // Debug code cv::Mat lmapx, lmapy, rmapx, rmapy; //rewrite for fisheye - cv::fisheye::initUndistortRectifyMap(K1, D1, R1, P1, requested_size, CV_32F, lmapx, lmapy); - cv::fisheye::initUndistortRectifyMap(K2, D2, R2, P2, requested_size, CV_32F, rmapx, rmapy); + cv::fisheye::initUndistortRectifyMap(K1, D1, R1, P1, requested_size, CV_32FC1, lmapx, lmapy); + cv::fisheye::initUndistortRectifyMap(K2, D2, R2, P2, requested_size, CV_32FC1, rmapx, rmapy); cv::Mat l, r, lundist, rundist; for (int i = 0; i < 34; ++i) @@ -691,7 +691,7 @@ std::string fisheyeTest::combine(const std::string& _item1, const std::string& _ void fisheyeTest::merge4(const cv::Mat& tl, const cv::Mat& tr, const cv::Mat& bl, const cv::Mat& br, cv::Mat& merged) { - int type = tl.type(); + ElemType type = tl.type(); cv::Size sz = tl.size(); ASSERT_EQ(type, tr.type()); ASSERT_EQ(type, bl.type()); ASSERT_EQ(type, br.type()); ASSERT_EQ(sz.width, tr.cols); ASSERT_EQ(sz.width, bl.cols); ASSERT_EQ(sz.width, br.cols); diff --git a/modules/calib3d/test/test_fundam.cpp b/modules/calib3d/test/test_fundam.cpp index 236db6ec4d66..2e642590f90e 100644 --- a/modules/calib3d/test/test_fundam.cpp +++ b/modules/calib3d/test/test_fundam.cpp @@ -102,9 +102,9 @@ static int cvTsRodrigues( const CvMat* src, CvMat* dst, CvMat* jacobian ) w3*w1, w3*w2, w3*w3 }; double R[9]; - CvMat _omegav = cvMat(3, 3, CV_64F, omegav); - CvMat matA = cvMat(3, 3, CV_64F, A); - CvMat matR = cvMat(3, 3, CV_64F, R); + CvMat _omegav = cvMat(3, 3, CV_64FC1, omegav); + CvMat matA = cvMat(3, 3, CV_64FC1, A); + CvMat matR = cvMat(3, 3, CV_64FC1, R); cvSetIdentity( &matR, cvRealScalar(alpha) ); cvScaleAdd( &_omegav, cvRealScalar(beta), &matR, &matR ); @@ -474,7 +474,7 @@ test_projectPoints( const Mat& _3d, const Mat& Rt, const Mat& A, Mat& _2d, RNG* CV_Assert( _3d.isContinuous() ); double p[12]; - Mat P( 3, 4, CV_64F, p ); + Mat P(3, 4, CV_64FC1, p); gemm(A, Rt, 1, Mat(), 0, P); int i, count = _3d.cols; @@ -525,13 +525,13 @@ class CV_RodriguesTest : public cvtest::ArrayTest CV_RodriguesTest(); protected: - int read_params( CvFileStorage* fs ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); - int prepare_test_case( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + int read_params(CvFileStorage* fs) CV_OVERRIDE; + void fill_array(int test_case_idx, int i, int j, Mat& arr) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; bool calc_jacobians; bool test_cpp; @@ -567,7 +567,7 @@ int CV_RodriguesTest::read_params( CvFileStorage* fs ) void CV_RodriguesTest::get_test_array_types_and_sizes( - int /*test_case_idx*/, vector >& sizes, vector >& types ) + int /*test_case_idx*/, vector >& sizes, vector >& types) { RNG& rng = ts->get_rng(); int depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F; @@ -647,7 +647,7 @@ void CV_RodriguesTest::fill_array( int test_case_idx, int i, int j, Mat& arr ) r[1] *= f; r[2] *= f; - cvtest::convert( _r, arr, arr.type() ); + cvtest::convert( _r, arr, arr.depth() ); } else cvtest::ArrayTest::fill_array( test_case_idx, i, j, arr ); @@ -696,19 +696,19 @@ void CV_RodriguesTest::run_func() { if( J1.size() != J1_0.size() ) J1 = J1.t(); - J1.convertTo(J1_0, J1_0.type()); + J1.convertTo(J1_0, J1_0.depth()); } if( J2.data != J2_0.data ) { if( J2.size() != J2_0.size() ) J2 = J2.t(); - J2.convertTo(J2_0, J2_0.type()); + J2.convertTo(J2_0, J2_0.depth()); } } if( M.data != M0.data ) - M.reshape(M0.channels(), M0.rows).convertTo(M0, M0.type()); + M.reshape(M0.channels(), M0.rows).convertTo(M0, M0.depth()); if( v2.data != v2_0.data ) - v2.reshape(v2_0.channels(), v2_0.rows).convertTo(v2_0, v2_0.type()); + v2.reshape(v2_0.channels(), v2_0.rows).convertTo(v2_0, v2_0.depth()); } } @@ -767,13 +767,13 @@ class CV_FundamentalMatTest : public cvtest::ArrayTest CV_FundamentalMatTest(); protected: - int read_params( CvFileStorage* fs ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); - int prepare_test_case( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + int read_params(CvFileStorage* fs) CV_OVERRIDE; + void fill_array(int test_case_idx, int i, int j, Mat& arr) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; int method; int img_size; @@ -830,7 +830,7 @@ int CV_FundamentalMatTest::read_params( CvFileStorage* fs ) void CV_FundamentalMatTest::get_test_array_types_and_sizes( int /*test_case_idx*/, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int pt_depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F; @@ -928,8 +928,8 @@ void CV_FundamentalMatTest::fill_array( int test_case_idx, int i, int j, Mat& ar case 3: { double r[3]; - Mat rot_vec( 3, 1, CV_64F, r ); - Mat rot_mat( 3, 3, CV_64F, t, 4*sizeof(t[0]) ); + Mat rot_vec(3, 1, CV_64FC1, r); + Mat rot_mat(3, 3, CV_64FC1, t, 4 * sizeof(t[0])); r[0] = cvtest::randReal(rng)*CV_PI*2; r[1] = cvtest::randReal(rng)*CV_PI*2; r[2] = cvtest::randReal(rng)*CV_PI*2; @@ -938,7 +938,7 @@ void CV_FundamentalMatTest::fill_array( int test_case_idx, int i, int j, Mat& ar t[3] = cvtest::randReal(rng)*cube_size; t[7] = cvtest::randReal(rng)*cube_size; t[11] = cvtest::randReal(rng)*cube_size; - Mat( 3, 4, CV_64F, t ).convertTo(arr, arr.type()); + Mat(3, 4, CV_64FC1, t).convertTo(arr, arr.depth()); } break; case 4: @@ -947,7 +947,7 @@ void CV_FundamentalMatTest::fill_array( int test_case_idx, int i, int j, Mat& ar t[2] = (img_size*0.5 + cvtest::randReal(rng)*4. - 2.)*t[0]; t[5] = (img_size*0.5 + cvtest::randReal(rng)*4. - 2.)*t[4]; t[8] = 1.; - Mat( 3, 3, CV_64F, t ).convertTo( arr, arr.type() ); + Mat(3, 3, CV_64FC1, t).convertTo(arr, arr.depth()); break; } } @@ -961,7 +961,7 @@ int CV_FundamentalMatTest::prepare_test_case( int test_case_idx ) const Mat& _3d = test_mat[INPUT][2]; RNG& rng = ts->get_rng(); double Idata[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 }; - Mat I( 3, 4, CV_64F, Idata ); + Mat I(3, 4, CV_64FC1, Idata); int k; for( k = 0; k < 2; k++ ) @@ -992,7 +992,7 @@ void CV_FundamentalMatTest::prepare_to_validation( int test_case_idx ) const Mat& A1 = test_mat[INPUT][4]; const Mat& A2 = test_mat[INPUT][5]; double f0[9], f[9]; - Mat F0(3, 3, CV_64FC1, f0), F(3, 3, CV_64F, f); + Mat F0(3, 3, CV_64FC1, f0), F(3, 3, CV_64FC1, f); Mat invA1, invA2, R=Rt.colRange(0, 3), T; @@ -1006,7 +1006,7 @@ void CV_FundamentalMatTest::prepare_to_validation( int test_case_idx ) double _t_x[] = { 0, -tz, ty, tz, 0, -tx, -ty, tx, 0 }; // F = (A2^-T)*[t]_x*R*(A1^-1) - cv::gemm( invA2, Mat( 3, 3, CV_64F, _t_x ), 1, Mat(), 0, T, CV_GEMM_A_T ); + cv::gemm(invA2, Mat(3, 3, CV_64FC1, _t_x), 1, Mat(), 0, T, CV_GEMM_A_T); cv::gemm( R, invA1, 1, Mat(), 0, invA2 ); cv::gemm( T, invA2, 1, Mat(), 0, F0 ); F0 *= 1./f0[8]; @@ -1025,7 +1025,7 @@ void CV_FundamentalMatTest::prepare_to_validation( int test_case_idx ) test_convertHomogeneous( test_mat[INPUT][0], p1 ); test_convertHomogeneous( test_mat[INPUT][1], p2 ); - cvtest::convert(test_mat[TEMP][0], F, F.type()); + cvtest::convert(test_mat[TEMP][0], F, F.depth()); if( method <= CV_FM_8POINT ) memset( status, 1, pt_count ); @@ -1063,13 +1063,13 @@ class CV_EssentialMatTest : public cvtest::ArrayTest CV_EssentialMatTest(); protected: - int read_params( CvFileStorage* fs ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); - int prepare_test_case( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + int read_params( CvFileStorage* fs ) CV_OVERRIDE; + void fill_array(int test_case_idx, int i, int j, Mat& arr) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; #if 0 double sampson_error(const double* f, double x1, double y1, double x2, double y2); @@ -1131,7 +1131,7 @@ int CV_EssentialMatTest::read_params( CvFileStorage* fs ) void CV_EssentialMatTest::get_test_array_types_and_sizes( int /*test_case_idx*/, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int pt_depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F; @@ -1230,8 +1230,8 @@ void CV_EssentialMatTest::fill_array( int test_case_idx, int i, int j, Mat& arr case 3: { double r[3]; - Mat rot_vec( 3, 1, CV_64F, r ); - Mat rot_mat( 3, 3, CV_64F, t, 4*sizeof(t[0]) ); + Mat rot_vec(3, 1, CV_64FC1, r); + Mat rot_mat(3, 3, CV_64FC1, t, 4 * sizeof(t[0])); r[0] = cvtest::randReal(rng)*CV_PI*2; r[1] = cvtest::randReal(rng)*CV_PI*2; r[2] = cvtest::randReal(rng)*CV_PI*2; @@ -1240,7 +1240,7 @@ void CV_EssentialMatTest::fill_array( int test_case_idx, int i, int j, Mat& arr t[3] = cvtest::randReal(rng)*cube_size; t[7] = cvtest::randReal(rng)*cube_size; t[11] = cvtest::randReal(rng)*cube_size; - Mat( 3, 4, CV_64F, t ).convertTo(arr, arr.type()); + Mat(3, 4, CV_64FC1, t).convertTo(arr, arr.depth()); } break; case 4: @@ -1248,7 +1248,7 @@ void CV_EssentialMatTest::fill_array( int test_case_idx, int i, int j, Mat& arr t[2] = (img_size*0.5 + cvtest::randReal(rng)*4. - 2.)*t[0]; t[5] = (img_size*0.5 + cvtest::randReal(rng)*4. - 2.)*t[4]; t[8] = 1.; - Mat( 3, 3, CV_64F, t ).convertTo( arr, arr.type() ); + Mat(3, 3, CV_64FC1, t).convertTo(arr, arr.depth()); break; } } @@ -1262,7 +1262,7 @@ int CV_EssentialMatTest::prepare_test_case( int test_case_idx ) const Mat& _3d = test_mat[INPUT][2]; RNG& rng = ts->get_rng(); double Idata[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 }; - Mat I( 3, 4, CV_64F, Idata ); + Mat I(3, 4, CV_64FC1, Idata); int k; for( k = 0; k < 2; k++ ) @@ -1331,8 +1331,8 @@ void CV_EssentialMatTest::prepare_to_validation( int test_case_idx ) const Mat& Rt0 = test_mat[INPUT][3]; const Mat& A = test_mat[INPUT][4]; double f0[9], f[9], e[9]; - Mat F0(3, 3, CV_64FC1, f0), F(3, 3, CV_64F, f); - Mat E(3, 3, CV_64F, e); + Mat F0(3, 3, CV_64FC1, f0), F(3, 3, CV_64FC1, f); + Mat E(3, 3, CV_64FC1, e); Mat invA, R=Rt0.colRange(0, 3), T1, T2; @@ -1345,7 +1345,7 @@ void CV_EssentialMatTest::prepare_to_validation( int test_case_idx ) double _t_x[] = { 0, -tz, ty, tz, 0, -tx, -ty, tx, 0 }; // F = (A2^-T)*[t]_x*R*(A1^-1) - cv::gemm( invA, Mat( 3, 3, CV_64F, _t_x ), 1, Mat(), 0, T1, CV_GEMM_A_T ); + cv::gemm(invA, Mat(3, 3, CV_64FC1, _t_x), 1, Mat(), 0, T1, CV_GEMM_A_T); cv::gemm( R, invA, 1, Mat(), 0, T2 ); cv::gemm( T1, T2, 1, Mat(), 0, F0 ); F0 *= 1./f0[8]; @@ -1356,7 +1356,7 @@ void CV_EssentialMatTest::prepare_to_validation( int test_case_idx ) uchar* mtfm2 = test_mat[OUTPUT][1].ptr(); double* e_prop1 = test_mat[REF_OUTPUT][0].ptr(); double* e_prop2 = test_mat[OUTPUT][0].ptr(); - Mat E_prop2 = Mat(3, 1, CV_64F, e_prop2); + Mat E_prop2 = Mat(3, 1, CV_64FC1, e_prop2); int i, pt_count = test_mat[INPUT][2].cols; Mat p1( 1, pt_count, CV_64FC2 ); @@ -1365,7 +1365,7 @@ void CV_EssentialMatTest::prepare_to_validation( int test_case_idx ) test_convertHomogeneous( test_mat[INPUT][0], p1 ); test_convertHomogeneous( test_mat[INPUT][1], p2 ); - cvtest::convert(test_mat[TEMP][0], E, E.type()); + cvtest::convert(test_mat[TEMP][0], E, E.depth()); cv::gemm( invA, E, 1, Mat(), 0, T1, CV_GEMM_A_T ); cv::gemm( T1, invA, 1, Mat(), 0, F ); @@ -1404,7 +1404,7 @@ void CV_EssentialMatTest::prepare_to_validation( int test_case_idx ) double* pose_prop2 = test_mat[OUTPUT][2].ptr(); double terr1 = cvtest::norm(Rt0.col(3) / cvtest::norm(Rt0.col(3), NORM_L2) + test_mat[TEMP][3], NORM_L2); double terr2 = cvtest::norm(Rt0.col(3) / cvtest::norm(Rt0.col(3), NORM_L2) - test_mat[TEMP][3], NORM_L2); - Mat rvec(3, 1, CV_32F); + Mat rvec(3, 1, CV_32FC1); cvtest::Rodrigues(Rt0.colRange(0, 3), rvec); pose_prop1[0] = 0; // No check for CV_LMeDS on translation. Since it @@ -1429,12 +1429,12 @@ class CV_ConvertHomogeneousTest : public cvtest::ArrayTest CV_ConvertHomogeneousTest(); protected: - int read_params( CvFileStorage* fs ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + int read_params(CvFileStorage* fs) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void fill_array(int test_case_idx, int i, int j, Mat& arr) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; int dims1, dims2; int pt_count; @@ -1460,7 +1460,7 @@ int CV_ConvertHomogeneousTest::read_params( CvFileStorage* fs ) void CV_ConvertHomogeneousTest::get_test_array_types_and_sizes( int /*test_case_idx*/, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int pt_depth1 = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F; @@ -1562,12 +1562,12 @@ class CV_ComputeEpilinesTest : public cvtest::ArrayTest CV_ComputeEpilinesTest(); protected: - int read_params( CvFileStorage* fs ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + int read_params(CvFileStorage* fs) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void fill_array(int test_case_idx, int i, int j, Mat& arr) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; int which_image; int dims; @@ -1595,7 +1595,7 @@ int CV_ComputeEpilinesTest::read_params( CvFileStorage* fs ) void CV_ComputeEpilinesTest::get_test_array_types_and_sizes( int /*test_case_idx*/, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int fm_depth = cvtest::randInt(rng) % 2 == 0 ? CV_32F : CV_64F; @@ -1688,7 +1688,7 @@ void CV_ComputeEpilinesTest::prepare_to_validation( int /*test_case_idx*/ ) Mat pt( 1, pt_count, CV_MAKETYPE(CV_64F, 3) ); Mat lines( 1, pt_count, CV_MAKETYPE(CV_64F, 3) ); double f[9]; - Mat F( 3, 3, CV_64F, f ); + Mat F(3, 3, CV_64FC1, f); test_convertHomogeneous( test_mat[INPUT][0], pt ); test_mat[INPUT][1].convertTo(F, CV_64F); @@ -1722,7 +1722,7 @@ TEST(Calib3d_FindFundamentalMat, correctMatches) double p1data[] = {200, 0, 1}; double p2data[] = {170, 0, 1}; - Mat F(3, 3, CV_64F, fdata); + Mat F(3, 3, CV_64FC1, fdata); Mat p1(1, 1, CV_64FC2, p1data); Mat p2(1, 1, CV_64FC2, p2data); Mat np1, np2; diff --git a/modules/calib3d/test/test_homography.cpp b/modules/calib3d/test/test_homography.cpp index 3001f0fec0dc..b41e2ea8b93e 100644 --- a/modules/calib3d/test/test_homography.cpp +++ b/modules/calib3d/test/test_homography.cpp @@ -262,8 +262,8 @@ void CV_HomographyTest::run(int) } cv::Mat src_mat_2f(1, N, CV_32FC2, src_data), - src_mat_2d(2, N, CV_32F, src_data), - src_mat_3d(3, N, CV_32F); + src_mat_2d(2, N, CV_32FC1, src_data), + src_mat_3d(3, N, CV_32FC1); cv::Mat dst_mat_2f, dst_mat_2d, dst_mat_3d; vector src_vec, dst_vec; @@ -287,13 +287,13 @@ void CV_HomographyTest::run(int) sin(fi), cos(fi), t_y, 0.0f, 0.0f, 1.0f }; - cv::Mat H_64(3, 3, CV_64F, Hdata), H_32; + cv::Mat H_64(3, 3, CV_64FC1, Hdata), H_32; H_64.convertTo(H_32, CV_32F); dst_mat_3d = H_32*src_mat_3d; - dst_mat_2d.create(2, N, CV_32F); dst_mat_2f.create(1, N, CV_32FC2); + dst_mat_2d.create(2, N, CV_32FC1); dst_mat_2f.create(1, N, CV_32FC2); for (int i = 0; i < N; ++i) { @@ -433,7 +433,7 @@ void CV_HomographyTest::run(int) Mat H_res_32; H_res_64[j].convertTo(H_res_32, CV_32F); - cv::Mat dst_res_3d(3, N, CV_32F), noise_2d(2, N, CV_32F); + cv::Mat dst_res_3d(3, N, CV_32FC1), noise_2d(2, N, CV_32FC1); for (int k = 0; k < N; ++k) { @@ -542,7 +542,7 @@ void CV_HomographyTest::run(int) dst_mat_3d.at(0, k) -= a[0]; dst_mat_3d.at(1, k) -= a[1]; - cv::Mat noise_2d(2, 1, CV_32F); + cv::Mat noise_2d(2, 1, CV_32FC1); noise_2d.at(0, 0) = a[0]; noise_2d.at(1, 0) = a[1]; for (int l = 0; l < COUNT_NORM_TYPES; ++l) diff --git a/modules/calib3d/test/test_modelest.cpp b/modules/calib3d/test/test_modelest.cpp index 55cb79ebaf13..be366cc67583 100644 --- a/modules/calib3d/test/test_modelest.cpp +++ b/modules/calib3d/test/test_modelest.cpp @@ -86,11 +86,11 @@ class CV_ModelEstimator2_Test : public cvtest::ArrayTest CV_ModelEstimator2_Test(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void fill_array( int test_case_idx, int i, int j, Mat& arr ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void run_func(); - void prepare_to_validation( int test_case_idx ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; bool checkPartialSubsets; int usedPointsCount; @@ -111,7 +111,7 @@ CV_ModelEstimator2_Test::CV_ModelEstimator2_Test() } void CV_ModelEstimator2_Test::get_test_array_types_and_sizes( int /*test_case_idx*/, - vector > &sizes, vector > &types ) + vector > &sizes, vector > &types ) { RNG &rng = ts->get_rng(); checkPartialSubsets = (cvtest::randInt(rng) % 2 == 0); diff --git a/modules/calib3d/test/test_solvepnp_ransac.cpp b/modules/calib3d/test/test_solvepnp_ransac.cpp index 8eec7a7167aa..6b722090dda6 100644 --- a/modules/calib3d/test/test_solvepnp_ransac.cpp +++ b/modules/calib3d/test/test_solvepnp_ransac.cpp @@ -368,7 +368,7 @@ TEST(Calib3d_SolvePnPRansac, concurrency) camera_mat.at(2, 0) = 0.f; camera_mat.at(2, 1) = 0.f; - Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0)); + Mat dist_coef(1, 8, CV_32FC1, cv::Scalar::all(0)); vector image_vec; Mat rvec_gold(1, 3, CV_32FC1); diff --git a/modules/calib3d/test/test_stereomatching.cpp b/modules/calib3d/test/test_stereomatching.cpp index 94fc9718ccac..f902eb1dbf5d 100644 --- a/modules/calib3d/test/test_stereomatching.cpp +++ b/modules/calib3d/test/test_stereomatching.cpp @@ -78,9 +78,9 @@ void computeTextureBasedMasks( const Mat& _img, Mat* texturelessMask, Mat* textu { Mat tmp; cvtColor( _img, tmp, COLOR_BGR2GRAY ); img = tmp; } - Mat dxI; Sobel( img, dxI, CV_32FC1, 1, 0, 3 ); + Mat dxI; Sobel( img, dxI, CV_32F, 1, 0, 3 ); Mat dxI2; pow( dxI / 8.f/*normalize*/, 2, dxI2 ); - Mat avgDxI2; boxFilter( dxI2, avgDxI2, CV_32FC1, Size(texturelessWidth,texturelessWidth) ); + Mat avgDxI2; boxFilter( dxI2, avgDxI2, CV_32F, Size(texturelessWidth,texturelessWidth) ); if( texturelessMask ) *texturelessMask = avgDxI2 < texturelessThresh; @@ -469,13 +469,13 @@ void CV_StereoMatchingTest::run(int) int dispScaleFactor = datasetsParams[datasetName].dispScaleFactor; Mat tmp; - trueLeftDisp.convertTo( tmp, CV_32FC1, 1.f/dispScaleFactor ); + trueLeftDisp.convertTo( tmp, CV_32F, 1.f/dispScaleFactor ); trueLeftDisp = tmp; tmp.release(); if( !trueRightDisp.empty() ) { - trueRightDisp.convertTo( tmp, CV_32FC1, 1.f/dispScaleFactor ); + trueRightDisp.convertTo( tmp, CV_32F, 1.f/dispScaleFactor ); trueRightDisp = tmp; tmp.release(); } @@ -483,11 +483,11 @@ void CV_StereoMatchingTest::run(int) Mat leftDisp, rightDisp; int ignBorder = max(runStereoMatchingAlgorithm(leftImg, rightImg, calcROI, leftDisp, rightDisp, ci), EVAL_IGNORE_BORDER); - leftDisp.convertTo( tmp, CV_32FC1 ); + leftDisp.convertTo( tmp, CV_32F ); leftDisp = tmp; tmp.release(); - rightDisp.convertTo( tmp, CV_32FC1 ); + rightDisp.convertTo( tmp, CV_32F ); rightDisp = tmp; tmp.release(); @@ -888,7 +888,7 @@ TEST(Calib3d_StereoSGBM_HH4, regression) Ptr sgbm = StereoSGBM::create( 0, 48, 3, 90, 360, 1, 63, 10, 100, 32, StereoSGBM::MODE_HH4); sgbm->compute( leftImg, rightImg, leftDisp); CV_Assert( leftDisp.type() == CV_16SC1 ); - leftDisp.convertTo(toCheck, CV_16UC1,1,16); + leftDisp.convertTo(toCheck, CV_16U,1,16); } Mat diff; absdiff(toCheck, testData,diff); diff --git a/modules/calib3d/test/test_undistort.cpp b/modules/calib3d/test/test_undistort.cpp index e4fe4fe1f3f0..2ab2d31ff537 100644 --- a/modules/calib3d/test/test_undistort.cpp +++ b/modules/calib3d/test/test_undistort.cpp @@ -50,9 +50,9 @@ class CV_DefaultNewCameraMatrixTest : public cvtest::ArrayTest public: CV_DefaultNewCameraMatrixTest(); protected: - int prepare_test_case (int test_case_idx); - void prepare_to_validation( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); + int prepare_test_case (int test_case_idx) CV_OVERRIDE; + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; void run_func(); private: @@ -79,11 +79,11 @@ CV_DefaultNewCameraMatrixTest::CV_DefaultNewCameraMatrixTest() center_principal_point = false; } -void CV_DefaultNewCameraMatrixTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_DefaultNewCameraMatrixTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { cvtest::ArrayTest::get_test_array_types_and_sizes(test_case_idx,sizes,types); RNG& rng = ts->get_rng(); - matrix_type = types[INPUT][0] = types[OUTPUT][0]= types[REF_OUTPUT][0] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; + matrix_type = types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(3,3); } @@ -105,14 +105,14 @@ int CV_DefaultNewCameraMatrixTest::prepare_test_case(int test_case_idx) double sz = MAX(img_size.width, img_size.height); double aspect_ratio = cvtest::randReal(rng)*0.6 + 0.7; double a[9] = {0,0,0,0,0,0,0,0,1}; - Mat _a(3,3,CV_64F,a); + Mat _a(3,3,CV_64FC1,a); a[2] = (img_size.width - 1)*0.5 + cvtest::randReal(rng)*10 - 5; a[5] = (img_size.height - 1)*0.5 + cvtest::randReal(rng)*10 - 5; a[0] = sz/(0.9 - cvtest::randReal(rng)*0.6); a[4] = aspect_ratio*a[0]; Mat& _a0 = test_mat[INPUT][0]; - cvtest::convert(_a, _a0, _a0.type()); + cvtest::convert(_a, _a0, _a0.depth()); camera_mat = _a0; return code; @@ -130,7 +130,7 @@ void CV_DefaultNewCameraMatrixTest::prepare_to_validation( int /*test_case_idx*/ Mat& dst = test_mat[REF_OUTPUT][0]; Mat& test_output = test_mat[OUTPUT][0]; Mat& output = new_camera_mat; - cvtest::convert( output, test_output, test_output.type() ); + cvtest::convert(output, test_output, test_output.depth()); if (!center_principal_point) { cvtest::copy(src, dst); @@ -138,7 +138,7 @@ void CV_DefaultNewCameraMatrixTest::prepare_to_validation( int /*test_case_idx*/ else { double a[9] = {0,0,0,0,0,0,0,0,1}; - Mat _a(3,3,CV_64F,a); + Mat _a(3,3,CV_64FC1,a); if (matrix_type == CV_64F) { a[0] = src.at(0,0); @@ -151,7 +151,7 @@ void CV_DefaultNewCameraMatrixTest::prepare_to_validation( int /*test_case_idx*/ } a[2] = (img_size.width - 1)*0.5; a[5] = (img_size.height - 1)*0.5; - cvtest::convert( _a, dst, dst.type() ); + cvtest::convert(_a, dst, dst.depth()); } } @@ -162,10 +162,10 @@ class CV_UndistortPointsTest : public cvtest::ArrayTest public: CV_UndistortPointsTest(); protected: - int prepare_test_case (int test_case_idx); - void prepare_to_validation( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + int prepare_test_case (int test_case_idx) CV_OVERRIDE; + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void run_func(); void distortPoints(const CvMat* _src, CvMat* _dst, const CvMat* _cameraMatrix, const CvMat* _distCoeffs, const CvMat* matR, const CvMat* matP); @@ -207,7 +207,7 @@ CV_UndistortPointsTest::CV_UndistortPointsTest() zero_new_cam = zero_distortion = zero_R = false; } -void CV_UndistortPointsTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_UndistortPointsTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { cvtest::ArrayTest::get_test_array_types_and_sizes(test_case_idx,sizes,types); RNG& rng = ts->get_rng(); @@ -221,10 +221,10 @@ void CV_UndistortPointsTest::get_test_array_types_and_sizes( int test_case_idx, { types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = types[TEMP][0]= cvtest::randInt(rng)%2 ? CV_64FC2 : CV_32FC2; } - types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; - types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; - types[INPUT][3] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; - types[INPUT][4] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; + types[INPUT][1] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; + types[INPUT][2] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; + types[INPUT][3] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; + types[INPUT][4] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = sizes[TEMP][0]= cvtest::randInt(rng)%2 ? cvSize(1,N_POINTS) : cvSize(N_POINTS,1); sizes[INPUT][1] = sizes[INPUT][3] = cvSize(3,3); @@ -272,9 +272,9 @@ int CV_UndistortPointsTest::prepare_test_case(int test_case_idx) vector proj(test_mat[INPUT][4].cols * test_mat[INPUT][4].rows); vector points(N_POINTS); - Mat _camera(3,3,CV_64F,cam); - Mat _distort(test_mat[INPUT][2].rows,test_mat[INPUT][2].cols,CV_64F,&dist[0]); - Mat _proj(test_mat[INPUT][4].size(), CV_64F, &proj[0]); + Mat _camera(3,3,CV_64FC1,cam); + Mat _distort(test_mat[INPUT][2].rows, test_mat[INPUT][2].cols, CV_64FC1, &dist[0]); + Mat _proj(test_mat[INPUT][4].size(), CV_64FC1, &proj[0]); Mat _points(test_mat[INPUT][0].size(), CV_64FC2, &points[0]); _proj = Scalar::all(0); @@ -344,8 +344,8 @@ int CV_UndistortPointsTest::prepare_test_case(int test_case_idx) } //Generating R matrix - Mat _rot(3,3,CV_64F); - Mat rotation(1,3,CV_64F); + Mat _rot(3,3,CV_64FC1); + Mat rotation(1,3,CV_64FC1); rotation.at(0) = CV_PI*(cvtest::randReal(rng) - (double)0.5); // phi rotation.at(1) = CV_PI*(cvtest::randReal(rng) - (double)0.5); // ksi rotation.at(2) = CV_PI*(cvtest::randReal(rng) - (double)0.5); //khi @@ -353,11 +353,11 @@ int CV_UndistortPointsTest::prepare_test_case(int test_case_idx) //copying data //src_points = &_points; - _points.convertTo(test_mat[INPUT][0], test_mat[INPUT][0].type()); - _camera.convertTo(test_mat[INPUT][1], test_mat[INPUT][1].type()); - _distort.convertTo(test_mat[INPUT][2], test_mat[INPUT][2].type()); - _rot.convertTo(test_mat[INPUT][3], test_mat[INPUT][3].type()); - _proj.convertTo(test_mat[INPUT][4], test_mat[INPUT][4].type()); + _points.convertTo(test_mat[INPUT][0], test_mat[INPUT][0].depth()); + _camera.convertTo(test_mat[INPUT][1], test_mat[INPUT][1].depth()); + _distort.convertTo(test_mat[INPUT][2], test_mat[INPUT][2].depth()); + _rot.convertTo(test_mat[INPUT][3], test_mat[INPUT][3].depth()); + _proj.convertTo(test_mat[INPUT][4], test_mat[INPUT][4].depth()); zero_distortion = (cvtest::randInt(rng)%2) == 0 ? false : true; zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true; @@ -388,8 +388,8 @@ void CV_UndistortPointsTest::prepare_to_validation(int /*test_case_idx*/) double* r_points = new double[N_POINTS*2]; //Run reference calculations CvMat ref_points= cvMat(test_mat[INPUT][0].rows,test_mat[INPUT][0].cols,CV_64FC2,r_points); - CvMat _camera = cvMat(3,3,CV_64F,cam); - CvMat _rot = cvMat(3,3,CV_64F,rot); + CvMat _camera = cvMat(3,3,CV_64FC1,cam); + CvMat _rot = cvMat(3,3,CV_64FC1,rot); CvMat _distort = cvMat(test_mat[INPUT][2].rows,test_mat[INPUT][2].cols,CV_64F,dist); CvMat _proj = cvMat(test_mat[INPUT][4].rows,test_mat[INPUT][4].cols,CV_64F,proj); CvMat _points= cvMat(test_mat[TEMP][0].rows,test_mat[TEMP][0].cols,CV_64FC2,points); @@ -401,10 +401,10 @@ void CV_UndistortPointsTest::prepare_to_validation(int /*test_case_idx*/) Mat __points = cvarrToMat(&_points); Mat _ref_points = cvarrToMat(&ref_points); - cvtest::convert(test_mat[INPUT][1], __camera, __camera.type()); - cvtest::convert(test_mat[INPUT][2], __distort, __distort.type()); - cvtest::convert(test_mat[INPUT][3], __rot, __rot.type()); - cvtest::convert(test_mat[INPUT][4], __proj, __proj.type()); + cvtest::convert(test_mat[INPUT][1], __camera, __camera.depth()); + cvtest::convert(test_mat[INPUT][2], __distort, __distort.depth()); + cvtest::convert(test_mat[INPUT][3], __rot, __rot.depth()); + cvtest::convert(test_mat[INPUT][4], __proj, __proj.depth()); if (useCPlus) { @@ -427,7 +427,7 @@ void CV_UndistortPointsTest::prepare_to_validation(int /*test_case_idx*/) } else { - cvtest::convert(test_mat[TEMP][0],__points, __points.type()); + cvtest::convert(test_mat[TEMP][0], __points, __points.depth()); } CvMat* input2 = zero_distortion ? 0 : &_distort; @@ -436,7 +436,7 @@ void CV_UndistortPointsTest::prepare_to_validation(int /*test_case_idx*/) distortPoints(&_points,&ref_points,&_camera,input2,input3,input4); Mat& dst = test_mat[REF_OUTPUT][0]; - cvtest::convert(_ref_points, dst, dst.type()); + cvtest::convert(_ref_points, dst, dst.depth()); cvtest::copy(test_mat[INPUT][0], test_mat[OUTPUT][0]); @@ -492,12 +492,12 @@ void CV_UndistortPointsTest::distortPoints(const CvMat* _src, CvMat* _dst, const CvMat* __P; if ((!matP)||(matP->cols == 3)) - __P = cvCreateMat(3,3,CV_64F); + __P = cvCreateMat(3,3,CV_64FC1); else - __P = cvCreateMat(3,4,CV_64F); + __P = cvCreateMat(3,4,CV_64FC1); if (matP) { - cvtest::convert(cvarrToMat(matP), cvarrToMat(__P), -1); + cvtest::convert(cvarrToMat(matP), cvarrToMat(__P), CV_DEPTH_AUTO); } else { @@ -506,7 +506,7 @@ void CV_UndistortPointsTest::distortPoints(const CvMat* _src, CvMat* _dst, const __P->data.db[4] = 1; __P->data.db[8] = 1; } - CvMat* __R = cvCreateMat(3,3,CV_64F); + CvMat* __R = cvCreateMat(3,3,CV_64FC1); if (matR) { cvCopy(matR,__R); @@ -523,7 +523,7 @@ void CV_UndistortPointsTest::distortPoints(const CvMat* _src, CvMat* _dst, const int movement = __P->cols > 3 ? 1 : 0; double x = (_src->data.db[2*i]-__P->data.db[2])/__P->data.db[0]; double y = (_src->data.db[2*i+1]-__P->data.db[5+movement])/__P->data.db[4+movement]; - CvMat inverse = cvMat(3,3,CV_64F,a); + CvMat inverse = cvMat(3,3,CV_64FC1,a); cvInvert(__R,&inverse); double w1 = x*inverse.data.db[6]+y*inverse.data.db[7]+inverse.data.db[8]; double _x = (x*inverse.data.db[0]+y*inverse.data.db[1]+inverse.data.db[2])/w1; @@ -572,10 +572,10 @@ class CV_InitUndistortRectifyMapTest : public cvtest::ArrayTest public: CV_InitUndistortRectifyMapTest(); protected: - int prepare_test_case (int test_case_idx); - void prepare_to_validation( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + int prepare_test_case (int test_case_idx) CV_OVERRIDE; + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void run_func(); private: @@ -598,7 +598,7 @@ class CV_InitUndistortRectifyMapTest : public cvtest::ArrayTest cv::Mat mapy; CvMat* _mapx; CvMat* _mapy; - int mat_type; + ElemType mat_type; }; CV_InitUndistortRectifyMapTest::CV_InitUndistortRectifyMapTest() @@ -614,10 +614,10 @@ CV_InitUndistortRectifyMapTest::CV_InitUndistortRectifyMapTest() useCPlus = false; zero_distortion = zero_new_cam = zero_R = false; _mapx = _mapy = NULL; - mat_type = 0; + mat_type = CV_8UC1; } -void CV_InitUndistortRectifyMapTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_InitUndistortRectifyMapTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { cvtest::ArrayTest::get_test_array_types_and_sizes(test_case_idx,sizes,types); RNG& rng = ts->get_rng(); @@ -625,10 +625,10 @@ void CV_InitUndistortRectifyMapTest::get_test_array_types_and_sizes( int test_ca //useCPlus = 0; types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_64FC2; - types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; - types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; - types[INPUT][3] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; - types[INPUT][4] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; + types[INPUT][1] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; + types[INPUT][2] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; + types[INPUT][3] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; + types[INPUT][4] = cvtest::randInt(rng) % 2 ? CV_64FC1 : CV_32FC1; sizes[INPUT][0] = sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(N_POINTS,1); sizes[INPUT][1] = sizes[INPUT][3] = cvSize(3,3); @@ -674,7 +674,7 @@ int CV_InitUndistortRectifyMapTest::prepare_test_case(int test_case_idx) { mat_type = (cvtest::randInt(rng) % 2) == 0 ? CV_32FC1 : CV_16SC2; if ((cvtest::randInt(rng) % 4) == 0) - mat_type = -1; + mat_type = CV_TYPE_AUTO; if ((cvtest::randInt(rng) % 4) == 0) mat_type = CV_32FC2; _mapx = 0; @@ -698,10 +698,10 @@ int CV_InitUndistortRectifyMapTest::prepare_test_case(int test_case_idx) vector new_cam(test_mat[INPUT][4].cols * test_mat[INPUT][4].rows); vector points(N_POINTS); - Mat _camera(3,3,CV_64F,cam); - Mat _distort(test_mat[INPUT][2].size(),CV_64F,&dist[0]); - Mat _new_cam(test_mat[INPUT][4].size(),CV_64F,&new_cam[0]); - Mat _points(test_mat[INPUT][0].size(),CV_64FC2, &points[0]); + Mat _camera(3, 3, CV_64FC1, cam); + Mat _distort(test_mat[INPUT][2].size(), CV_64FC1, &dist[0]); + Mat _new_cam(test_mat[INPUT][4].size(), CV_64FC1, &new_cam[0]); + Mat _points(test_mat[INPUT][0].size(), CV_64FC2, &points[0]); //Generating points for (int i=0;i(0) = CV_PI/8*(cvtest::randReal(rng) - (double)0.5); // phi rotation.at(1) = CV_PI/8*(cvtest::randReal(rng) - (double)0.5); // ksi rotation.at(2) = CV_PI/3*(cvtest::randReal(rng) - (double)0.5); //khi @@ -762,11 +762,11 @@ int CV_InitUndistortRectifyMapTest::prepare_test_case(int test_case_idx) //cvSetIdentity(_rot); //copying data - cvtest::convert( _points, test_mat[INPUT][0], test_mat[INPUT][0].type()); - cvtest::convert( _camera, test_mat[INPUT][1], test_mat[INPUT][1].type()); - cvtest::convert( _distort, test_mat[INPUT][2], test_mat[INPUT][2].type()); - cvtest::convert( _rot, test_mat[INPUT][3], test_mat[INPUT][3].type()); - cvtest::convert( _new_cam, test_mat[INPUT][4], test_mat[INPUT][4].type()); + cvtest::convert(_points, test_mat[INPUT][0], test_mat[INPUT][0].depth()); + cvtest::convert(_camera, test_mat[INPUT][1], test_mat[INPUT][1].depth()); + cvtest::convert(_distort, test_mat[INPUT][2], test_mat[INPUT][2].depth()); + cvtest::convert(_rot, test_mat[INPUT][3], test_mat[INPUT][3].depth()); + cvtest::convert(_new_cam, test_mat[INPUT][4], test_mat[INPUT][4].depth()); zero_distortion = (cvtest::randInt(rng)%2) == 0 ? false : true; zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true; @@ -795,8 +795,8 @@ void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/ vector r_points(N_POINTS); //Run reference calculations Mat ref_points(test_mat[INPUT][0].size(),CV_64FC2,&r_points[0]); - Mat _camera(3,3,CV_64F,cam); - Mat _rot(3,3,CV_64F,rot); + Mat _camera(3,3,CV_64FC1,cam); + Mat _rot(3,3,CV_64FC1,rot); Mat _distort(test_mat[INPUT][2].size(),CV_64F,&dist[0]); Mat _new_cam(test_mat[INPUT][4].size(),CV_64F,&new_cam[0]); Mat _points(test_mat[INPUT][0].size(),CV_64FC2,&points[0]); @@ -847,8 +847,8 @@ void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/ double* r_points = new double[N_POINTS*2]; //Run reference calculations CvMat ref_points= cvMat(test_mat[INPUT][0].rows,test_mat[INPUT][0].cols,CV_64FC2,r_points); - CvMat _camera = cvMat(3,3,CV_64F,cam); - CvMat _rot = cvMat(3,3,CV_64F,rot); + CvMat _camera = cvMat(3,3,CV_64FC1,cam); + CvMat _rot = cvMat(3,3,CV_64FC1,rot); CvMat _distort = cvMat(test_mat[INPUT][2].rows,test_mat[INPUT][2].cols,CV_64F,dist); CvMat _new_cam = cvMat(test_mat[INPUT][4].rows,test_mat[INPUT][4].cols,CV_64F,new_cam); CvMat _points= cvMat(test_mat[INPUT][0].rows,test_mat[INPUT][0].cols,CV_64FC2,points); @@ -858,10 +858,10 @@ void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/ CvMat _input3 = cvMat(test_mat[INPUT][3]); CvMat _input4 = cvMat(test_mat[INPUT][4]); - cvtest::convert(cvarrToMat(&_input1), cvarrToMat(&_camera), -1); - cvtest::convert(cvarrToMat(&_input2), cvarrToMat(&_distort), -1); - cvtest::convert(cvarrToMat(&_input3), cvarrToMat(&_rot), -1); - cvtest::convert(cvarrToMat(&_input4), cvarrToMat(&_new_cam), -1); + cvtest::convert(cvarrToMat(&_input1), cvarrToMat(&_camera), CV_DEPTH_AUTO); + cvtest::convert(cvarrToMat(&_input2), cvarrToMat(&_distort), CV_DEPTH_AUTO); + cvtest::convert(cvarrToMat(&_input3), cvarrToMat(&_rot), CV_DEPTH_AUTO); + cvtest::convert(cvarrToMat(&_input4), cvarrToMat(&_new_cam), CV_DEPTH_AUTO); //Applying precalculated undistort rectify map if (!useCPlus) @@ -887,7 +887,7 @@ void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/ zero_distortion ? 0 : &_distort, zero_R ? 0 : &_rot, zero_new_cam ? &_camera : &_new_cam); //cvTsDistortPoints(&_points,&ref_points,&_camera,&_distort,&_rot,&_new_cam); CvMat dst = cvMat(test_mat[REF_OUTPUT][0]); - cvtest::convert(cvarrToMat(&ref_points), cvarrToMat(&dst), -1); + cvtest::convert(cvarrToMat(&ref_points), cvarrToMat(&dst), CV_DEPTH_AUTO); cvtest::copy(test_mat[INPUT][0],test_mat[OUTPUT][0]); diff --git a/modules/calib3d/test/test_undistort_badarg.cpp b/modules/calib3d/test/test_undistort_badarg.cpp index 4e4587d3c6eb..ed3cdcf826d8 100644 --- a/modules/calib3d/test/test_undistort_badarg.cpp +++ b/modules/calib3d/test/test_undistort_badarg.cpp @@ -114,10 +114,10 @@ void CV_UndistortPointsBadArgTest::run(int) double p[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f}; double r[9] = {1,0,0,0,1,0,0,0,1}; - CvMat _camera_mat_orig = cvMat(3,3,CV_64F,cam); - CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64F,dist); - CvMat _P_orig = cvMat(3,3,CV_64F,p); - CvMat _R_orig = cvMat(3,3,CV_64F,r); + CvMat _camera_mat_orig = cvMat(3,3,CV_64FC1,cam); + CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64FC1,dist); + CvMat _P_orig = cvMat(3,3,CV_64FC1,p); + CvMat _R_orig = cvMat(3,3,CV_64FC1,r); CvMat _src_points_orig = cvMat(1,4,CV_64FC2,s_points); CvMat _dst_points_orig = cvMat(1,4,CV_64FC2,d_points); @@ -144,20 +144,20 @@ void CV_UndistortPointsBadArgTest::run(int) errcount += run_test_case( CV_StsAssert, "Output data is not CvMat*" ); _dst_points = &_dst_points_orig; - temp = cvCreateMat(2,3,CV_64F); + temp = cvCreateMat(2,3,CV_64FC1); _src_points = temp; errcount += run_test_case( CV_StsAssert, "Invalid input data matrix size" ); _src_points = &_src_points_orig; cvReleaseMat(&temp); - temp = cvCreateMat(2,3,CV_64F); + temp = cvCreateMat(2,3,CV_64FC1); _dst_points = temp; errcount += run_test_case(CV_StsAssert, "Invalid output data matrix size" ); _dst_points = &_dst_points_orig; cvReleaseMat(&temp); - temp = cvCreateMat(1,3,CV_64F); - temp1 = cvCreateMat(4,1,CV_64F); + temp = cvCreateMat(1,3,CV_64FC1); + temp1 = cvCreateMat(4,1,CV_64FC1); _dst_points = temp; _src_points = temp1; errcount += run_test_case(CV_StsAssert, "Output and input data sizes mismatch" ); @@ -166,25 +166,25 @@ void CV_UndistortPointsBadArgTest::run(int) cvReleaseMat(&temp); cvReleaseMat(&temp1); - temp = cvCreateMat(1,3,CV_32S); + temp = cvCreateMat(1,3,CV_32SC1); _dst_points = temp; errcount += run_test_case(CV_StsAssert, "Invalid output data matrix type" ); _dst_points = &_dst_points_orig; cvReleaseMat(&temp); - temp = cvCreateMat(1,3,CV_32S); + temp = cvCreateMat(1,3,CV_32SC1); _src_points = temp; errcount += run_test_case(CV_StsAssert, "Invalid input data matrix type" ); _src_points = &_src_points_orig; cvReleaseMat(&temp); //------------ - temp = cvCreateMat(2,3,CV_64F); + temp = cvCreateMat(2,3,CV_64FC1); _camera_mat = temp; errcount += run_test_case( CV_StsAssert, "Invalid camera data matrix size" ); _camera_mat = &_camera_mat_orig; cvReleaseMat(&temp); - temp = cvCreateMat(3,4,CV_64F); + temp = cvCreateMat(3,4,CV_64FC1); _camera_mat = temp; errcount += run_test_case( CV_StsAssert, "Invalid camera data matrix size" ); _camera_mat = &_camera_mat_orig; @@ -201,13 +201,13 @@ void CV_UndistortPointsBadArgTest::run(int) errcount += run_test_case( CV_StsAssert, "Distortion coefficients data is not CvMat*" ); _distortion_coeffs = &_distortion_coeffs_orig; - temp = cvCreateMat(1,6,CV_64F); + temp = cvCreateMat(1,6,CV_64FC1); _distortion_coeffs = temp; errcount += run_test_case( CV_StsAssert, "Invalid distortion coefficients data matrix size" ); _distortion_coeffs = &_distortion_coeffs_orig; cvReleaseMat(&temp); - temp = cvCreateMat(3,3,CV_64F); + temp = cvCreateMat(3,3,CV_64FC1); _distortion_coeffs = temp; errcount += run_test_case( CV_StsAssert, "Invalid distortion coefficients data matrix size" ); _distortion_coeffs = &_distortion_coeffs_orig; @@ -218,13 +218,13 @@ void CV_UndistortPointsBadArgTest::run(int) errcount += run_test_case( CV_StsAssert, "R data is not CvMat*" ); matR = &_R_orig; - temp = cvCreateMat(4,3,CV_64F); + temp = cvCreateMat(4,3,CV_64FC1); matR = temp; errcount += run_test_case( CV_StsAssert, "Invalid R data matrix size" ); matR = &_R_orig; cvReleaseMat(&temp); - temp = cvCreateMat(3,2,CV_64F); + temp = cvCreateMat(3,2,CV_64FC1); matR = temp; errcount += run_test_case( CV_StsAssert, "Invalid R data matrix size" ); matR = &_R_orig; @@ -236,13 +236,13 @@ void CV_UndistortPointsBadArgTest::run(int) errcount += run_test_case( CV_StsAssert, "P data is not CvMat*" ); matP = &_P_orig; - temp = cvCreateMat(4,3,CV_64F); + temp = cvCreateMat(4,3,CV_64FC1); matP = temp; errcount += run_test_case( CV_StsAssert, "Invalid P data matrix size" ); matP = &_P_orig; cvReleaseMat(&temp); - temp = cvCreateMat(3,2,CV_64F); + temp = cvCreateMat(3,2,CV_64FC1); matP = temp; errcount += run_test_case( CV_StsAssert, "Invalid P data matrix size" ); matP = &_P_orig; @@ -312,7 +312,7 @@ class CV_InitUndistortRectifyMapBadArgTest : public cvtest::BadArgTest cv::Mat distortion_coeffs; cv::Mat mapx; cv::Mat mapy; - int mat_type; + ElemType mat_type; }; @@ -347,13 +347,13 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int) double arr_new_camera_mat[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f}; double r[9] = {1,0,0,0,1,0,0,0,1}; - CvMat _camera_mat_orig = cvMat(3,3,CV_64F,cam); - CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64F,dist); - CvMat _new_camera_mat_orig = cvMat(3,3,CV_64F,arr_new_camera_mat); - CvMat _R_orig = cvMat(3,3,CV_64F,r); + CvMat _camera_mat_orig = cvMat(3,3,CV_64FC1,cam); + CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64FC1,dist); + CvMat _new_camera_mat_orig = cvMat(3,3,CV_64FC1,arr_new_camera_mat); + CvMat _R_orig = cvMat(3,3,CV_64FC1,r); CvMat _mapx_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_mapx); CvMat _mapy_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_mapy); - int mat_type_orig = CV_32FC1; + ElemType mat_type_orig = CV_32FC1; _camera_mat = &_camera_mat_orig; _distortion_coeffs = &_distortion_coeffs_orig; @@ -378,7 +378,7 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int) mapy = cv::cvarrToMat(&_mapy_orig); - mat_type = CV_64F; + mat_type = CV_64FC1; errcount += run_test_case( CV_StsAssert, "Invalid map matrix type" ); mat_type = mat_type_orig; @@ -468,9 +468,9 @@ void CV_UndistortBadArgTest::run(int) float* arr_dst = new float[img_size.width*img_size.height]; double arr_new_camera_mat[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f}; - CvMat _camera_mat_orig = cvMat(3,3,CV_64F,cam); - CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64F,dist); - CvMat _new_camera_mat_orig = cvMat(3,3,CV_64F,arr_new_camera_mat); + CvMat _camera_mat_orig = cvMat(3,3,CV_64FC1,cam); + CvMat _distortion_coeffs_orig = cvMat(1,4,CV_64FC1,dist); + CvMat _new_camera_mat_orig = cvMat(3,3,CV_64FC1,arr_new_camera_mat); CvMat _src_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_src); CvMat _dst_orig = cvMat(img_size.height,img_size.width,CV_32FC1,arr_dst); @@ -488,8 +488,8 @@ void CV_UndistortBadArgTest::run(int) //C tests useCPlus = false; - temp = cvCreateMat(800,600,CV_32F); - temp1 = cvCreateMat(800,601,CV_32F); + temp = cvCreateMat(800,600,CV_32FC1); + temp1 = cvCreateMat(800,601,CV_32FC1); _src = temp; _dst = temp1; errcount += run_test_case( CV_StsAssert, "Input and output data matrix sizes mismatch" ); @@ -498,8 +498,8 @@ void CV_UndistortBadArgTest::run(int) cvReleaseMat(&temp); cvReleaseMat(&temp1); - temp = cvCreateMat(800,600,CV_32F); - temp1 = cvCreateMat(800,600,CV_64F); + temp = cvCreateMat(800,600,CV_32FC1); + temp1 = cvCreateMat(800,600,CV_64FC1); _src = temp; _dst = temp1; errcount += run_test_case( CV_StsAssert, "Input and output data matrix types mismatch" ); diff --git a/modules/calib3d/test/test_undistort_points.cpp b/modules/calib3d/test/test_undistort_points.cpp index 9b12dd9da4fd..adfb4247379e 100644 --- a/modules/calib3d/test/test_undistort_points.cpp +++ b/modules/calib3d/test/test_undistort_points.cpp @@ -113,7 +113,7 @@ TEST(Calib3d_Undistort, stop_criteria) std::vector pt_redistorted_vec; std::vector pt_undist_vec_homogeneous; pt_undist_vec_homogeneous.push_back( Point3d(pt_undist_vec[0].x, pt_undist_vec[0].y, 1.0) ); - projectPoints(pt_undist_vec_homogeneous, Mat::zeros(3,1,CV_64F), Mat::zeros(3,1,CV_64F), cameraMatrix, distCoeffs, pt_redistorted_vec); + projectPoints(pt_undist_vec_homogeneous, Mat::zeros(3, 1, CV_64FC1), Mat::zeros(3, 1, CV_64FC1), cameraMatrix, distCoeffs, pt_redistorted_vec); const double obtainedError = sqrt( pow(pt_distorted.x - pt_redistorted_vec[0].x, 2) + pow(pt_distorted.y - pt_redistorted_vec[0].y, 2) ); ASSERT_LE(obtainedError, maxError); diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index c8216b28f393..9d181c82c030 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -325,23 +325,23 @@ The first function in the list above can be replaced with matrix expressions: @endcode The input arrays and the output array can all have the same or different depths. For example, you can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit -floating-point array. Depth of the output array is determined by the dtype parameter. In the second -and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can -be set to the default -1. In this case, the output array will have the same depth as the input +floating-point array. Depth of the output array is determined by the ddepth parameter. In the second +and third cases above, as well as in the first case, when src1.depth() == src2.depth(), ddepth can +be set to the default CV_DEPTH_AUTO. In this case, the output array will have the same depth as the input array, be it src1, src2 or both. @note Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow. @param src1 first input array or a scalar. @param src2 second input array or a scalar. @param dst output array that has the same size and number of channels as the input array(s); the -depth is defined by dtype or src1/src2. +depth is defined by ddepth or src1/src2. @param mask optional operation mask - 8-bit single channel array, that specifies elements of the output array to be changed. -@param dtype optional depth of the output array (see the discussion below). +@param ddepth optional depth of the output array (see the discussion below). @sa subtract, addWeighted, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, - InputArray mask = noArray(), int dtype = -1); + InputArray mask = noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Calculates the per-element difference between two arrays or array and a scalar. @@ -367,8 +367,8 @@ The first function in the list above can be replaced with matrix expressions: @endcode The input arrays and the output array can all have the same or different depths. For example, you can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of -the output array is determined by dtype parameter. In the second and third cases above, as well as -in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this +the output array is determined by ddepth parameter. In the second and third cases above, as well as +in the first case, when src1.depth() == src2.depth(), ddepth can be set to the default CV_DEPTH_AUTO. In this case the output array will have the same depth as the input array, be it src1, src2 or both. @note Saturation is not applied when the output array has the depth CV_32S. You may even get result of an incorrect sign in the case of overflow. @@ -377,11 +377,11 @@ result of an incorrect sign in the case of overflow. @param dst output array of the same size and the same number of channels as the input array. @param mask optional operation mask; this is an 8-bit single channel array that specifies elements of the output array to be changed. -@param dtype optional depth of the output array +@param ddepth optional depth of the output array @sa add, addWeighted, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, - InputArray mask = noArray(), int dtype = -1); + InputArray mask = noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Calculates the per-element scaled product of two arrays. @@ -401,12 +401,12 @@ overflow. @param src2 second input array of the same size and the same type as src1. @param dst output array of the same size and type as src1. @param scale optional scale factor. -@param dtype optional depth of the output array +@param ddepth optional depth of the output array @sa add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare, Mat::convertTo */ CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, - OutputArray dst, double scale = 1, int dtype = -1); + OutputArray dst, double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Performs per-element division of two arrays or a scalar by an array. @@ -424,16 +424,16 @@ result of an incorrect sign in the case of overflow. @param src2 second input array of the same size and type as src1. @param scale scalar factor. @param dst output array of the same size and type as src2. -@param dtype optional depth of the output array; if -1, dst will have depth src2.depth(), but in +@param ddepth optional depth of the output array; if CV_DEPTH_AUTO, dst will have depth src2.depth(), but in case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth(). @sa multiply, add, subtract */ CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, - double scale = 1, int dtype = -1); + double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); /** @overload */ CV_EXPORTS_W void divide(double scale, InputArray src2, - OutputArray dst, int dtype = -1); + OutputArray dst, ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Calculates the sum of a scaled array and another array. @@ -443,7 +443,7 @@ the sum of a scaled array and another array: \f[\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2} (I)\f] The function can also be emulated with a matrix expression, for example: @code{.cpp} - Mat A(3, 3, CV_64F); + Mat A(3, 3, CV_64FC1); ... A.row(0) = A.row(1)*2 + A.row(2); @endcode @@ -477,12 +477,12 @@ result of an incorrect sign in the case of overflow. @param beta weight of the second array elements. @param gamma scalar added to each sum. @param dst output array that has the same size and number of channels as the input arrays. -@param dtype optional depth of the output array; when both input arrays have the same depth, dtype -can be set to -1, which will be equivalent to src1.depth(). +@param ddepth optional depth of the output array; when both input arrays have the same depth, ddepth +can be set to CV_DEPTH_AUTO, which will be equivalent to src1.depth(). @sa add, subtract, scaleAdd, Mat::convertTo */ CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, - double beta, double gamma, OutputArray dst, int dtype = -1); + double beta, double gamma, OutputArray dst, ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Scales, calculates absolute values, and converts the result to 8-bit. @@ -706,7 +706,7 @@ see http://en.wikipedia.org/wiki/Nearest_neighbor_search @todo document */ CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2, - OutputArray dist, int dtype, OutputArray nidx, + OutputArray dist, ElemType dtype, OutputArray nidx, int normType = NORM_L2, int K = 0, InputArray mask = noArray(), int update = 0, bool crosscheck = false); @@ -764,13 +764,12 @@ normalization. @param beta upper range boundary in case of the range normalization; it is not used for the norm normalization. @param norm_type normalization type (see cv::NormTypes). -@param dtype when negative, the output array has the same type as src; otherwise, it has the same -number of channels as src and the depth =CV_MAT_DEPTH(dtype). +@param ddepth desired output matrix depth. when it is CV_DEPTH_AUTO, the output array has the same type as src. @param mask optional operation mask. @sa norm, Mat::convertTo, SparseMat::convertTo */ CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0, - int norm_type = NORM_L2, int dtype = -1, InputArray mask = noArray()); + int norm_type = NORM_L2, ElemDepth ddepth = CV_DEPTH_AUTO, InputArray mask = noArray()); /** @overload @param src input array. @@ -858,15 +857,15 @@ And the following code demonstrates its usage for a two-channel matrix. @snippet snippets/core_reduce.cpp example2 @param src input 2D matrix. -@param dst output vector. Its size and type is defined by dim and dtype parameters. +@param dst output vector. Its size and type is defined by dim and ddepth parameters. @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column. @param rtype reduction operation that could be one of #ReduceTypes -@param dtype when negative, the output vector will have the same type as the input matrix, -otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()). +@param ddepth when it is CV_DEPTH_AUTO, the output vector will have the same type as the input matrix, +otherwise, its type will be CV_MAKE_TYPE(ddepth, src.channels()). @sa repeat */ -CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype = -1); +CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Creates one multi-channel array out of several single-channel ones. @@ -1649,16 +1648,16 @@ assumed to be zero, that is, nothing is subtracted. If it has the same size as src , it is simply subtracted. Otherwise, it is "repeated" (see repeat ) to cover the full src and then subtracted. Type of the delta matrix, when it is not empty, must be the same as the type of created -output matrix. See the dtype parameter description below. +output matrix. See the ddepth parameter description below. @param scale Optional scale factor for the matrix product. -@param dtype Optional type of the output matrix. When it is negative, -the output matrix will have the same type as src . Otherwise, it will be -type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F . +@param ddepth Optional depth of the output matrix. When it is CV_DEPTH_AUTO, +the output matrix will have the same type as src . Otherwise, it should be either CV_32F or CV_64F, +and the output type will be CV_MAKE_TYPE(ddepth, src.channels()). @sa calcCovarMatrix, gemm, repeat, reduce */ CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, InputArray delta = noArray(), - double scale = 1, int dtype = -1 ); + double scale = 1, ElemDepth ddepth = CV_DEPTH_AUTO); /** @brief Transposes a matrix. @@ -1748,7 +1747,7 @@ The function cv::setIdentity initializes a scaled identity matrix: The function can also be emulated using the matrix initializers and the matrix expressions: @code - Mat A = Mat::eye(4, 3, CV_32F)*5; + Mat A = Mat::eye(4, 3, CV_32FC1)*5; // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]] @endcode @param mtx matrix to initialize (not necessarily square). @@ -1855,7 +1854,7 @@ ascending or descending order. So you should pass two operation flags to get desired behaviour. Instead of reordering the elements themselves, it stores the indices of sorted elements in the output array. For example: @code - Mat A = Mat::eye(3,3,CV_32F), B; + Mat A = Mat::eye(3,3,CV_32FC1), B; sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING); // B will probably contain // (because of equal elements in A some permutations are possible): @@ -1938,26 +1937,26 @@ The function cv::calcCovarMatrix calculates the covariance matrix and, optionall the set of input vectors. @param samples samples stored as separate matrices @param nsamples number of samples -@param covar output covariance matrix of the type ctype and square size. +@param covar output covariance matrix of the depth cdepth and square size. @param mean input or output (depending on the flags) array as the average value of the input vectors. @param flags operation flags as a combination of #CovarFlags -@param ctype type of the matrixl; it equals 'CV_64F' by default. +@param cdepth depth of the matrixl; it equals 'CV_64F' by default. @sa PCA, mulTransposed, Mahalanobis @todo InputArrayOfArrays */ CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, - int flags, int ctype = CV_64F); + int flags, ElemDepth cdepth = CV_64F); /** @overload @note use #COVAR_ROWS or #COVAR_COLS flag @param samples samples stored as rows/columns of a single matrix. -@param covar output covariance matrix of the type ctype and square size. +@param covar output covariance matrix of the depth cdepth and square size. @param mean input or output (depending on the flags) array as the average value of the input vectors. @param flags operation flags as a combination of #CovarFlags -@param ctype type of the matrixl; it equals 'CV_64F' by default. +@param cdepth depth of the matrixl; it equals 'CV_64F' by default. */ CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, - InputOutputArray mean, int flags, int ctype = CV_64F); + InputOutputArray mean, int flags, ElemDepth cdepth = CV_64F); /** wrap PCA::operator() */ CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean, @@ -2951,7 +2950,7 @@ and groups the input samples around the clusters. As an output, \f$\texttt{label opencv_source_code/samples/python/kmeans.py @param data Data for clustering. An array of N-Dimensional points with float coordinates is needed. Examples of this array can be: -- Mat points(count, 2, CV_32F); +- Mat points(count, 2, CV_32FC1); - Mat points(count, 1, CV_32FC2); - Mat points(1, count, CV_32FC2); - std::vector\ points(sampleCount); diff --git a/modules/core/include/opencv2/core/affine.hpp b/modules/core/include/opencv2/core/affine.hpp index 7e2ed3078583..b2fbdc9b4b88 100644 --- a/modules/core/include/opencv2/core/affine.hpp +++ b/modules/core/include/opencv2/core/affine.hpp @@ -300,23 +300,22 @@ namespace cv typedef Affine3::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 16, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 16; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template - struct Depth< Affine3<_Tp> > { enum { value = Depth<_Tp>::value }; }; + struct Depth< Affine3<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template - struct Type< Affine3<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 16) }; }; + struct Type< Affine3<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 16); }; } // namespace //! @} core diff --git a/modules/core/include/opencv2/core/check.hpp b/modules/core/include/opencv2/core/check.hpp index bf441383e840..32e045ebdf36 100644 --- a/modules/core/include/opencv2/core/check.hpp +++ b/modules/core/include/opencv2/core/check.hpp @@ -10,20 +10,20 @@ namespace cv { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "" */ -CV_EXPORTS const char* depthToString(int depth); +CV_EXPORTS const char* depthToString(ElemDepth depth); /** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or "" */ -CV_EXPORTS const String typeToString(int type); +CV_EXPORTS const String typeToString(ElemType type); //! @cond IGNORED namespace detail { /** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or NULL */ -CV_EXPORTS const char* depthToString_(int depth); +CV_EXPORTS const char* depthToString_(ElemDepth depth); /** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or cv::String() */ -CV_EXPORTS const cv::String typeToString_(int type); +CV_EXPORTS const cv::String typeToString_(ElemType type); enum TestOp { TEST_CUSTOM = 0, @@ -69,16 +69,16 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemDepth v1, const ElemDepth v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx); -CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const ElemDepth v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const ElemType v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckContext& ctx); diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index 91513978f10e..a50fc3cddbc4 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -805,7 +805,7 @@ Below are the two samples from the cvReshape description rewritten using cvResha gray_img = (IplImage*)cvReshapeMatND(color_img, sizeof(gray_img_hdr), &gray_img_hdr, 1, 0, 0); ... int size[] = { 2, 2, 2 }; - CvMatND* mat = cvCreateMatND(3, size, CV_32F); + CvMatND* mat = cvCreateMatND(3, size, CV_32FC1); CvMat row_header, *row; row = (CvMat*)cvReshapeMatND(mat, sizeof(row_header), &row_header, 0, 1, 0); @endcode @@ -853,7 +853,7 @@ The following example code creates one image buffer and two image headers, the f @endcode And the next example converts a 3x3 matrix to a single 1x9 vector: @code - CvMat* mat = cvCreateMat(3, 3, CV_32F); + CvMat* mat = cvCreateMat(3, 3, CV_32FC1); CvMat row_header, *row; row = cvReshape(mat, &row_header, 0, 1); @endcode @@ -2132,7 +2132,7 @@ Below is the code that creates the YAML file shown in the CvFileStorage descript int main( int argc, char** argv ) { - CvMat* mat = cvCreateMat( 3, 3, CV_32F ); + CvMat* mat = cvCreateMat( 3, 3, CV_32FC1); CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE ); cvSetIdentity( mat ); diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index 4863a6567457..bf93650f8816 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -123,19 +123,19 @@ class CV_EXPORTS_W GpuMat CV_WRAP explicit GpuMat(GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); //! constructs GpuMat of the specified size and type - CV_WRAP GpuMat(int rows, int cols, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); - CV_WRAP GpuMat(Size size, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(int rows, int cols, ElemType type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, ElemType type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); //! constucts GpuMat and fills it with the specified value _s - CV_WRAP GpuMat(int rows, int cols, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); - CV_WRAP GpuMat(Size size, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(int rows, int cols, ElemType type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, ElemType type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); //! copy constructor CV_WRAP GpuMat(const GpuMat& m); //! constructor for GpuMat headers pointing to user-allocated data - CV_WRAP GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP); - CV_WRAP GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP); + CV_WRAP GpuMat(int rows, int cols, ElemType type, void* data, size_t step = Mat::AUTO_STEP); + CV_WRAP GpuMat(Size size, ElemType type, void* data, size_t step = Mat::AUTO_STEP); //! creates a GpuMat header for a part of the bigger matrix CV_WRAP GpuMat(const GpuMat& m, Range rowRange, Range colRange); @@ -151,8 +151,8 @@ class CV_EXPORTS_W GpuMat GpuMat& operator =(const GpuMat& m); //! allocates new GpuMat data unless the GpuMat already has specified size and type - CV_WRAP void create(int rows, int cols, int type); - CV_WRAP void create(Size size, int type); + CV_WRAP void create(int rows, int cols, ElemType type); + CV_WRAP void create(Size size, ElemType type); //! decreases reference counter, deallocate the data when reference counter reaches 0 void release(); @@ -222,21 +222,21 @@ class CV_EXPORTS_W GpuMat CV_WRAP GpuMat& setTo(Scalar s, InputArray mask, Stream& stream); //! converts GpuMat to another datatype (Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth) const; //! converts GpuMat to another datatype (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, Stream& stream) const; //! converts GpuMat to another datatype with scaling (Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta = 0.0) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta = 0.0) const; //! converts GpuMat to another datatype with scaling (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, Stream& stream) const; //! converts GpuMat to another datatype with scaling (Non-Blocking call) - CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta, Stream& stream) const; + CV_WRAP void convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta, Stream& stream) const; - CV_WRAP void assignTo(GpuMat& m, int type = -1) const; + CV_WRAP void assignTo(GpuMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; //! returns pointer to y-th row uchar* ptr(int y = 0); @@ -288,10 +288,10 @@ class CV_EXPORTS_W GpuMat CV_WRAP size_t elemSize1() const; //! returns element type - CV_WRAP int type() const; + CV_WRAP ElemType type() const; //! returns element type - CV_WRAP int depth() const; + CV_WRAP ElemDepth depth() const; //! returns number of channels CV_WRAP int channels() const; @@ -314,7 +314,7 @@ class CV_EXPORTS_W GpuMat - depth - number of channels */ - int flags; + MagicFlag flags; //! the number of rows and columns int rows, cols; @@ -348,7 +348,7 @@ class CV_EXPORTS_W GpuMat Matrix is called continuous if its elements are stored continuously, that is, without gaps at the end of each row. */ -CV_EXPORTS_W void createContinuous(int rows, int cols, int type, OutputArray arr); +CV_EXPORTS_W void createContinuous(int rows, int cols, ElemType type, OutputArray arr); /** @brief Ensures that the size of a matrix is big enough and the matrix has a proper type. @@ -359,7 +359,7 @@ CV_EXPORTS_W void createContinuous(int rows, int cols, int type, OutputArray arr The function does not reallocate memory if the matrix has proper attributes already. */ -CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr); +CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, ElemType type, OutputArray arr); /** @brief BufferPool for use with CUDA streams @@ -486,10 +486,10 @@ class CV_EXPORTS_W BufferPool explicit BufferPool(Stream& stream); //! Allocates a new GpuMat of given size and type. - CV_WRAP GpuMat getBuffer(int rows, int cols, int type); + CV_WRAP GpuMat getBuffer(int rows, int cols, ElemType type); //! Allocates a new GpuMat of given size and type. - CV_WRAP GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); } + CV_WRAP GpuMat getBuffer(Size size, ElemType type) { return getBuffer(size.height, size.width, type); } //! Returns the allocator associated with the stream. CV_WRAP Ptr getAllocator() const { return allocator_; } @@ -532,8 +532,8 @@ class CV_EXPORTS_W HostMem HostMem(const HostMem& m); - CV_WRAP HostMem(int rows, int cols, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); - CV_WRAP HostMem(Size size, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + CV_WRAP HostMem(int rows, int cols, ElemType type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + CV_WRAP HostMem(Size size, ElemType type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); //! creates from host memory with coping data CV_WRAP explicit HostMem(InputArray arr, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); @@ -549,8 +549,8 @@ class CV_EXPORTS_W HostMem CV_WRAP HostMem clone() const; //! allocates new matrix data unless the matrix already has specified size and type. - CV_WRAP void create(int rows, int cols, int type); - void create(Size size, int type); + CV_WRAP void create(int rows, int cols, ElemType type); + void create(Size size, ElemType type); //! creates alternative HostMem header for the same data, with different //! number of channels and/or different number of rows @@ -575,15 +575,15 @@ class CV_EXPORTS_W HostMem CV_WRAP bool isContinuous() const; CV_WRAP size_t elemSize() const; CV_WRAP size_t elemSize1() const; - CV_WRAP int type() const; - CV_WRAP int depth() const; + CV_WRAP ElemType type() const; + CV_WRAP ElemDepth depth() const; CV_WRAP int channels() const; CV_WRAP size_t step1() const; CV_WRAP Size size() const; CV_WRAP bool empty() const; // Please see cv::Mat for descriptions - int flags; + MagicFlag flags; int rows, cols; CV_PROP size_t step; diff --git a/modules/core/include/opencv2/core/cuda.inl.hpp b/modules/core/include/opencv2/core/cuda.inl.hpp index 35ae2e49d77f..c5bc931710fc 100644 --- a/modules/core/include/opencv2/core/cuda.inl.hpp +++ b/modules/core/include/opencv2/core/cuda.inl.hpp @@ -56,28 +56,28 @@ namespace cv { namespace cuda { inline GpuMat::GpuMat(Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) {} inline -GpuMat::GpuMat(int rows_, int cols_, int type_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(int rows_, int cols_, ElemType type_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (rows_ > 0 && cols_ > 0) create(rows_, cols_, type_); } inline -GpuMat::GpuMat(Size size_, int type_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(Size size_, ElemType type_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (size_.height > 0 && size_.width > 0) create(size_.height, size_.width, type_); } inline -GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(int rows_, int cols_, ElemType type_, Scalar s_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (rows_ > 0 && cols_ > 0) { @@ -87,8 +87,8 @@ GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_, Allocator* allocator_ } inline -GpuMat::GpuMat(Size size_, int type_, Scalar s_, Allocator* allocator_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +GpuMat::GpuMat(Size size_, ElemType type_, Scalar s_, Allocator* allocator_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { if (size_.height > 0 && size_.width > 0) { @@ -107,7 +107,7 @@ GpuMat::GpuMat(const GpuMat& m) inline GpuMat::GpuMat(InputArray arr, Allocator* allocator_) : - flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) + flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) { upload(arr); } @@ -131,7 +131,7 @@ GpuMat& GpuMat::operator =(const GpuMat& m) } inline -void GpuMat::create(Size size_, int type_) +void GpuMat::create(Size size_, ElemType type_) { create(size_.height, size_.width, type_); } @@ -177,30 +177,30 @@ GpuMat& GpuMat::setTo(Scalar s, InputArray mask) } inline -void GpuMat::convertTo(OutputArray dst, int rtype) const +void GpuMat::convertTo(OutputArray dst, ElemDepth ddepth) const { - convertTo(dst, rtype, Stream::Null()); + convertTo(dst, ddepth, Stream::Null()); } inline -void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, double beta) const +void GpuMat::convertTo(OutputArray dst, ElemDepth ddepth, double alpha, double beta) const { - convertTo(dst, rtype, alpha, beta, Stream::Null()); + convertTo(dst, ddepth, alpha, beta, Stream::Null()); } inline -void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const +void GpuMat::convertTo(OutputArray dst, ElemDepth ddepth, double alpha, Stream& stream) const { - convertTo(dst, rtype, alpha, 0.0, stream); + convertTo(dst, ddepth, alpha, 0.0, stream); } inline -void GpuMat::assignTo(GpuMat& m, int _type) const +void GpuMat::assignTo(GpuMat& m, ElemDepth _depth) const { - if (_type < 0) + if (_depth == CV_DEPTH_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline @@ -292,7 +292,7 @@ GpuMat GpuMat::operator ()(Rect roi) const inline bool GpuMat::isContinuous() const { - return (flags & Mat::CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(Mat::CONTINUOUS_FLAG)); } inline @@ -308,13 +308,13 @@ size_t GpuMat::elemSize1() const } inline -int GpuMat::type() const +ElemType GpuMat::type() const { return CV_MAT_TYPE(flags); } inline -int GpuMat::depth() const +ElemDepth GpuMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -344,7 +344,7 @@ bool GpuMat::empty() const } static inline -GpuMat createContinuous(int rows, int cols, int type) +GpuMat createContinuous(int rows, int cols, ElemType type) { GpuMat m; createContinuous(rows, cols, type, m); @@ -352,13 +352,13 @@ GpuMat createContinuous(int rows, int cols, int type) } static inline -void createContinuous(Size size, int type, OutputArray arr) +void createContinuous(Size size, ElemType type, OutputArray arr) { createContinuous(size.height, size.width, type, arr); } static inline -GpuMat createContinuous(Size size, int type) +GpuMat createContinuous(Size size, ElemType type) { GpuMat m; createContinuous(size, type, m); @@ -366,7 +366,7 @@ GpuMat createContinuous(Size size, int type) } static inline -void ensureSizeIsEnough(Size size, int type, OutputArray arr) +void ensureSizeIsEnough(Size size, ElemType type, OutputArray arr) { ensureSizeIsEnough(size.height, size.width, type, arr); } @@ -383,7 +383,7 @@ void swap(GpuMat& a, GpuMat& b) inline HostMem::HostMem(AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { } @@ -396,16 +396,16 @@ HostMem::HostMem(const HostMem& m) } inline -HostMem::HostMem(int rows_, int cols_, int type_, AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +HostMem::HostMem(int rows_, int cols_, ElemType type_, AllocType alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { if (rows_ > 0 && cols_ > 0) create(rows_, cols_, type_); } inline -HostMem::HostMem(Size size_, int type_, AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +HostMem::HostMem(Size size_, ElemType type_, AllocType alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { if (size_.height > 0 && size_.width > 0) create(size_.height, size_.width, type_); @@ -413,7 +413,7 @@ HostMem::HostMem(Size size_, int type_, AllocType alloc_type_) inline HostMem::HostMem(InputArray arr, AllocType alloc_type_) - : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) + : flags(CV_MAGIC_FLAG_NONE), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) { arr.getMat().copyTo(*this); } @@ -459,7 +459,7 @@ HostMem HostMem::clone() const } inline -void HostMem::create(Size size_, int type_) +void HostMem::create(Size size_, ElemType type_) { create(size_.height, size_.width, type_); } @@ -473,7 +473,7 @@ Mat HostMem::createMatHeader() const inline bool HostMem::isContinuous() const { - return (flags & Mat::CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(Mat::CONTINUOUS_FLAG)); } inline @@ -489,13 +489,13 @@ size_t HostMem::elemSize1() const } inline -int HostMem::type() const +ElemType HostMem::type() const { return CV_MAT_TYPE(flags); } inline -int HostMem::depth() const +ElemDepth HostMem::depth() const { return CV_MAT_DEPTH(flags); } @@ -619,7 +619,7 @@ namespace cv { inline Mat::Mat(const cuda::GpuMat& m) - : flags(0), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) + : flags(CV_MAGIC_FLAG_NONE), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { m.download(*this); } diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index cf97d53de877..908058580df0 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -305,9 +305,9 @@ Cv64suf; \****************************************************************************************/ #define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) -#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_CN(flags) (((static_cast(flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) #define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) -#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_TYPE(flags) static_cast(static_cast(flags) & CV_MAT_TYPE_MASK) #define CV_MAT_CONT_FLAG_SHIFT 14 #define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) #define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) @@ -382,68 +382,68 @@ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_8(EnumType, __VA_ARGS__)); \ #define __CV_ENUM_FLAGS_LOGICAL_NOT(EnumType) \ -static inline bool operator!(const EnumType& val) \ +static inline bool operator!(const EnumType val) \ { \ typedef std::underlying_type::type UnderlyingType; \ return !static_cast(val); \ } \ #define __CV_ENUM_FLAGS_LOGICAL_NOT_EQ(Arg1Type, Arg2Type) \ -static inline bool operator!=(const Arg1Type& a, const Arg2Type& b) \ +static inline bool operator!=(const Arg1Type a, const Arg2Type b) \ { \ return static_cast(a) != static_cast(b); \ } \ #define __CV_ENUM_FLAGS_LOGICAL_EQ(Arg1Type, Arg2Type) \ -static inline bool operator==(const Arg1Type& a, const Arg2Type& b) \ +static inline bool operator==(const Arg1Type a, const Arg2Type b) \ { \ return static_cast(a) == static_cast(b); \ } \ #define __CV_ENUM_FLAGS_BITWISE_NOT(EnumType) \ -static inline EnumType operator~(const EnumType& val) \ +static inline EnumType operator~(const EnumType val) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(~static_cast(val)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_OR(EnumType, Arg1Type, Arg2Type) \ -static inline EnumType operator|(const Arg1Type& a, const Arg2Type& b) \ +static inline EnumType operator|(const Arg1Type a, const Arg2Type b) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(static_cast(a) | static_cast(b)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_AND(EnumType, Arg1Type, Arg2Type) \ -static inline EnumType operator&(const Arg1Type& a, const Arg2Type& b) \ +static inline EnumType operator&(const Arg1Type a, const Arg2Type b) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(static_cast(a) & static_cast(b)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_XOR(EnumType, Arg1Type, Arg2Type) \ -static inline EnumType operator^(const Arg1Type& a, const Arg2Type& b) \ +static inline EnumType operator^(const Arg1Type a, const Arg2Type b) \ { \ typedef std::underlying_type::type UnderlyingType; \ return static_cast(static_cast(a) ^ static_cast(b)); \ } \ #define __CV_ENUM_FLAGS_BITWISE_OR_EQ(EnumType, Arg1Type) \ -static inline EnumType& operator|=(EnumType& _this, const Arg1Type& val) \ +static inline EnumType& operator|=(EnumType& _this, const Arg1Type val) \ { \ _this = static_cast(static_cast(_this) | static_cast(val)); \ return _this; \ } \ #define __CV_ENUM_FLAGS_BITWISE_AND_EQ(EnumType, Arg1Type) \ -static inline EnumType& operator&=(EnumType& _this, const Arg1Type& val) \ +static inline EnumType& operator&=(EnumType& _this, const Arg1Type val) \ { \ _this = static_cast(static_cast(_this) & static_cast(val)); \ return _this; \ } \ #define __CV_ENUM_FLAGS_BITWISE_XOR_EQ(EnumType, Arg1Type) \ -static inline EnumType& operator^=(EnumType& _this, const Arg1Type& val) \ +static inline EnumType& operator^=(EnumType& _this, const Arg1Type val) \ { \ _this = static_cast(static_cast(_this) ^ static_cast(val)); \ return _this; \ diff --git a/modules/core/include/opencv2/core/cvstd.inl.hpp b/modules/core/include/opencv2/core/cvstd.inl.hpp index 5df48abb63b1..8b3c3ddac5fa 100644 --- a/modules/core/include/opencv2/core/cvstd.inl.hpp +++ b/modules/core/include/opencv2/core/cvstd.inl.hpp @@ -64,11 +64,11 @@ template class DataType< std::complex<_Tp> > typedef value_type work_type; typedef _Tp channel_type; - enum { generic_type = 0, - depth = DataType::depth, - channels = 2, - fmt = DataType::fmt + ((channels - 1) << 8), - type = CV_MAKETYPE(depth, channels) }; + static const bool generic_type = false; + static const ElemDepth depth = DataType::depth; + static const int channels = 2; + static const int fmt = DataType::fmt + ((channels - 1) << 8); + static const ElemType type = CV_MAKETYPE(depth, channels); typedef Vec vec_type; }; diff --git a/modules/core/include/opencv2/core/directx.hpp b/modules/core/include/opencv2/core/directx.hpp index 056a85a1bc99..e4b02d9602d0 100644 --- a/modules/core/include/opencv2/core/directx.hpp +++ b/modules/core/include/opencv2/core/directx.hpp @@ -170,12 +170,12 @@ CV_EXPORTS void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9 //! @brief Get OpenCV type from DirectX type //! @param iDXGI_FORMAT - enum DXGI_FORMAT for D3D10/D3D11 //! @return OpenCV type or -1 if there is no equivalent -CV_EXPORTS int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11 +CV_EXPORTS ElemType getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11 //! @brief Get OpenCV type from DirectX type //! @param iD3DFORMAT - enum D3DTYPE for D3D9 //! @return OpenCV type or -1 if there is no equivalent -CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9 +CV_EXPORTS ElemType getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9 //! @} diff --git a/modules/core/include/opencv2/core/eigen.hpp b/modules/core/include/opencv2/core/eigen.hpp index c8603aca9731..8be03c60dc5b 100644 --- a/modules/core/include/opencv2/core/eigen.hpp +++ b/modules/core/include/opencv2/core/eigen.hpp @@ -104,17 +104,17 @@ void cv2eigen( const Mat& src, transpose(src, _dst); else if( src.cols == src.rows ) { - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); transpose(_dst, _dst); } else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } @@ -150,17 +150,17 @@ void cv2eigen( const Mat& src, transpose(src, _dst); else if( src.cols == src.rows ) { - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); transpose(_dst, _dst); } else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } @@ -198,13 +198,13 @@ void cv2eigen( const Mat& src, if( src.type() == _dst.type() ) transpose(src, _dst); else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } @@ -243,13 +243,13 @@ void cv2eigen( const Mat& src, if( src.type() == _dst.type() ) transpose(src, _dst); else - Mat(src.t()).convertTo(_dst, _dst.type()); + Mat(src.t()).convertTo(_dst, _dst.depth()); } else { const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); - src.convertTo(_dst, _dst.type()); + src.convertTo(_dst, _dst.depth()); } } diff --git a/modules/core/include/opencv2/core/hal/hal.hpp b/modules/core/include/opencv2/core/hal/hal.hpp index 0d68078d98d6..be11826c43a4 100644 --- a/modules/core/include/opencv2/core/hal/hal.hpp +++ b/modules/core/include/opencv2/core/hal/hal.hpp @@ -203,14 +203,14 @@ CV_EXPORTS void addRNGBias64f( double* arr, const double* scaleBiasPairs, int le struct CV_EXPORTS DFT1D { - static Ptr create(int len, int count, int depth, int flags, bool * useBuffer = 0); + static Ptr create(int len, int count, ElemDepth depth, int flags, bool * useBuffer = 0); virtual void apply(const uchar *src, uchar *dst) = 0; virtual ~DFT1D() {} }; struct CV_EXPORTS DFT2D { - static Ptr create(int width, int height, int depth, + static Ptr create(int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows = 0); virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; @@ -219,7 +219,7 @@ struct CV_EXPORTS DFT2D struct CV_EXPORTS DCT2D { - static Ptr create(int width, int height, int depth, int flags); + static Ptr create(int width, int height, ElemDepth depth, int flags); virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; virtual ~DCT2D() {} }; diff --git a/modules/core/include/opencv2/core/hal/interface.h b/modules/core/include/opencv2/core/hal/interface.h index 6f0a83d35928..c66cda92df1e 100644 --- a/modules/core/include/opencv2/core/hal/interface.h +++ b/modules/core/include/opencv2/core/hal/interface.h @@ -64,74 +64,101 @@ typedef signed char schar; # define CV_BIG_UINT(n) n##ULL #endif -#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" +#define __CV_MAX_DEPTH_0(m, n) (m != 7 || n <= 3 ? m : n) /* CV_16F workaround */ +#define __CV_MAX_DEPTH_1(d1, d2) __CV_MAX_DEPTH_0(std::max(d1, d2), std::min(d1, d2)) +#define __CV_MAX_DEPTH_2(d1, d2) __CV_MAX_DEPTH_1(static_cast(d1), static_cast(d2)) +#define __CV_MAX_DEPTH_3(d, ...) __CV_EXPAND(__CV_MAX_DEPTH_2(d, __CV_MAX_DEPTH_2(__VA_ARGS__))) +#define __CV_MAX_DEPTH_4(d, ...) __CV_EXPAND(__CV_MAX_DEPTH_2(d, __CV_MAX_DEPTH_3(__VA_ARGS__))) +#define CV_MAX_DEPTH(...) __CV_EXPAND(static_cast(__CV_CAT(__CV_MAX_DEPTH_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__))) + +#define __CV_MIN_DEPTH_0(m, n) (m == 7 && n >= 4 ? m : n) /* CV_16F workaround */ +#define __CV_MIN_DEPTH_1(d1, d2) __CV_MIN_DEPTH_0(std::max(d1, d2), std::min(d1, d2)) +#define __CV_MIN_DEPTH_2(d1, d2) __CV_MIN_DEPTH_1(static_cast(d1), static_cast(d2)) +#define __CV_MIN_DEPTH_3(d, ...) __CV_EXPAND(__CV_MIN_DEPTH_2(d, __CV_MIN_DEPTH_2(__VA_ARGS__))) +#define __CV_MIN_DEPTH_4(d, ...) __CV_EXPAND(__CV_MIN_DEPTH_2(d, __CV_MIN_DEPTH_3(__VA_ARGS__))) +#define CV_MIN_DEPTH(...) __CV_EXPAND(static_cast(__CV_CAT(__CV_MIN_DEPTH_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__))) #define CV_CN_MAX 512 #define CV_CN_SHIFT 3 #define CV_DEPTH_MAX (1 << CV_CN_SHIFT) -#define CV_8U 0 -#define CV_8S 1 -#define CV_16U 2 -#define CV_16S 3 -#define CV_32S 4 -#define CV_32F 5 -#define CV_64F 6 -#define CV_16F 7 - #define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) -#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) - -#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAT_DEPTH(flags) static_cast(static_cast(flags) & CV_MAT_DEPTH_MASK) +#define __CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) | (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKETYPE(depth,cn) static_cast(__CV_MAKETYPE(depth,cn)) #define CV_MAKE_TYPE CV_MAKETYPE +typedef int MagicFlag; +#define CV_MAGIC_FLAG_NONE 0 + +typedef int ElemDepth; +#define CV_DEPTH_AUTO -1 +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_16F 7 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 + +typedef int ElemType; +#define CV_TYPE_AUTO -1 +#define CV_TYPE_UNDEFINED -2 + +#define CV_SEQ_ELTYPE_PTR CV_MAKE_TYPE(CV_8U, 8 /*sizeof(void*)*/) + #define CV_8UC1 CV_MAKETYPE(CV_8U,1) #define CV_8UC2 CV_MAKETYPE(CV_8U,2) #define CV_8UC3 CV_MAKETYPE(CV_8U,3) #define CV_8UC4 CV_MAKETYPE(CV_8U,4) -#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) #define CV_8SC1 CV_MAKETYPE(CV_8S,1) #define CV_8SC2 CV_MAKETYPE(CV_8S,2) #define CV_8SC3 CV_MAKETYPE(CV_8S,3) #define CV_8SC4 CV_MAKETYPE(CV_8S,4) -#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) #define CV_16UC1 CV_MAKETYPE(CV_16U,1) #define CV_16UC2 CV_MAKETYPE(CV_16U,2) #define CV_16UC3 CV_MAKETYPE(CV_16U,3) #define CV_16UC4 CV_MAKETYPE(CV_16U,4) -#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) #define CV_16SC1 CV_MAKETYPE(CV_16S,1) #define CV_16SC2 CV_MAKETYPE(CV_16S,2) #define CV_16SC3 CV_MAKETYPE(CV_16S,3) #define CV_16SC4 CV_MAKETYPE(CV_16S,4) -#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_16FC1 CV_MAKETYPE(CV_16F,1) +#define CV_16FC2 CV_MAKETYPE(CV_16F,2) +#define CV_16FC3 CV_MAKETYPE(CV_16F,3) +#define CV_16FC4 CV_MAKETYPE(CV_16F,4) #define CV_32SC1 CV_MAKETYPE(CV_32S,1) #define CV_32SC2 CV_MAKETYPE(CV_32S,2) #define CV_32SC3 CV_MAKETYPE(CV_32S,3) #define CV_32SC4 CV_MAKETYPE(CV_32S,4) -#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) #define CV_32FC1 CV_MAKETYPE(CV_32F,1) #define CV_32FC2 CV_MAKETYPE(CV_32F,2) #define CV_32FC3 CV_MAKETYPE(CV_32F,3) #define CV_32FC4 CV_MAKETYPE(CV_32F,4) -#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) #define CV_64FC1 CV_MAKETYPE(CV_64F,1) #define CV_64FC2 CV_MAKETYPE(CV_64F,2) #define CV_64FC3 CV_MAKETYPE(CV_64F,3) #define CV_64FC4 CV_MAKETYPE(CV_64F,4) -#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) -#define CV_16FC1 CV_MAKETYPE(CV_16F,1) -#define CV_16FC2 CV_MAKETYPE(CV_16F,2) -#define CV_16FC3 CV_MAKETYPE(CV_16F,3) -#define CV_16FC4 CV_MAKETYPE(CV_16F,4) +#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" + +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) #define CV_16FC(n) CV_MAKETYPE(CV_16F,(n)) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + //! @} //! @name Comparison operation diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 178ecd493852..35b16435357c 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -61,10 +61,13 @@ namespace cv //! @addtogroup core_basic //! @{ -enum AccessFlag { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25, - ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 }; +enum AccessFlag +{ + ACCESS_READ=1<<24, ACCESS_WRITE=1<<25, + ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 +}; CV_ENUM_FLAGS(AccessFlag); -__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, int, AccessFlag); +__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, MagicFlag, AccessFlag); CV__DEBUG_NS_BEGIN @@ -118,7 +121,7 @@ it, according to the assertion statement inside) : // get Mat headers for input arrays. This is O(1) operation, // unless _src and/or _m are matrix expressions. Mat src = _src.getMat(), m = _m.getMat(); - CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) ); + CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32FC1 && m.size() == Size(3, 2) ); // [re]create the output array so that it has the proper size and type. // In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize. @@ -158,7 +161,8 @@ Custom type is wrapped as Mat-compatible `CV_8UC` values (N = sizeof(T), N <= class CV_EXPORTS _InputArray { public: - enum KindFlag { + enum KindFlag + { KIND_SHIFT = 16, FIXED_TYPE = 0x8000 << KIND_SHIFT, FIXED_SIZE = 0x4000 << KIND_SHIFT, @@ -183,7 +187,7 @@ class CV_EXPORTS _InputArray }; _InputArray(); - _InputArray(int _flags, void* _obj); + _InputArray(MagicFlag _flags, void* _obj); _InputArray(const Mat& m); _InputArray(const MatExpr& expr); _InputArray(const std::vector& vec); @@ -219,7 +223,7 @@ class CV_EXPORTS _InputArray cuda::GpuMat getGpuMat() const; ogl::Buffer getOGlBuffer() const; - int getFlags() const; + MagicFlag getFlags() const; void* getObj() const; Size getSz() const; @@ -231,8 +235,8 @@ class CV_EXPORTS _InputArray int sizend(int* sz, int i=-1) const; bool sameSize(const _InputArray& arr) const; size_t total(int i=-1) const; - int type(int i=-1) const; - int depth(int i=-1) const; + ElemType type(int i = -1) const; + ElemDepth depth(int i = -1) const; int channels(int i=-1) const; bool isContinuous(int i=-1) const; bool isSubmatrix(int i=-1) const; @@ -252,15 +256,17 @@ class CV_EXPORTS _InputArray ~_InputArray(); protected: - int flags; + MagicFlag flags; void* obj; Size sz; - void init(int _flags, const void* _obj); - void init(int _flags, const void* _obj, Size _sz); + void init(MagicFlag _flags, const void* _obj); + void init(MagicFlag _flags, const void* _obj, Size _sz); }; CV_ENUM_FLAGS(_InputArray::KindFlag); -__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, int, _InputArray::KindFlag); +__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, MagicFlag, _InputArray::KindFlag); +__CV_ENUM_FLAGS_BITWISE_OR_EQ(MagicFlag, _InputArray::KindFlag); + /** @brief This type is very similar to InputArray except that it is used for input/output and output function parameters. @@ -307,7 +313,7 @@ class CV_EXPORTS _OutputArray : public _InputArray }; _OutputArray(); - _OutputArray(int _flags, void* _obj); + _OutputArray(MagicFlag _flags, void* _obj); _OutputArray(Mat& m); _OutputArray(std::vector& vec); _OutputArray(cuda::GpuMat& d_mat); @@ -359,10 +365,10 @@ class CV_EXPORTS _OutputArray : public _InputArray std::vector& getGpuMatVecRef() const; ogl::Buffer& getOGlBufferRef() const; cuda::HostMem& getHostMemRef() const; - void create(Size sz, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; - void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; - void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; - void createSameSize(const _InputArray& arr, int mtype) const; + void create(Size sz, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; + void create(int rows, int cols, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; + void create(int dims, const int* size, ElemType type, int i = -1, bool allowTransposed = false, _OutputArray::DepthMask fixedDepthMask = static_cast<_OutputArray::DepthMask>(0)) const; + void createSameSize(const _InputArray& arr, ElemType mtype) const; void release() const; void clear() const; void setTo(const _InputArray& value, const _InputArray & mask = _InputArray()) const; @@ -379,7 +385,7 @@ class CV_EXPORTS _InputOutputArray : public _OutputArray { public: _InputOutputArray(); - _InputOutputArray(int _flags, void* _obj); + _InputOutputArray(MagicFlag _flags, void* _obj); _InputOutputArray(Mat& m); _InputOutputArray(std::vector& vec); _InputOutputArray(cuda::GpuMat& d_mat); @@ -466,10 +472,10 @@ class CV_EXPORTS MatAllocator virtual ~MatAllocator() {} // let's comment it off for now to detect and fix all the uses of allocator - //virtual void allocate(int dims, const int* sizes, int type, int*& refcount, + //virtual void allocate(int dims, const int* sizes, ElemType type, int*& refcount, // uchar*& datastart, uchar*& data, size_t* step) = 0; //virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; - virtual UMatData* allocate(int dims, const int* sizes, int type, + virtual UMatData* allocate(int dims, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const = 0; virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0; virtual void deallocate(UMatData* data) const = 0; @@ -526,7 +532,8 @@ template class MatCommaInitializer_ // it should be explicitly initialized using init(). struct CV_EXPORTS UMatData { - enum MemoryFlag { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2, + enum MemoryFlag + { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2, DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24, USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64, ASYNC_CLEANUP=128 @@ -641,7 +648,7 @@ or type of the current array are different from the specified ones. @code // create a 100x100x100 8-bit array int sz[] = {100, 100, 100}; - Mat bigCube(3, sz, CV_8U, Scalar::all(0)); + Mat bigCube(3, sz, CV_8UC1, Scalar::all(0)); @endcode It passes the number of dimensions =1 to the Mat constructor but the created array will be 2-dimensional with the number of columns set to 1. So, Mat::dims is always \>= 2 (can also be 0 @@ -674,7 +681,7 @@ actually modify a part of the array using this feature, for example: Due to the additional datastart and dataend members, it is possible to compute a relative sub-array position in the main *container* array using locateROI(): @code - Mat A = Mat::eye(10, 10, CV_32S); + Mat A = Mat::eye(10, 10, CV_32SC1); // extracts A columns, 1 (inclusive) to 3 (exclusive). Mat B = A(Range::all(), Range(1, 3)); // extracts B rows, 5 (inclusive) to 9 (exclusive). @@ -701,7 +708,7 @@ sub-matrices. -# Quickly initialize small matrices and/or get a super-fast element access. @code double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}}; - Mat M = Mat(3, 3, CV_64F, m).inv(); + Mat M = Mat(3, 3, CV_64FC1, m).inv(); @endcode . Partial yet very common cases of this *user-allocated data* case are conversions from CvMat and @@ -712,7 +719,7 @@ sub-matrices. - Use MATLAB-style array initializers, zeros(), ones(), eye(), for example: @code // create a double-precision identity matrix and add it to M. - M += Mat::eye(M.rows, M.cols, CV_64F); + M += Mat::eye(M.rows, M.cols, CV_64FC1); @endcode - Use a comma-separated initializer: @@ -807,7 +814,7 @@ class CV_EXPORTS Mat @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(int rows, int cols, int type); + Mat(int rows, int cols, ElemType type); /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -815,7 +822,7 @@ class CV_EXPORTS Mat @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(Size size, int type); + Mat(Size size, ElemType type); /** @overload @param rows Number of rows in a 2D array. @@ -826,7 +833,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(int rows, int cols, int type, const Scalar& s); + Mat(int rows, int cols, ElemType type, const Scalar& s); /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -837,7 +844,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(Size size, int type, const Scalar& s); + Mat(Size size, ElemType type, const Scalar& s); /** @overload @param ndims Array dimensionality. @@ -845,14 +852,14 @@ class CV_EXPORTS Mat @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(int ndims, const int* sizes, int type); + Mat(int ndims, const int* sizes, ElemType type); /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. */ - Mat(const std::vector& sizes, int type); + Mat(const std::vector& sizes, ElemType type); /** @overload @param ndims Array dimensionality. @@ -863,7 +870,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(int ndims, const int* sizes, int type, const Scalar& s); + Mat(int ndims, const int* sizes, ElemType type, const Scalar& s); /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @@ -873,7 +880,7 @@ class CV_EXPORTS Mat the particular value after the construction, use the assignment operator Mat::operator=(const Scalar& value) . */ - Mat(const std::vector& sizes, int type, const Scalar& s); + Mat(const std::vector& sizes, ElemType type, const Scalar& s); /** @overload @@ -899,7 +906,7 @@ class CV_EXPORTS Mat the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize. */ - Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP); + Mat(int rows, int cols, ElemType type, void* data, size_t step = AUTO_STEP); /** @overload @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the @@ -915,7 +922,7 @@ class CV_EXPORTS Mat the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed and the actual step is calculated as cols*elemSize(). See Mat::elemSize. */ - Mat(Size size, int type, void* data, size_t step=AUTO_STEP); + Mat(Size size, ElemType type, void* data, size_t step = AUTO_STEP); /** @overload @param ndims Array dimensionality. @@ -930,7 +937,7 @@ class CV_EXPORTS Mat @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always set to the element size). If not specified, the matrix is assumed to be continuous. */ - Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0); + Mat(int ndims, const int* sizes, ElemType type, void* data, const size_t* steps = 0); /** @overload @param sizes Array of integers specifying an n-dimensional array shape. @@ -944,7 +951,7 @@ class CV_EXPORTS Mat @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always set to the element size). If not specified, the matrix is assumed to be continuous. */ - Mat(const std::vector& sizes, int type, void* data, const size_t* steps=0); + Mat(const std::vector& sizes, ElemType type, void* data, const size_t* steps = 0); /** @overload @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied @@ -1222,20 +1229,19 @@ class CV_EXPORTS Mat \f[m(x,y) = saturate \_ cast( \alpha (*this)(x,y) + \beta )\f] @param m output matrix; if it does not have a proper size or type before the operation, it is reallocated. - @param rtype desired output matrix type or, rather, the depth since the number of channels are the - same as the input has; if rtype is negative, the output matrix will have the same type as the input. + @param ddepth desired output matrix depth. @param alpha optional scale factor. @param beta optional delta added to the scaled values. */ - void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + void convertTo(OutputArray m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; /** @brief Provides a functional form of convertTo. This is an internally used method called by the @ref MatrixExpressions engine. @param m Destination array. - @param type Desired destination array depth (or -1 if it should be the same as the source type). + @param depth Desired destination array depth (or CV_DEPTH_AUTO if it should be the same as the source type). */ - void assignTo( Mat& m, int type=-1 ) const; + void assignTo(Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const; /** @brief Sets all or some of the array elements to the specified value. @param s Assigned scalar converted to the actual array type. @@ -1343,7 +1349,7 @@ class CV_EXPORTS Mat array as a function parameter, part of a matrix expression, or as a matrix initializer: @code Mat A; - A = Mat::zeros(3, 3, CV_32F); + A = Mat::zeros(3, 3, CV_32FC1); @endcode In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. Otherwise, the existing matrix A is filled with zeros. @@ -1351,27 +1357,27 @@ class CV_EXPORTS Mat @param cols Number of columns. @param type Created matrix type. */ - static MatExpr zeros(int rows, int cols, int type); + static MatExpr zeros(int rows, int cols, ElemType type); /** @overload @param size Alternative to the matrix size specification Size(cols, rows) . @param type Created matrix type. */ - static MatExpr zeros(Size size, int type); + static MatExpr zeros(Size size, ElemType type); /** @overload @param ndims Array dimensionality. @param sz Array of integers specifying the array shape. @param type Created matrix type. */ - static MatExpr zeros(int ndims, const int* sz, int type); + static MatExpr zeros(int ndims, const int* sz, ElemType type); /** @brief Returns an array of all 1's of the specified size and type. The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using this method you can initialize an array with an arbitrary value, using the following Matlab idiom: @code - Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. + Mat A = Mat::ones(100, 100, CV_8UC1)*3; // make 100x100 matrix filled with 3. @endcode The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it just remembers the scale factor (3 in this case) and use it when actually invoking the matrix @@ -1382,20 +1388,20 @@ class CV_EXPORTS Mat @param cols Number of columns. @param type Created matrix type. */ - static MatExpr ones(int rows, int cols, int type); + static MatExpr ones(int rows, int cols, ElemType type); /** @overload @param size Alternative to the matrix size specification Size(cols, rows) . @param type Created matrix type. */ - static MatExpr ones(Size size, int type); + static MatExpr ones(Size size, ElemType type); /** @overload @param ndims Array dimensionality. @param sz Array of integers specifying the array shape. @param type Created matrix type. */ - static MatExpr ones(int ndims, const int* sz, int type); + static MatExpr ones(int ndims, const int* sz, ElemType type); /** @brief Returns an identity matrix of the specified size and type. @@ -1403,7 +1409,7 @@ class CV_EXPORTS Mat Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently: @code // make a 4x4 diagonal matrix with 0.1's on the diagonal. - Mat A = Mat::eye(4, 4, CV_32F)*0.1; + Mat A = Mat::eye(4, 4, CV_32FC1)*0.1; @endcode @note In case of multi-channels type, identity matrix will be initialized only for the first channel, the others will be set to 0's @@ -1411,13 +1417,13 @@ class CV_EXPORTS Mat @param cols Number of columns. @param type Created matrix type. */ - static MatExpr eye(int rows, int cols, int type); + static MatExpr eye(int rows, int cols, ElemType type); /** @overload @param size Alternative matrix size specification as Size(cols, rows) . @param type Created matrix type. */ - static MatExpr eye(Size size, int type); + static MatExpr eye(Size size, ElemType type); /** @brief Allocates new array data if needed. @@ -1452,26 +1458,26 @@ class CV_EXPORTS Mat @param cols New number of columns. @param type New matrix type. */ - void create(int rows, int cols, int type); + void create(int rows, int cols, ElemType type); /** @overload @param size Alternative new matrix size specification: Size(cols, rows) @param type New matrix type. */ - void create(Size size, int type); + void create(Size size, ElemType type); /** @overload @param ndims New array dimensionality. @param sizes Array of integers specifying a new array shape. @param type New matrix type. */ - void create(int ndims, const int* sizes, int type); + void create(int ndims, const int* sizes, ElemType type); /** @overload @param sizes Array of integers specifying a new array shape. @param type New matrix type. */ - void create(const std::vector& sizes, int type); + void create(const std::vector& sizes, ElemType type); /** @brief Increments the reference counter. @@ -1752,7 +1758,7 @@ class CV_EXPORTS Mat The method returns a matrix element type. This is an identifier compatible with the CvMat type system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. */ - int type() const; + ElemType type() const; /** @brief Returns the depth of a matrix element. @@ -1767,7 +1773,7 @@ class CV_EXPORTS Mat - CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) - CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) */ - int depth() const; + ElemDepth depth() const; /** @brief Returns the number of matrix channels. @@ -1811,7 +1817,7 @@ class CV_EXPORTS Mat * if the number of planes is not one, then the number of rows * within every plane has to be 1; if the number of rows within * every plane is not 1, then the number of planes has to be 1. - * @param depth The depth the matrix should have. Set it to -1 when any depth is fine. + * @param depth The depth the matrix should have. Set it to CV_DEPTH_AUTO when any depth is fine. * @param requireContinuous Set it to true to require the matrix to be continuous * @return -1 if the requirement is not satisfied. * Otherwise, it returns the number of elements in the matrix. Note @@ -1823,7 +1829,7 @@ class CV_EXPORTS Mat * The following code demonstrates its usage for a 3-d matrix: * @snippet snippets/core_mat_checkVector.cpp example-3d */ - int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + int checkVector(int elemChannels, ElemDepth depth = CV_DEPTH_AUTO, bool requireContinuous = true) const; /** @brief Returns a pointer to the specified matrix row. @@ -1899,7 +1905,7 @@ class CV_EXPORTS Mat The example below initializes a Hilbert matrix: @code - Mat H(100, 100, CV_64F); + Mat H(100, 100, CV_64FC1); for(int i = 0; i < H.rows; i++) for(int j = 0; j < H.cols; j++) H.at(i,j)=1./(i+j+1); @@ -2079,8 +2085,16 @@ class CV_EXPORTS Mat Mat(Mat&& m); Mat& operator = (Mat&& m); - enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; - enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + enum + { + MAGIC_VAL = 0x42FF0000, + AUTO_STEP = 0, + CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, + SUBMATRIX_FLAG = CV_SUBMAT_FLAG, + MAGIC_MASK = 0xFFFF0000, + TYPE_MASK = 0x00000FFF, + DEPTH_MASK = 7, + }; /*! includes several bit-fields: - the magic signature @@ -2088,7 +2102,7 @@ class CV_EXPORTS Mat - depth - number of channels */ - int flags; + MagicFlag flags; //! the matrix dimensionality, >= 2 int dims; //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions @@ -2140,7 +2154,7 @@ extra data fields. Nor this class nor Mat has any virtual methods. Thus, referen these two classes can be freely but carefully converted one to another. For example: @code{.cpp} // create a 100x100 8-bit matrix - Mat M(100,100,CV_8U); + Mat M(100,100,CV_8UC1); // this will be compiled fine. no any data conversion will be done. Mat_& M1 = (Mat_&)M; // the program is likely to crash at the statement below @@ -2275,8 +2289,8 @@ template class Mat_ : public Mat //! overridden forms of Mat::elemSize() etc. size_t elemSize() const; size_t elemSize1() const; - int type() const; - int depth() const; + ElemType type() const; + ElemDepth depth() const; int channels() const; size_t step1(int i=0) const; //! returns step()/sizeof(_Tp) @@ -2387,15 +2401,15 @@ class CV_EXPORTS UMat UMat(UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constructs 2D matrix of the specified size and type // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) - UMat(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - UMat(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constucts 2D matrix and fills it with the specified value _s. - UMat(int rows, int cols, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); - UMat(Size size, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int rows, int cols, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constructs n-dimensional matrix - UMat(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - UMat(int ndims, const int* sizes, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int ndims, const int* sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int ndims, const int* sizes, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! copy constructor UMat(const UMat& m); @@ -2452,9 +2466,9 @@ class CV_EXPORTS UMat //! copies those matrix elements to "m" that are marked with non-zero mask elements. void copyTo( OutputArray m, InputArray mask ) const; //! converts matrix to another datatype with optional scaling. See cvConvertScale. - void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + void convertTo(OutputArray m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; - void assignTo( UMat& m, int type=-1 ) const; + void assignTo(UMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; //! sets every matrix element to s UMat& operator = (const Scalar& s); @@ -2476,21 +2490,21 @@ class CV_EXPORTS UMat double dot(InputArray m) const; //! Matlab-style matrix initialization - static UMat zeros(int rows, int cols, int type); - static UMat zeros(Size size, int type); - static UMat zeros(int ndims, const int* sz, int type); - static UMat ones(int rows, int cols, int type); - static UMat ones(Size size, int type); - static UMat ones(int ndims, const int* sz, int type); - static UMat eye(int rows, int cols, int type); - static UMat eye(Size size, int type); + static UMat zeros(int rows, int cols, ElemType type); + static UMat zeros(Size size, ElemType type); + static UMat zeros(int ndims, const int* sz, ElemType type); + static UMat ones(int rows, int cols, ElemType type); + static UMat ones(Size size, ElemType type); + static UMat ones(int ndims, const int* sz, ElemType type); + static UMat eye(int rows, int cols, ElemType type); + static UMat eye(Size size, ElemType type); //! allocates new matrix data unless the matrix already has specified size and type. // previous data is unreferenced if needed. - void create(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - void create(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - void create(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - void create(const std::vector& sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(int ndims, const int* sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(const std::vector& sizes, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! increases the reference counter; use with care to avoid memleaks void addref(); @@ -2528,9 +2542,9 @@ class CV_EXPORTS UMat //! returns the size of element channel in bytes. size_t elemSize1() const; //! returns element type, similar to CV_MAT_TYPE(cvmat->type) - int type() const; + ElemType type() const; //! returns element type, similar to CV_MAT_DEPTH(cvmat->type) - int depth() const; + ElemDepth depth() const; //! returns element type, similar to CV_MAT_CN(cvmat->type) int channels() const; //! returns step/elemSize1() @@ -2541,7 +2555,7 @@ class CV_EXPORTS UMat size_t total() const; //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise - int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + int checkVector(int elemChannels, ElemDepth depth = CV_DEPTH_AUTO, bool requireContinuous = true) const; UMat(UMat&& m); UMat& operator = (UMat&& m); @@ -2553,8 +2567,16 @@ class CV_EXPORTS UMat void* handle(AccessFlag accessFlags) const; void ndoffset(size_t* ofs) const; - enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; - enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + enum + { + MAGIC_VAL = 0x42FF0000, + AUTO_STEP = 0, + CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, + SUBMATRIX_FLAG = CV_SUBMAT_FLAG, + MAGIC_MASK = 0xFFFF0000, + TYPE_MASK = 0x00000FFF, + DEPTH_MASK = 7, + }; /*! includes several bit-fields: - the magic signature @@ -2562,7 +2584,7 @@ class CV_EXPORTS UMat - depth - number of channels */ - int flags; + MagicFlag flags; //! the matrix dimensionality, >= 2 int dims; //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions @@ -2590,6 +2612,7 @@ class CV_EXPORTS UMat }; + /////////////////////////// multi-dimensional sparse matrix ////////////////////////// /** @brief The class SparseMat represents multi-dimensional sparse numerical arrays. @@ -2605,7 +2628,7 @@ Elements can be accessed using the following methods: @code const int dims = 5; int size[5] = {10, 10, 10, 10, 10}; - SparseMat sparse_mat(dims, size, CV_32F); + SparseMat sparse_mat(dims, size, CV_32FC1); for(int i = 0; i < 1000; i++) { int idx[dims]; @@ -2677,12 +2700,18 @@ class CV_EXPORTS SparseMat typedef SparseMatIterator iterator; typedef SparseMatConstIterator const_iterator; - enum { MAGIC_VAL=0x42FD0000, MAX_DIM=32, HASH_SCALE=0x5bd1e995, HASH_BIT=0x80000000 }; + enum + { + MAGIC_VAL = 0x42FD0000, + MAX_DIM = 32, + HASH_SCALE = 0x5bd1e995, + HASH_BIT = 0x80000000, + }; //! the sparse matrix header struct CV_EXPORTS Hdr { - Hdr(int _dims, const int* _sizes, int _type); + Hdr(int _dims, const int* _sizes, ElemType _type); void clear(); int refcount; int dims; @@ -2715,7 +2744,7 @@ class CV_EXPORTS SparseMat @param _sizes Sparce matrix size on all dementions. @param _type Sparse matrix data type. */ - SparseMat(int dims, const int* _sizes, int _type); + SparseMat(int dims, const int* _sizes, ElemType _type); /** @overload @param m Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted @@ -2745,21 +2774,19 @@ class CV_EXPORTS SparseMat //! converts sparse matrix to dense matrix. void copyTo( Mat& m ) const; //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type - void convertTo( SparseMat& m, int rtype, double alpha=1 ) const; + void convertTo(SparseMat& m, ElemDepth ddepth, double alpha = 1) const; //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. /*! @param [out] m - output matrix; if it does not have a proper size or type before the operation, it is reallocated - @param [in] rtype - desired output matrix type or, rather, the depth since the number of channels - are the same as the input has; if rtype is negative, the output matrix will have the - same type as the input. + @param [in] ddepth - desired output matrix depth. @param [in] alpha - optional scale factor @param [in] beta - optional delta added to the scaled values */ - void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const; + void convertTo(Mat& m, ElemDepth ddepth, double alpha = 1, double beta = 0) const; // not used now - void assignTo( SparseMat& m, int type=-1 ) const; + void assignTo(SparseMat& m, ElemDepth depth = CV_DEPTH_AUTO) const; //! reallocates sparse matrix. /*! @@ -2767,7 +2794,7 @@ class CV_EXPORTS SparseMat it is simply cleared with clear(), otherwise, the old matrix is released (using release()) and the new one is allocated. */ - void create(int dims, const int* _sizes, int _type); + void create(int dims, const int* _sizes, ElemType _type); //! sets all the sparse matrix elements to 0, which means clearing the hash table. void clear(); //! manually increments the reference counter to the header. @@ -2783,9 +2810,9 @@ class CV_EXPORTS SparseMat size_t elemSize1() const; //! returns type of sparse matrix elements - int type() const; + ElemType type() const; //! returns the depth of sparse matrix elements - int depth() const; + ElemDepth depth() const; //! returns the number of channels int channels() const; @@ -2930,12 +2957,13 @@ class CV_EXPORTS SparseMat void removeNode(size_t hidx, size_t nidx, size_t previdx); void resizeHashTab(size_t newsize); - int flags; + MagicFlag flags; Hdr* hdr; }; + ///////////////////////////////// SparseMat_<_Tp> //////////////////////////////////// /** @brief Template sparse n-dimensional array class derived from SparseMat @@ -2982,9 +3010,9 @@ template class SparseMat_ : public SparseMat //operator CvSparseMat*() const; //! returns type of the matrix elements - int type() const; + ElemType type() const; //! returns depth of the matrix elements - int depth() const; + ElemDepth depth() const; //! returns the number of channels in each matrix element int channels() const; @@ -3191,7 +3219,7 @@ class MatIterator_ : public MatConstIterator_<_Tp> \code SparseMatConstIterator it = m.begin(), it_end = m.end(); double s = 0; - CV_Assert( m.type() == CV_32F ); + CV_Assert( m.type() == CV_32FC1 ); for( ; it != it_end; ++it ) s += it.value(); \endcode @@ -3354,7 +3382,7 @@ The example below illustrates how you can compute a normalized and threshold 3D const int histSize[] = {N, N, N}; // make sure that the histogram has a proper size and type - hist.create(3, histSize, CV_32F); + hist.create(3, histSize, CV_32FC1); // and clear it hist = Scalar(0); @@ -3442,7 +3470,7 @@ class CV_EXPORTS MatOp virtual ~MatOp(); virtual bool elementWise(const MatExpr& expr) const; - virtual void assign(const MatExpr& expr, Mat& m, int type=-1) const = 0; + virtual void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const = 0; virtual void roi(const MatExpr& expr, const Range& rowRange, const Range& colRange, MatExpr& res) const; virtual void diag(const MatExpr& expr, int d, MatExpr& res) const; @@ -3473,7 +3501,7 @@ class CV_EXPORTS MatOp virtual void invert(const MatExpr& expr, int method, MatExpr& res) const; virtual Size size(const MatExpr& expr) const; - virtual int type(const MatExpr& expr) const; + virtual ElemType type(const MatExpr& expr) const; }; /** @brief Matrix expression representation @@ -3535,7 +3563,7 @@ class CV_EXPORTS MatExpr template operator Mat_<_Tp>() const; Size size() const; - int type() const; + ElemType type() const; MatExpr row(int y) const; MatExpr col(int x) const; diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index 0ef6405bb9e6..5ece6f5ffef2 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -64,91 +64,91 @@ CV__DEBUG_NS_BEGIN ////////////////////////// Custom (raw) type wrapper ////////////////////////// template static inline -int rawType() +ElemType rawType() { CV_StaticAssert(sizeof(_Tp) <= CV_CN_MAX, "sizeof(_Tp) is too large"); const int elemSize = sizeof(_Tp); - return (int)CV_MAKETYPE(CV_8U, elemSize); + return CV_MAKETYPE(CV_8U, elemSize); } //////////////////////// Input/Output Arrays //////////////////////// -inline void _InputArray::init(int _flags, const void* _obj) +inline void _InputArray::init(MagicFlag _flags, const void* _obj) { flags = _flags; obj = (void*)_obj; } -inline void _InputArray::init(int _flags, const void* _obj, Size _sz) +inline void _InputArray::init(MagicFlag _flags, const void* _obj, Size _sz) { flags = _flags; obj = (void*)_obj; sz = _sz; } inline void* _InputArray::getObj() const { return obj; } -inline int _InputArray::getFlags() const { return flags; } +inline MagicFlag _InputArray::getFlags() const { return flags; } inline Size _InputArray::getSz() const { return sz; } -inline _InputArray::_InputArray() { init(0 + NONE, 0); } -inline _InputArray::_InputArray(int _flags, void* _obj) { init(_flags, _obj); } -inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); } -inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); } -inline _InputArray::_InputArray(const UMat& m) { init(UMAT+ACCESS_READ, &m); } -inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_READ, &vec); } +inline _InputArray::_InputArray() { init(static_cast(NONE), 0); } +inline _InputArray::_InputArray(MagicFlag _flags, void* _obj) { init(_flags, _obj); } +inline _InputArray::_InputArray(const Mat& m) { init(MAT | ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_MAT | ACCESS_READ, &vec); } +inline _InputArray::_InputArray(const UMat& m) { init(UMAT | ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_UMAT | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::vector<_Tp>& vec) -{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, arr.data(), Size(1, _Nm)); } template inline _InputArray::_InputArray(const std::array& arr) -{ init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); } +{ init(STD_ARRAY_MAT | ACCESS_READ, arr.data(), Size(1, _Nm)); } inline _InputArray::_InputArray(const std::vector& vec) -{ init(FIXED_TYPE + STD_BOOL_VECTOR + traits::Type::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_BOOL_VECTOR | traits::Type::value | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_READ, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &vec); } template inline _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &mtx, Size(n, m)); } template inline _InputArray::_InputArray(const _Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, vec, Size(n, 1)); } template inline _InputArray::_InputArray(const Mat_<_Tp>& m) -{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_READ, &m); } +{ init(FIXED_TYPE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_READ, &m); } inline _InputArray::_InputArray(const double& val) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F + ACCESS_READ, &val, Size(1,1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | CV_64FC1 | ACCESS_READ, &val, Size(1,1)); } inline _InputArray::_InputArray(const MatExpr& expr) -{ init(FIXED_TYPE + FIXED_SIZE + EXPR + ACCESS_READ, &expr); } +{ init(FIXED_TYPE | FIXED_SIZE | EXPR | ACCESS_READ, &expr); } inline _InputArray::_InputArray(const cuda::GpuMat& d_mat) -{ init(CUDA_GPU_MAT + ACCESS_READ, &d_mat); } +{ init(CUDA_GPU_MAT | ACCESS_READ, &d_mat); } inline _InputArray::_InputArray(const std::vector& d_mat) -{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_READ, &d_mat);} +{ init(STD_VECTOR_CUDA_GPU_MAT | ACCESS_READ, &d_mat);} inline _InputArray::_InputArray(const ogl::Buffer& buf) -{ init(OPENGL_BUFFER + ACCESS_READ, &buf); } +{ init(OPENGL_BUFFER | ACCESS_READ, &buf); } inline _InputArray::_InputArray(const cuda::HostMem& cuda_mem) -{ init(CUDA_HOST_MEM + ACCESS_READ, &cuda_mem); } +{ init(CUDA_HOST_MEM | ACCESS_READ, &cuda_mem); } template inline _InputArray _InputArray::rawIn(const std::vector<_Tp>& vec) { _InputArray v; - v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_READ; + v.flags = _InputArray::FIXED_TYPE | _InputArray::STD_VECTOR | rawType<_Tp>() | ACCESS_READ; v.obj = (void*)&vec; return v; } @@ -157,7 +157,7 @@ template inline _InputArray _InputArray::rawIn(const std::array<_Tp, _Nm>& arr) { _InputArray v; - v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ; + v.flags = FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_READ; v.obj = (void*)arr.data(); v.sz = Size(1, _Nm); return v; @@ -185,116 +185,116 @@ inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray:: //////////////////////////////////////////////////////////////////////////////////////// -inline _OutputArray::_OutputArray() { init(NONE + ACCESS_WRITE, 0); } -inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags + ACCESS_WRITE, _obj); } -inline _OutputArray::_OutputArray(Mat& m) { init(MAT+ACCESS_WRITE, &m); } -inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_MAT + ACCESS_WRITE, &vec); } -inline _OutputArray::_OutputArray(UMat& m) { init(UMAT + ACCESS_WRITE, &m); } -inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } +inline _OutputArray::_OutputArray() { init(NONE | ACCESS_WRITE, 0); } +inline _OutputArray::_OutputArray(MagicFlag _flags, void* _obj) { init(_flags | ACCESS_WRITE, _obj); } +inline _OutputArray::_OutputArray(Mat& m) { init(MAT | ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_MAT | ACCESS_WRITE, &vec); } +inline _OutputArray::_OutputArray(UMat& m) { init(UMAT | ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_UMAT | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(std::vector<_Tp>& vec) -{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(std::array& arr) -{ init(STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(STD_ARRAY_MAT | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(Mat_<_Tp>& m) -{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &m); } template inline _OutputArray::_OutputArray(Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &mtx, Size(n, m)); } template inline _OutputArray::_OutputArray(_Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, vec, Size(n, 1)); } template inline _OutputArray::_OutputArray(const std::vector<_Tp>& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(const std::array& arr) -{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } +{ init(FIXED_SIZE | STD_ARRAY_MAT | ACCESS_WRITE, arr.data(), Size(1, _Nm)); } template inline _OutputArray::_OutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &vec); } template inline _OutputArray::_OutputArray(const Mat_<_Tp>& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &m); } template inline _OutputArray::_OutputArray(const Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, &mtx, Size(n, m)); } template inline _OutputArray::_OutputArray(const _Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE, vec, Size(n, 1)); } inline _OutputArray::_OutputArray(cuda::GpuMat& d_mat) -{ init(CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } +{ init(CUDA_GPU_MAT | ACCESS_WRITE, &d_mat); } inline _OutputArray::_OutputArray(std::vector& d_mat) -{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_WRITE, &d_mat);} +{ init(STD_VECTOR_CUDA_GPU_MAT | ACCESS_WRITE, &d_mat);} inline _OutputArray::_OutputArray(ogl::Buffer& buf) -{ init(OPENGL_BUFFER + ACCESS_WRITE, &buf); } +{ init(OPENGL_BUFFER | ACCESS_WRITE, &buf); } inline _OutputArray::_OutputArray(cuda::HostMem& cuda_mem) -{ init(CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } +{ init(CUDA_HOST_MEM | ACCESS_WRITE, &cuda_mem); } inline _OutputArray::_OutputArray(const Mat& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | ACCESS_WRITE, &m); } inline _OutputArray::_OutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_WRITE, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_MAT | ACCESS_WRITE, &vec); } inline _OutputArray::_OutputArray(const UMat& m) -{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_WRITE, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | UMAT | ACCESS_WRITE, &m); } inline _OutputArray::_OutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_UMAT | ACCESS_WRITE, &vec); } inline _OutputArray::_OutputArray(const cuda::GpuMat& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_GPU_MAT | ACCESS_WRITE, &d_mat); } inline _OutputArray::_OutputArray(const ogl::Buffer& buf) -{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_WRITE, &buf); } +{ init(FIXED_TYPE | FIXED_SIZE | OPENGL_BUFFER | ACCESS_WRITE, &buf); } inline _OutputArray::_OutputArray(const cuda::HostMem& cuda_mem) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_HOST_MEM | ACCESS_WRITE, &cuda_mem); } template inline _OutputArray _OutputArray::rawOut(std::vector<_Tp>& vec) { _OutputArray v; - v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_WRITE; + v.flags = _InputArray::FIXED_TYPE | _InputArray::STD_VECTOR | rawType<_Tp>() | ACCESS_WRITE; v.obj = (void*)&vec; return v; } @@ -303,7 +303,7 @@ template inline _OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr) { _OutputArray v; - v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE; + v.flags = FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_WRITE; v.obj = (void*)arr.data(); v.sz = Size(1, _Nm); return v; @@ -311,112 +311,112 @@ _OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr) /////////////////////////////////////////////////////////////////////////////////////////// -inline _InputOutputArray::_InputOutputArray() { init(0+ACCESS_RW, 0); } -inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags+ACCESS_RW, _obj); } -inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT+ACCESS_RW, &m); } -inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); } -inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT+ACCESS_RW, &m); } -inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_RW, &vec); } +inline _InputOutputArray::_InputOutputArray() { init(_InputArray::NONE | ACCESS_RW, 0); } +inline _InputOutputArray::_InputOutputArray(MagicFlag _flags, void* _obj) { init(_flags | ACCESS_RW, _obj); } +inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT | ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_MAT | ACCESS_RW, &vec); } +inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT | ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_UMAT | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec) -{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(std::array& arr) -{ init(STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(STD_ARRAY_MAT | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(std::vector >& vec) -{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(Mat_<_Tp>& m) -{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } +{ init(FIXED_TYPE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &m); } template inline _InputOutputArray::_InputOutputArray(Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &mtx, Size(n, m)); } template inline _InputOutputArray::_InputOutputArray(_Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, vec, Size(n, 1)); } template inline _InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr) -{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(const std::array& arr) -{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } +{ init(FIXED_SIZE | STD_ARRAY_MAT | ACCESS_RW, arr.data(), Size(1, _Nm)); } template inline _InputOutputArray::_InputOutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_VECTOR | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(const std::vector >& vec) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &vec); } template inline _InputOutputArray::_InputOutputArray(const Mat_<_Tp>& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &m); } template inline _InputOutputArray::_InputOutputArray(const Matx<_Tp, m, n>& mtx) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, &mtx, Size(n, m)); } template inline _InputOutputArray::_InputOutputArray(const _Tp* vec, int n) -{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } +{ init(FIXED_TYPE | FIXED_SIZE | MATX | static_cast(traits::Type<_Tp>::value) | ACCESS_RW, vec, Size(n, 1)); } inline _InputOutputArray::_InputOutputArray(cuda::GpuMat& d_mat) -{ init(CUDA_GPU_MAT + ACCESS_RW, &d_mat); } +{ init(CUDA_GPU_MAT | ACCESS_RW, &d_mat); } inline _InputOutputArray::_InputOutputArray(ogl::Buffer& buf) -{ init(OPENGL_BUFFER + ACCESS_RW, &buf); } +{ init(OPENGL_BUFFER | ACCESS_RW, &buf); } inline _InputOutputArray::_InputOutputArray(cuda::HostMem& cuda_mem) -{ init(CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } +{ init(CUDA_HOST_MEM | ACCESS_RW, &cuda_mem); } inline _InputOutputArray::_InputOutputArray(const Mat& m) -{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_RW, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | MAT | ACCESS_RW, &m); } inline _InputOutputArray::_InputOutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_RW, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_MAT | ACCESS_RW, &vec); } inline _InputOutputArray::_InputOutputArray(const UMat& m) -{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_RW, &m); } +{ init(FIXED_TYPE | FIXED_SIZE | UMAT | ACCESS_RW, &m); } inline _InputOutputArray::_InputOutputArray(const std::vector& vec) -{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_RW, &vec); } +{ init(FIXED_SIZE | STD_VECTOR_UMAT | ACCESS_RW, &vec); } inline _InputOutputArray::_InputOutputArray(const cuda::GpuMat& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_RW, &d_mat); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_GPU_MAT | ACCESS_RW, &d_mat); } inline _InputOutputArray::_InputOutputArray(const std::vector& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_CUDA_GPU_MAT | ACCESS_RW, &d_mat);} template<> inline _InputOutputArray::_InputOutputArray(std::vector& d_mat) -{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} +{ init(FIXED_TYPE | FIXED_SIZE | STD_VECTOR_CUDA_GPU_MAT | ACCESS_RW, &d_mat);} inline _InputOutputArray::_InputOutputArray(const ogl::Buffer& buf) -{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_RW, &buf); } +{ init(FIXED_TYPE | FIXED_SIZE | OPENGL_BUFFER | ACCESS_RW, &buf); } inline _InputOutputArray::_InputOutputArray(const cuda::HostMem& cuda_mem) -{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } +{ init(FIXED_TYPE | FIXED_SIZE | CUDA_HOST_MEM | ACCESS_RW, &cuda_mem); } template inline _InputOutputArray _InputOutputArray::rawInOut(std::vector<_Tp>& vec) @@ -431,7 +431,7 @@ template inline _InputOutputArray _InputOutputArray::rawInOut(std::array<_Tp, _Nm>& arr) { _InputOutputArray v; - v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW; + v.flags = FIXED_TYPE | FIXED_SIZE | STD_ARRAY | static_cast(traits::Type<_Tp>::value) | ACCESS_RW; v.obj = (void*)arr.data(); v.sz = Size(1, _Nm); return v; @@ -448,21 +448,21 @@ CV__DEBUG_NS_END inline Mat::Mat() - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) {} inline -Mat::Mat(int _rows, int _cols, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _rows, int _cols, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_rows, _cols, _type); } inline -Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _rows, int _cols, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_rows, _cols, _type); @@ -470,16 +470,16 @@ Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) } inline -Mat::Mat(Size _sz, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(Size _sz, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create( _sz.height, _sz.width, _type ); } inline -Mat::Mat(Size _sz, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(Size _sz, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_sz.height, _sz.width, _type); @@ -487,16 +487,16 @@ Mat::Mat(Size _sz, int _type, const Scalar& _s) } inline -Mat::Mat(int _dims, const int* _sz, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _dims, const int* _sz, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_dims, _sz, _type); } inline -Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _dims, const int* _sz, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_dims, _sz, _type); @@ -504,16 +504,16 @@ Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) } inline -Mat::Mat(const std::vector& _sz, int _type) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(const std::vector& _sz, ElemType _type) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_sz, _type); } inline -Mat::Mat(const std::vector& _sz, int _type, const Scalar& _s) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(const std::vector& _sz, ElemType _type, const Scalar& _s) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { create(_sz, _type); @@ -540,8 +540,8 @@ Mat::Mat(const Mat& m) } inline -Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step) - : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols), +Mat::Mat(int _rows, int _cols, ElemType _type, void* _data, size_t _step) + : flags(static_cast(MAGIC_VAL | (_type & TYPE_MASK))), dims(2), rows(_rows), cols(_cols), data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { @@ -569,8 +569,8 @@ Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step) } inline -Mat::Mat(Size _sz, int _type, void* _data, size_t _step) - : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width), +Mat::Mat(Size _sz, ElemType _type, void* _data, size_t _step) + : flags(static_cast(MAGIC_VAL | (_type & TYPE_MASK))), dims(2), rows(_sz.height), cols(_sz.width), data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { @@ -600,7 +600,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step) template 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(static_cast(MAGIC_VAL) | static_cast(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()) @@ -637,7 +637,7 @@ Mat::Mat(const std::initializer_list sizes, const std::initializer_list<_Tp template 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(static_cast(MAGIC_VAL) | static_cast(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()) @@ -654,7 +654,7 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) template 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(static_cast(MAGIC_VAL) | static_cast(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 ) @@ -670,7 +670,7 @@ Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) template inline Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), + : flags(static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value) | CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -686,7 +686,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) template 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(static_cast(MAGIC_VAL) | static_cast(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 ) @@ -705,7 +705,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData) template 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(static_cast(MAGIC_VAL) | static_cast(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 ) @@ -725,7 +725,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData) template 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(static_cast(MAGIC_VAL) | static_cast(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>(); @@ -813,18 +813,18 @@ Mat Mat::clone() const } inline -void Mat::assignTo( Mat& m, int _type ) const +void Mat::assignTo(Mat& m, ElemDepth _depth) const { - if( _type < 0 ) + if (_depth == CV_DEPTH_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline -void Mat::create(int _rows, int _cols, int _type) +void Mat::create(int _rows, int _cols, ElemType _type) { - _type &= TYPE_MASK; + _type &= static_cast(TYPE_MASK); if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data ) return; int sz[] = {_rows, _cols}; @@ -832,7 +832,7 @@ void Mat::create(int _rows, int _cols, int _type) } inline -void Mat::create(Size _sz, int _type) +void Mat::create(Size _sz, ElemType _type) { create(_sz.height, _sz.width, _type); } @@ -854,7 +854,7 @@ void Mat::release() for(int i = 0; i < dims; i++) size.p[i] = 0; #ifdef _DEBUG - flags = MAGIC_VAL; + flags = static_cast(MAGIC_VAL); dims = rows = cols = 0; if(step.p != step.buf) { @@ -892,13 +892,13 @@ Mat Mat::operator()(const std::vector& ranges) const inline bool Mat::isContinuous() const { - return (flags & CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(CONTINUOUS_FLAG)); } inline bool Mat::isSubmatrix() const { - return (flags & SUBMATRIX_FLAG) != 0; + return !!(flags & static_cast(SUBMATRIX_FLAG)); } inline @@ -916,13 +916,13 @@ size_t Mat::elemSize1() const } inline -int Mat::type() const +ElemType Mat::type() const { return CV_MAT_TYPE(flags); } inline -int Mat::depth() const +ElemDepth Mat::depth() const { return CV_MAT_DEPTH(flags); } @@ -1320,7 +1320,7 @@ Mat::operator Vec<_Tp, n>() const return Vec<_Tp, n>((_Tp*)data); Vec<_Tp, n> v; Mat tmp(rows, cols, traits::Type<_Tp>::value, v.val); - convertTo(tmp, tmp.type()); + convertTo(tmp, tmp.depth()); return v; } @@ -1333,7 +1333,7 @@ Mat::operator Matx<_Tp, m, n>() const return Matx<_Tp, m, n>((_Tp*)data); Matx<_Tp, m, n> mtx; Mat tmp(rows, cols, traits::Type<_Tp>::value, mtx.val); - convertTo(tmp, tmp.type()); + convertTo(tmp, tmp.depth()); return mtx; } @@ -1395,7 +1395,7 @@ Mat::Mat(Mat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL; m.allocator = NULL; m.u = NULL; @@ -1430,7 +1430,7 @@ Mat& Mat::operator = (Mat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL; m.allocator = NULL; m.u = NULL; @@ -1554,7 +1554,7 @@ template inline Mat_<_Tp>::Mat_() : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); } template inline @@ -1611,7 +1611,7 @@ template inline Mat_<_Tp>::Mat_(const Mat& m) : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); *this = m; } @@ -1709,7 +1709,7 @@ Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0)); } CV_Assert(DataType<_Tp>::channels == m.channels() || m.empty()); - m.convertTo(*this, type()); + m.convertTo(*this, depth()); return *this; } @@ -1751,7 +1751,7 @@ void Mat_<_Tp>::release() { Mat::release(); #ifdef _DEBUG - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); #endif } @@ -1806,14 +1806,14 @@ size_t Mat_<_Tp>::elemSize1() const } template inline -int Mat_<_Tp>::type() const +ElemType Mat_<_Tp>::type() const { CV_DbgAssert( Mat::type() == traits::Type<_Tp>::value ); return traits::Type<_Tp>::value; } template inline -int Mat_<_Tp>::depth() const +ElemDepth Mat_<_Tp>::depth() const { CV_DbgAssert( Mat::depth() == traits::Depth<_Tp>::value ); return traits::Depth<_Tp>::value; @@ -2069,7 +2069,7 @@ template inline Mat_<_Tp>::Mat_(Mat&& m) : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); *this = m; } @@ -2087,7 +2087,7 @@ Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m) return *this; } CV_DbgAssert(DataType<_Tp>::channels == m.channels()); - m.convertTo(*this, type()); + m.convertTo(*this, depth()); return *this; } @@ -2095,7 +2095,7 @@ template inline Mat_<_Tp>::Mat_(MatExpr&& e) : Mat() { - flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + flags = static_cast((flags & ~CV_MAT_TYPE_MASK) | static_cast(traits::Type<_Tp>::value)); *this = Mat(e); } @@ -2104,12 +2104,12 @@ Mat_<_Tp>::Mat_(MatExpr&& e) inline SparseMat::SparseMat() - : flags(MAGIC_VAL), hdr(0) + : flags(static_cast(MAGIC_VAL)), hdr(0) {} inline -SparseMat::SparseMat(int _dims, const int* _sizes, int _type) - : flags(MAGIC_VAL), hdr(0) +SparseMat::SparseMat(int _dims, const int* _sizes, ElemType _type) + : flags(static_cast(MAGIC_VAL)), hdr(0) { create(_dims, _sizes, _type); } @@ -2156,12 +2156,12 @@ SparseMat SparseMat::clone() const } inline -void SparseMat::assignTo( SparseMat& m, int _type ) const +void SparseMat::assignTo(SparseMat& m, ElemDepth _depth) const { - if( _type < 0 ) + if (_depth == CV_DEPTH_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline @@ -2192,13 +2192,13 @@ size_t SparseMat::elemSize1() const } inline -int SparseMat::type() const +ElemType SparseMat::type() const { return CV_MAT_TYPE(flags); } inline -int SparseMat::depth() const +ElemDepth SparseMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -2431,7 +2431,7 @@ SparseMatConstIterator_<_Tp> SparseMat::end() const template inline SparseMat_<_Tp>::SparseMat_() { - flags = MAGIC_VAL + traits::Type<_Tp>::value; + flags = static_cast(MAGIC_VAL) | static_cast(traits::Type<_Tp>::value); } template inline @@ -2507,13 +2507,13 @@ void SparseMat_<_Tp>::create(int _dims, const int* _sizes) } template inline -int SparseMat_<_Tp>::type() const +ElemType SparseMat_<_Tp>::type() const { return traits::Type<_Tp>::value; } template inline -int SparseMat_<_Tp>::depth() const +ElemDepth SparseMat_<_Tp>::depth() const { return traits::Depth<_Tp>::value; } @@ -3352,13 +3352,13 @@ Mat& Mat::operator = (const MatExpr& e) template inline Mat_<_Tp>::Mat_(const MatExpr& e) { - e.op->assign(e, *this, traits::Type<_Tp>::value); + e.op->assign(e, *this, traits::Depth<_Tp>::value); } template inline Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e) { - e.op->assign(e, *this, traits::Type<_Tp>::value); + e.op->assign(e, *this, traits::Depth<_Tp>::value); return *this; } @@ -3421,7 +3421,7 @@ template inline MatExpr::operator Mat_<_Tp>() const { Mat_<_Tp> m; - op->assign(*this, m, traits::Type<_Tp>::value); + op->assign(*this, m, traits::Depth<_Tp>::value); return m; } @@ -3586,49 +3586,49 @@ const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) inline UMat::UMat(UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) {} inline -UMat::UMat(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _rows, int _cols, ElemType _type, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_rows, _cols, _type); } inline -UMat::UMat(int _rows, int _cols, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _rows, int _cols, ElemType _type, const Scalar& _s, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_rows, _cols, _type); *this = _s; } inline -UMat::UMat(Size _sz, int _type, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(Size _sz, ElemType _type, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create( _sz.height, _sz.width, _type ); } inline -UMat::UMat(Size _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(Size _sz, ElemType _type, const Scalar& _s, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_sz.height, _sz.width, _type); *this = _s; } inline -UMat::UMat(int _dims, const int* _sz, int _type, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _dims, const int* _sz, ElemType _type, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_dims, _sz, _type); } inline -UMat::UMat(int _dims, const int* _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) -: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) +UMat::UMat(int _dims, const int* _sz, ElemType _type, const Scalar& _s, UMatUsageFlags _usageFlags) +: flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) { create(_dims, _sz, _type); *this = _s; @@ -3654,7 +3654,7 @@ UMat::UMat(const UMat& m) template 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(static_cast(MAGIC_VAL) | static_cast(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()) @@ -3740,18 +3740,18 @@ UMat UMat::clone() const } inline -void UMat::assignTo( UMat& m, int _type ) const +void UMat::assignTo(UMat& m, ElemDepth _depth) const { - if( _type < 0 ) + if (_depth == CV_DEPTH_AUTO) m = *this; else - convertTo(m, _type); + convertTo(m, _depth); } inline -void UMat::create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) +void UMat::create(int _rows, int _cols, ElemType _type, UMatUsageFlags _usageFlags) { - _type &= TYPE_MASK; + _type &= static_cast(TYPE_MASK); if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && u ) return; int sz[] = {_rows, _cols}; @@ -3759,7 +3759,7 @@ void UMat::create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) } inline -void UMat::create(Size _sz, int _type, UMatUsageFlags _usageFlags) +void UMat::create(Size _sz, ElemType _type, UMatUsageFlags _usageFlags) { create(_sz.height, _sz.width, _type, _usageFlags); } @@ -3807,13 +3807,13 @@ UMat UMat::operator()(const std::vector& ranges) const inline bool UMat::isContinuous() const { - return (flags & CONTINUOUS_FLAG) != 0; + return !!(flags & static_cast(CONTINUOUS_FLAG)); } inline bool UMat::isSubmatrix() const { - return (flags & SUBMATRIX_FLAG) != 0; + return !!(flags & static_cast(SUBMATRIX_FLAG)); } inline @@ -3831,13 +3831,13 @@ size_t UMat::elemSize1() const } inline -int UMat::type() const +ElemType UMat::type() const { return CV_MAT_TYPE(flags); } inline -int UMat::depth() const +ElemDepth UMat::depth() const { return CV_MAT_DEPTH(flags); } @@ -3889,7 +3889,7 @@ UMat::UMat(UMat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.allocator = NULL; m.u = NULL; m.offset = 0; @@ -3924,7 +3924,7 @@ UMat& UMat::operator = (UMat&& m) m.step.p = m.step.buf; m.size.p = &m.rows; } - m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; + m.flags = static_cast(MAGIC_VAL); m.dims = m.rows = m.cols = 0; m.allocator = NULL; m.u = NULL; m.offset = 0; @@ -3932,11 +3932,11 @@ UMat& UMat::operator = (UMat&& m) } -inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; } -inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; } -inline bool UMatData::deviceMemMapped() const { return (flags & DEVICE_MEM_MAPPED) != 0; } -inline bool UMatData::copyOnMap() const { return (flags & COPY_ON_MAP) != 0; } -inline bool UMatData::tempUMat() const { return (flags & TEMP_UMAT) != 0; } +inline bool UMatData::hostCopyObsolete() const { return !!(flags & HOST_COPY_OBSOLETE); } +inline bool UMatData::deviceCopyObsolete() const { return !!(flags & DEVICE_COPY_OBSOLETE); } +inline bool UMatData::deviceMemMapped() const { return !!(flags & DEVICE_MEM_MAPPED); } +inline bool UMatData::copyOnMap() const { return !!(flags & COPY_ON_MAP); } +inline bool UMatData::tempUMat() const { return !!(flags & TEMP_UMAT); } inline bool UMatData::tempCopiedUMat() const { return (flags & TEMP_COPIED_UMAT) == TEMP_COPIED_UMAT; } inline void UMatData::markDeviceMemMapped(bool flag) diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp index 82de1f88d83f..863a798c2c45 100644 --- a/modules/core/include/opencv2/core/matx.hpp +++ b/modules/core/include/opencv2/core/matx.hpp @@ -99,16 +99,14 @@ In case if C++11 features are available, std::initializer_list can be also used template class Matx { public: - enum { - rows = m, - cols = n, - channels = rows*cols, + static const int rows = m; + static const int cols = n; + static const int channels = rows*cols; + static const int shortdim = (m < n ? m : n); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - depth = traits::Type<_Tp>::value, - type = CV_MAKETYPE(depth, channels), + static const ElemDepth depth = traits::Depth<_Tp>::value; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - shortdim = (m < n ? m : n) - }; typedef _Tp value_type; typedef Matx<_Tp, m, n> mat_type; @@ -258,21 +256,20 @@ template class DataType< Matx<_Tp, m, n> > typedef _Tp channel_type; typedef value_type vec_type; - enum { generic_type = 0, - channels = m * n, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = m * n; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; }; namespace traits { template -struct Depth< Matx<_Tp, m, n> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Matx<_Tp, m, n> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Matx<_Tp, m, n> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, n*m) }; }; +struct Type< Matx<_Tp, m, n> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, n*m); }; } // namespace @@ -333,14 +330,11 @@ template class Vec : public Matx<_Tp, cn, 1> { public: typedef _Tp value_type; - enum { - channels = cn, + static const int channels = cn; #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - depth = Matx<_Tp, cn, 1>::depth, - type = CV_MAKETYPE(depth, channels), + static const ElemDepth depth = Matx<_Tp, cn, 1>::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - _dummy_enum_finalizer = 0 - }; //! default constructor Vec(); @@ -433,22 +427,20 @@ template class DataType< Vec<_Tp, cn> > typedef _Tp channel_type; typedef value_type vec_type; - enum { generic_type = 0, - channels = cn, - fmt = DataType::fmt + ((channels - 1) << 8), + static const bool generic_type = false; + static const int channels = cn; + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - depth = DataType::depth, - type = CV_MAKETYPE(depth, channels), + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - _dummy_enum_finalizer = 0 - }; }; namespace traits { template -struct Depth< Vec<_Tp, cn> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Vec<_Tp, cn> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Vec<_Tp, cn> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, cn) }; }; +struct Type< Vec<_Tp, cn> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, cn); }; } // namespace diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index 888477e15440..90e1fbbb36b6 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -307,7 +307,7 @@ CV_EXPORTS void attachContext(const String& platformName, void* platformID, void @param type OpenCV type of image @param dst destination UMat */ -CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst); +CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, ElemType type, UMat& dst); /** @brief Convert OpenCL image2d_t to UMat @note @@ -728,12 +728,12 @@ class CV_EXPORTS PlatformInfo Impl* p; }; -CV_EXPORTS const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf); +CV_EXPORTS const char* convertTypeStr(ElemDepth sdepth, ElemDepth ddepth, int cn, char* buf); CV_EXPORTS const char* typeToStr(int t); CV_EXPORTS const char* memopTypeToStr(int t); CV_EXPORTS const char* vecopTypeToStr(int t); CV_EXPORTS const char* getOpenCLErrorString(int errorCode); -CV_EXPORTS String kernelToStr(InputArray _kernel, int ddepth = -1, const char * name = NULL); +CV_EXPORTS String kernelToStr(InputArray _kernel, ElemDepth ddepth = CV_DEPTH_AUTO, const char * name = NULL); CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); @@ -791,7 +791,7 @@ class CV_EXPORTS Image2D /** Indicates if the image format is supported. */ - static bool isFormatSupported(int depth, int cn, bool norm); + static bool isFormatSupported(ElemDepth depth, int cn, bool norm); void* ptr() const; protected: diff --git a/modules/core/include/opencv2/core/opengl.hpp b/modules/core/include/opencv2/core/opengl.hpp index ddc0db6943c5..888b03082564 100644 --- a/modules/core/include/opencv2/core/opengl.hpp +++ b/modules/core/include/opencv2/core/opengl.hpp @@ -110,7 +110,7 @@ class CV_EXPORTS Buffer @param abufId Buffer object name. @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false); + Buffer(int arows, int acols, ElemType atype, unsigned int abufId, bool autoRelease = false); /** @overload @param asize 2D array size. @@ -118,7 +118,7 @@ class CV_EXPORTS Buffer @param abufId Buffer object name. @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false); + Buffer(Size asize, ElemType atype, unsigned int abufId, bool autoRelease = false); /** @overload @param arows Number of rows in a 2D array. @@ -127,7 +127,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + Buffer(int arows, int acols, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @overload @param asize 2D array size. @@ -135,7 +135,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + Buffer(Size asize, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @overload @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). @@ -152,7 +152,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + void create(int arows, int acols, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @overload @param asize 2D array size. @@ -160,7 +160,7 @@ class CV_EXPORTS Buffer @param target Buffer usage. See cv::ogl::Buffer::Target . @param autoRelease Auto release mode (if true, release will be called in object's destructor). */ - void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + void create(Size asize, ElemType atype, Target target = ARRAY_BUFFER, bool autoRelease = false); /** @brief Decrements the reference counter and destroys the buffer object if needed. @@ -260,8 +260,8 @@ class CV_EXPORTS Buffer Size size() const; bool empty() const; - int type() const; - int depth() const; + ElemType type() const; + ElemDepth depth() const; int channels() const; int elemSize() const; int elemSize1() const; @@ -275,7 +275,7 @@ class CV_EXPORTS Buffer Ptr impl_; int rows_; int cols_; - int type_; + ElemType type_; }; /** @brief Smart pointer for OpenGL 2D texture memory with reference counting. @@ -374,7 +374,7 @@ class CV_EXPORTS Texture2D @param ddepth Destination depth. @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture). */ - void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const; + void copyTo(OutputArray arr, ElemDepth ddepth = CV_32F, bool autoRelease = false) const; /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target. */ @@ -584,19 +584,19 @@ CV_EXPORTS void setGlDevice(int device = 0); //////////////////////////////////////////////////////////////////////// inline -cv::ogl::Buffer::Buffer(int arows, int acols, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(int arows, int acols, ElemType atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { create(arows, acols, atype, target, autoRelease); } inline -cv::ogl::Buffer::Buffer(Size asize, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(Size asize, ElemType atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { create(asize, atype, target, autoRelease); } inline -void cv::ogl::Buffer::create(Size asize, int atype, Target target, bool autoRelease) +void cv::ogl::Buffer::create(Size asize, ElemType atype, Target target, bool autoRelease) { create(asize.height, asize.width, atype, target, autoRelease); } @@ -626,13 +626,13 @@ bool cv::ogl::Buffer::empty() const } inline -int cv::ogl::Buffer::type() const +ElemType cv::ogl::Buffer::type() const { return type_; } inline -int cv::ogl::Buffer::depth() const +ElemDepth cv::ogl::Buffer::depth() const { return CV_MAT_DEPTH(type_); } diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 0d28b6c9440c..6754165d9c37 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -267,14 +267,14 @@ CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a,b,a), Mat_<_Tp>, Mat_<_Tp>) CV_MAT_AUG_OPERATOR (*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat, Mat) CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat) CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat_<_Tp>) -CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, -1, b), Mat, double) -CV_MAT_AUG_OPERATOR_T(*=, a.convertTo(a, -1, b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, CV_DEPTH_AUTO, b), Mat, double) +CV_MAT_AUG_OPERATOR_T(*= , a.convertTo(a, CV_DEPTH_AUTO, b), Mat_<_Tp>, double) CV_MAT_AUG_OPERATOR (/=, cv::divide(a,b,a), Mat, Mat) CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a,b,a), Mat_<_Tp>, Mat) CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a,b,a), Mat_<_Tp>, Mat_<_Tp>) -CV_MAT_AUG_OPERATOR (/=, a.convertTo((Mat&)a, -1, 1./b), Mat, double) -CV_MAT_AUG_OPERATOR_T(/=, a.convertTo((Mat&)a, -1, 1./b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR(/= , a.convertTo((Mat&)a, CV_DEPTH_AUTO, 1. / b), Mat, double) +CV_MAT_AUG_OPERATOR_T(/= , a.convertTo((Mat&)a, CV_DEPTH_AUTO, 1. / b), Mat_<_Tp>, double) CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a,b,a), Mat, Mat) CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a,b,a), Mat, Scalar) diff --git a/modules/core/include/opencv2/core/private.cuda.hpp b/modules/core/include/opencv2/core/private.cuda.hpp index cda6cbc4aed1..7fd419616014 100644 --- a/modules/core/include/opencv2/core/private.cuda.hpp +++ b/modules/core/include/opencv2/core/private.cuda.hpp @@ -93,8 +93,8 @@ namespace cv { namespace cuda { CV_EXPORTS GpuMat getInputMat(InputArray _src, Stream& stream); - CV_EXPORTS GpuMat getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream); - static inline GpuMat getOutputMat(OutputArray _dst, Size size, int type, Stream& stream) + CV_EXPORTS GpuMat getOutputMat(OutputArray _dst, int rows, int cols, ElemType type, Stream& stream); + static inline GpuMat getOutputMat(OutputArray _dst, Size size, ElemType type, Stream& stream) { return getOutputMat(_dst, size.height, size.width, type, stream); } diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index 05c486f4edef..99930b770618 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -313,7 +313,7 @@ static inline IppiMaskSize ippiGetMaskSize(int kx, int ky) (IppiMaskSize)-1; } -static inline IppDataType ippiGetDataType(int depth) +static inline IppDataType ippiGetDataType(ElemDepth depth) { depth = CV_MAT_DEPTH(depth); return depth == CV_8U ? ipp8u : diff --git a/modules/core/include/opencv2/core/traits.hpp b/modules/core/include/opencv2/core/traits.hpp index 52ab083ca43d..c3f2f2c6c2e1 100644 --- a/modules/core/include/opencv2/core/traits.hpp +++ b/modules/core/include/opencv2/core/traits.hpp @@ -77,7 +77,11 @@ DataType itself that is used but its specialized versions, such as: typedef uchar value_type; typedef int work_type; typedef uchar channel_type; - enum { channel_type = CV_8U, channels = 1, fmt='u', type = CV_8U }; + + static const int channel_type = CV_8U; + static const int channels = 1; + static const int fmt = 'u'; + static const ElemType type = CV_8UC1; }; ... template DataType > @@ -86,9 +90,11 @@ DataType itself that is used but its specialized versions, such as: typedef std::complex<_Tp> work_type; typedef _Tp channel_type; // DataDepth is another helper trait class - enum { depth = DataDepth<_Tp>::value, channels=2, - fmt=(channels-1)*256+DataDepth<_Tp>::fmt, - type=CV_MAKETYPE(depth, channels) }; + + static const ElemDepth depth = DataDepth<_Tp>::value; + static const int channels = 2; + static const int fmt = (channels-1)*256 + DataDepth<_Tp>::fmt; + static const ElemType type = CV_MAKETYPE(depth, channels); }; ... @endcode @@ -117,12 +123,12 @@ template class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 1, - depth = -1, - channels = 1, - fmt = 0, - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = true; + static const ElemDepth depth = CV_DEPTH_AUTO; + static const int channels = 1; + static const int fmt = 0; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif }; @@ -133,12 +139,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8U, - channels = 1, - fmt = (int)'u', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_8U; + static const int channels = 1; + static const int fmt = (int)'u'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -148,12 +154,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8U, - channels = 1, - fmt = (int)'u', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_8U; + static const int channels = 1; + static const int fmt = (int)'u'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -163,12 +169,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8S, - channels = 1, - fmt = (int)'c', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_8S; + static const int channels = 1; + static const int fmt = (int)'c'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -178,12 +184,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_8S, - channels = 1, - fmt = (int)'c', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_8S; + static const int channels = 1; + static const int fmt = (int)'c'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -193,12 +199,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_16U, - channels = 1, - fmt = (int)'w', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_16U; + static const int channels = 1; + static const int fmt = (int)'w'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -208,12 +214,12 @@ template<> class DataType typedef int work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_16S, - channels = 1, - fmt = (int)'s', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_16S; + static const int channels = 1; + static const int fmt = (int)'s'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -223,12 +229,12 @@ template<> class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_32S, - channels = 1, - fmt = (int)'i', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_32S; + static const int channels = 1; + static const int fmt = (int)'i'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -238,12 +244,12 @@ template<> class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_32F, - channels = 1, - fmt = (int)'f', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_32F; + static const int channels = 1; + static const int fmt = (int)'f'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -253,12 +259,12 @@ template<> class DataType typedef value_type work_type; typedef value_type channel_type; typedef value_type vec_type; - enum { generic_type = 0, - depth = CV_64F, - channels = 1, - fmt = (int)'d', - type = CV_MAKETYPE(depth, channels) - }; + + static const bool generic_type = false; + static const ElemDepth depth = CV_64F; + static const int channels = 1; + static const int fmt = (int)'d'; + static const ElemType type = CV_MAKETYPE(depth, channels); }; template<> class DataType @@ -284,11 +290,8 @@ DataDepth::value constant. template class DataDepth { public: - enum - { - value = DataType<_Tp>::depth, - fmt = DataType<_Tp>::fmt - }; + static const ElemDepth value = DataType<_Tp>::depth; + static const int fmt = DataType<_Tp>::fmt; }; @@ -379,11 +382,11 @@ CV_CREATE_MEMBER_CHECK(type) template struct Depth -{ enum { value = DataType::depth }; }; +{ static const ElemDepth value = DataType::depth; }; template struct Type -{ enum { value = DataType::type }; }; +{ static const ElemType value = DataType::type; }; /** Similar to traits::Type but has value = -1 in case of unknown type (instead of compiler error) */ template >::value > diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 3aabfa138df3..61ccd42aaef3 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -97,23 +97,22 @@ template class DataType< Complex<_Tp> > typedef value_type work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 2, - fmt = DataType::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Complex<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Complex<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Complex<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +struct Type< Complex<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace @@ -200,23 +199,22 @@ template class DataType< Point_<_Tp> > typedef Point_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 2, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Point_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Point_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Point_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +struct Type< Point_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace @@ -278,23 +276,22 @@ template class DataType< Point3_<_Tp> > typedef Point3_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 3, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 3; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Point3_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Point3_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Point3_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 3) }; }; +struct Type< Point3_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 3); }; } // namespace //////////////////////////////// Size_ //////////////////////////////// @@ -353,23 +350,22 @@ template class DataType< Size_<_Tp> > typedef Size_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 2, - fmt = DataType::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Size_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Size_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Size_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +struct Type< Size_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 2); }; } // namespace //////////////////////////////// Rect_ //////////////////////////////// @@ -468,23 +464,22 @@ template class DataType< Rect_<_Tp> > typedef Rect_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 4, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 4; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Rect_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Rect_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Rect_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +struct Type< Rect_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 4); }; } // namespace ///////////////////////////// RotatedRect ///////////////////////////// @@ -541,23 +536,22 @@ template<> class DataType< RotatedRect > typedef value_type work_type; typedef float channel_type; - enum { generic_type = 0, - channels = (int)sizeof(value_type)/sizeof(channel_type), // 5 - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = (int)sizeof(value_type) / sizeof(channel_type); // 5 + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template<> -struct Depth< RotatedRect > { enum { value = Depth::value }; }; +struct Depth< RotatedRect > { static const ElemDepth value = Depth::value; }; template<> -struct Type< RotatedRect > { enum { value = CV_MAKETYPE(Depth::value, (int)sizeof(RotatedRect)/sizeof(float)) }; }; +struct Type< RotatedRect > { static const ElemType value = CV_MAKETYPE(Depth::value, (int)sizeof(RotatedRect)/sizeof(float)); }; } // namespace @@ -605,23 +599,22 @@ template<> class DataType typedef value_type work_type; typedef int channel_type; - enum { generic_type = 0, - channels = 2, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 2; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template<> -struct Depth< Range > { enum { value = Depth::value }; }; +struct Depth< Range > { static const ElemDepth value = Depth::value; }; template<> -struct Type< Range > { enum { value = CV_MAKETYPE(Depth::value, 2) }; }; +struct Type< Range > { static const ElemType value = CV_MAKETYPE(Depth::value, 2); }; } // namespace @@ -675,23 +668,22 @@ template class DataType< Scalar_<_Tp> > typedef Scalar_::work_type> work_type; typedef _Tp channel_type; - enum { generic_type = 0, - channels = 4, - fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = 4; + static const int fmt = traits::SafeFmt::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template -struct Depth< Scalar_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +struct Depth< Scalar_<_Tp> > { static const ElemDepth value = Depth<_Tp>::value; }; template -struct Type< Scalar_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +struct Type< Scalar_<_Tp> > { static const ElemType value = CV_MAKETYPE(Depth<_Tp>::value, 4); }; } // namespace @@ -786,12 +778,11 @@ template<> class DataType typedef float work_type; typedef float channel_type; - enum { generic_type = 0, - depth = DataType::depth, - channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 7 - fmt = DataType::fmt + ((channels - 1) << 8), - type = CV_MAKETYPE(depth, channels) - }; + static const bool generic_type = false; + static const ElemDepth depth = DataType::depth; + static const int channels = (int)(sizeof(value_type)/sizeof(channel_type)); // 7 + static const int fmt = DataType::fmt + ((channels - 1) << 8); + static const ElemType type = CV_MAKETYPE(depth, channels); typedef Vec vec_type; }; @@ -830,12 +821,11 @@ template<> class DataType typedef int work_type; typedef int channel_type; - enum { generic_type = 0, - depth = DataType::depth, - channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 4 - fmt = DataType::fmt + ((channels - 1) << 8), - type = CV_MAKETYPE(depth, channels) - }; + static const bool generic_type = false; + static const ElemDepth depth = DataType::depth; + static const int channels = (int)(sizeof(value_type)/sizeof(channel_type)); // 4 + static const int fmt = DataType::fmt + ((channels - 1) << 8); + static const ElemType type = CV_MAKETYPE(depth, channels); typedef Vec vec_type; }; @@ -959,23 +949,22 @@ template<> class DataType typedef double work_type; typedef double channel_type; - enum { generic_type = 0, - channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 24 - fmt = DataType::fmt + ((channels - 1) << 8) + static const bool generic_type = false; + static const int channels = (int)(sizeof(value_type) / sizeof(channel_type)); // 24 + static const int fmt = DataType::fmt + ((channels - 1) << 8); #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED - ,depth = DataType::depth - ,type = CV_MAKETYPE(depth, channels) + static const ElemDepth depth = DataType::depth; + static const ElemType type = CV_MAKETYPE(depth, channels); #endif - }; typedef Vec vec_type; }; namespace traits { template<> -struct Depth< Moments > { enum { value = Depth::value }; }; +struct Depth< Moments > { static const ElemDepth value = Depth::value; }; template<> -struct Type< Moments > { enum { value = CV_MAKETYPE(Depth::value, (int)(sizeof(Moments)/sizeof(double))) }; }; +struct Type< Moments > { static const ElemType value = CV_MAKETYPE(Depth::value, (int)(sizeof(Moments)/sizeof(double))); }; } // namespace //! @} imgproc_shape diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index f745db93d1a3..c9bde01cdcf4 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -546,7 +546,7 @@ CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL) { CvMat m; - assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F ); + assert((unsigned)CV_MAT_DEPTH(type) <= (unsigned)CV_64F); type = CV_MAT_TYPE(type); m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type; m.cols = cols; @@ -567,7 +567,7 @@ CV_INLINE CvMat cvMat(const cv::Mat& m) CV_DbgAssert(m.dims <= 2); self = cvMat(m.rows, m.dims == 1 ? 1 : m.cols, m.type(), m.data); self.step = (int)m.step[0]; - self.type = (self.type & ~cv::Mat::CONTINUOUS_FLAG) | (m.flags & cv::Mat::CONTINUOUS_FLAG); + self.type = (self.type & static_cast(~cv::Mat::CONTINUOUS_FLAG)) | (m.flags & static_cast(cv::Mat::CONTINUOUS_FLAG)); return self; } CV_INLINE CvMat cvMat() @@ -656,7 +656,7 @@ CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) CV_INLINE int cvIplDepth( int type ) { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || depth == CV_32S ? IPL_DEPTH_SIGN : 0); } @@ -1705,7 +1705,6 @@ typedef CvContour CvPoint2DSeq; #define CV_SEQ_ELTYPE_POINT CV_32SC2 /**< (x,y) */ #define CV_SEQ_ELTYPE_CODE CV_8UC1 /**< freeman code: 0..7 */ #define CV_SEQ_ELTYPE_GENERIC 0 -#define CV_SEQ_ELTYPE_PTR CV_MAKE_TYPE(CV_8U, 8 /*sizeof(void*)*/) #define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /**< &(x,y) */ #define CV_SEQ_ELTYPE_INDEX CV_32SC1 /**< #(x,y) */ #define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /**< &next_o, &next_d, &vtx_o, &vtx_d */ diff --git a/modules/core/misc/java/src/cpp/core_manual.hpp b/modules/core/misc/java/src/cpp/core_manual.hpp index 82d460fa5341..d09d96d206a3 100644 --- a/modules/core/misc/java/src/cpp/core_manual.hpp +++ b/modules/core/misc/java/src/cpp/core_manual.hpp @@ -13,13 +13,13 @@ CV_EXPORTS_W void setErrorVerbosity(bool verbose); namespace cv { -CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1); +CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); -CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1); +CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), ElemDepth ddepth = CV_DEPTH_AUTO); -CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1); +CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemDepth ddepth = CV_DEPTH_AUTO); -CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1); +CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, ElemDepth ddepth = CV_DEPTH_AUTO); CV_EXPORTS_W void absdiff(InputArray src1, Scalar src2, OutputArray dst); diff --git a/modules/core/misc/java/src/java/core+CvType.java b/modules/core/misc/java/src/java/core+CvType.java index 748c1cd75c22..0166ff90e229 100644 --- a/modules/core/misc/java/src/java/core+CvType.java +++ b/modules/core/misc/java/src/java/core+CvType.java @@ -118,9 +118,6 @@ public static final String typeToString(int type) { case CV_64F: s = "CV_64F"; break; - case CV_USRTYPE1: - s = "CV_USRTYPE1"; - break; default: throw new java.lang.UnsupportedOperationException( "Unsupported CvType value: " + type); diff --git a/modules/core/misc/python/pyopencv_core.hpp b/modules/core/misc/python/pyopencv_core.hpp index 9017a5beccda..60deeffc069b 100644 --- a/modules/core/misc/python/pyopencv_core.hpp +++ b/modules/core/misc/python/pyopencv_core.hpp @@ -1,30 +1,13 @@ #ifdef HAVE_OPENCV_CORE -#include "opencv2/core/cuda.hpp" +#include "opencv2/core.hpp" -typedef std::vector vector_GpuMat; -typedef cuda::GpuMat::Allocator GpuMat_Allocator; -typedef cuda::HostMem::AllocType HostMem_AllocType; -typedef cuda::Event::CreateFlags Event_CreateFlags; +#ifdef CV_TYPE_SAFE_API +CV_PY_FROM_ENUM(ElemType); +CV_PY_TO_ENUM(ElemType); -CV_PY_TO_CLASS(cuda::GpuMat); -CV_PY_TO_CLASS(cuda::Stream); -CV_PY_TO_CLASS(cuda::Event); -CV_PY_TO_CLASS(cuda::HostMem); - -CV_PY_TO_CLASS_PTR(cuda::GpuMat); -CV_PY_TO_CLASS_PTR(cuda::GpuMat::Allocator); - -CV_PY_TO_ENUM(cuda::Event::CreateFlags); -CV_PY_TO_ENUM(cuda::HostMem::AllocType); -CV_PY_TO_ENUM(cuda::FeatureSet); - -CV_PY_FROM_CLASS(cuda::GpuMat); -CV_PY_FROM_CLASS(cuda::Stream); -CV_PY_FROM_CLASS(cuda::HostMem); - -CV_PY_FROM_CLASS_PTR(cuda::GpuMat::Allocator); - -CV_PY_FROM_ENUM(cuda::DeviceInfo::ComputeMode); +CV_PY_FROM_ENUM(ElemDepth); +CV_PY_TO_ENUM(ElemDepth); +#endif #endif diff --git a/modules/core/misc/python/pyopencv_cuda.hpp b/modules/core/misc/python/pyopencv_cuda.hpp new file mode 100644 index 000000000000..9017a5beccda --- /dev/null +++ b/modules/core/misc/python/pyopencv_cuda.hpp @@ -0,0 +1,30 @@ +#ifdef HAVE_OPENCV_CORE + +#include "opencv2/core/cuda.hpp" + +typedef std::vector vector_GpuMat; +typedef cuda::GpuMat::Allocator GpuMat_Allocator; +typedef cuda::HostMem::AllocType HostMem_AllocType; +typedef cuda::Event::CreateFlags Event_CreateFlags; + +CV_PY_TO_CLASS(cuda::GpuMat); +CV_PY_TO_CLASS(cuda::Stream); +CV_PY_TO_CLASS(cuda::Event); +CV_PY_TO_CLASS(cuda::HostMem); + +CV_PY_TO_CLASS_PTR(cuda::GpuMat); +CV_PY_TO_CLASS_PTR(cuda::GpuMat::Allocator); + +CV_PY_TO_ENUM(cuda::Event::CreateFlags); +CV_PY_TO_ENUM(cuda::HostMem::AllocType); +CV_PY_TO_ENUM(cuda::FeatureSet); + +CV_PY_FROM_CLASS(cuda::GpuMat); +CV_PY_FROM_CLASS(cuda::Stream); +CV_PY_FROM_CLASS(cuda::HostMem); + +CV_PY_FROM_CLASS_PTR(cuda::GpuMat::Allocator); + +CV_PY_FROM_ENUM(cuda::DeviceInfo::ComputeMode); + +#endif diff --git a/modules/core/misc/python/shadow_umat.hpp b/modules/core/misc/python/shadow_umat.hpp index 39ffef1d4712..dd3a88ad5b14 100644 --- a/modules/core/misc/python/shadow_umat.hpp +++ b/modules/core/misc/python/shadow_umat.hpp @@ -11,11 +11,11 @@ class CV_EXPORTS_W UMat CV_WRAP UMat(UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constructs 2D matrix of the specified size and type // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) - CV_WRAP UMat(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); - CV_WRAP UMat(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(int rows, int cols, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(Size size, ElemType type, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! constucts 2D matrix and fills it with the specified value _s. - CV_WRAP UMat(int rows, int cols, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); - CV_WRAP UMat(Size size, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(int rows, int cols, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + CV_WRAP UMat(Size size, ElemType type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); //! Mat is mappable to UMat CV_WRAP_MAPPABLE(Ptr); diff --git a/modules/core/perf/cuda/perf_gpumat.cpp b/modules/core/perf/cuda/perf_gpumat.cpp index f04b7962ba59..dfc3844b42ab 100644 --- a/modules/core/perf/cuda/perf_gpumat.cpp +++ b/modules/core/perf/cuda/perf_gpumat.cpp @@ -60,10 +60,10 @@ PERF_TEST_P(Sz_Depth_Cn, CUDA_GpuMat_SetTo, CUDA_CHANNELS_1_3_4)) { const cv::Size size = GET_PARAM(0); - const int depth = GET_PARAM(1); + const ElemDepth depth = GET_PARAM(1); const int channels = GET_PARAM(2); - const int type = CV_MAKE_TYPE(depth, channels); + const ElemType type = CV_MAKE_TYPE(depth, channels); const cv::Scalar val(1, 2, 3, 4); @@ -92,10 +92,10 @@ PERF_TEST_P(Sz_Depth_Cn, CUDA_GpuMat_SetToMasked, CUDA_CHANNELS_1_3_4)) { const cv::Size size = GET_PARAM(0); - const int depth = GET_PARAM(1); + const ElemDepth depth = GET_PARAM(1); const int channels = GET_PARAM(2); - const int type = CV_MAKE_TYPE(depth, channels); + const ElemType type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); cv::Mat mask(size, CV_8UC1); @@ -129,10 +129,10 @@ PERF_TEST_P(Sz_Depth_Cn, CUDA_GpuMat_CopyToMasked, CUDA_CHANNELS_1_3_4)) { const cv::Size size = GET_PARAM(0); - const int depth = GET_PARAM(1); + const ElemDepth depth = GET_PARAM(1); const int channels = GET_PARAM(2); - const int type = CV_MAKE_TYPE(depth, channels); + const ElemType type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); cv::Mat mask(size, CV_8UC1); @@ -167,10 +167,10 @@ PERF_TEST_P(Sz_2Depth, CUDA_GpuMat_ConvertTo, Values(CV_8U, CV_16U, CV_32F, CV_64F))) { const cv::Size size = GET_PARAM(0); - const int depth1 = GET_PARAM(1); - const int depth2 = GET_PARAM(2); + const ElemDepth depth1 = GET_PARAM(1); + const ElemDepth depth2 = GET_PARAM(2); - cv::Mat src(size, depth1); + cv::Mat src(size, CV_MAKETYPE(depth1, 1)); declare.in(src, WARMUP_RNG); const double a = 0.5; diff --git a/modules/core/perf/opencl/perf_arithm.cpp b/modules/core/perf/opencl/perf_arithm.cpp index 9f5f6e9e772d..f39004c51bc6 100644 --- a/modules/core/perf/opencl/perf_arithm.cpp +++ b/modules/core/perf/opencl/perf_arithm.cpp @@ -57,12 +57,13 @@ OCL_PERF_TEST_P(LUTFixture, LUT, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), cn = CV_MAT_CN(type); + const ElemType type = get<1>(params); + const int cn = CV_MAT_CN(type); checkDeviceMaxMemoryAllocSize(srcSize, type); UMat src(srcSize, CV_8UC(cn)), lut(1, 256, type); - int dstType = CV_MAKETYPE(lut.depth(), src.channels()); + ElemType dstType = CV_MAKETYPE(lut.depth(), src.channels()); UMat dst(srcSize, dstType); declare.in(src, lut, WARMUP_RNG).out(dst); @@ -81,7 +82,7 @@ OCL_PERF_TEST_P(ExpFixture, Exp, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -106,7 +107,7 @@ OCL_PERF_TEST_P(LogFixture, Log, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -130,7 +131,7 @@ OCL_PERF_TEST_P(AddFixture, Add, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134)) { const Size srcSize = GET_PARAM(0); - const int type = GET_PARAM(1); + const ElemType type = GET_PARAM(1); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -151,7 +152,7 @@ OCL_PERF_TEST_P(SubtractFixture, Subtract, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -171,7 +172,7 @@ OCL_PERF_TEST_P(MulFixture, Multiply, ::testing::Combine(OCL_TEST_SIZES, OCL_TES { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -192,7 +193,7 @@ OCL_PERF_TEST_P(DivFixture, Divide, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -204,7 +205,7 @@ OCL_PERF_TEST_P(DivFixture, Divide, Mat m2 = src2.getMat(ACCESS_RW); Mat zero_mask = m2 == 0; Mat fix; - zero_mask.convertTo(fix, type); // 0 or 255 + zero_mask.convertTo(fix, CV_MAT_DEPTH(type)); // 0 or 255 cv::add(m2, fix, m2); } @@ -225,7 +226,7 @@ OCL_PERF_TEST_P(AbsDiffFixture, Absdiff, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -246,7 +247,7 @@ OCL_PERF_TEST_P(CartToPolarFixture, CartToPolar, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -269,7 +270,7 @@ OCL_PERF_TEST_P(PolarToCartFixture, PolarToCart, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -292,7 +293,7 @@ OCL_PERF_TEST_P(MagnitudeFixture, Magnitude, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -314,7 +315,7 @@ OCL_PERF_TEST_P(TransposeFixture, Transpose, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -331,7 +332,7 @@ OCL_PERF_TEST_P(TransposeFixture, TransposeInplace, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -361,7 +362,7 @@ OCL_PERF_TEST_P(FlipFixture, Flip, { const FlipParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const int flipType = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -383,7 +384,7 @@ OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); bool onecn = CV_MAT_CN(type) == 1; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -419,7 +420,8 @@ OCL_PERF_TEST_P(SumFixture, Sum, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), depth = CV_MAT_DEPTH(type); + const ElemType type = get<1>(params); + const ElemDepth depth = CV_MAT_DEPTH(type); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -446,7 +448,7 @@ OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -469,7 +471,7 @@ OCL_PERF_TEST_P(PhaseFixture, Phase, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -491,7 +493,7 @@ OCL_PERF_TEST_P(BitwiseAndFixture, Bitwise_and, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -512,7 +514,7 @@ OCL_PERF_TEST_P(BitwiseXorFixture, Bitwise_xor, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -533,7 +535,7 @@ OCL_PERF_TEST_P(BitwiseOrFixture, Bitwise_or, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -554,7 +556,7 @@ OCL_PERF_TEST_P(BitwiseNotFixture, Bitwise_not, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -579,7 +581,7 @@ OCL_PERF_TEST_P(CompareFixture, Compare, { const CompareParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const int cmpCode = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -594,12 +596,12 @@ OCL_PERF_TEST_P(CompareFixture, Compare, OCL_PERF_TEST_P(CompareFixture, CompareScalar, ::testing::Combine(OCL_TEST_SIZES, - OCL_PERF_ENUM((MatType)CV_32FC1), // TODO: OCL_TEST_TYPES_134 + OCL_PERF_ENUM(CV_32FC1), // TODO: OCL_TEST_TYPES_134 CmpCode::all())) { const CompareParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const int cmpCode = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -621,7 +623,7 @@ OCL_PERF_TEST_P(PowFixture, Pow, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -643,7 +645,8 @@ OCL_PERF_TEST_P(AddWeightedFixture, AddWeighted, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), depth = CV_MAT_DEPTH(type); + const ElemType type = get<1>(params); + const ElemDepth depth = CV_MAT_DEPTH(type); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -668,7 +671,7 @@ OCL_PERF_TEST_P(SqrtFixture, Sqrt, ::testing::Combine( { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -693,7 +696,7 @@ OCL_PERF_TEST_P(SetIdentityFixture, SetIdentity, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -715,7 +718,7 @@ OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDev, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const double eps = 2e-5; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -745,7 +748,7 @@ OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDevWithMask, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const double eps = 2e-5; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -782,7 +785,7 @@ OCL_PERF_TEST_P(NormFixture, Norm1Arg, { const NormParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const int normType = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -802,7 +805,7 @@ OCL_PERF_TEST_P(NormFixture, Norm, { const NormParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const int normType = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -822,7 +825,7 @@ OCL_PERF_TEST_P(NormFixture, NormRel, { const NormParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const int normType = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -846,7 +849,7 @@ OCL_PERF_TEST_P(UMatDotFixture, UMatDot, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); double r = 0.0; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -868,7 +871,8 @@ OCL_PERF_TEST_P(RepeatFixture, Repeat, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), nx = 2, ny = 2; + const ElemType type = get<1>(params); + const int nx = 2, ny = 2; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -889,7 +893,7 @@ OCL_PERF_TEST_P(MinFixture, Min, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -910,7 +914,7 @@ OCL_PERF_TEST_P(MaxFixture, Max, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -931,7 +935,7 @@ OCL_PERF_TEST_P(InRangeFixture, InRange, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -956,7 +960,8 @@ OCL_PERF_TEST_P(NormalizeFixture, Normalize, { const NormalizeParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), mode = get<2>(params); + const ElemType type = get<1>(params); + const int mode = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -974,14 +979,15 @@ OCL_PERF_TEST_P(NormalizeFixture, NormalizeWithMask, { const NormalizeParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), mode = get<2>(params); + const ElemType type = get<1>(params); + const int mode = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); UMat src(srcSize, type), mask(srcSize, CV_8UC1), dst(srcSize, type); declare.in(src, mask, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() cv::normalize(src, dst, 10, 110, mode, -1, mask); + OCL_TEST_CYCLE() cv::normalize(src, dst, 10, 110, mode, CV_DEPTH_AUTO, mask); SANITY_CHECK(dst, 5e-2); } @@ -995,7 +1001,8 @@ OCL_PERF_TEST_P(ConvertScaleAbsFixture, ConvertScaleAbs, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), cn = CV_MAT_CN(type); + const ElemType type = get<1>(params); + const int cn = CV_MAT_CN(type); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -1016,7 +1023,8 @@ OCL_PERF_TEST_P(PatchNaNsFixture, PatchNaNs, { const Size_MatType_t params = GetParam(); Size srcSize = get<0>(params); - const int type = get<1>(params), cn = CV_MAT_CN(type); + const ElemType type = get<1>(params); + const int cn = CV_MAT_CN(type); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -1050,7 +1058,7 @@ OCL_PERF_TEST_P(ScaleAddFixture, ScaleAdd, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -1072,7 +1080,7 @@ OCL_PERF_TEST_P(TransformFixture, Transform, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -1099,7 +1107,7 @@ OCL_PERF_TEST_P(PSNRFixture, PSNR, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -1128,8 +1136,8 @@ OCL_PERF_TEST_P(ReduceMinMaxFixture, Reduce, { const ReduceMinMaxParams params = GetParam(); const std::pair types = get<1>(params); - const int stype = types.first, dtype = types.second, - dim = get<2>(params), op = get<3>(params); + const ElemType stype = types.first, dtype = types.second; + const int dim = get<2>(params), op = get<3>(params); const Size srcSize = get<0>(params), dstSize(dim == 0 ? srcSize.width : 1, dim == 0 ? 1 : srcSize.height); const double eps = CV_MAT_DEPTH(dtype) <= CV_32S ? 1 : 1e-5; @@ -1140,7 +1148,7 @@ OCL_PERF_TEST_P(ReduceMinMaxFixture, Reduce, UMat src(srcSize, stype), dst(dstSize, dtype); declare.in(src, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() cv::reduce(src, dst, dim, op, dtype); + OCL_TEST_CYCLE() cv::reduce(src, dst, dim, op, CV_MAT_DEPTH(dtype)); SANITY_CHECK(dst, eps); } @@ -1159,8 +1167,8 @@ OCL_PERF_TEST_P(ReduceAccFixture, Reduce, { const ReduceAccParams params = GetParam(); const std::pair types = get<1>(params); - const int stype = types.first, dtype = types.second, - dim = get<2>(params), op = get<3>(params); + const ElemType stype = types.first, dtype = types.second; + const int dim = get<2>(params), op = get<3>(params); const Size srcSize = get<0>(params), dstSize(dim == 0 ? srcSize.width : 1, dim == 0 ? 1 : srcSize.height); const double eps = CV_MAT_DEPTH(dtype) <= CV_32S ? 1 : 3e-4; @@ -1171,7 +1179,7 @@ OCL_PERF_TEST_P(ReduceAccFixture, Reduce, UMat src(srcSize, stype), dst(dstSize, dtype); declare.in(src, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() cv::reduce(src, dst, dim, op, dtype); + OCL_TEST_CYCLE() cv::reduce(src, dst, dim, op, CV_MAT_DEPTH(dtype)); SANITY_CHECK(dst, eps); } diff --git a/modules/core/perf/opencl/perf_channels.cpp b/modules/core/perf/opencl/perf_channels.cpp index b82ac6dc49c9..eb37b72c9f6b 100644 --- a/modules/core/perf/opencl/perf_channels.cpp +++ b/modules/core/perf/opencl/perf_channels.cpp @@ -62,7 +62,9 @@ OCL_PERF_TEST_P(MergeFixture, Merge, { const MergeParams params = GetParam(); const Size srcSize = get<0>(params); - const int depth = get<1>(params), cn = get<2>(params), dtype = CV_MAKE_TYPE(depth, cn); + const ElemDepth depth = get<1>(params); + const int cn = get<2>(params); + const ElemType dtype = CV_MAKE_TYPE(depth, cn); checkDeviceMaxMemoryAllocSize(srcSize, dtype); @@ -90,7 +92,9 @@ OCL_PERF_TEST_P(SplitFixture, Split, { const SplitParams params = GetParam(); const Size srcSize = get<0>(params); - const int depth = get<1>(params), cn = get<2>(params), type = CV_MAKE_TYPE(depth, cn); + const ElemDepth depth = get<1>(params); + const int cn = get<2>(params); + const ElemType type = CV_MAKE_TYPE(depth, cn); ASSERT_TRUE(cn == 3 || cn == 2); @@ -133,7 +137,9 @@ OCL_PERF_TEST_P(MixChannelsFixture, MixChannels, { const MixChannelsParams params = GetParam(); const Size srcSize = get<0>(params); - const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 2), n = 2; + const ElemDepth depth = get<1>(params); + const ElemType type = CV_MAKE_TYPE(depth, 2); + int n = 2; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -167,11 +173,12 @@ OCL_PERF_TEST_P(InsertChannelFixture, InsertChannel, { const Size_MatDepth_t params = GetParam(); const Size srcSize = get<0>(params); - const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 3); + const ElemDepth depth = get<1>(params); + const ElemType type = CV_MAKE_TYPE(depth, 3); checkDeviceMaxMemoryAllocSize(srcSize, type); - UMat src(srcSize, depth), dst(srcSize, type, Scalar::all(17)); + UMat src(srcSize, CV_MAKETYPE(depth, 1)), dst(srcSize, type, Scalar::all(17)); declare.in(src, WARMUP_RNG).out(dst); OCL_TEST_CYCLE() cv::insertChannel(src, dst, 1); @@ -189,11 +196,12 @@ OCL_PERF_TEST_P(ExtractChannelFixture, ExtractChannel, { const Size_MatDepth_t params = GetParam(); const Size srcSize = get<0>(params); - const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 3); + const ElemDepth depth = get<1>(params); + const ElemType type = CV_MAKE_TYPE(depth, 3); checkDeviceMaxMemoryAllocSize(srcSize, type); - UMat src(srcSize, type), dst(srcSize, depth); + UMat src(srcSize, type), dst(srcSize, CV_MAKETYPE(depth, 1)); declare.in(src, WARMUP_RNG).out(dst); OCL_TEST_CYCLE() cv::extractChannel(src, dst, 1); diff --git a/modules/core/perf/opencl/perf_gemm.cpp b/modules/core/perf/opencl/perf_gemm.cpp index e0ee67c0fe70..602f99642a48 100644 --- a/modules/core/perf/opencl/perf_gemm.cpp +++ b/modules/core/perf/opencl/perf_gemm.cpp @@ -66,7 +66,7 @@ OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine( GemmParams params = GetParam(); const Size srcSize = get<0>(params); const int flags = get<1>(params); - const int type = get<2>(params); + const ElemType type = get<2>(params); UMat src1(srcSize, type), src2(srcSize, type), src3(srcSize, type), dst(srcSize, type); declare.in(src1, src2, src3).out(dst); diff --git a/modules/core/perf/opencl/perf_matop.cpp b/modules/core/perf/opencl/perf_matop.cpp index 97a881b872a1..7509d69f1e68 100644 --- a/modules/core/perf/opencl/perf_matop.cpp +++ b/modules/core/perf/opencl/perf_matop.cpp @@ -22,7 +22,7 @@ OCL_PERF_TEST_P(SetToFixture, SetTo, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const Scalar s = Scalar::all(17); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -44,7 +44,7 @@ OCL_PERF_TEST_P(SetToFixture, SetToWithMask, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const Scalar s = Scalar::all(17); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -66,8 +66,10 @@ OCL_PERF_TEST_P(ConvertToFixture, ConvertTo, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ddepth = CV_MAT_DEPTH(type) == CV_8U ? CV_32F : CV_8U, - cn = CV_MAT_CN(type), dtype = CV_MAKE_TYPE(ddepth, cn); + const ElemType type = get<1>(params); + const ElemDepth ddepth = CV_MAT_DEPTH(type) == CV_8U ? CV_32F : CV_8U; + const int cn = CV_MAT_CN(type); + const ElemType dtype = CV_MAKE_TYPE(ddepth, cn); checkDeviceMaxMemoryAllocSize(srcSize, type); checkDeviceMaxMemoryAllocSize(srcSize, dtype); @@ -75,7 +77,7 @@ OCL_PERF_TEST_P(ConvertToFixture, ConvertTo, UMat src(srcSize, type), dst(srcSize, dtype); declare.in(src, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() src.convertTo(dst, dtype); + OCL_TEST_CYCLE() src.convertTo(dst, ddepth); SANITY_CHECK(dst); } @@ -89,7 +91,7 @@ OCL_PERF_TEST_P(CopyToFixture, CopyTo, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -110,7 +112,7 @@ OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -127,7 +129,7 @@ OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); diff --git a/modules/core/perf/perf_abs.cpp b/modules/core/perf/perf_abs.cpp index 253f15282745..ed738887f0cb 100644 --- a/modules/core/perf/perf_abs.cpp +++ b/modules/core/perf/perf_abs.cpp @@ -11,7 +11,7 @@ using namespace perf; PERF_TEST_P(Size_MatType, abs, TYPICAL_MATS_ABS) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat c = Mat(sz, type); diff --git a/modules/core/perf/perf_addWeighted.cpp b/modules/core/perf/perf_addWeighted.cpp index 2822bc61e73b..48000f876484 100644 --- a/modules/core/perf/perf_addWeighted.cpp +++ b/modules/core/perf/perf_addWeighted.cpp @@ -10,7 +10,7 @@ using namespace perf; PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); int depth = CV_MAT_DEPTH(type); Mat src1(size, type); Mat src2(size, type); @@ -29,7 +29,7 @@ PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED) src2 /= 2048; } - TEST_CYCLE() cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() ); + TEST_CYCLE() cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.depth() ); SANITY_CHECK(dst, depth == CV_32S ? 4 : 1); } diff --git a/modules/core/perf/perf_arithm.cpp b/modules/core/perf/perf_arithm.cpp index 70e2f49210e5..568c970c0d24 100644 --- a/modules/core/perf/perf_arithm.cpp +++ b/modules/core/perf/perf_arithm.cpp @@ -9,7 +9,7 @@ typedef Size_MatType BinaryOpTest; PERF_TEST_P_(BinaryOpTest, min) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -24,7 +24,7 @@ PERF_TEST_P_(BinaryOpTest, min) PERF_TEST_P_(BinaryOpTest, minScalarDouble) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -39,7 +39,7 @@ PERF_TEST_P_(BinaryOpTest, minScalarDouble) PERF_TEST_P_(BinaryOpTest, minScalarSameType) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -63,7 +63,7 @@ PERF_TEST_P_(BinaryOpTest, minScalarSameType) PERF_TEST_P_(BinaryOpTest, max) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -78,7 +78,7 @@ PERF_TEST_P_(BinaryOpTest, max) PERF_TEST_P_(BinaryOpTest, maxScalarDouble) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -93,7 +93,7 @@ PERF_TEST_P_(BinaryOpTest, maxScalarDouble) PERF_TEST_P_(BinaryOpTest, maxScalarSameType) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -117,7 +117,7 @@ PERF_TEST_P_(BinaryOpTest, maxScalarSameType) PERF_TEST_P_(BinaryOpTest, absdiff) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -139,7 +139,7 @@ PERF_TEST_P_(BinaryOpTest, absdiff) PERF_TEST_P_(BinaryOpTest, absdiffScalarDouble) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -161,7 +161,7 @@ PERF_TEST_P_(BinaryOpTest, absdiffScalarDouble) PERF_TEST_P_(BinaryOpTest, absdiffScalarSameType) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -187,7 +187,7 @@ PERF_TEST_P_(BinaryOpTest, absdiffScalarSameType) PERF_TEST_P_(BinaryOpTest, add) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -210,7 +210,7 @@ PERF_TEST_P_(BinaryOpTest, add) PERF_TEST_P_(BinaryOpTest, addScalarDouble) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -232,25 +232,26 @@ PERF_TEST_P_(BinaryOpTest, addScalarDouble) PERF_TEST_P_(BinaryOpTest, addScalarSameType) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); + ElemDepth depth = CV_MAT_DEPTH(type); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); declare.in(a, b, WARMUP_RNG).out(c); - if (CV_MAT_DEPTH(type) < CV_32S) + if (depth < CV_32S) { b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing } - else if (CV_MAT_DEPTH(type) == CV_32S) + else if (depth == CV_32S) { //see ticket 1529: add can be without saturation on 32S a /= 2; b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing } - TEST_CYCLE() cv::add(a, b, c, noArray(), type); + TEST_CYCLE() cv::add(a, b, c, noArray(), depth); SANITY_CHECK_NOTHING(); } @@ -258,7 +259,7 @@ PERF_TEST_P_(BinaryOpTest, addScalarSameType) PERF_TEST_P_(BinaryOpTest, subtract) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -280,7 +281,7 @@ PERF_TEST_P_(BinaryOpTest, subtract) PERF_TEST_P_(BinaryOpTest, subtractScalarDouble) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); @@ -302,25 +303,26 @@ PERF_TEST_P_(BinaryOpTest, subtractScalarDouble) PERF_TEST_P_(BinaryOpTest, subtractScalarSameType) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); + ElemDepth depth = CV_MAT_DEPTH(type); cv::Mat a = Mat(sz, type); cv::Scalar b; cv::Mat c = Mat(sz, type); declare.in(a, b, WARMUP_RNG).out(c); - if (CV_MAT_DEPTH(type) < CV_32S) + if (depth < CV_32S) { b = Scalar(1, 0, 3, 4); // don't pass non-integer values for 8U/8S/16U/16S processing } - else if (CV_MAT_DEPTH(type) == CV_32S) + else if (depth == CV_32S) { //see ticket 1529: subtract can be without saturation on 32S a /= 2; b = Scalar(1, 0, -3, 4); // don't pass non-integer values for 32S processing } - TEST_CYCLE() cv::subtract(a, b, c, noArray(), type); + TEST_CYCLE() cv::subtract(a, b, c, noArray(), depth); SANITY_CHECK_NOTHING(); } @@ -328,7 +330,7 @@ PERF_TEST_P_(BinaryOpTest, subtractScalarSameType) PERF_TEST_P_(BinaryOpTest, multiply) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a(sz, type), b(sz, type), c(sz, type); declare.in(a, b, WARMUP_RNG).out(c); @@ -347,7 +349,7 @@ PERF_TEST_P_(BinaryOpTest, multiply) PERF_TEST_P_(BinaryOpTest, multiplyScale) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a(sz, type), b(sz, type), c(sz, type); double scale = 0.5; @@ -368,7 +370,7 @@ PERF_TEST_P_(BinaryOpTest, multiplyScale) PERF_TEST_P_(BinaryOpTest, divide) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a(sz, type), b(sz, type), c(sz, type); double scale = 0.5; @@ -382,7 +384,7 @@ PERF_TEST_P_(BinaryOpTest, divide) PERF_TEST_P_(BinaryOpTest, reciprocal) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat b(sz, type), c(sz, type); double scale = 0.5; diff --git a/modules/core/perf/perf_bitwise.cpp b/modules/core/perf/perf_bitwise.cpp index ed1279af545e..90337712b842 100644 --- a/modules/core/perf/perf_bitwise.cpp +++ b/modules/core/perf/perf_bitwise.cpp @@ -11,7 +11,7 @@ using namespace perf; PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -27,7 +27,7 @@ PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM) PERF_TEST_P(Size_MatType, bitwise_and, TYPICAL_MATS_BITW_ARITHM) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -43,7 +43,7 @@ PERF_TEST_P(Size_MatType, bitwise_and, TYPICAL_MATS_BITW_ARITHM) PERF_TEST_P(Size_MatType, bitwise_or, TYPICAL_MATS_BITW_ARITHM) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); @@ -59,7 +59,7 @@ PERF_TEST_P(Size_MatType, bitwise_or, TYPICAL_MATS_BITW_ARITHM) PERF_TEST_P(Size_MatType, bitwise_xor, TYPICAL_MATS_BITW_ARITHM) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); cv::Mat a = Mat(sz, type); cv::Mat b = Mat(sz, type); cv::Mat c = Mat(sz, type); diff --git a/modules/core/perf/perf_compare.cpp b/modules/core/perf/perf_compare.cpp index be706e1a83fc..0ba09f74ea0e 100644 --- a/modules/core/perf/perf_compare.cpp +++ b/modules/core/perf/perf_compare.cpp @@ -18,7 +18,7 @@ PERF_TEST_P( Size_MatType_CmpType, compare, ) { Size sz = get<0>(GetParam()); - int matType1 = get<1>(GetParam()); + ElemType matType1 = get<1>(GetParam()); CmpType cmpType = get<2>(GetParam()); Mat src1(sz, matType1); @@ -41,7 +41,7 @@ PERF_TEST_P( Size_MatType_CmpType, compareScalar, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); CmpType cmpType = get<2>(GetParam()); Mat src1(sz, matType); diff --git a/modules/core/perf/perf_convertTo.cpp b/modules/core/perf/perf_convertTo.cpp index 344d81cb8a59..11f403281881 100644 --- a/modules/core/perf/perf_convertTo.cpp +++ b/modules/core/perf/perf_convertTo.cpp @@ -4,7 +4,7 @@ namespace opencv_test { using namespace perf; -typedef tuple Size_DepthSrc_DepthDst_Channels_alpha_t; +typedef tuple Size_DepthSrc_DepthDst_Channels_alpha_t; typedef perf::TestBaseWithParam Size_DepthSrc_DepthDst_Channels_alpha; PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, @@ -19,8 +19,8 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, ) { Size sz = get<0>(GetParam()); - int depthSrc = get<1>(GetParam()); - int depthDst = get<2>(GetParam()); + ElemDepth depthSrc = get<1>(GetParam()); + ElemDepth depthDst = get<2>(GetParam()); int channels = get<3>(GetParam()); double alpha = get<4>(GetParam()); diff --git a/modules/core/perf/perf_cvround.cpp b/modules/core/perf/perf_cvround.cpp index 933792dcaa1f..61495bf27151 100644 --- a/modules/core/perf/perf_cvround.cpp +++ b/modules/core/perf/perf_cvround.cpp @@ -22,7 +22,8 @@ PERF_TEST_P(Size_MatType, CvRound_Float, testing::Values(CV_32FC1, CV_64FC1))) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()), depth = CV_MAT_DEPTH(type); + ElemType type = get<1>(GetParam()); + ElemDepth depth = CV_MAT_DEPTH(type); cv::Mat src(size, type), dst(size, CV_32SC1); diff --git a/modules/core/perf/perf_dft.cpp b/modules/core/perf/perf_dft.cpp index 7abc3a891dd4..15aa1e9d0efc 100644 --- a/modules/core/perf/perf_dft.cpp +++ b/modules/core/perf/perf_dft.cpp @@ -17,7 +17,7 @@ typedef perf::TestBaseWithParam Size_MatType PERF_TEST_P(Size_MatType_FlagsType_NzeroRows, dft, TEST_MATS_DFT) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); int flags = get<2>(GetParam()); bool isNzeroRows = get<3>(GetParam()); @@ -50,7 +50,7 @@ PERF_TEST_P(Size_MatType_Flag, dct, testing::Combine( testing::Values(CV_32FC1, CV_64FC1), DCT_FlagsType::all())) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); int flags = get<2>(GetParam()); Mat src(sz, type); diff --git a/modules/core/perf/perf_dot.cpp b/modules/core/perf/perf_dot.cpp index 532196231961..60444241cd58 100644 --- a/modules/core/perf/perf_dot.cpp +++ b/modules/core/perf/perf_dot.cpp @@ -13,7 +13,7 @@ PERF_TEST_P( MatType_Length, dot, testing::Values( 32, 64, 128, 256, 512, 1024 ) )) { - int type = get<0>(GetParam()); + ElemType type = get<0>(GetParam()); int size = get<1>(GetParam()); Mat a(size, size, type); Mat b(size, size, type); diff --git a/modules/core/perf/perf_inRange.cpp b/modules/core/perf/perf_inRange.cpp index 61deb6d15875..a3fa9b9222a5 100644 --- a/modules/core/perf/perf_inRange.cpp +++ b/modules/core/perf/perf_inRange.cpp @@ -10,7 +10,7 @@ using namespace perf; PERF_TEST_P(Size_MatType, inRange, TYPICAL_MATS_INRANGE) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat src1(size, type); Mat src2(size, type); Mat src3(size, type); diff --git a/modules/core/perf/perf_io_base64.cpp b/modules/core/perf/perf_io_base64.cpp index ebc9ee14636b..90f1b9e960a1 100644 --- a/modules/core/perf/perf_io_base64.cpp +++ b/modules/core/perf/perf_io_base64.cpp @@ -19,7 +19,7 @@ PERF_TEST_P(Size_Mat_StrType, fs_text, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); String ext = get<2>(GetParam()); Mat src(size.height, size.width, type); @@ -55,7 +55,7 @@ PERF_TEST_P(Size_Mat_StrType, fs_base64, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); String ext = get<2>(GetParam()); Mat src(size.height, size.width, type); diff --git a/modules/core/perf/perf_mat.cpp b/modules/core/perf/perf_mat.cpp index a179483503eb..9a98b4d4e78a 100644 --- a/modules/core/perf/perf_mat.cpp +++ b/modules/core/perf/perf_mat.cpp @@ -11,7 +11,7 @@ PERF_TEST_P(Size_MatType, Mat_Eye, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat diagonalMatrix(size.height, size.width, type); declare.out(diagonalMatrix); @@ -32,7 +32,7 @@ PERF_TEST_P(Size_MatType, Mat_Zeros, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat zeroMatrix(size.height, size.width, type); declare.out(zeroMatrix); @@ -53,7 +53,7 @@ PERF_TEST_P(Size_MatType, Mat_Clone, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat source(size.height, size.width, type); Mat destination(size.height, size.width, type); @@ -76,7 +76,7 @@ PERF_TEST_P(Size_MatType, Mat_Clone_Roi, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); unsigned int width = size.width; unsigned int height = size.height; @@ -104,7 +104,7 @@ PERF_TEST_P(Size_MatType, Mat_CopyToWithMask, { const Size_MatType_t params = GetParam(); const Size size = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); Mat src(size, type), dst(size, type), mask(size, CV_8UC1); declare.in(src, mask, WARMUP_RNG).out(dst); @@ -124,7 +124,7 @@ PERF_TEST_P(Size_MatType, Mat_SetToWithMask, { const Size_MatType_t params = GetParam(); const Size size = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const Scalar sc = Scalar::all(27); Mat src(size, type), mask(size, CV_8UC1); @@ -148,7 +148,7 @@ PERF_TEST_P(Size_MatType, Mat_Transform, const Size_MatType_t params = GetParam(); const Size srcSize0 = get<0>(params); const Size srcSize = Size(1, srcSize0.width*srcSize0.height); - const int type = get<1>(params); + const ElemType type = get<1>(params); const float transform[] = { 0.5f, 0.f, 0.86602540378f, 128, 0.f, 1.f, 0.f, -64, 0.86602540378f, 0.f, 0.5f, 32,}; diff --git a/modules/core/perf/perf_math.cpp b/modules/core/perf/perf_math.cpp index 16d262e4c927..1ea9ee37a145 100644 --- a/modules/core/perf/perf_math.cpp +++ b/modules/core/perf/perf_math.cpp @@ -46,11 +46,11 @@ PERF_TEST_P_(KMeans, single_iter) const int N = testing::get<2>(GetParam()); const int attempts = 5; - Mat data(N, dims, CV_32F); + Mat data(N, dims, CV_32FC1); rng.fill(data, RNG::UNIFORM, -0.1, 0.1); const int N0 = K; - Mat data0(N0, dims, CV_32F); + Mat data0(N0, dims, CV_32FC1); rng.fill(data0, RNG::UNIFORM, -1, 1); for (int i = 0; i < N; i++) @@ -80,11 +80,11 @@ PERF_TEST_P_(KMeans, good) const int N = testing::get<2>(GetParam()); const int attempts = 5; - Mat data(N, dims, CV_32F); + Mat data(N, dims, CV_32FC1); rng.fill(data, RNG::UNIFORM, -0.1, 0.1); const int N0 = K; - Mat data0(N0, dims, CV_32F); + Mat data0(N0, dims, CV_32FC1); rng.fill(data0, RNG::UNIFORM, -1, 1); for (int i = 0; i < N; i++) @@ -114,10 +114,10 @@ PERF_TEST_P_(KMeans, with_duplicates) const int N = testing::get<2>(GetParam()); const int attempts = 5; - Mat data(N, dims, CV_32F, Scalar::all(0)); + Mat data(N, dims, CV_32FC1, Scalar::all(0)); const int N0 = std::max(2, K * 2 / 3); - Mat data0(N0, dims, CV_32F); + Mat data0(N0, dims, CV_32FC1); rng.fill(data0, RNG::UNIFORM, -1, 1); for (int i = 0; i < N; i++) diff --git a/modules/core/perf/perf_merge.cpp b/modules/core/perf/perf_merge.cpp index e10642dcb493..af8fad6a318a 100644 --- a/modules/core/perf/perf_merge.cpp +++ b/modules/core/perf/perf_merge.cpp @@ -4,7 +4,7 @@ namespace opencv_test { using namespace perf; -typedef tuple Size_SrcDepth_DstChannels_t; +typedef tuple Size_SrcDepth_DstChannels_t; typedef perf::TestBaseWithParam Size_SrcDepth_DstChannels; PERF_TEST_P( Size_SrcDepth_DstChannels, merge, @@ -17,7 +17,7 @@ PERF_TEST_P( Size_SrcDepth_DstChannels, merge, ) { Size sz = get<0>(GetParam()); - int srcDepth = get<1>(GetParam()); + ElemDepth srcDepth = get<1>(GetParam()); int dstChannels = get<2>(GetParam()); int maxValue = 255; diff --git a/modules/core/perf/perf_minmaxloc.cpp b/modules/core/perf/perf_minmaxloc.cpp index 9fc605233cdf..58526c0e18a5 100644 --- a/modules/core/perf/perf_minmaxloc.cpp +++ b/modules/core/perf/perf_minmaxloc.cpp @@ -11,15 +11,15 @@ PERF_TEST_P(Size_MatType, minMaxLoc, testing::Combine( ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); Mat src(sz, matType); double minVal, maxVal; Point minLoc, maxLoc; - if (matType == CV_8U) + if (matType == CV_8UC1) randu(src, 1, 254 /*do not include 0 and 255 to avoid early exit on 1 byte data*/); - else if (matType == CV_8S) + else if (matType == CV_8SC1) randu(src, -127, 126); else warmup(src, WARMUP_RNG); diff --git a/modules/core/perf/perf_norm.cpp b/modules/core/perf/perf_norm.cpp index 4e0673652b4f..fc7442b7ff1d 100644 --- a/modules/core/perf/perf_norm.cpp +++ b/modules/core/perf/perf_norm.cpp @@ -20,7 +20,7 @@ PERF_TEST_P(Size_MatType_NormType, norm, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<2>(GetParam()); Mat src(sz, matType); @@ -42,11 +42,11 @@ PERF_TEST_P(Size_MatType_NormType, norm_mask, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<2>(GetParam()); Mat src(sz, matType); - Mat mask = Mat::ones(sz, CV_8U); + Mat mask = Mat::ones(sz, CV_8UC1); double n; declare.in(src, WARMUP_RNG).in(mask); @@ -65,7 +65,7 @@ PERF_TEST_P(Size_MatType_NormType, norm2, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<2>(GetParam()); Mat src1(sz, matType); @@ -88,12 +88,12 @@ PERF_TEST_P(Size_MatType_NormType, norm2_mask, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<2>(GetParam()); Mat src1(sz, matType); Mat src2(sz, matType); - Mat mask = Mat::ones(sz, CV_8U); + Mat mask = Mat::ones(sz, CV_8UC1); double n; declare.in(src1, src2, WARMUP_RNG).in(mask); @@ -116,7 +116,7 @@ PERF_TEST_P(PerfHamming, norm, ) { Size sz = get<2>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<0>(GetParam()); Mat src(sz, matType); @@ -139,7 +139,7 @@ PERF_TEST_P(PerfHamming, norm2, ) { Size sz = get<2>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<0>(GetParam()); Mat src1(sz, matType); @@ -166,7 +166,7 @@ PERF_TEST_P(Size_MatType_NormType, normalize, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<2>(GetParam()); Mat src(sz, matType); @@ -192,12 +192,12 @@ PERF_TEST_P(Size_MatType_NormType, normalize_mask, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<2>(GetParam()); Mat src(sz, matType); Mat dst(sz, matType); - Mat mask = Mat::ones(sz, CV_8U); + Mat mask = Mat::ones(sz, CV_8UC1); double alpha = 100.; if(normType==NORM_L1) alpha = (double)src.total() * src.channels(); @@ -206,7 +206,7 @@ PERF_TEST_P(Size_MatType_NormType, normalize_mask, declare.in(src, WARMUP_RNG).in(mask).out(dst); declare.time(100); - TEST_CYCLE() cv::normalize(src, dst, alpha, 0., normType, -1, mask); + TEST_CYCLE() cv::normalize(src, dst, alpha, 0., normType, CV_DEPTH_AUTO, mask); SANITY_CHECK(dst, 1e-6); } @@ -220,11 +220,11 @@ PERF_TEST_P(Size_MatType_NormType, normalize_32f, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int normType = get<2>(GetParam()); Mat src(sz, matType); - Mat dst(sz, CV_32F); + Mat dst(sz, CV_32FC1); double alpha = 100.; if(normType==NORM_L1) alpha = (double)src.total() * src.channels(); @@ -240,7 +240,7 @@ PERF_TEST_P(Size_MatType_NormType, normalize_32f, PERF_TEST_P( Size_MatType, normalize_minmax, TYPICAL_MATS ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); Mat src(sz, matType); Mat dst(sz, matType); diff --git a/modules/core/perf/perf_reduce.cpp b/modules/core/perf/perf_reduce.cpp index 4fc5aa55f995..14c0df482595 100644 --- a/modules/core/perf/perf_reduce.cpp +++ b/modules/core/perf/perf_reduce.cpp @@ -19,15 +19,15 @@ PERF_TEST_P(Size_MatType_ROp, reduceR, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int reduceOp = get<2>(GetParam()); - int ddepth = -1; + ElemDepth ddepth = CV_DEPTH_AUTO; if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG) ) ddepth = CV_32S; Mat src(sz, matType); - Mat vec(1, sz.width, ddepth < 0 ? matType : ddepth); + Mat vec(1, sz.width, ddepth == CV_DEPTH_AUTO ? matType : CV_MAKETYPE(ddepth, 1)); declare.in(src, WARMUP_RNG).out(vec); declare.time(100); @@ -47,15 +47,15 @@ PERF_TEST_P(Size_MatType_ROp, reduceC, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int reduceOp = get<2>(GetParam()); - int ddepth = -1; + ElemDepth ddepth = CV_DEPTH_AUTO; if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG) ) ddepth = CV_32S; Mat src(sz, matType); - Mat vec(sz.height, 1, ddepth < 0 ? matType : ddepth); + Mat vec(sz.height, 1, ddepth == CV_DEPTH_AUTO ? matType : CV_MAKETYPE(ddepth, 1)); declare.in(src, WARMUP_RNG).out(vec); declare.time(100); diff --git a/modules/core/perf/perf_sort.cpp b/modules/core/perf/perf_sort.cpp index 98056901aea1..ac347ea6d2a7 100644 --- a/modules/core/perf/perf_sort.cpp +++ b/modules/core/perf/perf_sort.cpp @@ -16,7 +16,8 @@ PERF_TEST_P(sortFixture, sort, TYPICAL_MATS_SORT) { const sortParams params = GetParam(); const Size sz = get<0>(params); - const int type = get<1>(params), flags = get<2>(params); + const ElemType type = get<1>(params); + const int flags = get<2>(params); cv::Mat a(sz, type), b(sz, type); @@ -36,7 +37,8 @@ PERF_TEST_P(sortIdxFixture, sorIdx, TYPICAL_MATS_SORT) { const sortParams params = GetParam(); const Size sz = get<0>(params); - const int type = get<1>(params), flags = get<2>(params); + const ElemType type = get<1>(params); + int flags = get<2>(params); cv::Mat a(sz, type), b(sz, type); diff --git a/modules/core/perf/perf_split.cpp b/modules/core/perf/perf_split.cpp index 2cbc0b289cae..df729b10d75c 100644 --- a/modules/core/perf/perf_split.cpp +++ b/modules/core/perf/perf_split.cpp @@ -4,7 +4,7 @@ namespace opencv_test { using namespace perf; -typedef tuple Size_Depth_Channels_t; +typedef tuple Size_Depth_Channels_t; typedef perf::TestBaseWithParam Size_Depth_Channels; PERF_TEST_P( Size_Depth_Channels, split, @@ -17,7 +17,7 @@ PERF_TEST_P( Size_Depth_Channels, split, ) { Size sz = get<0>(GetParam()); - int depth = get<1>(GetParam()); + ElemDepth depth = get<1>(GetParam()); int channels = get<2>(GetParam()); Mat m(sz, CV_MAKETYPE(depth, channels)); diff --git a/modules/core/perf/perf_stat.cpp b/modules/core/perf/perf_stat.cpp index 15ca2e655976..80224218788c 100644 --- a/modules/core/perf/perf_stat.cpp +++ b/modules/core/perf/perf_stat.cpp @@ -7,7 +7,7 @@ using namespace perf; PERF_TEST_P(Size_MatType, sum, TYPICAL_MATS) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat arr(sz, type); Scalar s; @@ -22,7 +22,7 @@ PERF_TEST_P(Size_MatType, sum, TYPICAL_MATS) PERF_TEST_P(Size_MatType, mean, TYPICAL_MATS) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat src(sz, type); Scalar s; @@ -37,10 +37,10 @@ PERF_TEST_P(Size_MatType, mean, TYPICAL_MATS) PERF_TEST_P(Size_MatType, mean_mask, TYPICAL_MATS) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat src(sz, type); - Mat mask = Mat::ones(src.size(), CV_8U); + Mat mask = Mat::ones(src.size(), CV_8UC1); Scalar s; declare.in(src, WARMUP_RNG).in(mask).out(s); @@ -53,7 +53,7 @@ PERF_TEST_P(Size_MatType, mean_mask, TYPICAL_MATS) PERF_TEST_P(Size_MatType, meanStdDev, TYPICAL_MATS) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); Mat src(sz, matType); Scalar mean; @@ -70,10 +70,10 @@ PERF_TEST_P(Size_MatType, meanStdDev, TYPICAL_MATS) PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); Mat src(sz, matType); - Mat mask = Mat::ones(sz, CV_8U); + Mat mask = Mat::ones(sz, CV_8UC1); Scalar mean; Scalar dev; @@ -88,7 +88,7 @@ PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS) PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) )) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); Mat src(sz, matType); int cnt = 0; diff --git a/modules/core/perf/perf_umat.cpp b/modules/core/perf/perf_umat.cpp index 54f97fe90a46..a98b0c10f3ce 100644 --- a/modules/core/perf/perf_umat.cpp +++ b/modules/core/perf/perf_umat.cpp @@ -34,7 +34,7 @@ OCL_PERF_TEST_P(UMatTest, CustomPtr, Combine(Values(sz1080p, sz2160p), Bool(), : { OpenCLState s(get<1>(GetParam())); - int type = CV_8UC1; + ElemType type = CV_8UC1; cv::Size size = get<0>(GetParam()); size_t align_base = 4096; const int align_offset = get<2>(GetParam()); diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index ce943e0ffb57..6e3f9cb49e95 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -61,7 +61,7 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl { int scn = (int)sc.total(), cn = CV_MAT_CN(buftype); size_t esz = CV_ELEM_SIZE(buftype); - getConvertFunc(sc.depth(), buftype)(sc.ptr(), 1, 0, 1, scbuf, 1, Size(std::min(cn, scn), 1), 0); + getConvertFunc(sc.depth(), CV_MAT_DEPTH(buftype))(sc.ptr(), 1, 0, 1, scbuf, 1, Size(std::min(cn, scn), 1), 0); // unroll the scalar if( scn < cn ) { @@ -91,7 +91,7 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst, { bool haveMask = !_mask.empty(); int srctype = _src1.type(); - int srcdepth = CV_MAT_DEPTH(srctype); + ElemDepth srcdepth = CV_MAT_DEPTH(srctype); int cn = CV_MAT_CN(srctype); const ocl::Device d = ocl::Device::getDefault(); @@ -168,8 +168,12 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst, { const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; _InputArray::KindFlag kind1 = psrc1->kind(), kind2 = psrc2->kind(); - int type1 = psrc1->type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); - int type2 = psrc2->type(), depth2 = CV_MAT_DEPTH(type2), cn2 = CV_MAT_CN(type2); + ElemType type1 = psrc1->type(); + ElemDepth depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); + ElemType type2 = psrc2->type(); + ElemDepth depth2 = CV_MAT_DEPTH(type2); + int cn2 = CV_MAT_CN(type2); int dims1 = psrc1->dims(), dims2 = psrc2->dims(); Size sz1 = dims1 <= 2 ? psrc1->size() : Size(); Size sz2 = dims2 <= 2 ? psrc2->size() : Size(); @@ -237,8 +241,8 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst, if( haveMask ) { - int mtype = _mask.type(); - CV_Assert( (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1)); + ElemType mtype = _mask.type(); + CV_Assert((mtype == CV_8UC1 || mtype == CV_8SC1) && _mask.sameSize(*psrc1)); copymask = getCopyMaskFunc(esz); reallocate = !_dst.sameSize(*psrc1) || _dst.type() != type1; } @@ -453,7 +457,7 @@ void cv::min(const UMat& src1, const UMat& src2, UMat& dst) namespace cv { -static int actualScalarDepth(const double* data, int len) +static ElemDepth actualScalarDepth(const double* data, int len) { int i = 0, minval = INT_MAX, maxval = INT_MIN; for(; i < len; ++i) @@ -475,24 +479,29 @@ static int actualScalarDepth(const double* data, int len) #ifdef HAVE_OPENCL static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray _mask, int wtype, + InputArray _mask, ElemType wtype, void* usrdata, int oclop, bool haveScalar ) { const ocl::Device d = ocl::Device::getDefault(); bool doubleSupport = d.doubleFPConfig() > 0; - int type1 = _src1.type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); + ElemType type1 = _src1.type(); + ElemDepth depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); bool haveMask = !_mask.empty(); if ( (haveMask || haveScalar) && cn > 4 ) return false; - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), wdepth = std::max(CV_32S, CV_MAT_DEPTH(wtype)); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); + ElemDepth wdepth = CV_MAX_DEPTH(CV_32S, CV_MAT_DEPTH(wtype)); if (!doubleSupport) - wdepth = std::min(wdepth, CV_32F); + wdepth = CV_MIN_DEPTH(wdepth, CV_32F); wtype = CV_MAKETYPE(wdepth, cn); - int type2 = haveScalar ? wtype : _src2.type(), depth2 = CV_MAT_DEPTH(type2); + ElemType type2 = haveScalar ? wtype : _src2.type(); + ElemDepth depth2 = CV_MAT_DEPTH(type2); if (!doubleSupport && (depth2 == CV_64F || depth1 == CV_64F)) return false; @@ -596,16 +605,21 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, #endif static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray _mask, int dtype, BinaryFuncC* tab, bool muldiv=false, + InputArray _mask, ElemDepth ddepth, BinaryFuncC* tab, bool muldiv=false, void* usrdata=0, int oclop=-1 ) { const _InputArray *psrc1 = &_src1, *psrc2 = &_src2; _InputArray::KindFlag kind1 = psrc1->kind(), kind2 = psrc2->kind(); bool haveMask = !_mask.empty(); bool reallocate = false; - int type1 = psrc1->type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1); - int type2 = psrc2->type(), depth2 = CV_MAT_DEPTH(type2), cn2 = CV_MAT_CN(type2); - int wtype, dims1 = psrc1->dims(), dims2 = psrc2->dims(); + ElemType type1 = psrc1->type(); + ElemDepth depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); + ElemType type2 = psrc2->type(); + ElemDepth depth2 = CV_MAT_DEPTH(type2); + int cn2 = CV_MAT_CN(type2); + ElemType wtype; + int dims1 = psrc1->dims(), dims2 = psrc2->dims(); Size sz1 = dims1 <= 2 ? psrc1->size() : Size(); Size sz2 = dims2 <= 2 ? psrc2->size() : Size(); #ifdef HAVE_OPENCL @@ -615,14 +629,14 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, bool src2Scalar = checkScalar(*psrc2, type1, kind2, kind1); if( (kind1 == kind2 || cn == 1) && sz1 == sz2 && dims1 <= 2 && dims2 <= 2 && type1 == type2 && - !haveMask && ((!_dst.fixedType() && (dtype < 0 || CV_MAT_DEPTH(dtype) == depth1)) || + !haveMask && ((!_dst.fixedType() && (ddepth == CV_DEPTH_AUTO || ddepth == depth1)) || (_dst.fixedType() && _dst.type() == type1)) && (src1Scalar == src2Scalar) ) { _dst.createSameSize(*psrc1, type1); CV_OCL_RUN(use_opencl, ocl_arithm_op(*psrc1, *psrc2, _dst, _mask, - (!usrdata ? type1 : std::max(depth1, CV_32F)), + (!usrdata ? type1 : CV_MAKE_TYPE(CV_MAX_DEPTH(depth1, CV_32F), 1)), usrdata, oclop, false)) Mat src1 = psrc1->getMat(), src2 = psrc2->getMat(), dst = _dst.getMat(); @@ -658,7 +672,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, "(where arrays have the same size and the same number of channels), " "nor 'array op scalar', nor 'scalar op array'" ); haveScalar = true; - CV_Assert(type2 == CV_64F && (sz2.height == 1 || sz2.height == 4)); + CV_Assert(type2 == CV_64FC1 && (sz2.height == 1 || sz2.height == 4)); if (!muldiv) { @@ -671,47 +685,43 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, depth2 = CV_64F; } - if( dtype < 0 ) + if (ddepth == CV_DEPTH_AUTO && !_dst.fixedType() && !haveScalar && type1 != type2) { - if( _dst.fixedType() ) - dtype = _dst.type(); - else - { - if( !haveScalar && type1 != type2 ) - CV_Error(CV_StsBadArg, - "When the input arrays in add/subtract/multiply/divide functions have different types, " - "the output array type must be explicitly specified"); - dtype = type1; - } + CV_Error(CV_StsBadArg, + "When the input arrays in add/subtract/multiply/divide functions have different types, " + "the output array type must be explicitly specified"); } - dtype = CV_MAT_DEPTH(dtype); + ElemType dtype = _dst.fixedType() ? _dst.type() : type1; + if (ddepth != CV_DEPTH_AUTO) + dtype = CV_MAKETYPE(ddepth, 1); + ddepth = CV_MAT_DEPTH(dtype); - if( depth1 == depth2 && dtype == depth1 ) + if (depth1 == depth2 && ddepth == depth1) wtype = dtype; else if( !muldiv ) { - wtype = depth1 <= CV_8S && depth2 <= CV_8S ? CV_16S : - depth1 <= CV_32S && depth2 <= CV_32S ? CV_32S : std::max(depth1, depth2); - wtype = std::max(wtype, dtype); + wtype = depth1 <= CV_8S && depth2 <= CV_8S ? CV_16SC1 : + depth1 <= CV_32S && depth2 <= CV_32S ? CV_32SC1 : CV_MAKETYPE(CV_MAX_DEPTH(depth1, depth2), 1); + wtype = CV_MAKETYPE(CV_MAX_DEPTH(wtype, ddepth), 1); // when the result of addition should be converted to an integer type, // and just one of the input arrays is floating-point, it makes sense to convert that input to integer type before the operation, // instead of converting the other input to floating-point and then converting the operation result back to integers. - if( dtype < CV_32F && (depth1 < CV_32F || depth2 < CV_32F) ) - wtype = CV_32S; + if (ddepth < CV_32F && (depth1 < CV_32F || depth2 < CV_32F)) + wtype = CV_32SC1; } else { - wtype = std::max(depth1, std::max(depth2, CV_32F)); - wtype = std::max(wtype, dtype); + wtype = CV_MAKETYPE(CV_MAX_DEPTH(depth1, depth2, CV_32F), 1); + wtype = CV_MAKETYPE(CV_MAX_DEPTH(wtype, ddepth), 1); } - dtype = CV_MAKETYPE(dtype, cn); + dtype = CV_MAKETYPE(ddepth, cn); wtype = CV_MAKETYPE(wtype, cn); if( haveMask ) { - int mtype = _mask.type(); + ElemType mtype = _mask.type(); CV_Assert( (mtype == CV_8UC1 || mtype == CV_8SC1) && _mask.sameSize(*psrc1) ); reallocate = !_dst.sameSize(*psrc1) || _dst.type() != dtype; } @@ -724,9 +734,9 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, ocl_arithm_op(*psrc1, *psrc2, _dst, _mask, wtype, usrdata, oclop, haveScalar)) - BinaryFunc cvtsrc1 = type1 == wtype ? 0 : getConvertFunc(type1, wtype); - BinaryFunc cvtsrc2 = type2 == type1 ? cvtsrc1 : type2 == wtype ? 0 : getConvertFunc(type2, wtype); - BinaryFunc cvtdst = dtype == wtype ? 0 : getConvertFunc(wtype, dtype); + BinaryFunc cvtsrc1 = type1 == wtype ? 0 : getConvertFunc(CV_MAT_DEPTH(type1), CV_MAT_DEPTH(wtype)); + BinaryFunc cvtsrc2 = type2 == type1 ? cvtsrc1 : type2 == wtype ? 0 : getConvertFunc(CV_MAT_DEPTH(type2), CV_MAT_DEPTH(wtype)); + BinaryFunc cvtdst = dtype == wtype ? 0 : getConvertFunc(CV_MAT_DEPTH(wtype), ddepth); size_t esz1 = CV_ELEM_SIZE(type1), esz2 = CV_ELEM_SIZE(type2); size_t dsz = CV_ELEM_SIZE(dtype), wsz = CV_ELEM_SIZE(wtype); @@ -919,26 +929,26 @@ static BinaryFuncC* getAbsDiffTab() } void cv::add( InputArray src1, InputArray src2, OutputArray dst, - InputArray mask, int dtype ) + InputArray mask, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, mask, dtype, getAddTab(), false, 0, OCL_OP_ADD ); + arithm_op(src1, src2, dst, mask, ddepth, getAddTab(), false, 0, OCL_OP_ADD ); } void cv::subtract( InputArray _src1, InputArray _src2, OutputArray _dst, - InputArray mask, int dtype ) + InputArray mask, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); - arithm_op(_src1, _src2, _dst, mask, dtype, getSubTab(), false, 0, OCL_OP_SUB ); + arithm_op(_src1, _src2, _dst, mask, ddepth, getSubTab(), false, 0, OCL_OP_SUB ); } void cv::absdiff( InputArray src1, InputArray src2, OutputArray dst ) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, noArray(), -1, getAbsDiffTab(), false, 0, OCL_OP_ABSDIFF); + arithm_op(src1, src2, dst, noArray(), CV_DEPTH_AUTO, getAbsDiffTab(), false, 0, OCL_OP_ABSDIFF); } /****************************************************************************************\ @@ -987,28 +997,28 @@ static BinaryFuncC* getRecipTab() } void cv::multiply(InputArray src1, InputArray src2, - OutputArray dst, double scale, int dtype) + OutputArray dst, double scale, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, noArray(), dtype, getMulTab(), + arithm_op(src1, src2, dst, noArray(), ddepth, getMulTab(), true, &scale, std::abs(scale - 1.0) < DBL_EPSILON ? OCL_OP_MUL : OCL_OP_MUL_SCALE); } void cv::divide(InputArray src1, InputArray src2, - OutputArray dst, double scale, int dtype) + OutputArray dst, double scale, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); - arithm_op(src1, src2, dst, noArray(), dtype, getDivTab(), true, &scale, OCL_OP_DIV_SCALE); + arithm_op(src1, src2, dst, noArray(), ddepth, getDivTab(), true, &scale, OCL_OP_DIV_SCALE); } void cv::divide(double scale, InputArray src2, - OutputArray dst, int dtype) + OutputArray dst, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); - arithm_op(src2, src2, dst, noArray(), dtype, getRecipTab(), true, &scale, OCL_OP_RECIP_SCALE); + arithm_op(src2, src2, dst, noArray(), ddepth, getRecipTab(), true, &scale, OCL_OP_RECIP_SCALE); } /****************************************************************************************\ @@ -1033,12 +1043,12 @@ static BinaryFuncC* getAddWeightedTab() } void cv::addWeighted( InputArray src1, double alpha, InputArray src2, - double beta, double gamma, OutputArray dst, int dtype ) + double beta, double gamma, OutputArray dst, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); double scalars[] = {alpha, beta, gamma}; - arithm_op(src1, src2, dst, noArray(), dtype, getAddWeightedTab(), true, scalars, OCL_OP_ADDW); + arithm_op(src1, src2, dst, noArray(), ddepth, getAddWeightedTab(), true, scalars, OCL_OP_ADDW); } @@ -1049,7 +1059,7 @@ void cv::addWeighted( InputArray src1, double alpha, InputArray src2, namespace cv { -static BinaryFuncC getCmpFunc(int depth) +static BinaryFuncC getCmpFunc(ElemDepth depth) { static BinaryFuncC cmpTab[] = { @@ -1063,13 +1073,13 @@ static BinaryFuncC getCmpFunc(int depth) return cmpTab[depth]; } -static double getMinVal(int depth) +static double getMinVal(ElemDepth depth) { static const double tab[] = {0, -128, 0, -32768, INT_MIN, -FLT_MAX, -DBL_MAX, 0}; return tab[depth]; } -static double getMaxVal(int depth) +static double getMaxVal(ElemDepth depth) { static const double tab[] = {255, 127, 65535, 32767, INT_MAX, FLT_MAX, DBL_MAX, 0}; return tab[depth]; @@ -1081,8 +1091,11 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in { const ocl::Device& dev = ocl::Device::getDefault(); bool doubleSupport = dev.doubleFPConfig() > 0; - int type1 = _src1.type(), depth1 = CV_MAT_DEPTH(type1), cn = CV_MAT_CN(type1), - type2 = _src2.type(), depth2 = CV_MAT_DEPTH(type2); + int type1 = _src1.type(); + ElemDepth depth1 = CV_MAT_DEPTH(type1); + int cn = CV_MAT_CN(type1); + ElemType type2 = _src2.type(); + ElemDepth depth2 = CV_MAT_DEPTH(type2); if (!doubleSupport && depth1 == CV_64F) return false; @@ -1148,7 +1161,7 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in else return dst.setTo(Scalar::all(op == CMP_NE ? 255 : 0)), true; } - convertAndUnrollScalar(Mat(1, 1, CV_32S, &ival), depth1, (uchar *)buf, kercn); + convertAndUnrollScalar(Mat(1, 1, CV_32SC1, &ival), depth1, (uchar *)buf, kercn); } ocl::KernelArg scalararg = ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, buf, esz); @@ -1227,7 +1240,8 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op) return; } - int cn = src1.channels(), depth1 = src1.depth(), depth2 = src2.depth(); + int cn = src1.channels(); + ElemDepth depth1 = src1.depth(), depth2 = src2.depth(); _dst.create(src1.dims, src1.size, CV_8UC(cn)); src1 = src1.reshape(1); src2 = src2.reshape(1); @@ -1290,7 +1304,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op) return; } } - convertAndUnrollScalar(Mat(1, 1, CV_32S, &ival), depth1, buf, blocksize); + convertAndUnrollScalar(Mat(1, 1, CV_32SC1, &ival), depth1, buf, blocksize); } for( size_t i = 0; i < it.nplanes; i++, ++it ) @@ -1569,7 +1583,7 @@ static void inRangeReduce(const uchar* src, uchar* dst, size_t len, int cn) typedef void (*InRangeFunc)( const uchar* src1, size_t step1, const uchar* src2, size_t step2, const uchar* src3, size_t step3, uchar* dst, size_t step, Size sz ); -static InRangeFunc getInRangeFunc(int depth) +static InRangeFunc getInRangeFunc(ElemDepth depth) { static InRangeFunc inRangeTab[] = { @@ -1589,8 +1603,8 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb, const ocl::Device & d = ocl::Device::getDefault(); _InputArray::KindFlag skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind(); Size ssize = _src.size(), lsize = _lowerb.size(), usize = _upperb.size(); - int stype = _src.type(), ltype = _lowerb.type(), utype = _upperb.type(); - int sdepth = CV_MAT_DEPTH(stype), ldepth = CV_MAT_DEPTH(ltype), udepth = CV_MAT_DEPTH(utype); + ElemType stype = _src.type(), ltype = _lowerb.type(), utype = _upperb.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype), ldepth = CV_MAT_DEPTH(ltype), udepth = CV_MAT_DEPTH(utype); int cn = CV_MAT_CN(stype), rowsPerWI = d.isIntel() ? 4 : 1; bool lbScalar = false, ubScalar = false; @@ -1658,19 +1672,19 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb, BinaryFunc sccvtfunc = getConvertFunc(ldepth, CV_32S); sccvtfunc(lscalar.ptr(), 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0); sccvtfunc(uscalar.ptr(), 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0); - int minval = cvRound(getMinVal(sdepth)), maxval = cvRound(getMaxVal(sdepth)); + int minval = cvRound(getMinVal(sdepth)), maxval = cvRound(getMaxVal(sdepth)); for( int k = 0; k < cn; k++ ) { if( ilbuf[k] > iubuf[k] || ilbuf[k] > maxval || iubuf[k] < minval ) ilbuf[k] = minval+1, iubuf[k] = minval; } - lscalar = Mat(cn, 1, CV_32S, ilbuf); - uscalar = Mat(cn, 1, CV_32S, iubuf); + lscalar = Mat(cn, 1, CV_32SC1, ilbuf); + uscalar = Mat(cn, 1, CV_32SC1, iubuf); } - lscalar.convertTo(lscalar, stype); - uscalar.convertTo(uscalar, stype); + lscalar.convertTo(lscalar, sdepth); + uscalar.convertTo(uscalar, sdepth); } else { @@ -1737,7 +1751,8 @@ void cv::inRange(InputArray _src, InputArray _lowerb, CV_Assert(lbScalar == ubScalar); - int cn = src.channels(), depth = src.depth(); + int cn = src.channels(); + ElemDepth depth = src.depth(); size_t esz = src.elemSize(); size_t blocksize0 = (size_t)(BLOCK_SIZE + esz-1)/esz; @@ -1763,7 +1778,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb, ubuf = buf = alignPtr(buf + blocksize*esz, 16); CV_Assert( lb.type() == ub.type() ); - int scdepth = lb.depth(); + ElemDepth scdepth = lb.depth(); if( scdepth != depth && depth < CV_32S ) { @@ -1773,15 +1788,15 @@ void cv::inRange(InputArray _src, InputArray _lowerb, BinaryFunc sccvtfunc = getConvertFunc(scdepth, CV_32S); sccvtfunc(lb.ptr(), 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0); sccvtfunc(ub.ptr(), 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0); - int minval = cvRound(getMinVal(depth)), maxval = cvRound(getMaxVal(depth)); + int minval = cvRound(getMinVal(depth)), maxval = cvRound(getMaxVal(depth)); for( int k = 0; k < cn; k++ ) { if( ilbuf[k] > iubuf[k] || ilbuf[k] > maxval || iubuf[k] < minval ) ilbuf[k] = minval+1, iubuf[k] = minval; } - lb = Mat(cn, 1, CV_32S, ilbuf); - ub = Mat(cn, 1, CV_32S, iubuf); + lb = Mat(cn, 1, CV_32SC1, ilbuf); + ub = Mat(cn, 1, CV_32SC1, iubuf); } convertAndUnrollScalar( lb, src.type(), lbuf, blocksize ); @@ -1904,7 +1919,7 @@ CV_IMPL void cvAdd( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, c CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::add( src1, src2, dst, mask, dst.type() ); + cv::add( src1, src2, dst, mask, dst.depth() ); } @@ -1915,7 +1930,7 @@ CV_IMPL void cvSub( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr, c CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::subtract( src1, src2, dst, mask, dst.type() ); + cv::subtract(src1, src2, dst, mask, dst.depth()); } @@ -1926,7 +1941,7 @@ CV_IMPL void cvAddS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::add( src1, (const cv::Scalar&)value, dst, mask, dst.type() ); + cv::add(src1, (const cv::Scalar&)value, dst, mask, dst.depth()); } @@ -1937,7 +1952,7 @@ CV_IMPL void cvSubRS( const CvArr* srcarr1, CvScalar value, CvArr* dstarr, const CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); if( maskarr ) mask = cv::cvarrToMat(maskarr); - cv::subtract( (const cv::Scalar&)value, src1, dst, mask, dst.type() ); + cv::subtract((const cv::Scalar&)value, src1, dst, mask, dst.depth()); } @@ -1947,7 +1962,7 @@ CV_IMPL void cvMul( const CvArr* srcarr1, const CvArr* srcarr2, cv::Mat src1 = cv::cvarrToMat(srcarr1), src2 = cv::cvarrToMat(srcarr2), dst = cv::cvarrToMat(dstarr); CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); - cv::multiply( src1, src2, dst, scale, dst.type() ); + cv::multiply(src1, src2, dst, scale, dst.depth()); } @@ -1959,9 +1974,9 @@ CV_IMPL void cvDiv( const CvArr* srcarr1, const CvArr* srcarr2, CV_Assert( src2.size == dst.size && src2.channels() == dst.channels() ); if( srcarr1 ) - cv::divide( cv::cvarrToMat(srcarr1), src2, dst, scale, dst.type() ); + cv::divide(cv::cvarrToMat(srcarr1), src2, dst, scale, dst.depth()); else - cv::divide( scale, src2, dst, dst.type() ); + cv::divide(scale, src2, dst, dst.depth()); } @@ -1973,7 +1988,7 @@ cvAddWeighted( const CvArr* srcarr1, double alpha, cv::Mat src1 = cv::cvarrToMat(srcarr1), src2 = cv::cvarrToMat(srcarr2), dst = cv::cvarrToMat(dstarr); CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() ); - cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() ); + cv::addWeighted(src1, alpha, src2, beta, gamma, dst, dst.depth()); } @@ -2002,7 +2017,7 @@ cvInRange( const void* srcarr1, const void* srcarr2, const void* srcarr3, void* dstarr ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr); - CV_Assert( src1.size == dst.size && dst.type() == CV_8U ); + CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 ); cv::inRange( src1, cv::cvarrToMat(srcarr2), cv::cvarrToMat(srcarr3), dst ); } @@ -2012,7 +2027,7 @@ CV_IMPL void cvInRangeS( const void* srcarr1, CvScalar lowerb, CvScalar upperb, void* dstarr ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr); - CV_Assert( src1.size == dst.size && dst.type() == CV_8U ); + CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 ); cv::inRange( src1, (const cv::Scalar&)lowerb, (const cv::Scalar&)upperb, dst ); } @@ -2022,7 +2037,7 @@ CV_IMPL void cvCmp( const void* srcarr1, const void* srcarr2, void* dstarr, int cmp_op ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr); - CV_Assert( src1.size == dst.size && dst.type() == CV_8U ); + CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 ); cv::compare( src1, cv::cvarrToMat(srcarr2), dst, cmp_op ); } @@ -2032,7 +2047,7 @@ CV_IMPL void cvCmpS( const void* srcarr1, double value, void* dstarr, int cmp_op ) { cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr); - CV_Assert( src1.size == dst.size && dst.type() == CV_8U ); + CV_Assert( src1.size == dst.size && dst.type() == CV_8UC1 ); cv::compare( src1, value, dst, cmp_op ); } diff --git a/modules/core/src/array.cpp b/modules/core/src/array.cpp index a1a23ec8d648..89ae34cfab8a 100644 --- a/modules/core/src/array.cpp +++ b/modules/core/src/array.cpp @@ -54,7 +54,6 @@ /* default image row align (in bytes) */ #define CV_DEFAULT_IMAGE_ROW_ALIGN 4 - static struct { Cv_iplCreateImageHeader createHeader; @@ -94,7 +93,7 @@ cvSetIPLAllocators( Cv_iplCreateImageHeader createHeader, // Creates CvMat and underlying data CV_IMPL CvMat* -cvCreateMat( int height, int width, int type ) +cvCreateMat(int height, int width, int type) { CvMat* arr = cvCreateMatHeader( height, width, type ); cvCreateData( arr ); @@ -111,7 +110,7 @@ static void icvCheckHuge( CvMat* arr ) // Creates CvMat header only CV_IMPL CvMat* -cvCreateMatHeader( int rows, int cols, int type ) +cvCreateMatHeader(int rows, int cols, int type) { type = CV_MAT_TYPE(type); @@ -525,7 +524,7 @@ CV_IMPL int cvNextNArraySlice( CvNArrayIterator* iterator ) // Creates CvMatND and underlying data CV_IMPL CvSparseMat* -cvCreateSparseMat( int dims, const int* sizes, int type ) +cvCreateSparseMat(int dims, const int* sizes, int type) { type = CV_MAT_TYPE( type ); int pix_size1 = CV_ELEM_SIZE1(type); @@ -899,7 +898,7 @@ cvSetData( CvArr* arr, void* data, int step ) { CvMat* mat = (CvMat*)arr; - int type = CV_MAT_TYPE(mat->type); + ElemType type = CV_MAT_TYPE(mat->type); pix_size = CV_ELEM_SIZE(type); min_step = mat->cols*pix_size; @@ -1082,7 +1081,7 @@ cvGetRawData( const CvArr* arr, uchar** data, int* step, CvSize* roi_size ) CV_IMPL int cvGetElemType( const CvArr* arr ) { - int type = -1; + ElemType type = CV_TYPE_AUTO; if( CV_IS_MAT_HDR(arr) || CV_IS_MATND_HDR(arr) || CV_IS_SPARSE_MAT_HDR(arr)) type = CV_MAT_TYPE( ((CvMat*)arr)->type ); else if( CV_IS_IMAGE(arr)) @@ -1377,7 +1376,7 @@ cvGetCols( const CvArr* arr, CvMat* submat, int start_col, int end_col ) submat->cols = end_col - start_col; submat->step = mat->step; submat->data.ptr = mat->data.ptr + (size_t)start_col*CV_ELEM_SIZE(mat->type); - submat->type = mat->type & (submat->rows > 1 && submat->cols < cols ? ~CV_MAT_CONT_FLAG : -1); + submat->type = mat->type & (submat->rows > 1 && submat->cols < cols ? ~CV_MAT_CONT_FLAG : CV_TYPE_AUTO); submat->refcount = 0; submat->hdr_refcount = 0; res = submat; @@ -1454,11 +1453,11 @@ cvGetDiag( const CvArr* arr, CvMat* submat, int diag ) // Converts CvScalar to specified type CV_IMPL void -cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_12 ) +cvScalarToRawData(const CvScalar* scalar, void* data, int type, int extend_to_12) { type = CV_MAT_TYPE(type); int cn = CV_MAT_CN( type ); - int depth = type & CV_MAT_DEPTH_MASK; + ElemDepth depth = CV_MAT_DEPTH(type); assert( scalar && data ); if( (unsigned)(cn - 1) >= 4 ) @@ -1600,41 +1599,34 @@ static double icvGetReal( const void* data, int type ) } -static void icvSetReal( double value, const void* data, int type ) +static void icvSetReal(double value, const void* data, int _depth) { - if( type < CV_32F ) + ElemDepth depth = static_cast(_depth); + switch (depth) { - int ivalue = cvRound(value); - switch( type ) - { - case CV_8U: - *(uchar*)data = cv::saturate_cast(ivalue); - break; - case CV_8S: - *(schar*)data = cv::saturate_cast(ivalue); - break; - case CV_16U: - *(ushort*)data = cv::saturate_cast(ivalue); - break; - case CV_16S: - *(short*)data = cv::saturate_cast(ivalue); - break; - case CV_32S: - *(int*)data = cv::saturate_cast(ivalue); - break; - } - } - else - { - switch( type ) - { - case CV_32F: - *(float*)data = (float)value; - break; - case CV_64F: - *(double*)data = value; - break; - } + case CV_8U: + *(uchar*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_8S: + *(schar*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_16U: + *(ushort*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_16S: + *(short*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_32S: + *(int*)data = cv::saturate_cast(cvRound(value)); + break; + case CV_32F: + *(float*)data = (float)value; + break; + case CV_64F: + *(double*)data = value; + break; + case CV_16F: + break;// unhandled } } @@ -1648,7 +1640,7 @@ cvPtr1D( const CvArr* arr, int idx, int* _type ) { CvMat* mat = (CvMat*)arr; - int type = CV_MAT_TYPE(mat->type); + ElemType type = CV_MAT_TYPE(mat->type); int pix_size = CV_ELEM_SIZE(type); if( _type ) @@ -1807,8 +1799,8 @@ cvPtr2D( const CvArr* arr, int y, int x, int* _type ) if( _type ) { - int type = IPL2CV_DEPTH(img->depth); - if( type < 0 || (unsigned)(img->nChannels - 1) > 3 ) + ElemType type = CV_MAKETYPE(IPL2CV_DEPTH(img->depth), 1); + if( type < CV_8UC1 || (unsigned)(img->nChannels - 1) > 3 ) CV_Error( CV_StsUnsupportedFormat, "" ); *_type = CV_MAKETYPE( type, img->nChannels ); @@ -2399,7 +2391,8 @@ cvGetMat( const CvArr* array, CvMat* mat, else if( CV_IS_IMAGE_HDR(src) ) { const IplImage* img = (const IplImage*)src; - int depth, order; + int depth; + int order; if( img->imageData == 0 ) CV_Error( CV_StsNullPtr, "The image has NULL data pointer" ); @@ -2414,7 +2407,7 @@ cvGetMat( const CvArr* array, CvMat* mat, { if( order == IPL_DATA_ORDER_PLANE ) { - int type = depth; + ElemType type = CV_MAKETYPE(depth, 1); if( img->roi->coi == 0 ) CV_Error( CV_StsBadFlag, @@ -2429,7 +2422,7 @@ cvGetMat( const CvArr* array, CvMat* mat, } else /* pixel order */ { - int type = CV_MAKETYPE( depth, img->nChannels ); + ElemType type = CV_MAKETYPE( depth, img->nChannels ); coi = img->roi->coi; if( img->nChannels > CV_CN_MAX ) @@ -2445,7 +2438,7 @@ cvGetMat( const CvArr* array, CvMat* mat, } else { - int type = CV_MAKETYPE( depth, img->nChannels ); + ElemType type = CV_MAKETYPE( depth, img->nChannels ); if( order != IPL_DATA_ORDER_PIXEL ) CV_Error( CV_StsBadFlag, "Pixel order should be used with coi == 0" ); @@ -2802,7 +2795,7 @@ cvGetImage( const CvArr* array, IplImage* img ) if( mat->data.ptr == 0 ) CV_Error( CV_StsNullPtr, "" ); - int depth = cvIplDepth(mat->type); + ElemDepth depth = static_cast(cvIplDepth(mat->type)); cvInitImageHeader( img, cvSize(mat->cols, mat->rows), depth, CV_MAT_CN(mat->type) ); @@ -2908,7 +2901,7 @@ cvCreateImage( CvSize size, int depth, int channels ) // initialize IplImage header, allocated by the user CV_IMPL IplImage* -cvInitImageHeader( IplImage * image, CvSize size, int depth, +cvInitImageHeader(IplImage * image, CvSize size, int depth, int channels, int origin, int align ) { const char *colorModel, *channelSeq; @@ -3226,7 +3219,8 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to) { CV_INSTRUMENT_REGION(); - const int depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + const ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert(cn <= 4); switch(depth) { diff --git a/modules/core/src/batch_distance.cpp b/modules/core/src/batch_distance.cpp index 71d0e9e3ff3b..184247a8b4de 100644 --- a/modules/core/src/batch_distance.cpp +++ b/modules/core/src/batch_distance.cpp @@ -263,23 +263,23 @@ struct BatchDistInvoker : public ParallelLoopBody } void cv::batchDistance( InputArray _src1, InputArray _src2, - OutputArray _dist, int dtype, OutputArray _nidx, + OutputArray _dist, ElemType dtype, OutputArray _nidx, int normType, int K, InputArray _mask, int update, bool crosscheck ) { CV_INSTRUMENT_REGION(); Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); - int type = src1.type(); + ElemType type = src1.type(); CV_Assert( type == src2.type() && src1.cols == src2.cols && - (type == CV_32F || type == CV_8U)); + (type == CV_32FC1 || type == CV_8UC1)); CV_Assert( _nidx.needed() == (K > 0) ); if( dtype == -1 ) { - dtype = normType == NORM_HAMMING || normType == NORM_HAMMING2 ? CV_32S : CV_32F; + dtype = normType == NORM_HAMMING || normType == NORM_HAMMING2 ? CV_32SC1 : CV_32FC1; } - CV_Assert( (type == CV_8U && dtype == CV_32S) || dtype == CV_32F); + CV_Assert((type == CV_8UC1 && dtype == CV_32SC1) || dtype == CV_32FC1); K = std::min(K, src2.rows); @@ -287,13 +287,13 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, Mat dist = _dist.getMat(), nidx; if( _nidx.needed() ) { - _nidx.create(dist.size(), CV_32S); + _nidx.create(dist.size(), CV_32SC1); nidx = _nidx.getMat(); } if( update == 0 && K > 0 ) { - dist = Scalar::all(dtype == CV_32S ? (double)INT_MAX : (double)FLT_MAX); + dist = Scalar::all(dtype == CV_32SC1 ? (double)INT_MAX : (double)FLT_MAX); nidx = Scalar::all(-1); } @@ -310,7 +310,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, // to i*-th element of src2 and i*-th element of src2 is the closest to idx-th element of src1. // If nidx[idx] = -1, it means that there is no such ideal couple for it in src2. // This O(N) procedure is called cross-check and it helps to eliminate some false matches. - if( dtype == CV_32S ) + if (dtype == CV_32SC1) { for( int i = 0; i < tdist.rows; i++ ) { @@ -340,24 +340,24 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, } BatchDistFunc func = 0; - if( type == CV_8U ) + if (type == CV_8UC1) { - if( normType == NORM_L1 && dtype == CV_32S ) + if (normType == NORM_L1 && dtype == CV_32SC1) func = (BatchDistFunc)batchDistL1_8u32s; - else if( normType == NORM_L1 && dtype == CV_32F ) + else if (normType == NORM_L1 && dtype == CV_32FC1) func = (BatchDistFunc)batchDistL1_8u32f; - else if( normType == NORM_L2SQR && dtype == CV_32S ) + else if (normType == NORM_L2SQR && dtype == CV_32SC1) func = (BatchDistFunc)batchDistL2Sqr_8u32s; - else if( normType == NORM_L2SQR && dtype == CV_32F ) + else if (normType == NORM_L2SQR && dtype == CV_32FC1) func = (BatchDistFunc)batchDistL2Sqr_8u32f; - else if( normType == NORM_L2 && dtype == CV_32F ) + else if (normType == NORM_L2 && dtype == CV_32FC1) func = (BatchDistFunc)batchDistL2_8u32f; - else if( normType == NORM_HAMMING && dtype == CV_32S ) + else if (normType == NORM_HAMMING && dtype == CV_32SC1) func = (BatchDistFunc)batchDistHamming; - else if( normType == NORM_HAMMING2 && dtype == CV_32S ) + else if (normType == NORM_HAMMING2 && dtype == CV_32SC1) func = (BatchDistFunc)batchDistHamming2; } - else if( type == CV_32F && dtype == CV_32F ) + else if (type == CV_32FC1 && dtype == CV_32FC1) { if( normType == NORM_L1 ) func = (BatchDistFunc)batchDistL1_32f; diff --git a/modules/core/src/channels.cpp b/modules/core/src/channels.cpp index 4e464d910c59..669bbfd4186b 100644 --- a/modules/core/src/channels.cpp +++ b/modules/core/src/channels.cpp @@ -77,7 +77,7 @@ static void mixChannels64s( const int64** src, const int* sdelta, typedef void (*MixChannelsFunc)( const uchar** src, const int* sdelta, uchar** dst, const int* ddelta, int len, int npairs ); -static MixChannelsFunc getMixchFunc(int depth) +static MixChannelsFunc getMixchFunc(ElemDepth depth) { static MixChannelsFunc mixchTab[] = { @@ -101,7 +101,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons CV_Assert( src && nsrcs > 0 && dst && ndsts > 0 && fromTo && npairs > 0 ); size_t i, j, k, esz1 = dst[0].elemSize1(); - int depth = dst[0].depth(); + ElemDepth depth = dst[0].depth(); AutoBuffer buf((nsrcs + ndsts + 1)*(sizeof(Mat*) + sizeof(uchar*)) + npairs*(sizeof(uchar*)*2 + sizeof(int)*6)); const Mat** arrays = (const Mat**)(uchar*)buf.data(); @@ -210,7 +210,8 @@ static bool ocl_mixChannels(InputArrayOfArrays _src, InputOutputArrayOfArrays _d CV_Assert(nsrc > 0 && ndst > 0); Size size = src[0].size(); - int depth = src[0].depth(), esz = CV_ELEM_SIZE(depth), + ElemDepth depth = src[0].depth(); + int esz = CV_ELEM_SIZE(depth), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; for (size_t i = 1, ssize = src.size(); i < ssize; ++i) @@ -421,7 +422,9 @@ void cv::extractChannel(InputArray _src, OutputArray _dst, int coi) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert( 0 <= coi && coi < cn ); int ch[] = { coi, 0 }; @@ -429,7 +432,7 @@ void cv::extractChannel(InputArray _src, OutputArray _dst, int coi) if (ocl::isOpenCLActivated() && _src.dims() <= 2 && _dst.isUMat()) { UMat src = _src.getUMat(); - _dst.create(src.dims, &src.size[0], depth); + _dst.create(src.dims, &src.size[0], CV_MAKETYPE(depth, 1)); UMat dst = _dst.getUMat(); mixChannels(std::vector(1, src), std::vector(1, dst), ch, 1); return; @@ -437,7 +440,7 @@ void cv::extractChannel(InputArray _src, OutputArray _dst, int coi) #endif Mat src = _src.getMat(); - _dst.create(src.dims, &src.size[0], depth); + _dst.create(src.dims, &src.size[0], CV_MAKETYPE(depth, 1)); Mat dst = _dst.getMat(); CV_IPP_RUN_FAST(ipp_extractChannel(src, dst, coi)) @@ -449,8 +452,12 @@ void cv::insertChannel(InputArray _src, InputOutputArray _dst, int coi) { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); + int dcn = CV_MAT_CN(dtype); CV_Assert( _src.sameSize(_dst) && sdepth == ddepth ); CV_Assert( 0 <= coi && coi < dcn && scn == 1 ); diff --git a/modules/core/src/check.cpp b/modules/core/src/check.cpp index 676f755d1d2f..0c09018a0b2b 100644 --- a/modules/core/src/check.cpp +++ b/modules/core/src/check.cpp @@ -8,13 +8,13 @@ namespace cv { -const char* depthToString(int depth) +const char* depthToString(ElemDepth depth) { const char* s = detail::depthToString_(depth); return s ? s : ""; } -const cv::String typeToString(int type) +const cv::String typeToString(ElemType type) { cv::String s = detail::typeToString_(type); if (s.empty()) @@ -41,17 +41,17 @@ static const char* getTestOpMath(unsigned testOp) return testOp < CV__LAST_TEST_OP ? _names[testOp] : "???"; } -const char* depthToString_(int depth) +const char* depthToString_(ElemDepth depth) { static const char* depthNames[] = { "CV_8U", "CV_8S", "CV_16U", "CV_16S", "CV_32S", "CV_32F", "CV_64F", "CV_16F" }; - return (depth <= CV_16F && depth >= 0) ? depthNames[depth] : NULL; + return (depth <= CV_16F && depth >= CV_8U) ? depthNames[depth] : NULL; } -const cv::String typeToString_(int type) +const cv::String typeToString_(ElemType type) { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); - if (depth >= 0 && depth <= CV_16F) + if (depth >= CV_8U && depth <= CV_16F) return cv::format("%sC%d", depthToString_(depth), cn); return cv::String(); } @@ -69,28 +69,28 @@ void check_failed_auto_(const T& v1, const T& v2, const CheckContext& ctx) ss << " '" << ctx.p2_str << "' is " << v2; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx) +void check_failed_MatDepth(const ElemDepth v1, const ElemDepth v2, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << " (expected: '" << ctx.p1_str << " " << getTestOpMath(ctx.testOp) << " " << ctx.p2_str << "'), where" << std::endl - << " '" << ctx.p1_str << "' is " << v1 << " (" << depthToString(v1) << ")" << std::endl; + << " '" << ctx.p1_str << "' is " << static_cast(v1) << " (" << depthToString(v1) << ")" << std::endl; if (ctx.testOp != TEST_CUSTOM && ctx.testOp < CV__LAST_TEST_OP) { ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl; } - ss << " '" << ctx.p2_str << "' is " << v2 << " (" << depthToString(v2) << ")"; + ss << " '" << ctx.p2_str << "' is " << static_cast(v2) << " (" << depthToString(v2) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx) +void check_failed_MatType(const ElemType v1, const ElemType v2, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << " (expected: '" << ctx.p1_str << " " << getTestOpMath(ctx.testOp) << " " << ctx.p2_str << "'), where" << std::endl - << " '" << ctx.p1_str << "' is " << v1 << " (" << typeToString(v1) << ")" << std::endl; + << " '" << ctx.p1_str << "' is " << static_cast(v1) << " (" << typeToString(v1) << ")" << std::endl; if (ctx.testOp != TEST_CUSTOM && ctx.testOp < CV__LAST_TEST_OP) { ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl; } - ss << " '" << ctx.p2_str << "' is " << v2 << " (" << typeToString(v2) << ")"; + ss << " '" << ctx.p2_str << "' is " << static_cast(v2) << " (" << typeToString(v2) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } void check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx) @@ -125,22 +125,22 @@ void check_failed_auto_(const T& v, const CheckContext& ctx) << " '" << ctx.p1_str << "' is " << v; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatDepth(const int v, const CheckContext& ctx) +void check_failed_MatDepth(const ElemDepth v, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << ":" << std::endl << " '" << ctx.p2_str << "'" << std::endl << "where" << std::endl - << " '" << ctx.p1_str << "' is " << v << " (" << depthToString(v) << ")"; + << " '" << ctx.p1_str << "' is " << static_cast(v) << " (" << depthToString(v) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } -void check_failed_MatType(const int v, const CheckContext& ctx) +void check_failed_MatType(const ElemType v, const CheckContext& ctx) { std::stringstream ss; ss << ctx.message << ":" << std::endl << " '" << ctx.p2_str << "'" << std::endl << "where" << std::endl - << " '" << ctx.p1_str << "' is " << v << " (" << typeToString(v) << ")"; + << " '" << ctx.p1_str << "' is " << static_cast(v) << " (" << typeToString(v) << ")"; cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line); } void check_failed_MatChannels(const int v, const CheckContext& ctx) diff --git a/modules/core/src/conjugate_gradient.cpp b/modules/core/src/conjugate_gradient.cpp index fecf0be156db..f8c4b6c32a9e 100644 --- a/modules/core/src/conjugate_gradient.cpp +++ b/modules/core/src/conjugate_gradient.cpp @@ -172,7 +172,7 @@ namespace cv if(x_mat.rows>1){ - Mat(ndim, 1, CV_64F, proxy_x.ptr()).copyTo(x); + Mat(ndim, 1, CV_64FC1, proxy_x.ptr()).copyTo(x); } return _Function->calc(proxy_x.ptr()); } diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index e31e1b2c4388..010d9aa0fe57 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -332,7 +332,7 @@ DEF_CVT_FUNC(32f64f, float, double) DEF_CPY_FUNC(64s, int64) */ -BinaryFunc getConvertFunc(int sdepth, int ddepth) +BinaryFunc getConvertFunc(ElemDepth sdepth, ElemDepth ddepth) { static BinaryFunc cvtTab[][8] = { @@ -380,7 +380,7 @@ BinaryFunc getConvertFunc(int sdepth, int ddepth) } #ifdef HAVE_OPENCL -static bool ocl_convertFp16( InputArray _src, OutputArray _dst, int sdepth, int ddepth ) +static bool ocl_convertFp16(InputArray _src, OutputArray _dst, ElemDepth sdepth, ElemDepth ddepth) { int type = _src.type(), cn = CV_MAT_CN(type); @@ -411,7 +411,7 @@ static bool ocl_convertFp16( InputArray _src, OutputArray _dst, int sdepth, int } // cv:: -void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const +void cv::Mat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta) const { CV_INSTRUMENT_REGION(); @@ -423,12 +423,13 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) bool noScale = fabs(alpha-1) < DBL_EPSILON && fabs(beta) < DBL_EPSILON; - if( _type < 0 ) - _type = _dst.fixedType() ? _dst.type() : type(); - else - _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), channels()); + int cn = channels(); + if (ddepth == CV_DEPTH_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); - int sdepth = depth(), ddepth = CV_MAT_DEPTH(_type); + ElemDepth sdepth = depth(); if( sdepth == ddepth && noScale ) { copyTo(_dst); @@ -437,15 +438,14 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) Mat src = *this; if( dims <= 2 ) - _dst.create( size(), _type ); + _dst.create(size(), dtype); else - _dst.create( dims, size, _type ); + _dst.create(dims, size, dtype); Mat dst = _dst.getMat(); BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth); double scale[] = {alpha, beta}; - int cn = channels(); CV_Assert( func != 0 ); if( dims <= 2 ) @@ -471,7 +471,7 @@ void cv::convertFp16( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int sdepth = _src.depth(), ddepth = 0; + ElemDepth sdepth = _src.depth(), ddepth = CV_8U; BinaryFunc func = 0; switch( sdepth ) @@ -502,7 +502,7 @@ void cv::convertFp16( InputArray _src, OutputArray _dst ) Mat src = _src.getMat(); - int type = CV_MAKETYPE(ddepth, src.channels()); + ElemType type = CV_MAKETYPE(ddepth, src.channels()); _dst.create( src.dims, src.size, type ); Mat dst = _dst.getMat(); int cn = src.channels(); diff --git a/modules/core/src/convert_c.cpp b/modules/core/src/convert_c.cpp index efe4de740ac2..656e55912ff1 100644 --- a/modules/core/src/convert_c.cpp +++ b/modules/core/src/convert_c.cpp @@ -110,7 +110,7 @@ cvConvertScale( const void* srcarr, void* dstarr, cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr); CV_Assert( src.size == dst.size && src.channels() == dst.channels() ); - src.convertTo(dst, dst.type(), scale, shift); + src.convertTo(dst, dst.depth(), scale, shift); } @@ -130,5 +130,5 @@ CV_IMPL void cvNormalize( const CvArr* srcarr, CvArr* dstarr, if( maskarr ) mask = cv::cvarrToMat(maskarr); CV_Assert( dst.size() == src.size() && src.channels() == dst.channels() ); - cv::normalize( src, dst, a, b, norm_type, dst.type(), mask ); + cv::normalize( src, dst, a, b, norm_type, dst.depth(), mask ); } diff --git a/modules/core/src/convert_scale.cpp b/modules/core/src/convert_scale.cpp index 2758685f4ae0..7fcc5ceb1b8b 100644 --- a/modules/core/src/convert_scale.cpp +++ b/modules/core/src/convert_scale.cpp @@ -287,7 +287,7 @@ DEF_CVT_SCALE_FUNC(32f16f, cvt1_32f, float, float16_t, float) DEF_CVT_SCALE_FUNC(64f16f, cvt_64f, double, float16_t, double) DEF_CVT_SCALE_FUNC(16f, cvt1_32f, float16_t, float16_t, float) -static BinaryFunc getCvtScaleAbsFunc(int depth) +static BinaryFunc getCvtScaleAbsFunc(ElemDepth depth) { static BinaryFunc cvtScaleAbsTab[] = { @@ -299,7 +299,7 @@ static BinaryFunc getCvtScaleAbsFunc(int depth) return cvtScaleAbsTab[depth]; } -BinaryFunc getConvertScaleFunc(int sdepth, int ddepth) +BinaryFunc getConvertScaleFunc(ElemDepth sdepth, ElemDepth ddepth) { static BinaryFunc cvtScaleTab[][8] = { @@ -354,7 +354,9 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha { const ocl::Device & d = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); bool doubleSupport = d.doubleFPConfig() > 0; if (!doubleSupport && depth == CV_64F) return false; @@ -374,7 +376,7 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha int rowsPerWI = d.isIntel() ? 4 : 1; char cvt[2][50]; - int wdepth = std::max(depth, CV_32F); + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32F); String build_opt = format("-D OP_CONVERT_SCALE_ABS -D UNARY_OP -D dstT=%s -D srcT1=%s" " -D workT=%s -D wdepth=%d -D convertToWT1=%s -D convertToDT=%s" " -D workT1=%s -D rowsPerWI=%d%s", @@ -447,20 +449,22 @@ namespace cv { #ifdef HAVE_OPENCL -static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _mask, int dtype, +static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _mask, ElemDepth ddepth, double scale, double delta ) { UMat src = _src.getUMat(); if( _mask.empty() ) - src.convertTo( _dst, dtype, scale, delta ); + src.convertTo(_dst, ddepth, scale, delta); else if (src.channels() <= 4) { const ocl::Device & dev = ocl::Device::getDefault(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype), - ddepth = CV_MAT_DEPTH(dtype), wdepth = std::max(CV_32F, std::max(sdepth, ddepth)), - rowsPerWI = dev.isIntel() ? 4 : 1; + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + ElemDepth wdepth = CV_MAX_DEPTH(CV_32F, sdepth, ddepth); + int rowsPerWI = dev.isIntel() ? 4 : 1; float fscale = static_cast(scale), fdelta = static_cast(delta); bool haveScale = std::fabs(scale - 1) > DBL_EPSILON, @@ -468,7 +472,7 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m haveDelta = std::fabs(delta) > DBL_EPSILON, doubleSupport = dev.doubleFPConfig() > 0; - if (!haveScale && !haveDelta && stype == dtype) + if (!haveScale && !haveDelta && sdepth == ddepth) { _src.copyTo(_dst, _mask); return true; @@ -485,7 +489,7 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m char cvt[2][40]; String opts = format("-D srcT=%s -D dstT=%s -D convertToWT=%s -D cn=%d -D rowsPerWI=%d" " -D convertToDT=%s -D workT=%s%s%s%s -D srcT1=%s -D dstT1=%s", - ocl::typeToStr(stype), ocl::typeToStr(dtype), + ocl::typeToStr(stype), ocl::typeToStr(ddepth), ocl::convertTypeStr(sdepth, wdepth, cn, cvt[0]), cn, rowsPerWI, ocl::convertTypeStr(wdepth, ddepth, cn, cvt[1]), ocl::typeToStr(CV_MAKE_TYPE(wdepth, cn)), @@ -525,7 +529,7 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m else { UMat temp; - src.convertTo( temp, dtype, scale, delta ); + src.convertTo(temp, ddepth, scale, delta); temp.copyTo( _dst, _mask ); } @@ -537,15 +541,16 @@ static bool ocl_normalize( InputArray _src, InputOutputArray _dst, InputArray _m } // cv:: void cv::normalize( InputArray _src, InputOutputArray _dst, double a, double b, - int norm_type, int rtype, InputArray _mask ) + int norm_type, ElemDepth ddepth, InputArray _mask ) { CV_INSTRUMENT_REGION(); double scale = 1, shift = 0; - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); - if( rtype < 0 ) - rtype = _dst.fixedType() ? _dst.depth() : depth; + if (ddepth == CV_DEPTH_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth; if( norm_type == CV_MINMAX ) { @@ -553,7 +558,7 @@ void cv::normalize( InputArray _src, InputOutputArray _dst, double a, double b, double dmin = MIN( a, b ), dmax = MAX( a, b ); minMaxIdx( _src, &smin, &smax, 0, 0, _mask ); scale = (dmax - dmin)*(smax - smin > DBL_EPSILON ? 1./(smax - smin) : 0); - if( rtype == CV_32F ) + if (ddepth == CV_32F) { scale = (float)scale; shift = (float)dmin - (float)(smin*scale); @@ -571,15 +576,15 @@ void cv::normalize( InputArray _src, InputOutputArray _dst, double a, double b, CV_Error( CV_StsBadArg, "Unknown/unsupported norm type" ); CV_OCL_RUN(_dst.isUMat(), - ocl_normalize(_src, _dst, _mask, rtype, scale, shift)) + ocl_normalize(_src, _dst, _mask, ddepth, scale, shift)) Mat src = _src.getMat(); if( _mask.empty() ) - src.convertTo( _dst, rtype, scale, shift ); + src.convertTo(_dst, ddepth, scale, shift); else { Mat temp; - src.convertTo( temp, rtype, scale, shift ); + src.convertTo(temp, ddepth, scale, shift); temp.copyTo( _dst, _mask ); } } diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 38264cc58f34..4bf062251676 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -246,11 +246,10 @@ void Mat::copyTo( OutputArray _dst ) const } #endif - int dtype = _dst.type(); - if( _dst.fixedType() && dtype != type() ) + if (_dst.fixedType() && _dst.type() != type()) { - CV_Assert( channels() == CV_MAT_CN(dtype) ); - convertTo( _dst, dtype ); + CV_Assert(channels() == _dst.channels()); + convertTo(_dst, _dst.depth()); return; } @@ -657,7 +656,9 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode ) CV_Assert(flipCode >= -1 && flipCode <= 1); const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), flipType, kercn = std::min(ocl::predictOptimalVectorWidth(_src, _dst), 4); bool doubleSupport = dev.doubleFPConfig() > 0; @@ -766,7 +767,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) CV_OCL_RUN( _dst.isUMat(), ocl_flip(_src, _dst, flip_mode)) Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); _dst.create( size, type ); Mat dst = _dst.getMat(); @@ -841,7 +842,9 @@ static bool ocl_repeat(InputArray _src, int ny, int nx, OutputArray _dst) return true; } - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1, kercn = ocl::predictOptimalVectorWidth(_src, _dst); @@ -1085,8 +1088,10 @@ namespace cv { static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom, int left, int right, int borderType, const Scalar& value ) { - int type = _src.type(), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type), - rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); + ElemDepth depth = CV_MAT_DEPTH(type); + int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; bool isolated = (borderType & BORDER_ISOLATED) != 0; borderType &= ~cv::BORDER_ISOLATED; @@ -1097,7 +1102,7 @@ static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP", "BORDER_REFLECT_101" }; int scalarcn = cn == 3 ? 4 : cn; - int sctype = CV_MAKETYPE(depth, scalarcn); + ElemType sctype = CV_MAKETYPE(depth, scalarcn); String buildOptions = format("-D T=%s -D %s -D T1=%s -D cn=%d -D ST=%s -D rowsPerWI=%d", ocl::memopTypeToStr(type), borderMap[borderType], ocl::memopTypeToStr(depth), cn, @@ -1190,7 +1195,7 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom, ocl_copyMakeBorder(_src, _dst, top, bottom, left, right, borderType, value)) Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); if( src.isSubmatrix() && (borderType & BORDER_ISOLATED) == 0 ) { diff --git a/modules/core/src/count_non_zero.cpp b/modules/core/src/count_non_zero.cpp index 3cff0944bc5f..6191d3693fbb 100644 --- a/modules/core/src/count_non_zero.cpp +++ b/modules/core/src/count_non_zero.cpp @@ -177,7 +177,7 @@ static int countNonZero64f( const double* src, int len ) typedef int (*CountNonZeroFunc)(const uchar*, int); -static CountNonZeroFunc getCountNonZeroTab(int depth) +static CountNonZeroFunc getCountNonZeroTab(ElemDepth depth) { static CountNonZeroFunc countNonZeroTab[] = { @@ -194,7 +194,9 @@ static CountNonZeroFunc getCountNonZeroTab(int depth) #ifdef HAVE_OPENCL static bool ocl_countNonZero( InputArray _src, int & res ) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), kercn = ocl::predictOptimalVectorWidth(_src); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int kercn = ocl::predictOptimalVectorWidth(_src); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; if (depth == CV_64F && !doubleSupport) @@ -241,7 +243,7 @@ static bool ipp_countNonZero( Mat &src, int &res ) #endif Ipp32s count = 0; - int depth = src.depth(); + ElemDepth depth = src.depth(); if(src.dims <= 2) { @@ -294,7 +296,8 @@ int cv::countNonZero( InputArray _src ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); CV_Assert( cn == 1 ); #if defined HAVE_OPENCL || defined HAVE_IPP @@ -331,7 +334,7 @@ void cv::findNonZero( InputArray _src, OutputArray _idx ) Mat src = _src.getMat(); CV_Assert( src.channels() == 1 && src.dims == 2 ); - int depth = src.depth(); + ElemDepth depth = src.depth(); std::vector idxvec; int rows = src.rows, cols = src.cols; AutoBuffer buf_(cols + 1); diff --git a/modules/core/src/cuda/gpu_mat.cu b/modules/core/src/cuda/gpu_mat.cu index e1b0c1b22d83..a64b13e78e74 100644 --- a/modules/core/src/cuda/gpu_mat.cu +++ b/modules/core/src/cuda/gpu_mat.cu @@ -151,11 +151,11 @@ void cv::cuda::GpuMat::setDefaultAllocator(Allocator* allocator) ///////////////////////////////////////////////////// /// create -void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) +void cv::cuda::GpuMat::create(int _rows, int _cols, ElemType _type) { CV_DbgAssert( _rows >= 0 && _cols >= 0 ); - _type &= Mat::TYPE_MASK; + _type &= static_cast(Mat::TYPE_MASK); if (rows == _rows && cols == _cols && type() == _type && data) return; @@ -165,7 +165,7 @@ void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) if (_rows > 0 && _cols > 0) { - flags = Mat::MAGIC_VAL + _type; + flags = static_cast(Mat::MAGIC_VAL | _type); rows = _rows; cols = _cols; @@ -182,7 +182,7 @@ void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) } if (esz * cols == step) - flags |= Mat::CONTINUOUS_FLAG; + flags |= static_cast(Mat::CONTINUOUS_FLAG); int64 _nettosize = static_cast(step) * rows; size_t nettosize = static_cast(_nettosize); @@ -523,15 +523,14 @@ namespace } } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, Stream& stream) const { - if (rtype < 0) - rtype = type(); - else - rtype = CV_MAKE_TYPE(CV_MAT_DEPTH(rtype), channels()); + if (ddepth == CV_DEPTH_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, channels()); - const int sdepth = depth(); - const int ddepth = CV_MAT_DEPTH(rtype); + const ElemDepth sdepth = depth(); if (sdepth == ddepth) { if (stream) @@ -546,7 +545,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co GpuMat src = *this; - _dst.create(size(), rtype); + _dst.create(size(), dtype); GpuMat dst = _dst.getGpuMat(); typedef void (*func_t)(const GpuMat& src, const GpuMat& dst, Stream& stream); @@ -564,19 +563,18 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co funcs[sdepth][ddepth](reshape(1), dst.reshape(1), stream); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, double beta, Stream& stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta, Stream& stream) const { - if (rtype < 0) - rtype = type(); - else - rtype = CV_MAKETYPE(CV_MAT_DEPTH(rtype), channels()); + if (ddepth == CV_DEPTH_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, channels()); - const int sdepth = depth(); - const int ddepth = CV_MAT_DEPTH(rtype); + const ElemDepth sdepth = depth(); GpuMat src = *this; - _dst.create(size(), rtype); + _dst.create(size(), dtype); GpuMat dst = _dst.getGpuMat(); typedef void (*func_t)(const GpuMat& src, const GpuMat& dst, double alpha, double beta, Stream& stream); @@ -597,7 +595,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, doub void cv::cuda::convertFp16(InputArray _src, OutputArray _dst, Stream& stream) { GpuMat src = _src.getGpuMat(); - int ddepth = 0; + ElemDepth ddepth = CV_DEPTH_AUTO; switch(src.depth()) { @@ -611,7 +609,7 @@ void cv::cuda::convertFp16(InputArray _src, OutputArray _dst, Stream& stream) CV_Error(Error::StsUnsupportedFormat, "Unsupported input depth"); return; } - int type = CV_MAKE_TYPE(CV_MAT_DEPTH(ddepth), src.channels()); + ElemType type = CV_MAKE_TYPE(CV_MAT_DEPTH(ddepth), src.channels()); _dst.create(src.size(), type); GpuMat dst = _dst.getGpuMat(); diff --git a/modules/core/src/cuda_gpu_mat.cpp b/modules/core/src/cuda_gpu_mat.cpp index a245b1a293ec..b004b43005a7 100644 --- a/modules/core/src/cuda_gpu_mat.cpp +++ b/modules/core/src/cuda_gpu_mat.cpp @@ -53,8 +53,8 @@ void cv::cuda::GpuMat::updateContinuityFlag() flags = cv::updateContinuityFlag(flags, 2, sz, steps); } -cv::cuda::GpuMat::GpuMat(int rows_, int cols_, int type_, void* data_, size_t step_) : - flags(Mat::MAGIC_VAL + (type_ & Mat::TYPE_MASK)), rows(rows_), cols(cols_), +cv::cuda::GpuMat::GpuMat(int rows_, int cols_, ElemType type_, void* data_, size_t step_) : + flags(static_cast(Mat::MAGIC_VAL | (type_ & Mat::TYPE_MASK))), rows(rows_), cols(cols_), step(step_), data((uchar*)data_), refcount(0), datastart((uchar*)data_), dataend((const uchar*)data_), allocator(defaultAllocator()) @@ -77,8 +77,8 @@ cv::cuda::GpuMat::GpuMat(int rows_, int cols_, int type_, void* data_, size_t st updateContinuityFlag(); } -cv::cuda::GpuMat::GpuMat(Size size_, int type_, void* data_, size_t step_) : - flags(Mat::MAGIC_VAL + (type_ & Mat::TYPE_MASK)), rows(size_.height), cols(size_.width), +cv::cuda::GpuMat::GpuMat(Size size_, ElemType type_, void* data_, size_t step_) : + flags(static_cast(Mat::MAGIC_VAL | (type_ & Mat::TYPE_MASK))), rows(size_.height), cols(size_.width), step(step_), data((uchar*)data_), refcount(0), datastart((uchar*)data_), dataend((const uchar*)data_), allocator(defaultAllocator()) @@ -256,7 +256,7 @@ GpuMat& cv::cuda::GpuMat::adjustROI(int dtop, int dbottom, int dleft, int dright namespace { template - void createContinuousImpl(int rows, int cols, int type, ObjType& obj) + void createContinuousImpl(int rows, int cols, ElemType type, ObjType& obj) { const int area = rows * cols; @@ -267,7 +267,7 @@ namespace } } -void cv::cuda::createContinuous(int rows, int cols, int type, OutputArray arr) +void cv::cuda::createContinuous(int rows, int cols, ElemType type, OutputArray arr) { switch (arr.kind()) { @@ -291,7 +291,7 @@ void cv::cuda::createContinuous(int rows, int cols, int type, OutputArray arr) namespace { template - void ensureSizeIsEnoughImpl(int rows, int cols, int type, ObjType& obj) + void ensureSizeIsEnoughImpl(int rows, int cols, ElemType type, ObjType& obj) { if (obj.empty() || obj.type() != type || obj.data != obj.datastart) { @@ -321,7 +321,7 @@ namespace } } -void cv::cuda::ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr) +void cv::cuda::ensureSizeIsEnough(int rows, int cols, ElemType type, OutputArray arr) { switch (arr.kind()) { @@ -364,7 +364,7 @@ GpuMat cv::cuda::getInputMat(InputArray _src, Stream& stream) #endif } -GpuMat cv::cuda::getOutputMat(OutputArray _dst, int rows, int cols, int type, Stream& stream) +GpuMat cv::cuda::getOutputMat(OutputArray _dst, int rows, int cols, ElemType type, Stream& stream) { #ifndef HAVE_CUDA CV_UNUSED(_dst); @@ -420,7 +420,7 @@ void cv::cuda::GpuMat::setDefaultAllocator(Allocator* allocator) throw_no_cuda(); } -void cv::cuda::GpuMat::create(int _rows, int _cols, int _type) +void cv::cuda::GpuMat::create(int _rows, int _cols, ElemType _type) { CV_UNUSED(_rows); CV_UNUSED(_cols); @@ -494,18 +494,18 @@ GpuMat& cv::cuda::GpuMat::setTo(Scalar s, InputArray _mask, Stream& _stream) throw_no_cuda(); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& _stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, Stream& _stream) const { CV_UNUSED(_dst); - CV_UNUSED(rtype); + CV_UNUSED(ddepth); CV_UNUSED(_stream); throw_no_cuda(); } -void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, double beta, Stream& _stream) const +void cv::cuda::GpuMat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta, Stream& _stream) const { CV_UNUSED(_dst); - CV_UNUSED(rtype); + CV_UNUSED(ddepth); CV_UNUSED(alpha); CV_UNUSED(beta); CV_UNUSED(_stream); diff --git a/modules/core/src/cuda_host_mem.cpp b/modules/core/src/cuda_host_mem.cpp index 0c120f82f99f..de06da82a059 100644 --- a/modules/core/src/cuda_host_mem.cpp +++ b/modules/core/src/cuda_host_mem.cpp @@ -58,7 +58,7 @@ class HostMemAllocator : public MatAllocator { } - UMatData* allocate(int dims, const int* sizes, int type, + UMatData* allocate(int dims, const int* sizes, ElemType type, void* data0, size_t* step, AccessFlag /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE { @@ -175,7 +175,7 @@ namespace } #endif -void cv::cuda::HostMem::create(int rows_, int cols_, int type_) +void cv::cuda::HostMem::create(int rows_, int cols_, ElemType type_) { #ifndef HAVE_CUDA CV_UNUSED(rows_); @@ -189,7 +189,7 @@ void cv::cuda::HostMem::create(int rows_, int cols_, int type_) CV_Assert( devInfo.canMapHostMemory() ); } - type_ &= Mat::TYPE_MASK; + type_ &= static_cast(Mat::TYPE_MASK); if (rows == rows_ && cols == cols_ && type() == type_ && data) return; @@ -201,7 +201,7 @@ void cv::cuda::HostMem::create(int rows_, int cols_, int type_) if (rows_ > 0 && cols_ > 0) { - flags = Mat::MAGIC_VAL + type_; + flags = static_cast(Mat::MAGIC_VAL | type_); rows = rows_; cols = cols_; step = elemSize() * cols; diff --git a/modules/core/src/cuda_stream.cpp b/modules/core/src/cuda_stream.cpp index 79d747722080..6790b0aa0ff2 100644 --- a/modules/core/src/cuda_stream.cpp +++ b/modules/core/src/cuda_stream.cpp @@ -711,7 +711,7 @@ cv::cuda::BufferPool::BufferPool(Stream& stream) : allocator_(stream.impl_->allo } #endif -GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, int type) +GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, ElemType type) { #ifndef HAVE_CUDA CV_UNUSED(rows); diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp index 1e374c8d84ee..6a22bb3f6164 100644 --- a/modules/core/src/datastructs.cpp +++ b/modules/core/src/datastructs.cpp @@ -385,7 +385,7 @@ cvCreateSeq( int seq_flags, size_t header_size, size_t elem_size, CvMemStorage* seq->header_size = (int)header_size; seq->flags = (seq_flags & ~CV_MAGIC_MASK) | CV_SEQ_MAGIC_VAL; { - int elemtype = CV_MAT_TYPE(seq_flags); + ElemType elemtype = CV_MAT_TYPE(seq_flags); int typesize = CV_ELEM_SIZE(elemtype); if( elemtype != CV_SEQ_ELTYPE_GENERIC && elemtype != CV_SEQ_ELTYPE_PTR && diff --git a/modules/core/src/directx.cpp b/modules/core/src/directx.cpp index 99c27ec7054e..a8243234e4da 100644 --- a/modules/core/src/directx.cpp +++ b/modules/core/src/directx.cpp @@ -59,13 +59,13 @@ namespace cv { namespace directx { -int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT) +ElemType getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT) { CV_UNUSED(iDXGI_FORMAT); #if !defined(HAVE_DIRECTX) NO_DIRECTX_SUPPORT_ERROR; #else - const int errorType = -1; + const ElemType errorType = CV_TYPE_AUTO; switch ((enum DXGI_FORMAT)iDXGI_FORMAT) { //case DXGI_FORMAT_UNKNOWN: @@ -177,13 +177,13 @@ int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT) #endif } -int getTypeFromD3DFORMAT(const int iD3DFORMAT) +ElemType getTypeFromD3DFORMAT(const int iD3DFORMAT) { CV_UNUSED(iD3DFORMAT); #if !defined(HAVE_DIRECTX) NO_DIRECTX_SUPPORT_ERROR; #else - const int errorType = -1; + const ElemType errorType = CV_TYPE_AUTO; switch ((enum _D3DFORMAT)iD3DFORMAT) { //case D3DFMT_UNKNOWN: @@ -774,7 +774,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D) pD3D11Texture2D->GetDesc(&desc); int srcType = src.type(); - int textureType = getTypeFromDXGI_FORMAT(desc.Format); + ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format); CV_Assert(textureType == srcType); Size srcSize = src.size(); @@ -882,8 +882,8 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst D3D11_TEXTURE2D_DESC desc = { 0 }; pD3D11Texture2D->GetDesc(&desc); - int textureType = getTypeFromDXGI_FORMAT(desc.Format); - CV_Assert(textureType >= 0); + ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format); + CV_Assert(textureType >= CV_8UC1); // TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying! dst.create(Size(desc.Width, desc.Height), textureType); @@ -1014,7 +1014,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D) pD3D10Texture2D->GetDesc(&desc); int srcType = src.type(); - int textureType = getTypeFromDXGI_FORMAT(desc.Format); + ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format); CV_Assert(textureType == srcType); Size srcSize = src.size(); @@ -1074,8 +1074,8 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst D3D10_TEXTURE2D_DESC desc = { 0 }; pD3D10Texture2D->GetDesc(&desc); - int textureType = getTypeFromDXGI_FORMAT(desc.Format); - CV_Assert(textureType >= 0); + ElemType textureType = getTypeFromDXGI_FORMAT(desc.Format); + CV_Assert(textureType >= CV_8UC1); using namespace cv::ocl; Context& ctx = Context::getDefault(); @@ -1232,8 +1232,8 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: Can't get D3D surface description"); } - int surfaceType = getTypeFromD3DFORMAT(desc.Format); - CV_Assert(surfaceType >= 0); + ElemType surfaceType = getTypeFromD3DFORMAT(desc.Format); + CV_Assert(surfaceType >= CV_8UC1); using namespace cv::ocl; Context& ctx = Context::getDefault(); diff --git a/modules/core/src/downhill_simplex.cpp b/modules/core/src/downhill_simplex.cpp index 15d6469465f4..0014bcb03e28 100644 --- a/modules/core/src/downhill_simplex.cpp +++ b/modules/core/src/downhill_simplex.cpp @@ -196,13 +196,13 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver if( !x.empty() ) { - Mat simplex_0m(x.rows, x.cols, CV_64F, simplex.ptr()); - simplex_0m.convertTo(x, x.type()); + Mat simplex_0m(x.rows, x.cols, CV_64FC1, simplex.ptr()); + simplex_0m.convertTo(x, x.depth()); } else { - int x_type = x_.fixedType() ? x_.type() : CV_64F; - simplex.row(0).convertTo(x_, x_type); + ElemDepth x_depth = x_.fixedType() ? x_.depth() : CV_64F; + simplex.row(0).convertTo(x_, x_depth); } return res; } @@ -238,12 +238,12 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver CV_Assert( _Function->getDims() == ndim ); Mat x = x0; if( x0.empty() ) - x = Mat::zeros(1, ndim, CV_64F); + x = Mat::zeros(1, ndim, CV_64FC1); CV_Assert( (x.cols == 1 && x.rows == ndim) || (x.cols == ndim && x.rows == 1) ); - CV_Assert( x.type() == CV_32F || x.type() == CV_64F ); + CV_Assert(x.type() == CV_32FC1 || x.type() == CV_64FC1); - simplex.create(ndim + 1, ndim, CV_64F); - Mat simplex_0m(x.rows, x.cols, CV_64F, simplex.ptr()); + simplex.create(ndim + 1, ndim, CV_64FC1); + Mat simplex_0m(x.rows, x.cols, CV_64FC1, simplex.ptr()); x.convertTo(simplex_0m, CV_64F); double* simplex_0 = simplex.ptr(); @@ -272,7 +272,7 @@ class DownhillSolverImpl CV_FINAL : public DownhillSolver double innerDownhillSimplex( Mat& p, double MinRange, double MinError, int& fcount, int nmax ) { int i, j, ndim = p.cols; - Mat coord_sum(1, ndim, CV_64F), buf(1, ndim, CV_64F), y(1, ndim+1, CV_64F); + Mat coord_sum(1, ndim, CV_64FC1), buf(1, ndim, CV_64FC1), y(1, ndim + 1, CV_64FC1); double* y_ = y.ptr(); fcount = ndim+1; diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index bfa61d05029c..39ee78a08b3e 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -1885,11 +1885,11 @@ struct OCL_FftPlan String buildOptions; int thread_count; int dft_size; - int dft_depth; + ElemDepth dft_depth; bool status; public: - OCL_FftPlan(int _size, int _depth) : dft_size(_size), dft_depth(_depth), status(true) + OCL_FftPlan(int _size, ElemDepth _depth) : dft_size(_size), dft_depth(_depth), status(true) { CV_Assert( dft_depth == CV_32F || dft_depth == CV_64F ); @@ -2092,7 +2092,7 @@ class OCL_FftPlanCache CV_SINGLETON_LAZY_INIT_REF(OCL_FftPlanCache, new OCL_FftPlanCache()) } - Ptr getFftPlan(int dft_size, int depth) + Ptr getFftPlan(int dft_size, ElemDepth depth) { int key = (dft_size << 16) | (depth & 0xFFFF); std::map >::iterator f = planStorage.find(key); @@ -2123,14 +2123,16 @@ class OCL_FftPlanCache static bool ocl_dft_rows(InputArray _src, OutputArray _dst, int nonzero_rows, int flags, int fftType) { - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); Ptr plan = OCL_FftPlanCache::getInstance().getFftPlan(_src.cols(), depth); return plan->enqueueTransform(_src, _dst, nonzero_rows, flags, fftType, true); } static bool ocl_dft_cols(InputArray _src, OutputArray _dst, int nonzero_cols, int flags, int fftType) { - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); Ptr plan = OCL_FftPlanCache::getInstance().getFftPlan(_src.rows(), depth); return plan->enqueueTransform(_src, _dst, nonzero_cols, flags, fftType, false); } @@ -2160,7 +2162,9 @@ inline FftType determineFFTType(bool real_input, bool complex_input, bool real_o static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_rows) { - int type = _src.type(), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); + ElemDepth depth = CV_MAT_DEPTH(type); Size ssize = _src.size(); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -2413,7 +2417,9 @@ static void CL_CALLBACK oclCleanupCallback(cl_event e, cl_int, void *p) static bool ocl_dft_amdfft(InputArray _src, OutputArray _dst, int flags) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); Size ssize = _src.size(); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -2500,7 +2506,7 @@ static void complementComplex(T * ptr, size_t step, int n, int len, int dft_dims } } -static void complementComplexOutput(int depth, uchar * ptr, size_t step, int count, int len, int dft_dims) +static void complementComplexOutput(ElemDepth depth, uchar * ptr, size_t step, int count, int len, int dft_dims) { if( depth == CV_32F ) complementComplex((float*)ptr, step, count, len, dft_dims); @@ -2620,7 +2626,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D DftMode mode; int elem_size; int complex_elem_size; - int depth; + ElemDepth depth; bool real_transform; int nonzero_rows; bool isRowTransform; @@ -2646,7 +2652,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D mode = InvalidDft; elem_size = 0; complex_elem_size = 0; - depth = 0; + depth = CV_8U; real_transform = false; nonzero_rows = 0; isRowTransform = false; @@ -2656,7 +2662,7 @@ class OcvDftImpl CV_FINAL : public hal::DFT2D dst_channels = 0; } - void init(int _width, int _height, int _depth, int _src_channels, int _dst_channels, int flags, int _nonzero_rows) + void init(int _width, int _height, ElemDepth _depth, int _src_channels, int _dst_channels, int flags, int _nonzero_rows) { bool isComplex = _src_channels != _dst_channels; nonzero_rows = _nonzero_rows; @@ -3056,7 +3062,7 @@ class OcvDftBasicImpl CV_FINAL : public hal::DFT1D { opt.factors = _factors; } - void init(int len, int count, int depth, int flags, bool *needBuffer) + void init(int len, int count, ElemDepth depth, int flags, bool *needBuffer) { int prev_len = opt.n; @@ -3208,7 +3214,7 @@ struct ReplacementDFT1D : public hal::DFT1D bool isInitialized; ReplacementDFT1D() : context(0), isInitialized(false) {} - bool init(int len, int count, int depth, int flags, bool *needBuffer) + bool init(int len, int count, ElemDepth depth, int flags, bool *needBuffer) { int res = cv_hal_dftInit1D(&context, len, count, depth, flags, needBuffer); isInitialized = (res == CV_HAL_ERROR_OK); @@ -3236,7 +3242,7 @@ struct ReplacementDFT2D : public hal::DFT2D bool isInitialized; ReplacementDFT2D() : context(0), isInitialized(false) {} - bool init(int width, int height, int depth, + bool init(int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { @@ -3264,7 +3270,7 @@ namespace hal { //================== 1D ====================== -Ptr DFT1D::create(int len, int count, int depth, int flags, bool *needBuffer) +Ptr DFT1D::create(int len, int count, ElemDepth depth, int flags, bool *needBuffer) { { ReplacementDFT1D *impl = new ReplacementDFT1D(); @@ -3283,7 +3289,7 @@ Ptr DFT1D::create(int len, int count, int depth, int flags, bool *needBuf //================== 2D ====================== -Ptr DFT2D::create(int width, int height, int depth, +Ptr DFT2D::create(int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { @@ -3329,8 +3335,8 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) Mat src0 = _src0.getMat(), src = src0; bool inv = (flags & DFT_INVERSE) != 0; - int type = src.type(); - int depth = src.depth(); + ElemType type = src.type(); + ElemDepth depth = src.depth(); CV_Assert( type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 ); @@ -3340,7 +3346,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows ) if( !inv && src.channels() == 1 && (flags & DFT_COMPLEX_OUTPUT) ) _dst.create( src.size(), CV_MAKETYPE(depth, 2) ); else if( inv && src.channels() == 2 && (flags & DFT_REAL_OUTPUT) ) - _dst.create( src.size(), depth ); + _dst.create( src.size(), CV_MAKETYPE(depth, 1) ); else _dst.create( src.size(), type ); @@ -3376,8 +3382,8 @@ namespace cv { static bool ocl_mulSpectrums( InputArray _srcA, InputArray _srcB, OutputArray _dst, int flags, bool conjB ) { - int atype = _srcA.type(), btype = _srcB.type(), - rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; + ElemType atype = _srcA.type(), btype = _srcB.type(); + int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; Size asize = _srcA.size(), bsize = _srcB.size(); CV_Assert(asize == bsize); @@ -3535,7 +3541,9 @@ void cv::mulSpectrums( InputArray _srcA, InputArray _srcB, ocl_mulSpectrums(_srcA, _srcB, _dst, flags, conjB)) Mat srcA = _srcA.getMat(), srcB = _srcB.getMat(); - int depth = srcA.depth(), cn = srcA.channels(), type = srcA.type(); + ElemDepth depth = srcA.depth(); + int cn = srcA.channels(); + ElemType type = srcA.type(); size_t rows = srcA.rows, cols = srcA.cols; CV_Assert( type == srcB.type() && srcA.size() == srcB.size() ); @@ -4065,9 +4073,9 @@ class OcvDctImpl CV_FINAL : public hal::DCT2D int end_stage; int width; int height; - int depth; + ElemDepth depth; - void init(int _width, int _height, int _depth, int flags) + void init(int _width, int _height, ElemDepth _depth, int flags) { width = _width; height = _height; @@ -4190,7 +4198,7 @@ struct ReplacementDCT2D : public hal::DCT2D bool isInitialized; ReplacementDCT2D() : context(0), isInitialized(false) {} - bool init(int width, int height, int depth, int flags) + bool init(int width, int height, ElemDepth depth, int flags) { int res = hal_ni_dctInit2D(&context, width, height, depth, flags); isInitialized = (res == CV_HAL_ERROR_OK); @@ -4214,7 +4222,7 @@ struct ReplacementDCT2D : public hal::DCT2D namespace hal { -Ptr DCT2D::create(int width, int height, int depth, int flags) +Ptr DCT2D::create(int width, int height, ElemDepth depth, int flags) { { ReplacementDCT2D *impl = new ReplacementDCT2D(); @@ -4239,7 +4247,8 @@ void cv::dct( InputArray _src0, OutputArray _dst, int flags ) CV_INSTRUMENT_REGION(); Mat src0 = _src0.getMat(), src = src0; - int type = src.type(), depth = src.depth(); + ElemType type = src.type(); + ElemDepth depth = src.depth(); CV_Assert( type == CV_32FC1 || type == CV_64FC1 ); _dst.create( src.rows, src.cols, type ); diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index 1a558f253278..24361fe61087 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -507,7 +507,7 @@ struct cvhalDFT {}; @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, CV_HAL_DFT_SCALE, ...) @param needBuffer pointer to boolean variable, if valid pointer provided, then variable value should be set to true to signal that additional memory buffer is needed for operations */ -inline int hal_ni_dftInit1D(cvhalDFT **context, int len, int count, int depth, int flags, bool *needBuffer) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dftInit1D(cvhalDFT **context, int len, int count, ElemDepth depth, int flags, bool *needBuffer) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src source data @@ -534,7 +534,7 @@ inline int hal_ni_dftFree1D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, ...) @param nonzero_rows number of nonzero rows in image, can be used for optimization */ -inline int hal_ni_dftInit2D(cvhalDFT **context, int width, int height, int depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dftInit2D(cvhalDFT **context, int width, int height, ElemDepth depth, int src_channels, int dst_channels, int flags, int nonzero_rows) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src_data,src_step source image data and step @@ -558,7 +558,7 @@ inline int hal_ni_dftFree2D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEME @param depth image type (CV_32F or CV64F) @param flags algorithm options (combination of CV_HAL_DFT_INVERSE, ...) */ -inline int hal_ni_dctInit2D(cvhalDFT **context, int width, int height, int depth, int flags) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_dctInit2D(cvhalDFT **context, int width, int height, ElemDepth depth, int flags) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @param context pointer to context storing all necessary data @param src_data,src_step source image data and step @@ -721,7 +721,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s @param minIdx,maxIdx Pointer to the returned minimum and maximum location. @param mask Specified array region. */ -inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal, +inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, ElemDepth depth, double* minVal, double* maxVal, int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED diff --git a/modules/core/src/kmeans.cpp b/modules/core/src/kmeans.cpp index 3f10780cd373..68e53046c023 100644 --- a/modules/core/src/kmeans.cpp +++ b/modules/core/src/kmeans.cpp @@ -234,22 +234,22 @@ double cv::kmeans( InputArray _data, int K, const bool isrow = data0.rows == 1; const int N = isrow ? data0.cols : data0.rows; const int dims = (isrow ? 1 : data0.cols)*data0.channels(); - const int type = data0.depth(); + const ElemType type = CV_MAKETYPE(data0.depth(), 1); attempts = std::max(attempts, 1); - CV_Assert( data0.dims <= 2 && type == CV_32F && K > 0 ); + CV_Assert(data0.dims <= 2 && type == CV_32FC1 && K > 0); CV_Assert( N >= K ); - Mat data(N, dims, CV_32F, data0.ptr(), isrow ? dims * sizeof(float) : static_cast(data0.step)); + Mat data(N, dims, CV_32FC1, data0.ptr(), isrow ? dims * sizeof(float) : static_cast(data0.step)); - _bestLabels.create(N, 1, CV_32S, -1, true); + _bestLabels.create(N, 1, CV_32SC1, -1, true); Mat _labels, best_labels = _bestLabels.getMat(); if (flags & CV_KMEANS_USE_INITIAL_LABELS) { CV_Assert( (best_labels.cols == 1 || best_labels.rows == 1) && best_labels.cols*best_labels.rows == N && - best_labels.type() == CV_32S && + best_labels.type() == CV_32SC1 && best_labels.isContinuous()); best_labels.reshape(1, N).copyTo(_labels); for (int i = 0; i < N; i++) @@ -261,10 +261,10 @@ double cv::kmeans( InputArray _data, int K, { if (!((best_labels.cols == 1 || best_labels.rows == 1) && best_labels.cols*best_labels.rows == N && - best_labels.type() == CV_32S && + best_labels.type() == CV_32SC1 && best_labels.isContinuous())) { - _bestLabels.create(N, 1, CV_32S); + _bestLabels.create(N, 1, CV_32SC1); best_labels = _bestLabels.getMat(); } _labels.create(best_labels.size(), best_labels.type()); @@ -431,7 +431,7 @@ double cv::kmeans( InputArray _data, int K, { // don't re-assign labels to avoid creation of empty clusters parallel_for_(Range(0, N), KMeansDistanceComputer(dists.data(), labels, data, centers), (double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY)); - compactness = sum(Mat(Size(N, 1), CV_64F, &dists[0]))[0]; + compactness = sum(Mat(Size(N, 1), CV_64FC1, &dists[0]))[0]; break; } else diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index d8ceaf6abbc9..4e8f87924a08 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -765,17 +765,18 @@ double cv::determinant( InputArray _mat ) Mat mat = _mat.getMat(); double result = 0; - int type = mat.type(), rows = mat.rows; + ElemType type = mat.type(); + int rows = mat.rows; size_t step = mat.step; const uchar* m = mat.ptr(); CV_Assert( !mat.empty() ); - CV_Assert( mat.rows == mat.cols && (type == CV_32F || type == CV_64F)); + CV_Assert(mat.rows == mat.cols && (type == CV_32FC1 || type == CV_64FC1)); #define Mf(y, x) ((float*)(m + y*step))[x] #define Md(y, x) ((double*)(m + y*step))[x] - if( type == CV_32F ) + if (type == CV_32FC1) { if( rows == 2 ) result = det2(Mf); @@ -787,7 +788,7 @@ double cv::determinant( InputArray _mat ) { size_t bufSize = rows*rows*sizeof(float); AutoBuffer buffer(bufSize); - Mat a(rows, rows, CV_32F, buffer.data()); + Mat a(rows, rows, CV_32FC1, buffer.data()); mat.copyTo(a); result = hal::LU32f(a.ptr(), a.step, rows, 0, 0, 0); @@ -810,7 +811,7 @@ double cv::determinant( InputArray _mat ) { size_t bufSize = rows*rows*sizeof(double); AutoBuffer buffer(bufSize); - Mat a(rows, rows, CV_64F, buffer.data()); + Mat a(rows, rows, CV_64FC1, buffer.data()); mat.copyTo(a); result = hal::LU64f(a.ptr(), a.step, rows, 0, 0, 0); @@ -843,9 +844,9 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) bool result = false; Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); - CV_Assert(type == CV_32F || type == CV_64F); + CV_Assert(type == CV_32FC1 || type == CV_64FC1); size_t esz = CV_ELEM_SIZE(type); int m = src.rows, n = src.cols; @@ -862,7 +863,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) SVD::compute(src, w, u, vt); SVD::backSubst(w, u, vt, Mat(), _dst); - return type == CV_32F ? + return type == CV_32FC1 ? (w.ptr()[0] >= FLT_EPSILON ? w.ptr()[n-1]/w.ptr()[0] : 0) : (w.ptr()[0] >= DBL_EPSILON ? @@ -882,7 +883,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) eigen(src, w, vt); transpose(vt, u); SVD::backSubst(w, u, vt, Mat(), _dst); - return type == CV_32F ? + return type == CV_32FC1 ? (w.ptr()[0] >= FLT_EPSILON ? w.ptr()[n-1]/w.ptr()[0] : 0) : (w.ptr()[0] >= DBL_EPSILON ? @@ -1076,11 +1077,11 @@ double cv::invert( InputArray _src, OutputArray _dst, int method ) src.copyTo(src1); setIdentity(dst); - if( method == DECOMP_LU && type == CV_32F ) + if (method == DECOMP_LU && type == CV_32FC1) result = hal::LU32f(src1.ptr(), src1.step, n, dst.ptr(), dst.step, n) != 0; - else if( method == DECOMP_LU && type == CV_64F ) + else if (method == DECOMP_LU && type == CV_64FC1) result = hal::LU64f(src1.ptr(), src1.step, n, dst.ptr(), dst.step, n) != 0; - else if( method == DECOMP_CHOLESKY && type == CV_32F ) + else if (method == DECOMP_CHOLESKY && type == CV_32FC1) result = hal::Cholesky32f(src1.ptr(), src1.step, n, dst.ptr(), dst.step, n); else result = hal::Cholesky64f(src1.ptr(), src1.step, n, dst.ptr(), dst.step, n); @@ -1103,10 +1104,10 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth bool result = true; Mat src = _src.getMat(), _src2 = _src2arg.getMat(); - int type = src.type(); + ElemType type = src.type(); bool is_normal = (method & DECOMP_NORMAL) != 0; - CV_Assert( type == _src2.type() && (type == CV_32F || type == CV_64F) ); + CV_Assert(type == _src2.type() && (type == CV_32FC1 || type == CV_64FC1)); method &= ~DECOMP_NORMAL; CV_Check(method, method == DECOMP_LU || method == DECOMP_SVD || method == DECOMP_EIG || @@ -1315,14 +1316,14 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth if( method == DECOMP_LU ) { - if( type == CV_32F ) + if (type == CV_32FC1) result = hal::LU32f(a.ptr(), a.step, n, dst.ptr(), dst.step, nb) != 0; else result = hal::LU64f(a.ptr(), a.step, n, dst.ptr(), dst.step, nb) != 0; } else if( method == DECOMP_CHOLESKY ) { - if( type == CV_32F ) + if (type == CV_32FC1) result = hal::Cholesky32f(a.ptr(), a.step, n, dst.ptr(), dst.step, nb); else result = hal::Cholesky64f(a.ptr(), a.step, n, dst.ptr(), dst.step, nb); @@ -1341,7 +1342,7 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth src2.copyTo(rhsMat); } - if( type == CV_32F ) + if (type == CV_32FC1) result = hal::QR32f(a.ptr(), a.step, a.rows, a.cols, rhsMat.cols, rhsMat.ptr(), rhsMat.step, NULL) != 0; else result = hal::QR64f(a.ptr(), a.step, a.rows, a.cols, rhsMat.cols, rhsMat.ptr(), rhsMat.step, NULL) != 0; @@ -1357,7 +1358,7 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth if( method == DECOMP_EIG ) { - if( type == CV_32F ) + if (type == CV_32FC1) Jacobi(a.ptr(), a.step, w.ptr(), v.ptr(), v.step, n, ptr); else Jacobi(a.ptr(), a.step, w.ptr(), v.ptr(), v.step, n, ptr); @@ -1365,14 +1366,14 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth } else { - if( type == CV_32F ) + if (type == CV_32FC1) JacobiSVD(a.ptr(), a.step, w.ptr(), v.ptr(), v.step, m_, n); else JacobiSVD(a.ptr(), a.step, w.ptr(), v.ptr(), v.step, m_, n); u = a; } - if( type == CV_32F ) + if (type == CV_32FC1) { SVBkSb(m_, n, w.ptr(), 0, u.ptr(), u.step, true, v.ptr(), v.step, true, src2.ptr(), @@ -1401,11 +1402,11 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects ) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); int n = src.rows; CV_Assert( src.rows == src.cols ); - CV_Assert (type == CV_32F || type == CV_64F); + CV_Assert(type == CV_32FC1 || type == CV_64FC1); Mat v; if( _evects.needed() ) @@ -1419,7 +1420,7 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects ) const int esOptions = evecNeeded ? Eigen::ComputeEigenvectors : Eigen::EigenvaluesOnly; _evals.create(n, 1, type); cv::Mat evals = _evals.getMat(); - if ( type == CV_64F ) + if (type == CV_64FC1) { Eigen::MatrixXd src_eig, zeros_eig; cv::cv2eigen(src, src_eig); @@ -1461,7 +1462,7 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects ) Mat a(n, n, type, ptr, astep), w(n, 1, type, ptr + astep*n); ptr += astep*n + elemSize*n; src.copyTo(a); - bool ok = type == CV_32F ? + bool ok = type == CV_32FC1 ? Jacobi(a.ptr(), a.step, w.ptr(), v.ptr(), v.step, n, ptr) : Jacobi(a.ptr(), a.step, w.ptr(), v.ptr(), v.step, n, ptr); @@ -1478,11 +1479,11 @@ static void _SVDcompute( InputArray _aarr, OutputArray _w, { Mat src = _aarr.getMat(); int m = src.rows, n = src.cols; - int type = src.type(); + ElemType type = src.type(); bool compute_uv = _u.needed() || _vt.needed(); bool full_uv = (flags & SVD::FULL_UV) != 0; - CV_Assert( type == CV_32F || type == CV_64F ); + CV_Assert(type == CV_32FC1 || type == CV_64FC1); if( flags & SVD::NO_UV ) { @@ -1517,7 +1518,7 @@ static void _SVDcompute( InputArray _aarr, OutputArray _w, else src.copyTo(temp_a); - if( type == CV_32F ) + if (type == CV_32FC1) { JacobiSVD(temp_a.ptr(), temp_u.step, temp_w.ptr(), temp_v.ptr(), temp_v.step, m, n, compute_uv ? urows : 0); @@ -1566,7 +1567,8 @@ void SVD::backSubst( InputArray _w, InputArray _u, InputArray _vt, InputArray _rhs, OutputArray _dst ) { Mat w = _w.getMat(), u = _u.getMat(), vt = _vt.getMat(), rhs = _rhs.getMat(); - int type = w.type(), esz = (int)w.elemSize(); + ElemType type = w.type(); + int esz = (int)w.elemSize(); int m = u.rows, n = vt.cols, nb = rhs.data ? rhs.cols : m, nm = std::min(m, n); size_t wstep = w.rows == 1 ? (size_t)esz : w.cols == 1 ? (size_t)w.step : (size_t)w.step + esz; AutoBuffer buffer(nb*sizeof(double) + 16); @@ -1577,11 +1579,11 @@ void SVD::backSubst( InputArray _w, InputArray _u, InputArray _vt, _dst.create( n, nb, type ); Mat dst = _dst.getMat(); - if( type == CV_32F ) + if (type == CV_32FC1) SVBkSb(m, n, w.ptr(), wstep, u.ptr(), u.step, false, vt.ptr(), vt.step, true, rhs.ptr(), rhs.step, nb, dst.ptr(), dst.step, buffer.data()); - else if( type == CV_64F ) + else if (type == CV_64FC1) SVBkSb(m, n, w.ptr(), wstep, u.ptr(), u.step, false, vt.ptr(), vt.step, true, rhs.ptr(), rhs.step, nb, dst.ptr(), dst.step, buffer.data()); @@ -1626,7 +1628,7 @@ cvDet( const CvArr* arr ) if( CV_IS_MAT(arr) && ((CvMat*)arr)->rows <= 3 ) { CvMat* mat = (CvMat*)arr; - int type = CV_MAT_TYPE(mat->type); + ElemType type = CV_MAT_TYPE(mat->type); int rows = mat->rows; uchar* m = mat->data.ptr; int step = mat->step; @@ -1635,14 +1637,14 @@ cvDet( const CvArr* arr ) #define Mf(y, x) ((float*)(m + y*step))[x] #define Md(y, x) ((double*)(m + y*step))[x] - if( type == CV_32F ) + if (type == CV_32FC1) { if( rows == 2 ) return det2(Mf); if( rows == 3 ) return det3(Mf); } - else if( type == CV_64F ) + else if (type == CV_64FC1) { if( rows == 2 ) return det2(Md); @@ -1693,7 +1695,7 @@ cvEigenVV( CvArr* srcarr, CvArr* evectsarr, CvArr* evalsarr, double, if( evects0.data != evects.data ) { const uchar* p = evects0.ptr(); - evects.convertTo(evects0, evects0.type()); + evects.convertTo(evects0, evects0.depth()); CV_Assert( p == evects0.ptr() ); } } @@ -1703,11 +1705,11 @@ cvEigenVV( CvArr* srcarr, CvArr* evectsarr, CvArr* evalsarr, double, { const uchar* p = evals0.ptr(); if( evals0.size() == evals.size() ) - evals.convertTo(evals0, evals0.type()); + evals.convertTo(evals0, evals0.depth()); else if( evals0.type() == evals.type() ) cv::transpose(evals, evals0); else - cv::Mat(evals.t()).convertTo(evals0, evals0.type()); + cv::Mat(evals.t()).convertTo(evals0, evals0.depth()); CV_Assert( p == evals0.ptr() ); } } @@ -1717,7 +1719,8 @@ CV_IMPL void cvSVD( CvArr* aarr, CvArr* warr, CvArr* uarr, CvArr* varr, int flags ) { cv::Mat a = cv::cvarrToMat(aarr), w = cv::cvarrToMat(warr), u, v; - int m = a.rows, n = a.cols, type = a.type(), mn = std::max(m, n), nm = std::min(m, n); + int m = a.rows, n = a.cols, mn = std::max(m, n), nm = std::min(m, n); + ElemType type = a.type(); CV_Assert( w.type() == type && (w.size() == cv::Size(nm,1) || w.size() == cv::Size(1, nm) || diff --git a/modules/core/src/lda.cpp b/modules/core/src/lda.cpp index a339b391363c..dfdb41e758a6 100644 --- a/modules/core/src/lda.cpp +++ b/modules/core/src/lda.cpp @@ -51,7 +51,7 @@ static Mat argsort(InputArray _src, bool ascending=true) return sorted_indices; } -static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) { +static Mat asRowMatrix(InputArrayOfArrays src, ElemType rtype, double alpha = 1, double beta = 0) { // make sure the input data is a vector of matrices or vector of vector if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_ARRAY_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) { @@ -78,9 +78,9 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double Mat xi = data.row(i); // make reshape happy by cloning for non-continuous matrices if(src.getMat(i).isContinuous()) { - src.getMat(i).reshape(1, 1).convertTo(xi, rtype, alpha, beta); + src.getMat(i).reshape(1, 1).convertTo(xi, CV_MAT_DEPTH(rtype), alpha, beta); } else { - src.getMat(i).clone().reshape(1, 1).convertTo(xi, rtype, alpha, beta); + src.getMat(i).clone().reshape(1, 1).convertTo(xi, CV_MAT_DEPTH(rtype), alpha, beta); } } return data; @@ -190,7 +190,7 @@ Mat LDA::subspaceProject(InputArray _W, InputArray _mean, InputArray _src) { // create temporary matrices Mat X, Y; // make sure you operate on correct type - src.convertTo(X, W.type()); + src.convertTo(X, W.depth()); // safe to do, because of above assertion if(!mean.empty()) { for(int i=0; in = tmp.cols; // Allocate the matrix data to work on. @@ -947,15 +947,16 @@ void eigenNonSymmetric(InputArray _src, OutputArray _evals, OutputArray _evects) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(); - int type = src.type(); + ElemType type = src.type(); + ElemDepth depth = src.depth(); size_t n = (size_t)src.rows; CV_Assert(src.rows == src.cols); - CV_Assert(type == CV_32F || type == CV_64F); + CV_Assert(type == CV_32FC1 || type == CV_64FC1); Mat src64f; - if (type == CV_32F) - src.convertTo(src64f, CV_32FC1); + if (depth == CV_32F) + src.convertTo(src64f, CV_32F); else src64f = src; @@ -972,7 +973,7 @@ void eigenNonSymmetric(InputArray _src, OutputArray _evals, OutputArray _evects) std::vector sorted_eigenvalues64f(n); for (size_t i = 0; i < n; i++) sorted_eigenvalues64f[i] = eigenvalues64f[sort_indexes[i]]; - Mat(sorted_eigenvalues64f).convertTo(_evals, type); + Mat(sorted_eigenvalues64f).convertTo(_evals, depth); if( _evects.needed() ) { @@ -987,7 +988,7 @@ void eigenNonSymmetric(InputArray _src, OutputArray _evals, OutputArray _evects) CV_Assert(pSrc != NULL); memcpy(pDst, pSrc, n * sizeof(double)); } - sorted_eigenvectors64f.convertTo(_evects, type); + sorted_eigenvectors64f.convertTo(_evects, depth); } } @@ -1054,7 +1055,7 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { // turn into row sampled matrix Mat data; // ensure working matrix is double precision - src.convertTo(data, CV_64FC1); + src.convertTo(data, CV_64F); // maps the labels, so they're ascending: [0,1,...,C] std::vector mapped_labels(labels.size()); std::vector num2label = remove_dups(labels); @@ -1108,10 +1109,10 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { numClass[classIdx]++; } // calculate total mean - meanTotal.convertTo(meanTotal, meanTotal.type(), 1.0 / static_cast (N)); + meanTotal.convertTo(meanTotal, meanTotal.depth(), 1.0 / static_cast (N)); // calculate class means for (int i = 0; i < C; i++) { - meanClass[i].convertTo(meanClass[i], meanClass[i].type(), 1.0 / static_cast (numClass[i])); + meanClass[i].convertTo(meanClass[i], meanClass[i].depth(), 1.0 / static_cast (numClass[i])); } // subtract class means for (int i = 0; i < N; i++) { diff --git a/modules/core/src/lpsolver.cpp b/modules/core/src/lpsolver.cpp index 1a1307d5b549..03d9328278cd 100644 --- a/modules/core/src/lpsolver.cpp +++ b/modules/core/src/lpsolver.cpp @@ -107,12 +107,12 @@ int solveLP(const Mat& Func, const Mat& Constr, Mat& z){ Mat_ bigC=Mat_(1,(Func.rows==1?Func.cols:Func.rows)+1), bigB=Mat_(Constr.rows,Constr.cols+1); if(Func.rows==1){ - Func.convertTo(bigC.colRange(1,bigC.cols),CV_64FC1); + Func.convertTo(bigC.colRange(1,bigC.cols),CV_64F); }else{ Mat FuncT=Func.t(); - FuncT.convertTo(bigC.colRange(1,bigC.cols),CV_64FC1); + FuncT.convertTo(bigC.colRange(1,bigC.cols),CV_64F); } - Constr.convertTo(bigB.colRange(1,bigB.cols),CV_64FC1); + Constr.convertTo(bigB.colRange(1,bigB.cols),CV_64F); double v=0; vector N,B; vector indexToRow; diff --git a/modules/core/src/lut.cpp b/modules/core/src/lut.cpp index 3b45b906e0a7..c03b4b940fc1 100644 --- a/modules/core/src/lut.cpp +++ b/modules/core/src/lut.cpp @@ -78,7 +78,8 @@ static LUTFunc lutTab[] = static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst) { - int lcn = _lut.channels(), dcn = _src.channels(), ddepth = _lut.depth(); + int lcn = _lut.channels(), dcn = _src.channels(); + ElemDepth ddepth = _lut.depth(); UMat src = _src.getUMat(), lut = _lut.getUMat(); _dst.create(src.size(), CV_MAKETYPE(ddepth, dcn)); @@ -360,7 +361,8 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int cn = _src.channels(), depth = _src.depth(); + int cn = _src.channels(); + ElemDepth depth = _src.depth(); int lutcn = _lut.channels(); CV_Assert( (lutcn == cn || lutcn == 1) && diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index e8067b512813..c0ce646266db 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -60,7 +60,9 @@ static const char* oclop2str[] = { "OP_LOG", "OP_EXP", "OP_MAG", "OP_PHASE_DEGRE static bool ocl_math_op(InputArray _src1, InputArray _src2, OutputArray _dst, int oclop) { - int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src1.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int kercn = oclop == OCL_OP_PHASE_DEGREES || oclop == OCL_OP_PHASE_RADIANS ? 1 : ocl::predictOptimalVectorWidth(_src1, _src2, _dst); @@ -147,7 +149,9 @@ void magnitude( InputArray src1, InputArray src2, OutputArray dst ) { CV_INSTRUMENT_REGION(); - int type = src1.type(), depth = src1.depth(), cn = src1.channels(); + int type = src1.type(); + ElemDepth depth = src1.depth(); + int cn = src1.channels(); CV_Assert( src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F)); CV_OCL_RUN(dst.isUMat() && src1.dims() <= 2 && src2.dims() <= 2, @@ -183,7 +187,9 @@ void phase( InputArray src1, InputArray src2, OutputArray dst, bool angleInDegre { CV_INSTRUMENT_REGION(); - int type = src1.type(), depth = src1.depth(), cn = src1.channels(); + ElemType type = src1.type(); + ElemDepth depth = src1.depth(); + int cn = src1.channels(); CV_Assert( src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F)); CV_OCL_RUN(dst.isUMat() && src1.dims() <= 2 && src2.dims() <= 2, @@ -228,7 +234,9 @@ static bool ocl_cartToPolar( InputArray _src1, InputArray _src2, OutputArray _dst1, OutputArray _dst2, bool angleInDegrees ) { const ocl::Device & d = ocl::Device::getDefault(); - int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src1.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -273,7 +281,9 @@ void cartToPolar( InputArray src1, InputArray src2, ocl_cartToPolar(src1, src2, dst1, dst2, angleInDegrees)) Mat X = src1.getMat(), Y = src2.getMat(); - int type = X.type(), depth = X.depth(), cn = X.channels(); + ElemType type = X.type(); + ElemDepth depth = X.depth(); + int cn = X.channels(); CV_Assert( X.size == Y.size && type == Y.type() && (depth == CV_32F || depth == CV_64F)); dst1.create( X.dims, X.size, type ); dst2.create( X.dims, X.size, type ); @@ -466,7 +476,9 @@ static bool ocl_polarToCart( InputArray _mag, InputArray _angle, OutputArray _dst1, OutputArray _dst2, bool angleInDegrees ) { const ocl::Device & d = ocl::Device::getDefault(); - int type = _angle.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _angle.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -503,7 +515,7 @@ static bool ipp_polarToCart(Mat &mag, Mat &angle, Mat &x, Mat &y) { CV_INSTRUMENT_REGION_IPP(); - int depth = angle.depth(); + ElemDepth depth = angle.depth(); if(depth != CV_32F && depth != CV_64F) return false; @@ -562,7 +574,9 @@ void polarToCart( InputArray src1, InputArray src2, { CV_INSTRUMENT_REGION(); - int type = src2.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = src2.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert((depth == CV_32F || depth == CV_64F) && (src1.empty() || src1.type() == type)); CV_OCL_RUN(!src1.empty() && src2.dims() <= 2 && dst1.isUMat() && dst2.isUMat(), @@ -665,7 +679,9 @@ void exp( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = _src.depth(), cn = _src.channels(); + ElemType type = _src.type(); + ElemDepth depth = _src.depth(); + int cn = _src.channels(); CV_Assert( depth == CV_32F || depth == CV_64F ); CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2, @@ -698,7 +714,9 @@ void log( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = _src.depth(), cn = _src.channels(); + ElemType type = _src.type(); + ElemDepth depth = _src.depth(); + int cn = _src.channels(); CV_Assert( depth == CV_32F || depth == CV_64F ); CV_OCL_RUN( _dst.isUMat() && _src.dims() <= 2, @@ -1136,7 +1154,9 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst, bool is_ipower, int ipower) { const ocl::Device & d = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = d.isIntel() ? 4 : 1; bool doubleSupport = d.doubleFPConfig() > 0; @@ -1204,8 +1224,9 @@ void pow( InputArray _src, double power, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), - cn = CV_MAT_CN(type), ipower = cvRound(power); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), ipower = cvRound(power); bool is_ipower = fabs(ipower - power) < DBL_EPSILON; #ifdef HAVE_OPENCL bool useOpenCL = _dst.isUMat() && _src.dims() <= 2; @@ -1396,7 +1417,7 @@ template<> struct mat_type_assotiations static const type max_allowable = INT_MAX; }; -template +template static bool checkIntegerRange(cv::Mat src, Point& bad_pt, int minVal, int maxVal) { typedef mat_type_assotiations type_ass; @@ -1462,7 +1483,7 @@ bool checkRange(InputArray _src, bool quiet, Point* pt, double minVal, double ma return true; } - int depth = src.depth(); + ElemDepth depth = src.depth(); Point badPt(-1, -1); if (depth < CV_32F) @@ -1740,9 +1761,9 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots ) const int n0 = 3; Mat coeffs = _coeffs.getMat(); - int ctype = coeffs.type(); + ElemType ctype = coeffs.type(); - CV_Assert( ctype == CV_32F || ctype == CV_64F ); + CV_Assert(ctype == CV_32FC1 || ctype == CV_64FC1); CV_Assert( (coeffs.size() == Size(n0, 1) || coeffs.size() == Size(n0+1, 1) || coeffs.size() == Size(1, n0) || @@ -1890,8 +1911,8 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) double maxDiff = 0; int iter, i, j; Mat coeffs0 = _coeffs0.getMat(); - int ctype = _coeffs0.type(); - int cdepth = CV_MAT_DEPTH(ctype); + ElemType ctype = _coeffs0.type(); + ElemDepth cdepth = CV_MAT_DEPTH(ctype); CV_Assert( CV_MAT_DEPTH(ctype) >= CV_32F && CV_MAT_CN(ctype) <= 2 ); CV_Assert( coeffs0.rows == 1 || coeffs0.cols == 1 ); @@ -1904,7 +1925,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) AutoBuffer buf(n*2+2); C *coeffs = buf.data(), *roots = coeffs + n + 1; Mat coeffs1(coeffs0.size(), CV_MAKETYPE(CV_64F, coeffs0.channels()), coeffs0.channels() == 2 ? coeffs : roots); - coeffs0.convertTo(coeffs1, coeffs1.type()); + coeffs0.convertTo(coeffs1, coeffs1.depth()); if( coeffs0.channels() == 1 ) { const double* rcoeffs = (const double*)roots; @@ -1999,7 +2020,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) for( ; n < n0; n++ ) roots[n+1] = roots[n]; - Mat(roots0.size(), CV_64FC2, roots).convertTo(roots0, roots0.type()); + Mat(roots0.size(), CV_64FC2, roots).convertTo(roots0, roots0.depth()); return maxDiff; } diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 7cd89c622210..7c083e69049b 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -700,7 +700,8 @@ static void GEMMStore_64fc( const Complexd* c_data, size_t c_step, static bool ocl_gemm_amdblas( InputArray matA, InputArray matB, double alpha, InputArray matC, double beta, OutputArray matD, int flags ) { - int type = matA.type(), esz = CV_ELEM_SIZE(type); + ElemType type = matA.type(); + int esz = CV_ELEM_SIZE(type); bool haveC = matC.kind() != cv::_InputArray::NONE; Size sizeA = matA.size(), sizeB = matB.size(), sizeC = haveC ? matC.size() : Size(0, 0); bool atrans = (flags & GEMM_1_T) != 0, btrans = (flags & GEMM_2_T) != 0, ctrans = (flags & GEMM_3_T) != 0; @@ -793,8 +794,9 @@ static bool ocl_gemm_amdblas( InputArray matA, InputArray matB, double alpha, static bool ocl_gemm( InputArray matA, InputArray matB, double alpha, InputArray matC, double beta, OutputArray matD, int flags ) { - int depth = matA.depth(), cn = matA.channels(); - int type = CV_MAKETYPE(depth, cn); + ElemDepth depth = matA.depth(); + int cn = matA.channels(); + ElemType type = CV_MAKETYPE(depth, cn); CV_Assert_N( type == matB.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) ); @@ -905,7 +907,8 @@ static void gemmImpl( Mat A, Mat B, double alpha, static float zerof[] = {0,0,0,0}; Size a_size = A.size(), d_size; - int i, len = 0, type = A.type(); + int i, len = 0; + ElemType type = A.type(); switch( flags & (GEMM_1_T|GEMM_2_T) ) { @@ -929,7 +932,7 @@ static void gemmImpl( Mat A, Mat B, double alpha, if( flags == 0 && 2 <= len && len <= 4 && (len == d_size.width || len == d_size.height) ) { - if( type == CV_32F ) + if (type == CV_32FC1) { float* d = D.ptr(); const float *a = A.ptr(), @@ -1057,7 +1060,7 @@ static void gemmImpl( Mat A, Mat B, double alpha, } } - if( type == CV_64F ) + if (type == CV_64FC1) { double* d = D.ptr(); const double *a = A.ptr(), @@ -1442,7 +1445,7 @@ static void gemmImpl( Mat A, Mat B, double alpha, template inline static void callGemmImpl(const fptype *src1, size_t src1_step, const fptype *src2, size_t src2_step, fptype alpha, - const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int m_a, int n_a, int n_d, int flags, int type) + const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int m_a, int n_a, int n_d, int flags, ElemType type) { CV_StaticAssert(GEMM_1_T == CV_HAL_GEMM_1_T, "Incompatible GEMM_1_T flag in HAL"); CV_StaticAssert(GEMM_2_T == CV_HAL_GEMM_2_T, "Incompatible GEMM_2_T flag in HAL"); @@ -1510,7 +1513,7 @@ void cv::hal::gemm32f(const float* src1, size_t src1_step, const float* src2, si { CALL_HAL(gemm32f, cv_hal_gemm32f, src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags) - callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_32F); + callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_32FC1); } void cv::hal::gemm64f(const double* src1, size_t src1_step, const double* src2, size_t src2_step, @@ -1518,7 +1521,7 @@ void cv::hal::gemm64f(const double* src1, size_t src1_step, const double* src2, int m_a, int n_a, int n_d, int flags) { CALL_HAL(gemm64f, cv_hal_gemm64f, src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags) - callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_64F); + callGemmImpl(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m_a, n_a, n_d, flags, CV_64FC1); } CV_EXPORTS void cv::hal::gemm32fc(const float* src1, size_t src1_step, const float* src2, size_t src2_step, @@ -1553,7 +1556,8 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha, Mat A = matA.getMat(), B = matB.getMat(), C = beta != 0.0 ? matC.getMat() : Mat(); Size a_size = A.size(), d_size; - int len = 0, type = A.type(); + int len = 0; + ElemType type = A.type(); CV_Assert_N( type == B.type(), (type == CV_32FC1 || type == CV_64FC1 || type == CV_32FC2 || type == CV_64FC2) ); @@ -2053,7 +2057,7 @@ diagtransform_64f(const double* src, double* dst, const double* m, int len, int typedef void (*TransformFunc)( const uchar* src, uchar* dst, const uchar* m, int, int, int ); -static TransformFunc getTransformFunc(int depth) +static TransformFunc getTransformFunc(ElemDepth depth) { static TransformFunc transformTab[] = { @@ -2065,7 +2069,7 @@ static TransformFunc getTransformFunc(int depth) return transformTab[depth]; } -static TransformFunc getDiagTransformFunc(int depth) +static TransformFunc getDiagTransformFunc(ElemDepth depth) { static TransformFunc diagTransformTab[] = { @@ -2084,14 +2088,15 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), m = _mtx.getMat(); - int depth = src.depth(), scn = src.channels(), dcn = m.rows; + ElemDepth depth = src.depth(); + int scn = src.channels(), dcn = m.rows; CV_Assert( scn == m.cols || scn + 1 == m.cols ); bool isDiag = false; _dst.create( src.size(), CV_MAKETYPE(depth, dcn) ); Mat dst = _dst.getMat(); - int mtype = depth == CV_32S || depth == CV_64F ? CV_64F : CV_32F; + ElemType mtype = depth == CV_32S || depth == CV_64F ? CV_64FC1 : CV_32FC1; AutoBuffer _mbuf; double* mbuf; @@ -2102,11 +2107,11 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) Mat tmp(dcn, scn+1, mtype, mbuf); memset(tmp.ptr(), 0, tmp.total()*tmp.elemSize()); if( m.cols == scn+1 ) - m.convertTo(tmp, mtype); + m.convertTo(tmp, CV_MAT_DEPTH(mtype)); else { Mat tmppart = tmp.colRange(0, m.cols); - m.convertTo(tmppart, mtype); + m.convertTo(tmppart, CV_MAT_DEPTH(mtype)); } m = tmp; } @@ -2116,16 +2121,16 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) if( scn == dcn ) { int i, j; - double eps = mtype == CV_32F ? FLT_EPSILON : DBL_EPSILON; + double eps = mtype == CV_32FC1 ? FLT_EPSILON : DBL_EPSILON; if( scn == 1 ) { double alpha, beta; - if( mtype == CV_32F ) + if (mtype == CV_32FC1) alpha = m.at(0), beta = m.at(1); else alpha = m.at(0), beta = m.at(1); - src.convertTo(dst, dst.type(), alpha, beta); + src.convertTo(dst, dst.depth(), alpha, beta); return; } @@ -2133,7 +2138,7 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx ) { for( j = 0; isDiag && j < scn; j++ ) { - double v = mtype == CV_32F ? m.at(i, j) : m.at(i, j); + double v = mtype == CV_32FC1 ? m.at(i, j) : m.at(i, j); if( i != j && fabs(v) > eps ) isDiag = false; } @@ -2264,14 +2269,15 @@ void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mt CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), m = _mtx.getMat(); - int depth = src.depth(), scn = src.channels(), dcn = m.rows-1; + ElemDepth depth = src.depth(); + int scn = src.channels(), dcn = m.rows - 1; CV_Assert( scn + 1 == m.cols ); CV_Assert( depth == CV_32F || depth == CV_64F ); _dst.create( src.size(), CV_MAKETYPE(depth, dcn) ); Mat dst = _dst.getMat(); - const int mtype = CV_64F; + const ElemType mtype = CV_64FC1; AutoBuffer _mbuf; double* mbuf = m.ptr(); @@ -2280,7 +2286,7 @@ void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mt _mbuf.allocate((dcn+1)*(scn+1)); mbuf = _mbuf.data(); Mat tmp(dcn+1, scn+1, mtype, mbuf); - m.convertTo(tmp, mtype); + m.convertTo(tmp, CV_MAT_DEPTH(mtype)); m = tmp; } @@ -2358,18 +2364,19 @@ typedef void (*ScaleAddFunc)(const uchar* src1, const uchar* src2, uchar* dst, i #ifdef HAVE_OPENCL -static bool ocl_scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray _dst, int type ) +static bool ocl_scaleAdd(InputArray _src1, double alpha, InputArray _src2, OutputArray _dst, ElemType type) { const ocl::Device & d = ocl::Device::getDefault(); bool doubleSupport = d.doubleFPConfig() > 0; Size size = _src1.size(); - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); if ( (!doubleSupport && depth == CV_64F) || size != _src2.size() ) return false; _dst.create(size, type); - int cn = CV_MAT_CN(type), wdepth = std::max(depth, CV_32F); + int cn = CV_MAT_CN(type); + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32F); int kercn = ocl::predictOptimalVectorWidthMax(_src1, _src2, _dst), rowsPerWI = d.isIntel() ? 4 : 1; @@ -2410,7 +2417,9 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray { CV_INSTRUMENT_REGION(); - int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src1.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert( type == _src2.type() ); CV_OCL_RUN(_src1.dims() <= 2 && _src2.dims() <= 2 && _dst.isUMat(), @@ -2453,25 +2462,26 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray * Covariation Matrix * \****************************************************************************************/ -void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int flags, int ctype ) +void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, int flags, ElemDepth cdepth ) { CV_INSTRUMENT_REGION(); CV_Assert_N( data, nsamples > 0 ); Size size = data[0].size(); int sz = size.width * size.height, esz = (int)data[0].elemSize(); - int type = data[0].type(); + ElemType type = data[0].type(); Mat mean; - ctype = std::max(std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), _mean.depth()), CV_32F); + cdepth = CV_MAT_DEPTH(cdepth); /* backwards compatibility */ + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), _mean.depth(), CV_32F); if( (flags & CV_COVAR_USE_AVG) != 0 ) { CV_Assert( _mean.size() == size ); - if( _mean.isContinuous() && _mean.type() == ctype ) + if (_mean.isContinuous() && _mean.depth() == cdepth) mean = _mean.reshape(1, 1); else { - _mean.convertTo(mean, ctype); + _mean.convertTo(mean, cdepth); mean = mean.reshape(1, 1); } } @@ -2490,15 +2500,16 @@ void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean, } } - 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, cdepth); if( (flags & CV_COVAR_USE_AVG) == 0 ) _mean = mean.reshape(1, size.height); } -void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, int ctype ) +void cv::calcCovarMatrix(InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, ElemDepth cdepth) { CV_INSTRUMENT_REGION(); + cdepth = CV_MAT_DEPTH(cdepth); /* backwards compatibility */ if(_src.kind() == _InputArray::STD_VECTOR_MAT || _src.kind() == _InputArray::STD_ARRAY_MAT) { std::vector src; @@ -2507,9 +2518,9 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray CV_Assert( src.size() > 0 ); Size size = src[0].size(); - int type = src[0].type(); + ElemType type = src[0].type(); - ctype = std::max(std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), _mean.depth()), CV_32F); + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), _mean.depth(), CV_32F); Mat _data(static_cast(src.size()), size.area(), type); @@ -2526,19 +2537,19 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray { CV_Assert( _mean.size() == size ); - if( mean.type() != ctype ) + if (mean.depth() != cdepth) { mean = _mean.getMat(); - _mean.create(mean.size(), ctype); + _mean.create(mean.size(), CV_MAKETYPE(cdepth, 1)); Mat tmp = _mean.getMat(); - mean.convertTo(tmp, ctype); + mean.convertTo(tmp, cdepth); mean = tmp; } 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, cdepth); if( (flags & CV_COVAR_USE_AVG) == 0 ) { @@ -2551,7 +2562,7 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray Mat data = _src.getMat(), mean; CV_Assert( ((flags & CV_COVAR_ROWS) != 0) ^ ((flags & CV_COVAR_COLS) != 0) ); bool takeRows = (flags & CV_COVAR_ROWS) != 0; - int type = data.type(); + ElemType 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); @@ -2559,25 +2570,25 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray 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); + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), mean.depth(), CV_32F); CV_Assert( mean.size() == size ); - if( mean.type() != ctype ) + if (mean.depth() != cdepth) { - _mean.create(mean.size(), ctype); + _mean.create(mean.size(), CV_MAKETYPE(cdepth, 1)); Mat tmp = _mean.getMat(); - mean.convertTo(tmp, ctype); + mean.convertTo(tmp, cdepth); mean = tmp; } } else { - ctype = std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), CV_32F); - reduce( _src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype ); + cdepth = CV_MAX_DEPTH(cdepth >= CV_8U ? cdepth : CV_MAT_DEPTH(type), CV_32F); + reduce(_src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, cdepth); mean = _mean.getMat(); } mulTransposed( data, _covar, ((flags & CV_COVAR_NORMAL) == 0) ^ takeRows, - mean, (flags & CV_COVAR_SCALE) != 0 ? 1./nsamples : 1, ctype ); + mean, (flags & CV_COVAR_SCALE) != 0 ? 1. / nsamples : 1, cdepth); } /****************************************************************************************\ @@ -2589,7 +2600,8 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar ) CV_INSTRUMENT_REGION(); Mat v1 = _v1.getMat(), v2 = _v2.getMat(), icovar = _icovar.getMat(); - int type = v1.type(), depth = v1.depth(); + ElemType type = v1.type(); + ElemDepth depth = v1.depth(); Size sz = v1.size(); int i, j, len = sz.width*sz.height*v1.channels(); AutoBuffer buf(len); @@ -2876,14 +2888,14 @@ typedef void (*MulTransposedFunc)(const Mat& src, Mat& dst, const Mat& delta, do } void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata, - InputArray _delta, double scale, int dtype ) + InputArray _delta, double scale, ElemDepth ddepth ) { CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), delta = _delta.getMat(); const int gemm_level = 100; // boundary above which GEMM is faster. - int stype = src.type(); - dtype = std::max(std::max(CV_MAT_DEPTH(dtype >= 0 ? dtype : stype), delta.depth()), CV_32F); + ElemDepth sdepth = src.depth(); + ddepth = CV_MAX_DEPTH(ddepth >= CV_8U ? ddepth : sdepth, delta.depth(), CV_32F); CV_Assert( src.channels() == 1 ); if( !delta.empty() ) @@ -2891,15 +2903,15 @@ void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata, CV_Assert_N( delta.channels() == 1, (delta.rows == src.rows || delta.rows == 1), (delta.cols == src.cols || delta.cols == 1)); - if( delta.type() != dtype ) - delta.convertTo(delta, dtype); + if (delta.depth() != ddepth) + delta.convertTo(delta, ddepth); } int dsize = ata ? src.cols : src.rows; - _dst.create( dsize, dsize, dtype ); + _dst.create(dsize, dsize, CV_MAKETYPE(ddepth, 1)); Mat dst = _dst.getMat(); - if( src.data == dst.data || (stype == dtype && + if (src.data == dst.data || (sdepth == ddepth && (dst.cols >= gemm_level && dst.rows >= gemm_level && src.cols >= gemm_level && src.rows >= gemm_level))) { @@ -2921,63 +2933,63 @@ void cv::mulTransposed( InputArray _src, OutputArray _dst, bool ata, else { MulTransposedFunc func = 0; - if(stype == CV_8U && dtype == CV_32F) + if (sdepth == CV_8U && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_8U && dtype == CV_64F) + else if (sdepth == CV_8U && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16U && dtype == CV_32F) + else if (sdepth == CV_16U && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16U && dtype == CV_64F) + else if (sdepth == CV_16U && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16S && dtype == CV_32F) + else if (sdepth == CV_16S && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_16S && dtype == CV_64F) + else if (sdepth == CV_16S && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_32F && dtype == CV_32F) + else if (sdepth == CV_32F && ddepth == CV_32F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_32F && dtype == CV_64F) + else if (sdepth == CV_32F && ddepth == CV_64F) { if(ata) func = MulTransposedR; else func = MulTransposedL; } - else if(stype == CV_64F && dtype == CV_64F) + else if (sdepth == CV_64F && ddepth == CV_64F) { if(ata) func = MulTransposedR; @@ -3271,7 +3283,7 @@ static double dotProd_64f(const double* src1, const double* src2, int len) typedef double (*DotProdFunc)(const uchar* src1, const uchar* src2, int len); -static DotProdFunc getDotProdFunc(int depth) +static DotProdFunc getDotProdFunc(ElemDepth depth) { static DotProdFunc dotProdTab[] = { @@ -3345,8 +3357,8 @@ cvTransform( const CvArr* srcarr, CvArr* dstarr, { cv::Mat v = cv::cvarrToMat(shiftvec).reshape(1,m.rows), _m(m.rows, m.cols + 1, m.type()), m1 = _m.colRange(0,m.cols), v1 = _m.col(m.cols); - m.convertTo(m1, m1.type()); - v.convertTo(v1, v1.type()); + m.convertTo(m1, m1.depth()); + v.convertTo(v1, v1.depth()); m = _m; } @@ -3389,21 +3401,21 @@ cvCalcCovarMatrix( const CvArr** vecarr, int count, { cv::Mat data = cv::cvarrToMat(vecarr[0]); - cv::calcCovarMatrix( data, cov, mean, flags, cov.type() ); + cv::calcCovarMatrix( data, cov, mean, flags, cov.depth() ); } else { std::vector data(count); for( int i = 0; i < count; i++ ) data[i] = cv::cvarrToMat(vecarr[i]); - cv::calcCovarMatrix( &data[0], count, cov, mean, flags, cov.type() ); + cv::calcCovarMatrix(&data[0], count, cov, mean, flags, cov.depth()); } if( mean.data != mean0.data && mean0.data ) - mean.convertTo(mean0, mean0.type()); + mean.convertTo(mean0, mean0.depth()); if( cov.data != cov0.data ) - cov.convertTo(cov0, cov0.type()); + cov.convertTo(cov0, cov0.depth()); } @@ -3421,9 +3433,9 @@ cvMulTransposed( const CvArr* srcarr, CvArr* dstarr, cv::Mat src = cv::cvarrToMat(srcarr), dst0 = cv::cvarrToMat(dstarr), dst = dst0, delta; if( deltaarr ) delta = cv::cvarrToMat(deltaarr); - cv::mulTransposed( src, dst, order != 0, delta, scale, dst.type()); + cv::mulTransposed( src, dst, order != 0, delta, scale, dst.depth()); if( dst.data != dst0.data ) - dst.convertTo(dst0, dst0.type()); + dst.convertTo(dst0, dst0.depth()); } CV_IMPL double cvDotProduct( const CvArr* srcAarr, const CvArr* srcBarr ) @@ -3448,10 +3460,10 @@ cvCalcPCA( const CvArr* data_arr, CvArr* avg_arr, CvArr* eigenvals, CvArr* eigen flags, !evals.empty() ? evals.rows + evals.cols - 1 : 0); if( pca.mean.size() == mean.size() ) - pca.mean.convertTo( mean, mean.type() ); + pca.mean.convertTo(mean, mean.depth()); else { - cv::Mat temp; pca.mean.convertTo( temp, mean.type() ); + cv::Mat temp; pca.mean.convertTo(temp, mean.depth()); transpose( temp, mean ); } @@ -3467,12 +3479,12 @@ cvCalcPCA( const CvArr* data_arr, CvArr* avg_arr, CvArr* eigenvals, CvArr* eigen cv::Mat temp = evals0; if( evals.rows == 1 ) - evals.colRange(0, ecount0).convertTo(temp, evals0.type()); + evals.colRange(0, ecount0).convertTo(temp, evals0.depth()); else - evals.rowRange(0, ecount0).convertTo(temp, evals0.type()); + evals.rowRange(0, ecount0).convertTo(temp, evals0.depth()); if( temp.data != evals0.data ) transpose(temp, evals0); - evects.rowRange(0, ecount0).convertTo( evects0, evects0.type() ); + evects.rowRange(0, ecount0).convertTo(evects0, evects0.depth()); // otherwise some datatype's or size's were incorrect, so the output arrays have been reallocated CV_Assert( mean0.data == mean.data ); @@ -3504,7 +3516,7 @@ cvProjectPCA( const CvArr* data_arr, const CvArr* avg_arr, cv::Mat result = pca.project(data); if( result.cols != dst.cols ) result = result.reshape(1, 1); - result.convertTo(dst, dst.type()); + result.convertTo(dst, dst.depth()); CV_Assert(dst0.data == dst.data); } @@ -3533,7 +3545,7 @@ cvBackProjectPCA( const CvArr* proj_arr, const CvArr* avg_arr, pca.eigenvectors = evects.rowRange(0, n); cv::Mat result = pca.backProject(data); - result.convertTo(dst, dst.type()); + result.convertTo(dst, dst.depth()); CV_Assert(dst0.data == dst.data); } diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index a353eee8c432..65c3f52e4135 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -38,8 +38,8 @@ void MatAllocator::download(UMatData* u, void* dstptr, isz[i] = (int)sz[i]; } - Mat src(dims, isz, CV_8U, srcptr, srcstep); - Mat dst(dims, isz, CV_8U, dstptr, dststep); + Mat src(dims, isz, CV_8UC1, srcptr, srcstep); + Mat dst(dims, isz, CV_8UC1, dstptr, dststep); const Mat* arrays[] = { &src, &dst }; uchar* ptrs[2]; @@ -69,8 +69,8 @@ void MatAllocator::upload(UMatData* u, const void* srcptr, int dims, const size_ isz[i] = (int)sz[i]; } - Mat src(dims, isz, CV_8U, (void*)srcptr, srcstep); - Mat dst(dims, isz, CV_8U, dstptr, dststep); + Mat src(dims, isz, CV_8UC1, (void*)srcptr, srcstep); + Mat dst(dims, isz, CV_8UC1, dstptr, dststep); const Mat* arrays[] = { &src, &dst }; uchar* ptrs[2]; @@ -104,8 +104,8 @@ void MatAllocator::copy(UMatData* usrc, UMatData* udst, int dims, const size_t s isz[i] = (int)sz[i]; } - Mat src(dims, isz, CV_8U, srcptr, srcstep); - Mat dst(dims, isz, CV_8U, dstptr, dststep); + Mat src(dims, isz, CV_8UC1, srcptr, srcstep); + Mat dst(dims, isz, CV_8UC1, dstptr, dststep); const Mat* arrays[] = { &src, &dst }; uchar* ptrs[2]; @@ -126,7 +126,7 @@ BufferPoolController* MatAllocator::getBufferPoolController(const char* id) cons class StdMatAllocator CV_FINAL : public MatAllocator { public: - UMatData* allocate(int dims, const int* sizes, int type, + UMatData* allocate(int dims, const int* sizes, ElemType type, void* data0, size_t* step, AccessFlag /*flags*/, UMatUsageFlags /*usageFlags*/) const CV_OVERRIDE { size_t total = CV_ELEM_SIZE(type); @@ -262,7 +262,7 @@ void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool auto } } -int updateContinuityFlag(int flags, int dims, const int* size, const size_t* step) +MagicFlag updateContinuityFlag(MagicFlag flags, int dims, const int* size, const size_t* step) { int i, j; for( i = 0; i < dims; i++ ) @@ -280,8 +280,8 @@ int updateContinuityFlag(int flags, int dims, const int* size, const size_t* ste } if( j <= i && t == (uint64)(int)t ) - return flags | Mat::CONTINUOUS_FLAG; - return flags & ~Mat::CONTINUOUS_FLAG; + return flags | static_cast(Mat::CONTINUOUS_FLAG); + return flags & static_cast(~Mat::CONTINUOUS_FLAG); } void Mat::updateContinuityFlag() @@ -315,7 +315,7 @@ void finalizeHdr(Mat& m) //================================================================================================== -void Mat::create(int d, const int* _sizes, int _type) +void Mat::create(int d, const int* _sizes, ElemType _type) { int i; CV_Assert(0 <= d && d <= CV_MAX_DIM && _sizes); @@ -343,7 +343,7 @@ void Mat::create(int d, const int* _sizes, int _type) release(); if( d == 0 ) return; - flags = (_type & CV_MAT_TYPE_MASK) | MAGIC_VAL; + flags = static_cast(MAGIC_VAL) | (_type & CV_MAT_TYPE_MASK); setSize(*this, d, _sizes, 0, true); if( total() > 0 ) @@ -373,7 +373,7 @@ void Mat::create(int d, const int* _sizes, int _type) finalizeHdr(*this); } -void Mat::create(const std::vector& _sizes, int _type) +void Mat::create(const std::vector& _sizes, ElemType _type) { create((int)_sizes.size(), _sizes.data(), _type); } @@ -399,7 +399,7 @@ void Mat::deallocate() } Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { CV_Assert( m.dims >= 2 ); @@ -423,7 +423,7 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) && _rowRange.end <= m.rows ); rows = _rowRange.size(); data += step*_rowRange.start; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } if( _colRange != Range::all() && _colRange != Range(0,cols) ) @@ -432,7 +432,7 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) && _colRange.end <= m.cols ); cols = _colRange.size(); data += _colRange.start*elemSize(); - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } CV_CATCH_ALL @@ -466,7 +466,7 @@ Mat::Mat(const Mat& m, const Rect& roi) if( u ) CV_XADD(&u->refcount, 1); if( roi.width < m.cols || roi.height < m.rows ) - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); step[0] = m.step[0]; step[1] = esz; updateContinuityFlag(); @@ -479,8 +479,8 @@ Mat::Mat(const Mat& m, const Rect& roi) } -Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _steps) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(int _dims, const int* _sizes, ElemType _type, void* _data, const size_t* _steps) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { flags |= CV_MAT_TYPE(_type); @@ -490,8 +490,8 @@ Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _st } -Mat::Mat(const std::vector& _sizes, int _type, void* _data, const size_t* _steps) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), +Mat::Mat(const std::vector& _sizes, ElemType _type, void* _data, const size_t* _steps) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { flags |= CV_MAT_TYPE(_type); @@ -502,7 +502,7 @@ Mat::Mat(const std::vector& _sizes, int _type, void* _data, const size_t* _ Mat::Mat(const Mat& m, const Range* ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { int d = m.dims; @@ -521,14 +521,14 @@ Mat::Mat(const Mat& m, const Range* ranges) { size.p[i] = r.end - r.start; data += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); } Mat::Mat(const Mat& m, const std::vector& ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) { int d = m.dims; @@ -547,7 +547,7 @@ Mat::Mat(const Mat& m, const std::vector& ranges) { size.p[i] = r.end - r.start; data += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); @@ -580,7 +580,7 @@ Mat Mat::diag(int d) const m.updateContinuityFlag(); if( size() != Size(1,1) ) - m.flags |= SUBMATRIX_FLAG; + m.flags |= static_cast(SUBMATRIX_FLAG); return m; } @@ -614,7 +614,7 @@ void Mat::push_back_(const void* elem) for( int i = 1; i < dims; i++ ) tsz *= size.p[i]; if( esz < step.p[0] || tsz != (uint64)(int)tsz ) - flags &= ~CONTINUOUS_FLAG; + flags &= static_cast(~CONTINUOUS_FLAG); } @@ -654,7 +654,7 @@ void Mat::reserve(size_t nelems) void Mat::reserveBuffer(size_t nbytes) { size_t esz = 1; - int mtype = CV_8UC1; + ElemType mtype = CV_8UC1; if (!empty()) { if (!isSubmatrix() && data + nbytes <= dataend)//Should it be datalimit? @@ -931,9 +931,9 @@ Mat Mat::diag(const Mat& d) return m; } -int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const +int Mat::checkVector(int _elemChannels, ElemDepth _depth, bool _requireContinuous) const { - return data && (depth() == _depth || _depth <= 0) && + return data && (depth() == _depth || _depth <= CV_8U) && (isContinuous() || !_requireContinuous) && ((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) || (cols == _elemChannels && channels() == 1))) || diff --git a/modules/core/src/matrix_c.cpp b/modules/core/src/matrix_c.cpp index 1c3e58857cb4..bd44397646d4 100644 --- a/modules/core/src/matrix_c.cpp +++ b/modules/core/src/matrix_c.cpp @@ -11,7 +11,7 @@ CvMatND cvMatND(const cv::Mat& m) int i, d = m.dims; for( i = 0; i < d; i++ ) self.dim[i].step = (int)m.step[i]; - self.type |= m.flags & cv::Mat::CONTINUOUS_FLAG; + self.type |= m.flags & static_cast(cv::Mat::CONTINUOUS_FLAG); return self; } @@ -35,7 +35,7 @@ static Mat cvMatToMat(const CvMat* m, bool copyData) if( !copyData ) { - thiz.flags = Mat::MAGIC_VAL + (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG)); + thiz.flags = static_cast(Mat::MAGIC_VAL | (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG))); thiz.dims = 2; thiz.rows = m->rows; thiz.cols = m->cols; @@ -50,7 +50,7 @@ static Mat cvMatToMat(const CvMat* m, bool copyData) else { thiz.datastart = thiz.dataend = thiz.data = 0; - Mat(m->rows, m->cols, m->type, m->data.ptr, m->step).copyTo(thiz); + Mat(m->rows, m->cols, static_cast(m->type), m->data.ptr, m->step).copyTo(thiz); } return thiz; @@ -97,14 +97,14 @@ static Mat iplImageToMat(const IplImage* img, bool copyData) m.dims = 2; CV_DbgAssert(CV_IS_IMAGE(img) && img->imageData != 0); - int imgdepth = IPL2CV_DEPTH(img->depth); + ElemDepth imgdepth = static_cast(IPL2CV_DEPTH(img->depth)); size_t esz; m.step[0] = img->widthStep; if(!img->roi) { CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL); - m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, img->nChannels); + m.flags = static_cast(Mat::MAGIC_VAL) | CV_MAKETYPE(imgdepth, img->nChannels); m.rows = img->height; m.cols = img->width; m.datastart = m.data = (uchar*)img->imageData; @@ -114,7 +114,7 @@ static Mat iplImageToMat(const IplImage* img, bool copyData) { CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL || img->roi->coi != 0); bool selectedPlane = img->roi->coi && img->dataOrder == IPL_DATA_ORDER_PLANE; - m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels); + m.flags = static_cast(Mat::MAGIC_VAL) | CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels); m.rows = img->roi->height; m.cols = img->roi->width; esz = CV_ELEM_SIZE(m.flags); @@ -169,16 +169,16 @@ Mat cvarrToMat(const CvArr* arr, bool copyData, return Mat(); CV_Assert(total > 0 && CV_ELEM_SIZE(seq->flags) == esz); if(!copyData && seq->first->next == seq->first) - return Mat(total, 1, type, seq->first->data); + return Mat(total, 1, static_cast(type), seq->first->data); if( abuf ) { abuf->allocate(((size_t)total*esz + sizeof(double)-1)/sizeof(double)); double* bufdata = abuf->data(); cvCvtSeqToArray(seq, bufdata, CV_WHOLE_SEQ); - return Mat(total, 1, type, bufdata); + return Mat(total, 1, static_cast(type), bufdata); } - Mat buf(total, 1, type); + Mat buf(total, 1, static_cast(type)); cvCvtSeqToArray(seq, buf.ptr(), CV_WHOLE_SEQ); return buf; } @@ -188,7 +188,7 @@ Mat cvarrToMat(const CvArr* arr, bool copyData, void extractImageCOI(const CvArr* arr, OutputArray _ch, int coi) { Mat mat = cvarrToMat(arr, false, true, 1); - _ch.create(mat.dims, mat.size, mat.depth()); + _ch.create(mat.dims, mat.size, CV_MAKETYPE(mat.depth(), 1)); Mat ch = _ch.getMat(); if(coi < 0) { @@ -273,7 +273,7 @@ cvReduce( const CvArr* srcarr, CvArr* dstarr, int dim, int op ) if( src.channels() != dst.channels() ) CV_Error( CV_StsUnmatchedFormats, "Input and output arrays must have the same number of channels" ); - cv::reduce(src, dst, dim, op, dst.type()); + cv::reduce(src, dst, dim, op, dst.depth()); } @@ -342,7 +342,7 @@ cvSort( const CvArr* _src, CvArr* _dst, CvArr* _idx, int flags ) if( _idx ) { cv::Mat idx0 = cv::cvarrToMat(_idx), idx = idx0; - CV_Assert( src.size() == idx.size() && idx.type() == CV_32S && src.data != idx.data ); + CV_Assert( src.size() == idx.size() && idx.type() == CV_32SC1 && src.data != idx.data ); cv::sortIdx( src, idx, flags ); CV_Assert( idx0.data == idx.data ); } @@ -375,7 +375,7 @@ cvKMeans2( const CvArr* _samples, int cluster_count, CvArr* _labels, CV_Assert( centers.cols == data.cols ); CV_Assert( centers.depth() == data.depth() ); } - CV_Assert( labels.isContinuous() && labels.type() == CV_32S && + CV_Assert( labels.isContinuous() && labels.type() == CV_32SC1 && (labels.cols == 1 || labels.rows == 1) && labels.cols + labels.rows - 1 == data.rows ); diff --git a/modules/core/src/matrix_expressions.cpp b/modules/core/src/matrix_expressions.cpp index 243d6b039725..f3ab0280466a 100644 --- a/modules/core/src/matrix_expressions.cpp +++ b/modules/core/src/matrix_expressions.cpp @@ -21,7 +21,7 @@ class MatOp_Identity CV_FINAL : public MatOp virtual ~MatOp_Identity() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, const Mat& m); }; @@ -35,7 +35,7 @@ class MatOp_AddEx CV_FINAL : public MatOp virtual ~MatOp_AddEx() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void add(const MatExpr& e1, const Scalar& s, MatExpr& res) const CV_OVERRIDE; void subtract(const Scalar& s, const MatExpr& expr, MatExpr& res) const CV_OVERRIDE; @@ -57,7 +57,7 @@ class MatOp_Bin CV_FINAL : public MatOp virtual ~MatOp_Bin() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e1, double s, MatExpr& res) const CV_OVERRIDE; void divide(double s, const MatExpr& e, MatExpr& res) const CV_OVERRIDE; @@ -75,7 +75,7 @@ class MatOp_Cmp CV_FINAL : public MatOp virtual ~MatOp_Cmp() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return true; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, int cmpop, const Mat& a, const Mat& b); static void makeExpr(MatExpr& res, int cmpop, const Mat& a, double alpha); @@ -90,7 +90,7 @@ class MatOp_GEMM CV_FINAL : public MatOp virtual ~MatOp_GEMM() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void add(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const CV_OVERRIDE; void subtract(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const CV_OVERRIDE; @@ -111,7 +111,7 @@ class MatOp_Invert CV_FINAL : public MatOp virtual ~MatOp_Invert() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const CV_OVERRIDE; @@ -127,7 +127,7 @@ class MatOp_T CV_FINAL : public MatOp virtual ~MatOp_T() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e1, double s, MatExpr& res) const CV_OVERRIDE; void transpose(const MatExpr& expr, MatExpr& res) const CV_OVERRIDE; @@ -144,7 +144,7 @@ class MatOp_Solve CV_FINAL : public MatOp virtual ~MatOp_Solve() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; static void makeExpr(MatExpr& res, int method, const Mat& a, const Mat& b); }; @@ -158,12 +158,12 @@ class MatOp_Initializer CV_FINAL : public MatOp virtual ~MatOp_Initializer() {} bool elementWise(const MatExpr& /*expr*/) const CV_OVERRIDE { return false; } - void assign(const MatExpr& expr, Mat& m, int type=-1) const CV_OVERRIDE; + void assign(const MatExpr& expr, Mat& m, ElemDepth depth = CV_DEPTH_AUTO) const CV_OVERRIDE; void multiply(const MatExpr& e, double s, MatExpr& res) const CV_OVERRIDE; - static void makeExpr(MatExpr& res, int method, Size sz, int type, double alpha=1); - static void makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha=1); + static void makeExpr(MatExpr& res, int method, Size sz, ElemType type, double alpha = 1); + static void makeExpr(MatExpr& res, int method, int ndims, const int* sizes, ElemType type, double alpha = 1); }; static MatOp_Initializer* getGlobalMatOpInitializer() @@ -571,7 +571,7 @@ Size MatOp::size(const MatExpr& expr) const return !expr.a.empty() ? expr.a.size() : expr.b.empty() ? expr.b.size() : expr.c.size(); } -int MatOp::type(const MatExpr& expr) const +ElemType MatOp::type(const MatExpr& expr) const { CV_INSTRUMENT_REGION(); @@ -1178,28 +1178,30 @@ Size MatExpr::size() const } -int MatExpr::type() const +ElemType MatExpr::type() const { CV_INSTRUMENT_REGION(); if( isInitializer(*this) ) return a.type(); if( isCmp(*this) ) - return CV_8U; - return op ? op->type(*this) : -1; + return CV_8UC1; + return op ? op->type(*this) : CV_TYPE_AUTO; } ///////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Identity::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Identity::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if( _type == -1 || _type == e.a.type() ) + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + if (_depth == e.a.depth()) m = e.a; else { - CV_Assert( CV_MAT_CN(_type) == e.a.channels() ); - e.a.convertTo(m, _type); + e.a.convertTo(m, _depth); } } @@ -1210,9 +1212,12 @@ inline void MatOp_Identity::makeExpr(MatExpr& res, const Mat& m) ///////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_AddEx::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - Mat temp, &dst = _type == -1 || e.a.type() == _type ? m : temp; + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = e.a.depth() == _depth ? m : temp; if( e.b.data ) { if( e.s == Scalar() || !e.s.isReal() ) @@ -1244,7 +1249,7 @@ void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const } else if( e.s.isReal() && (dst.data != m.data || fabs(e.alpha) != 1)) { - e.a.convertTo(m, _type, e.alpha, e.s[0]); + e.a.convertTo(m, _depth, e.alpha, e.s[0]); return; } else if( e.alpha == 1 ) @@ -1253,12 +1258,12 @@ void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const cv::subtract(e.s, e.a, dst); else { - e.a.convertTo(dst, e.a.type(), e.alpha); + e.a.convertTo(dst, CV_MAT_DEPTH(e.a.depth()), e.alpha); cv::add(dst, e.s, dst); } if( dst.data != m.data ) - dst.convertTo(m, m.type()); + dst.convertTo(m, CV_MAT_DEPTH(m.depth())); } @@ -1331,9 +1336,12 @@ inline void MatOp_AddEx::makeExpr(MatExpr& res, const Mat& a, const Mat& b, doub ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Bin::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Bin::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - Mat temp, &dst = _type == -1 || e.a.type() == _type ? m : temp; + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = e.a.depth() == _depth ? m : temp; if( e.flags == '*' ) cv::multiply(e.a, e.b, dst, e.alpha); @@ -1371,7 +1379,7 @@ void MatOp_Bin::assign(const MatExpr& e, Mat& m, int _type) const CV_Error(CV_StsError, "Unknown operation"); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } void MatOp_Bin::multiply(const MatExpr& e, double s, MatExpr& res) const @@ -1409,9 +1417,13 @@ inline void MatOp_Bin::makeExpr(MatExpr& res, char op, const Mat& a, const Scala /////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Cmp::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Cmp::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - Mat temp, &dst = _type == -1 || _type == CV_8U ? m : temp; + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + //TODO: Investigate why CV_8U is coded here + Mat temp, &dst = _depth == e.a.depth() || _depth == CV_8U ? m : temp; if( e.b.data ) cv::compare(e.a, e.b, dst, e.flags); @@ -1419,7 +1431,7 @@ void MatOp_Cmp::assign(const MatExpr& e, Mat& m, int _type) const cv::compare(e.a, e.alpha, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } inline void MatOp_Cmp::makeExpr(MatExpr& res, int cmpop, const Mat& a, const Mat& b) @@ -1434,14 +1446,17 @@ inline void MatOp_Cmp::makeExpr(MatExpr& res, int cmpop, const Mat& a, double al ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_T::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_T::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::transpose(e.a, dst); if( dst.data != m.data || e.alpha != 1 ) - dst.convertTo(m, _type, e.alpha); + dst.convertTo(m, _depth, e.alpha); } void MatOp_T::multiply(const MatExpr& e, double s, MatExpr& res) const @@ -1469,13 +1484,16 @@ inline void MatOp_T::makeExpr(MatExpr& res, const Mat& a, double alpha) ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_GEMM::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_GEMM::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::gemm(e.a, e.b, e.alpha, e.c, e.beta, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } void MatOp_GEMM::add(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const @@ -1544,13 +1562,16 @@ inline void MatOp_GEMM::makeExpr(MatExpr& res, int flags, const Mat& a, const Ma /////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Invert::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Invert::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::invert(e.a, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } void MatOp_Invert::matmul(const MatExpr& e1, const MatExpr& e2, MatExpr& res) const @@ -1570,13 +1591,16 @@ inline void MatOp_Invert::makeExpr(MatExpr& res, int method, const Mat& m) ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Solve::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Solve::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - Mat temp, &dst = _type == -1 || _type == e.a.type() ? m : temp; + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); + + Mat temp, &dst = _depth == e.a.depth() ? m : temp; cv::solve(e.a, e.b, dst, e.flags); if( dst.data != m.data ) - dst.convertTo(m, _type); + dst.convertTo(m, _depth); } inline void MatOp_Solve::makeExpr(MatExpr& res, int method, const Mat& a, const Mat& b) @@ -1586,15 +1610,15 @@ inline void MatOp_Solve::makeExpr(MatExpr& res, int method, const Mat& a, const ////////////////////////////////////////////////////////////////////////////////////////////////////////// -void MatOp_Initializer::assign(const MatExpr& e, Mat& m, int _type) const +void MatOp_Initializer::assign(const MatExpr& e, Mat& m, ElemDepth _depth) const { - if( _type == -1 ) - _type = e.a.type(); + if (_depth == CV_DEPTH_AUTO) + _depth = e.a.depth(); if( e.a.dims <= 2 ) - m.create(e.a.size(), _type); + m.create(e.a.size(), CV_MAKETYPE(_depth, e.a.channels())); else - m.create(e.a.dims, e.a.size, _type); + m.create(e.a.dims, e.a.size, CV_MAKETYPE(_depth, e.a.channels())); if( e.flags == 'I' && e.a.dims <= 2 ) setIdentity(m, Scalar(e.alpha)); @@ -1614,12 +1638,12 @@ void MatOp_Initializer::multiply(const MatExpr& e, double s, MatExpr& res) const res.alpha *= s; } -inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, int type, double alpha) +inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, ElemType type, double alpha) { res = MatExpr(getGlobalMatOpInitializer(), method, Mat(sz, type, (void*)(size_t)0xEEEEEEEE), Mat(), Mat(), alpha, 0); } -inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha) +inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, int ndims, const int* sizes, ElemType type, double alpha) { res = MatExpr(getGlobalMatOpInitializer(), method, Mat(ndims, sizes, type, (void*)(size_t)0xEEEEEEEE), Mat(), Mat(), alpha, 0); } @@ -1660,7 +1684,7 @@ MatExpr Mat::mul(InputArray m, double scale) const return e; } -MatExpr Mat::zeros(int rows, int cols, int type) +MatExpr Mat::zeros(int rows, int cols, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1669,7 +1693,7 @@ MatExpr Mat::zeros(int rows, int cols, int type) return e; } -MatExpr Mat::zeros(Size size, int type) +MatExpr Mat::zeros(Size size, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1678,7 +1702,7 @@ MatExpr Mat::zeros(Size size, int type) return e; } -MatExpr Mat::zeros(int ndims, const int* sizes, int type) +MatExpr Mat::zeros(int ndims, const int* sizes, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1687,7 +1711,7 @@ MatExpr Mat::zeros(int ndims, const int* sizes, int type) return e; } -MatExpr Mat::ones(int rows, int cols, int type) +MatExpr Mat::ones(int rows, int cols, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1696,7 +1720,7 @@ MatExpr Mat::ones(int rows, int cols, int type) return e; } -MatExpr Mat::ones(Size size, int type) +MatExpr Mat::ones(Size size, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1705,7 +1729,7 @@ MatExpr Mat::ones(Size size, int type) return e; } -MatExpr Mat::ones(int ndims, const int* sizes, int type) +MatExpr Mat::ones(int ndims, const int* sizes, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1714,7 +1738,7 @@ MatExpr Mat::ones(int ndims, const int* sizes, int type) return e; } -MatExpr Mat::eye(int rows, int cols, int type) +MatExpr Mat::eye(int rows, int cols, ElemType type) { CV_INSTRUMENT_REGION(); @@ -1723,7 +1747,7 @@ MatExpr Mat::eye(int rows, int cols, int type) return e; } -MatExpr Mat::eye(Size size, int type) +MatExpr Mat::eye(Size size, ElemType type) { CV_INSTRUMENT_REGION(); diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index 6d865a51a91e..e20bbb01cb3c 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -143,8 +143,10 @@ namespace cv { static bool ocl_setIdentity( InputOutputArray _m, const Scalar& s ) { - int type = _m.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), kercn = cn, rowsPerWI = 1; - int sctype = CV_MAKE_TYPE(depth, cn == 3 ? 4 : cn); + ElemType type = _m.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), kercn = cn, rowsPerWI = 1; + ElemType sctype = CV_MAKE_TYPE(depth, cn == 3 ? 4 : cn); if (ocl::Device::getDefault().isIntel()) { rowsPerWI = 4; @@ -230,7 +232,7 @@ cv::Scalar cv::trace( InputArray _m ) Mat m = _m.getMat(); CV_Assert( m.dims <= 2 ); - int type = m.type(); + ElemType type = m.type(); int nm = std::min(m.rows, m.cols); if( type == CV_32FC1 ) @@ -370,8 +372,10 @@ static bool ocl_transpose( InputArray _src, OutputArray _dst ) { const ocl::Device & dev = ocl::Device::getDefault(); const int TILE_DIM = 32, BLOCK_ROWS = 8; - int type = _src.type(), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type), - rowsPerWI = dev.isIntel() ? 4 : 1; + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); + ElemDepth depth = CV_MAT_DEPTH(type); + int rowsPerWI = dev.isIntel() ? 4 : 1; UMat src = _src.getUMat(); _dst.create(src.cols, src.rows, type); @@ -425,7 +429,7 @@ static bool ipp_transpose( Mat &src, Mat &dst ) { CV_INSTRUMENT_REGION_IPP(); - int type = src.type(); + ElemType type = src.type(); typedef IppStatus (CV_STDCALL * IppiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize); typedef IppStatus (CV_STDCALL * IppiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize); IppiTranspose ippiTranspose = 0; @@ -494,7 +498,8 @@ void cv::transpose( InputArray _src, OutputArray _dst ) { CV_INSTRUMENT_REGION(); - int type = _src.type(), esz = CV_ELEM_SIZE(type); + ElemType type = _src.type(); + int esz = CV_ELEM_SIZE(type); CV_Assert( _src.dims() <= 2 && esz <= 32 ); CV_OCL_RUN(_dst.isUMat(), @@ -562,7 +567,8 @@ void cv::completeSymm( InputOutputArray _m, bool LtoR ) cv::Mat cv::Mat::cross(InputArray _m) const { Mat m = _m.getMat(); - int tp = type(), d = CV_MAT_DEPTH(tp); + ElemType tp = type(); + ElemDepth d = CV_MAT_DEPTH(tp); CV_Assert( dims <= 2 && m.dims <= 2 && size() == m.size() && tp == m.type() && ((rows == 3 && cols == 1) || (cols*channels() == 3 && rows == 1))); Mat result(rows, cols, tp); @@ -713,8 +719,8 @@ typedef void (*ReduceFunc)( const Mat& src, Mat& dst ); #ifdef HAVE_IPP static inline bool ipp_reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat) { - int sstep = (int)srcmat.step, stype = srcmat.type(), - ddepth = dstmat.depth(); + int sstep = (int)srcmat.step, stype = srcmat.type(); + ElemDepth ddepth = dstmat.depth(); IppiSize roisize = { srcmat.size().width, 1 }; @@ -771,7 +777,7 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds if(dstmat.depth() == CV_64F) { - int sdepth = CV_MAT_DEPTH(srcmat.type()); + ElemDepth sdepth = CV_MAT_DEPTH(srcmat.type()); func = sdepth == CV_8U ? (cv::ReduceFunc)cv::reduceC_ > : sdepth == CV_16U ? (cv::ReduceFunc)cv::reduceC_ > : @@ -860,11 +866,12 @@ REDUCE_OP(32f, Min, float, float) namespace cv { static bool ocl_reduce(InputArray _src, OutputArray _dst, - int dim, int op, int op0, int stype, int dtype) + int dim, int op, int op0, ElemType stype, ElemType dtype) { const int min_opt_cols = 128, buf_cols = 32; - int sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype), - ddepth = CV_MAT_DEPTH(dtype), ddepth0 = ddepth; + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + ElemDepth ddepth = CV_MAT_DEPTH(dtype), ddepth0 = ddepth; const ocl::Device &defDev = ocl::Device::getDefault(); bool doubleSupport = defDev.doubleFPConfig() > 0; @@ -882,7 +889,7 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst, const char * const ops[4] = { "OCL_CV_REDUCE_SUM", "OCL_CV_REDUCE_AVG", "OCL_CV_REDUCE_MAX", "OCL_CV_REDUCE_MIN" }; - int wdepth = std::max(ddepth, CV_32F); + ElemDepth wdepth = CV_MAX_DEPTH(ddepth, CV_32F); if (useOptimized) { size_t tileHeight = (size_t)(wgs / buf_cols); @@ -962,17 +969,19 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst, #endif -void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) +void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, ElemDepth ddepth) { CV_INSTRUMENT_REGION(); CV_Assert( _src.dims() <= 2 ); int op0 = op; - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); - if( dtype < 0 ) - dtype = _dst.fixedType() ? _dst.type() : stype; - dtype = CV_MAKETYPE(dtype >= 0 ? dtype : stype, cn); - int ddepth = CV_MAT_DEPTH(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = _src.depth(); + int cn = CV_MAT_CN(stype); + if (ddepth == CV_DEPTH_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : sdepth; + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); CV_Assert( cn == CV_MAT_CN(dtype) ); CV_Assert( op == CV_REDUCE_SUM || op == CV_REDUCE_MAX || @@ -1113,7 +1122,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype) func( src, temp ); if( op0 == CV_REDUCE_AVG ) - temp.convertTo(dst, dst.type(), 1./(dim == 0 ? src.rows : src.cols)); + temp.convertTo(dst, dst.depth(), 1. / (dim == 0 ? src.rows : src.cols)); } @@ -1174,7 +1183,7 @@ template static void sort_( const Mat& src, Mat& dst, int flags ) #ifdef HAVE_IPP typedef IppStatus (CV_STDCALL *IppSortFunc)(void *pSrcDst, int len, Ipp8u *pBuffer); -static IppSortFunc getSortFunc(int depth, bool sortDescending) +static IppSortFunc getSortFunc(ElemDepth depth, bool sortDescending) { if (!sortDescending) return depth == CV_8U ? (IppSortFunc)ippsSortRadixAscend_8u_I : @@ -1201,7 +1210,7 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags) bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW; bool sortDescending = (flags & CV_SORT_DESCENDING) != 0; bool inplace = (src.data == dst.data); - int depth = src.depth(); + ElemDepth depth = src.depth(); IppDataType type = ippiGetDataType(depth); IppSortFunc ippsSortRadix_I = getSortFunc(depth, sortDescending); @@ -1322,7 +1331,7 @@ template static void sortIdx_( const Mat& src, Mat& dst, int flags ) #ifdef HAVE_IPP typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(const void* pSrc, Ipp32s srcStrideBytes, Ipp32s *pDstIndx, int len, Ipp8u *pBuffer); -static IppSortIndexFunc getSortIndexFunc(int depth, bool sortDescending) +static IppSortIndexFunc getSortIndexFunc(ElemDepth depth, bool sortDescending) { if (!sortDescending) return depth == CV_8U ? (IppSortIndexFunc)ippsSortRadixIndexAscend_8u : @@ -1346,7 +1355,7 @@ static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags ) bool sortRows = (flags & 1) == SORT_EVERY_ROW; bool sortDescending = (flags & SORT_DESCENDING) != 0; - int depth = src.depth(); + ElemDepth depth = src.depth(); IppDataType type = ippiGetDataType(depth); IppSortIndexFunc ippsSortRadixIndex = getSortIndexFunc(depth, sortDescending); @@ -1432,7 +1441,7 @@ void cv::sortIdx( InputArray _src, OutputArray _dst, int flags ) Mat dst = _dst.getMat(); if( dst.data == src.data ) _dst.release(); - _dst.create( src.size(), CV_32S ); + _dst.create( src.size(), CV_32SC1 ); dst = _dst.getMat(); CV_IPP_RUN_FAST(ipp_sortIdx(src, dst, flags)); diff --git a/modules/core/src/matrix_sparse.cpp b/modules/core/src/matrix_sparse.cpp index 61e7e90a5659..7fa54235b5fa 100644 --- a/modules/core/src/matrix_sparse.cpp +++ b/modules/core/src/matrix_sparse.cpp @@ -149,7 +149,7 @@ static inline bool isZeroElem(const uchar* data, size_t elemSize) return true; } -SparseMat::Hdr::Hdr( int _dims, const int* _sizes, int _type ) +SparseMat::Hdr::Hdr(int _dims, const int* _sizes, ElemType _type) { refcount = 1; @@ -178,7 +178,7 @@ void SparseMat::Hdr::clear() SparseMat::SparseMat(const Mat& m) -: flags(MAGIC_VAL), hdr(0) +: flags(static_cast(MAGIC_VAL)), hdr(0) { create( m.dims, m.size, m.type() ); @@ -209,7 +209,7 @@ SparseMat::SparseMat(const Mat& m) } } -void SparseMat::create(int d, const int* _sizes, int _type) +void SparseMat::create(int d, const int* _sizes, ElemType _type) { CV_Assert( _sizes && 0 < d && d <= CV_MAX_DIM ); for( int i = 0; i < d; i++ ) @@ -235,7 +235,7 @@ void SparseMat::create(int d, const int* _sizes, int _type) _sizes = _sizes_backup; } release(); - flags = MAGIC_VAL | _type; + flags = static_cast(MAGIC_VAL) | _type; hdr = new Hdr(d, _sizes, _type); } @@ -278,30 +278,32 @@ void SparseMat::copyTo( Mat& m ) const } -void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const +void SparseMat::convertTo(SparseMat& m, ElemDepth ddepth, double alpha) const { int cn = channels(); - if( rtype < 0 ) - rtype = type(); - rtype = CV_MAKETYPE(rtype, cn); - if( hdr == m.hdr && rtype != type() ) + if (ddepth == CV_DEPTH_AUTO) + ddepth = depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); + + if (hdr == m.hdr && dtype != type()) { SparseMat temp; - convertTo(temp, rtype, alpha); + convertTo(temp, CV_MAT_DEPTH(dtype), alpha); m = temp; return; } CV_Assert(hdr != 0); if( hdr != m.hdr ) - m.create( hdr->dims, hdr->size, rtype ); + m.create(hdr->dims, hdr->size, dtype); SparseMatConstIterator from = begin(); size_t N = nzcount(); if( alpha == 1 ) { - ConvertData cvtfunc = getConvertElem(type(), rtype); + ConvertData cvtfunc = getConvertElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -311,7 +313,7 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const } else { - ConvertScaleData cvtfunc = getConvertScaleElem(type(), rtype); + ConvertScaleData cvtfunc = getConvertScaleElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -321,16 +323,16 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const } } - -void SparseMat::convertTo( Mat& m, int rtype, double alpha, double beta ) const +void SparseMat::convertTo(Mat& m, ElemDepth ddepth, double alpha, double beta) const { int cn = channels(); - if( rtype < 0 ) - rtype = type(); - rtype = CV_MAKETYPE(rtype, cn); + if (ddepth == CV_DEPTH_AUTO) + ddepth = depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); CV_Assert( hdr ); - m.create( dims(), hdr->size, rtype ); + m.create(dims(), hdr->size, dtype); m = Scalar(beta); SparseMatConstIterator from = begin(); @@ -338,7 +340,7 @@ void SparseMat::convertTo( Mat& m, int rtype, double alpha, double beta ) const if( alpha == 1 && beta == 0 ) { - ConvertData cvtfunc = getConvertElem(type(), rtype); + ConvertData cvtfunc = getConvertElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -348,7 +350,7 @@ void SparseMat::convertTo( Mat& m, int rtype, double alpha, double beta ) const } else { - ConvertScaleData cvtfunc = getConvertScaleElem(type(), rtype); + ConvertScaleData cvtfunc = getConvertScaleElem(type(), dtype); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -621,12 +623,12 @@ double norm( const SparseMat& src, int normType ) size_t i, N = src.nzcount(); normType &= NORM_TYPE_MASK; - int type = src.type(); + ElemType type = src.type(); double result = 0; CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 ); - if( type == CV_32F ) + if (type == CV_32FC1) { if( normType == NORM_INF ) for( i = 0; i < N; i++, ++it ) @@ -648,7 +650,7 @@ double norm( const SparseMat& src, int normType ) result += v*v; } } - else if( type == CV_64F ) + else if (type == CV_64FC1) { if( normType == NORM_INF ) for( i = 0; i < N; i++, ++it ) @@ -684,10 +686,10 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi SparseMatConstIterator it = src.begin(); size_t i, N = src.nzcount(), d = src.hdr ? src.hdr->dims : 0; - int type = src.type(); + ElemType type = src.type(); const int *minidx = 0, *maxidx = 0; - if( type == CV_32F ) + if (type == CV_32FC1) { float minval = FLT_MAX, maxval = -FLT_MAX; for( i = 0; i < N; i++, ++it ) @@ -710,7 +712,7 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi if( _maxval ) *_maxval = maxval; } - else if( type == CV_64F ) + else if (type == CV_64FC1) { double minval = DBL_MAX, maxval = -DBL_MAX; for( i = 0; i < N; i++, ++it ) @@ -758,7 +760,7 @@ void normalize( const SparseMat& src, SparseMat& dst, double a, int norm_type ) else CV_Error( CV_StsBadArg, "Unknown/unsupported norm type" ); - src.convertTo( dst, -1, scale ); + src.convertTo(dst, CV_DEPTH_AUTO, scale); } } // cv:: @@ -787,7 +789,7 @@ CvSparseMat* cvCreateSparseMat(const cv::SparseMat& sm) void CvSparseMat::copyToSparseMat(cv::SparseMat& m) const { - m.create( dims, &size[0], type ); + m.create(dims, &size[0], static_cast(type)); CvSparseMatIterator it; CvSparseNode* n = cvInitSparseMatIterator(this, &it); diff --git a/modules/core/src/matrix_wrap.cpp b/modules/core/src/matrix_wrap.cpp index 5ee7ab3696ef..6feb83dcf661 100644 --- a/modules/core/src/matrix_wrap.cpp +++ b/modules/core/src/matrix_wrap.cpp @@ -42,13 +42,13 @@ Mat _InputArray::getMat_(int i) const if( k == MATX || k == STD_ARRAY ) { CV_Assert( i < 0 ); - return Mat(sz, flags, obj); + return Mat(sz, CV_MAT_TYPE(flags), obj); } if( k == STD_VECTOR ) { CV_Assert( i < 0 ); - int t = CV_MAT_TYPE(flags); + ElemType t = CV_MAT_TYPE(flags); const std::vector& v = *(const std::vector*)obj; return !v.empty() ? Mat(size(), t, (void*)&v[0]) : Mat(); @@ -57,7 +57,7 @@ Mat _InputArray::getMat_(int i) const if( k == STD_BOOL_VECTOR ) { CV_Assert( i < 0 ); - int t = CV_8U; + ElemType t = CV_8UC1; const std::vector& v = *(const std::vector*)obj; int j, n = (int)v.size(); if( n == 0 ) @@ -74,7 +74,7 @@ Mat _InputArray::getMat_(int i) const if( k == STD_VECTOR_VECTOR ) { - int t = type(i); + ElemType t = type(i); const std::vector >& vv = *(const std::vector >*)obj; CV_Assert( 0 <= i && i < (int)vv.size() ); const std::vector& v = vv[i]; @@ -205,7 +205,8 @@ void _InputArray::getMatVector(std::vector& mv) const const std::vector& v = *(const std::vector*)obj; size_t n = size().width, esz = CV_ELEM_SIZE(flags); - int t = CV_MAT_DEPTH(flags), cn = CV_MAT_CN(flags); + ElemType t = CV_MAKETYPE(CV_MAT_DEPTH(flags), 1); + int cn = CV_MAT_CN(flags); mv.resize(n); for( size_t i = 0; i < n; i++ ) @@ -223,7 +224,7 @@ void _InputArray::getMatVector(std::vector& mv) const { const std::vector >& vv = *(const std::vector >*)obj; int n = (int)vv.size(); - int t = CV_MAT_TYPE(flags); + ElemType t = CV_MAT_TYPE(flags); mv.resize(n); for( int i = 0; i < n; i++ ) @@ -762,7 +763,7 @@ size_t _InputArray::total(int i) const return size(i).area(); } -int _InputArray::type(int i) const +ElemType _InputArray::type(int i) const { _InputArray::KindFlag k = kind(); @@ -779,7 +780,7 @@ int _InputArray::type(int i) const return CV_MAT_TYPE(flags); if( k == NONE ) - return -1; + return CV_TYPE_AUTO; if( k == STD_VECTOR_UMAT ) { @@ -841,7 +842,7 @@ int _InputArray::type(int i) const CV_Error(Error::StsNotImplemented, "Unknown/unsupported array type"); } -int _InputArray::depth(int i) const +ElemDepth _InputArray::depth(int i) const { return CV_MAT_DEPTH(type(i)); } @@ -1186,7 +1187,7 @@ bool _OutputArray::fixedType() const return (flags & FIXED_TYPE) == FIXED_TYPE; } -void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const +void _OutputArray::create(Size _sz, ElemType mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const { _InputArray::KindFlag k = kind(); if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 ) @@ -1228,7 +1229,7 @@ void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, _Out create(2, sizes, mtype, i, allowTransposed, fixedDepthMask); } -void _OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const +void _OutputArray::create(int _rows, int _cols, ElemType mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const { _InputArray::KindFlag k = kind(); if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 ) @@ -1270,7 +1271,7 @@ void _OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTran create(2, sizes, mtype, i, allowTransposed, fixedDepthMask); } -void _OutputArray::create(int d, const int* sizes, int mtype, int i, +void _OutputArray::create(int d, const int* sizes, ElemType mtype, int i, bool allowTransposed, _OutputArray::DepthMask fixedDepthMask) const { int sizebuf[2]; @@ -1355,7 +1356,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, if( k == MATX ) { CV_Assert( i < 0 ); - int type0 = CV_MAT_TYPE(flags); + ElemType type0 = CV_MAT_TYPE(flags); CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) ); CV_Assert( d == 2 && ((sizes[0] == sz.height && sizes[1] == sz.width) || (allowTransposed && sizes[0] == sz.width && sizes[1] == sz.height))); @@ -1364,7 +1365,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, if( k == STD_ARRAY ) { - int type0 = CV_MAT_TYPE(flags); + ElemType type0 = CV_MAT_TYPE(flags); CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) ); CV_Assert( d == 2 && sz.area() == sizes[0]*sizes[1]); return; @@ -1391,7 +1392,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, else CV_Assert( i < 0 ); - int type0 = CV_MAT_TYPE(flags); + ElemType type0 = CV_MAT_TYPE(flags); CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) ); int esz = CV_ELEM_SIZE(type0); @@ -1491,13 +1492,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, v.resize(len); if( fixedType() ) { - int _type = CV_MAT_TYPE(flags); + ElemType _type = CV_MAT_TYPE(flags); for( size_t j = len0; j < len; j++ ) { if( v[j].type() == _type ) continue; CV_Assert( v[j].empty() ); - v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type; + v[j].flags = static_cast((v[j].flags & ~CV_MAT_TYPE_MASK) | _type); } } return; @@ -1549,13 +1550,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, CV_Assert(len == len0); if( fixedType() ) { - int _type = CV_MAT_TYPE(flags); + ElemType _type = CV_MAT_TYPE(flags); for( size_t j = len0; j < len; j++ ) { if( v[j].type() == _type ) continue; CV_Assert( v[j].empty() ); - v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type; + v[j].flags = static_cast((v[j].flags & ~CV_MAT_TYPE_MASK) | _type); } } return; @@ -1609,13 +1610,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, v.resize(len); if( fixedType() ) { - int _type = CV_MAT_TYPE(flags); + ElemType _type = CV_MAT_TYPE(flags); for( size_t j = len0; j < len; j++ ) { if( v[j].type() == _type ) continue; CV_Assert( v[j].empty() ); - v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type; + v[j].flags = static_cast((v[j].flags & ~CV_MAT_TYPE_MASK) | _type); } } return; @@ -1658,7 +1659,7 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i, CV_Error(Error::StsNotImplemented, "Unknown/unsupported array type"); } -void _OutputArray::createSameSize(const _InputArray& arr, int mtype) const +void _OutputArray::createSameSize(const _InputArray& arr, ElemType mtype) const { int arrsz[CV_MAX_DIM], d = arr.sizend(arrsz); create(d, arrsz, mtype); diff --git a/modules/core/src/mean.cpp b/modules/core/src/mean.cpp index 8542381d4994..48042cbf904f 100644 --- a/modules/core/src/mean.cpp +++ b/modules/core/src/mean.cpp @@ -24,7 +24,7 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) ) { IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); if( !mask.empty() ) { typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -109,9 +109,10 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) CV_INSTRUMENT_REGION(); Mat src = _src.getMat(), mask = _mask.getMat(); - CV_Assert( mask.empty() || mask.type() == CV_8U ); + CV_Assert(mask.empty() || mask.type() == CV_8UC1); - int k, cn = src.channels(), depth = src.depth(); + int k, cn = src.channels(); + ElemDepth depth = src.depth(); Scalar s; CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s) @@ -466,7 +467,7 @@ static int sqsum64f( const double* src, const uchar* mask, double* sum, double* typedef int (*SumSqrFunc)(const uchar*, const uchar* mask, uchar*, uchar*, int, int); -static SumSqrFunc getSumSqrTab(int depth) +static SumSqrFunc getSumSqrTab(ElemDepth depth) { static SumSqrFunc sumSqrTab[] = { @@ -490,7 +491,8 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv return false; { - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0, isContinuous = _src.isContinuous(), isMaskContinuous = _mask.isContinuous(); @@ -503,9 +505,9 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv } size_t wgs = defDev.maxWorkGroupSize(); - int ddepth = std::max(CV_32S, depth), sqddepth = std::max(CV_32F, depth), - dtype = CV_MAKE_TYPE(ddepth, cn), - sqdtype = CV_MAKETYPE(sqddepth, cn); + ElemDepth ddepth = CV_MAX_DEPTH(CV_32S, depth), sqddepth = CV_MAX_DEPTH(CV_32F, depth); + ElemType sqdtype = CV_MAKETYPE(sqddepth, cn); + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); CV_Assert(!haveMask || _mask.type() == CV_8UC1); int wgs2_aligned = 1; @@ -581,10 +583,10 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv continue; if( !_dst.fixedSize() ) - _dst.create(cn, 1, CV_64F, -1, true); + _dst.create(cn, 1, CV_64FC1, -1, true); Mat dst = _dst.getMat(); int dcn = (int)dst.total(); - CV_Assert( dst.type() == CV_64F && dst.isContinuous() && + CV_Assert(dst.type() == CV_64FC1 && dst.isContinuous() && (dst.cols == 1 || dst.rows == 1) && dcn >= cn ); double* dptr = dst.ptr(); for( k = 0; k < cn; k++ ) @@ -625,9 +627,9 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv if (_mean.needed()) { if (!_mean.fixedSize()) - _mean.create(1, 1, CV_64F, -1, true); + _mean.create(1, 1, CV_64FC1, -1, true); Mat mean = _mean.getMat(); - CV_Assert(mean.type() == CV_64F && mean.isContinuous() && + CV_Assert(mean.type() == CV_64FC1 && mean.isContinuous() && (mean.cols == 1 || mean.rows == 1) && mean.total() >= 1); double *pmean = mean.ptr(); pmean[0] = mean_temp; @@ -638,9 +640,9 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv if (_sdv.needed()) { if (!_sdv.fixedSize()) - _sdv.create(1, 1, CV_64F, -1, true); + _sdv.create(1, 1, CV_64FC1, -1, true); Mat stddev = _sdv.getMat(); - CV_Assert(stddev.type() == CV_64F && stddev.isContinuous() && + CV_Assert(stddev.type() == CV_64FC1 && stddev.isContinuous() && (stddev.cols == 1 || stddev.rows == 1) && stddev.total() >= 1); double *pstddev = stddev.ptr(); pstddev[0] = stddev_temp; @@ -688,7 +690,7 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m if( _mean.needed() ) { if( !_mean.fixedSize() ) - _mean.create(cn, 1, CV_64F, -1, true); + _mean.create(cn, 1, CV_64FC1, -1, true); mean = _mean.getMat(); dcn_mean = (int)mean.total(); pmean = mean.ptr(); @@ -697,7 +699,7 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m if( _sdv.needed() ) { if( !_sdv.fixedSize() ) - _sdv.create(cn, 1, CV_64F, -1, true); + _sdv.create(cn, 1, CV_64FC1, -1, true); stddev = _sdv.getMat(); dcn_stddev = (int)stddev.total(); pstddev = stddev.ptr(); @@ -707,7 +709,7 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m for( int c = cn; c < dcn_stddev; c++ ) pstddev[c] = 0; IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); if( !mask.empty() ) { typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *, Ipp64f *); @@ -799,7 +801,8 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_meanStdDev(src, _mean, _sdv, mask)); - int k, cn = src.channels(), depth = src.depth(); + int k, cn = src.channels(); + ElemDepth depth = src.depth(); SumSqrFunc func = getSumSqrTab(depth); @@ -877,10 +880,10 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input continue; if( !_dst.fixedSize() ) - _dst.create(cn, 1, CV_64F, -1, true); + _dst.create(cn, 1, CV_64FC1, -1, true); Mat dst = _dst.getMat(); int dcn = (int)dst.total(); - CV_Assert( dst.type() == CV_64F && dst.isContinuous() && + CV_Assert( dst.type() == CV_64FC1 && dst.isContinuous() && (dst.cols == 1 || dst.rows == 1) && dcn >= cn ); double* dptr = dst.ptr(); for( k = 0; k < cn; k++ ) diff --git a/modules/core/src/merge.cpp b/modules/core/src/merge.cpp index 1f74a06aba86..2ecb3609a5df 100644 --- a/modules/core/src/merge.cpp +++ b/modules/core/src/merge.cpp @@ -212,7 +212,7 @@ void merge64s(const int64** src, int64* dst, int len, int cn ) typedef void (*MergeFunc)(const uchar** src, uchar* dst, int len, int cn); -static MergeFunc getMergeFunc(int depth) +static MergeFunc getMergeFunc(ElemDepth depth) { static MergeFunc mergeTab[] = { @@ -285,7 +285,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst) CV_Assert( mv && n > 0 ); - int depth = mv[0].depth(); + ElemDepth depth = mv[0].depth(); bool allch1 = true; int k, cn = 0; size_t i; @@ -371,14 +371,17 @@ static bool ocl_merge( InputArrayOfArrays _mv, OutputArray _dst ) _mv.getUMatVector(src); CV_Assert(!src.empty()); - int type = src[0].type(), depth = CV_MAT_DEPTH(type), - rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; + ElemType type = src[0].type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; Size size = src[0].size(); for (size_t i = 0, srcsize = src.size(); i < srcsize; ++i) { - int itype = src[i].type(), icn = CV_MAT_CN(itype), idepth = CV_MAT_DEPTH(itype), - esz1 = CV_ELEM_SIZE1(idepth); + int itype = src[i].type(); + int icn = CV_MAT_CN(itype); + ElemDepth idepth = CV_MAT_DEPTH(itype); + int esz1 = CV_ELEM_SIZE1(idepth); if (src[i].dims > 2) return false; diff --git a/modules/core/src/minmax.cpp b/modules/core/src/minmax.cpp index 7c5b31839802..5e0cdef99012 100644 --- a/modules/core/src/minmax.cpp +++ b/modules/core/src/minmax.cpp @@ -93,7 +93,7 @@ static void minMaxIdx_64f(const double* src, const uchar* mask, double* minval, typedef void (*MinMaxIdxFunc)(const uchar*, const uchar*, int*, int*, size_t*, size_t*, int, size_t); -static MinMaxIdxFunc getMinmaxTab(int depth) +static MinMaxIdxFunc getMinmaxTab(ElemDepth depth) { static MinMaxIdxFunc minmaxTab[] = { @@ -230,7 +230,7 @@ typedef void (*getMinMaxResFunc)(const Mat & db, double * minVal, double * maxVa int * minLoc, int *maxLoc, int gropunum, int cols, double * maxVal2); bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc, int* maxLoc, InputArray _mask, - int ddepth, bool absValues, InputArray _src2, double * maxVal2) + ElemDepth ddepth, bool absValues, InputArray _src2, double * maxVal2) { const ocl::Device & dev = ocl::Device::getDefault(); @@ -241,17 +241,19 @@ bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc bool doubleSupport = dev.doubleFPConfig() > 0, haveMask = !_mask.empty(), haveSrc2 = _src2.kind() != _InputArray::NONE; - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), kercn = haveMask ? cn : std::min(4, ocl::predictOptimalVectorWidth(_src, _src2)); // disabled following modes since it occasionally fails on AMD devices (e.g. A10-6800K, sep. 2014) if ((haveMask || type == CV_32FC1) && dev.isAMD()) return false; - CV_Assert( (cn == 1 && (!haveMask || _mask.type() == CV_8U)) || + CV_Assert( (cn == 1 && (!haveMask || _mask.type() == CV_8UC1)) || (cn >= 1 && !minLoc && !maxLoc) ); - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = depth; CV_Assert(!haveSrc2 || _src2.type() == type); @@ -374,7 +376,7 @@ namespace ovx { } static bool openvx_minMaxIdx(Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask) { - int stype = src.type(); + ElemType stype = src.type(); size_t total_size = src.total(); int rows = src.size[0], cols = rows ? (int)(total_size / rows) : 0; if ((stype != CV_8UC1 && stype != CV_16SC1) || !mask.empty() || @@ -697,7 +699,7 @@ static bool ipp_minMaxIdx(Mat &src, double* _minVal, double* _maxVal, int* _minI // Crude zero-mask check, waiting for fix in IPP function if(ptrs[1]) { - Mat localMask(Size(size.width, 1), CV_8U, ptrs[1], maskStep); + Mat localMask(Size(size.width, 1), CV_8UC1, ptrs[1], maskStep); if(!cv::countNonZero(localMask)) continue; } @@ -748,8 +750,10 @@ void cv::minMaxIdx(InputArray _src, double* minVal, { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - CV_Assert( (cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) || + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + CV_Assert( (cn == 1 && (_mask.empty() || _mask.type() == CV_8UC1)) || (cn > 1 && _mask.empty() && !minIdx && !maxIdx) ); CV_OCL_RUN(OCL_PERFORMANCE_CHECK(_src.isUMat()) && _src.dims() <= 2 && (_mask.empty() || _src.size() == _mask.size()), diff --git a/modules/core/src/norm.cpp b/modules/core/src/norm.cpp index e0642ea3d919..b4a8c4a92bcf 100644 --- a/modules/core/src/norm.cpp +++ b/modules/core/src/norm.cpp @@ -395,7 +395,7 @@ CV_DEF_NORM_ALL(64f, double, double, double, double) typedef int (*NormFunc)(const uchar*, const uchar*, uchar*, int, int); typedef int (*NormDiffFunc)(const uchar*, const uchar*, const uchar*, uchar*, int, int); -static NormFunc getNormFunc(int normType, int depth) +static NormFunc getNormFunc(int normType, ElemDepth depth) { static NormFunc normTab[3][8] = { @@ -416,7 +416,7 @@ static NormFunc getNormFunc(int normType, int depth) return normTab[normType][depth]; } -static NormDiffFunc getNormDiffFunc(int normType, int depth) +static NormDiffFunc getNormDiffFunc(int normType, ElemDepth depth) { static NormDiffFunc normDiffTab[3][8] = { @@ -456,7 +456,8 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & const int cn = _src.channels(); if (cn > 4) return false; - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); bool doubleSupport = d.doubleFPConfig() > 0, haveMask = _mask.kind() != _InputArray::NONE; @@ -469,7 +470,7 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & if (normType == NORM_INF) { if (!ocl_minMaxIdx(_src, NULL, &result, NULL, NULL, _mask, - std::max(depth, CV_32S), depth != CV_8U && depth != CV_16U)) + CV_MAX_DEPTH(depth, CV_32S), depth != CV_8U && depth != CV_16U)) return false; } else if (normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR) @@ -508,7 +509,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) if( !mask.empty() ) { IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); ippiMaskNormFuncC1 ippiNorm_C1MR = @@ -573,33 +574,33 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) else { IppiSize sz = { cols*src.channels(), rows }; - int type = src.depth(); + ElemDepth type = src.depth(); typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *); ippiNormFuncHint ippiNormHint = normType == NORM_L1 ? - (type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R : + (type == CV_32F ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R : 0) : normType == NORM_L2 || normType == NORM_L2SQR ? - (type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L2_32f_C1R : + (type == CV_32F ? (ippiNormFuncHint)ippiNorm_L2_32f_C1R : 0) : 0; ippiNormFuncNoHint ippiNorm = normType == NORM_INF ? - (type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R : - type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C1R : - type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C1R : - type == CV_32FC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C1R : + (type == CV_8U ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R : + type == CV_16U ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C1R : + type == CV_16S ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C1R : + type == CV_32F ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C1R : 0) : normType == NORM_L1 ? - (type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C1R : - type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C1R : - type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C1R : + (type == CV_8U ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C1R : + type == CV_16U ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C1R : + type == CV_16S ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C1R : 0) : normType == NORM_L2 || normType == NORM_L2SQR ? - (type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C1R : - type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C1R : - type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C1R : + (type == CV_8U ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C1R : + type == CV_16U ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C1R : + type == CV_16S ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C1R : 0) : 0; if( ippiNormHint || ippiNorm ) { @@ -630,7 +631,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) normType &= NORM_TYPE_MASK; CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR || - ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && _src.type() == CV_8U) ); + ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && _src.type() == CV_8UC1) ); #if defined HAVE_OPENCL || defined HAVE_IPP double _result = 0; @@ -645,7 +646,8 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) Mat src = _src.getMat(), mask = _mask.getMat(); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_norm(src, normType, mask, _result), _result); - int depth = src.depth(), cn = src.channels(); + ElemDepth depth = src.depth(); + int cn = src.channels(); if( src.isContinuous() && mask.empty() ) { size_t len = src.total()*cn; @@ -697,7 +699,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) } } - CV_Assert( mask.empty() || mask.type() == CV_8U ); + CV_Assert( mask.empty() || mask.type() == CV_8UC1 ); if( normType == NORM_HAMMING || normType == NORM_HAMMING2 ) { @@ -819,7 +821,8 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr int cn = _src1.channels(); if (cn > 4) return false; - int type = _src1.type(), depth = CV_MAT_DEPTH(type); + int type = _src1.type(); + ElemDepth depth = CV_MAT_DEPTH(type); bool relative = (normType & NORM_RELATIVE) != 0; normType &= ~NORM_RELATIVE; bool normsum = normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR; @@ -837,7 +840,7 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr } else { - if (!ocl_minMaxIdx(_src1, NULL, &sc1[0], NULL, NULL, _mask, std::max(CV_32S, depth), + if (!ocl_minMaxIdx(_src1, NULL, &sc1[0], NULL, NULL, _mask, CV_MAX_DEPTH(CV_32S, depth), false, _src2, relative ? &sc2[0] : NULL)) return false; cn = 1; @@ -922,7 +925,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra else { IppiSize sz = { cols*src1.channels(), rows }; - int type = src1.depth(); + ElemDepth type = src1.depth(); typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -1051,7 +1054,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra else { IppiSize sz = { cols*src1.channels(), rows }; - int type = src1.depth(); + ElemDepth type = src1.depth(); typedef IppStatus (CV_STDCALL* ippiNormDiffFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); typedef IppStatus (CV_STDCALL* ippiNormDiffFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); @@ -1125,12 +1128,13 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m } Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); - int depth = src1.depth(), cn = src1.channels(); + ElemDepth depth = src1.depth(); + int cn = src1.channels(); normType &= 7; CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR || - ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) ); + ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8UC1) ); if( src1.isContinuous() && src2.isContinuous() && mask.empty() ) { @@ -1170,7 +1174,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m } } - CV_Assert( mask.empty() || mask.type() == CV_8U ); + CV_Assert( mask.empty() || mask.type() == CV_8UC1 ); if( normType == NORM_HAMMING || normType == NORM_HAMMING2 ) { diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 50dd13b533ed..138db3aae4fa 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -1993,7 +1993,7 @@ struct Context::Impl }; cl_uint i, nd0 = 0, nd = 0; - int dtype = dtype0 & 15; + ElemType dtype = static_cast(dtype0 & 15); CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, 0, 0, &nd0)); AutoBuffer dlistbuf(nd0*2+1); @@ -2007,9 +2007,9 @@ struct Context::Impl Device d(dlist[i]); if( !d.available() || !d.compilerAvailable() ) continue; - if( dtype0 == Device::TYPE_DGPU && d.hostUnifiedMemory() ) + if (dtype0 == static_cast(Device::TYPE_DGPU) && d.hostUnifiedMemory()) continue; - if( dtype0 == Device::TYPE_IGPU && !d.hostUnifiedMemory() ) + if( dtype0 == static_cast(Device::TYPE_IGPU) && !d.hostUnifiedMemory() ) continue; String name = d.name(); if( nd != 0 && name != name0 ) @@ -4515,7 +4515,7 @@ class OpenCLAllocator CV_FINAL : public MatAllocator flushCleanupQueue(); } - UMatData* defaultAllocate(int dims, const int* sizes, int type, void* data, size_t* step, + UMatData* defaultAllocate(int dims, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const { UMatData* u = matStdAllocator->allocate(dims, sizes, type, data, step, flags, usageFlags); @@ -4535,7 +4535,7 @@ class OpenCLAllocator CV_FINAL : public MatAllocator flags0 = UMatData::COPY_ON_MAP; } - UMatData* allocate(int dims, const int* sizes, int type, + UMatData* allocate(int dims, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE { if(!useOpenCL()) @@ -5220,8 +5220,8 @@ class OpenCLAllocator CV_FINAL : public MatAllocator isz[i] = (int)sz[i]; } - Mat src(dims, isz, CV_8U, srcptr, srcstep); - Mat dst(dims, isz, CV_8U, dstptr, dststep); + Mat src(dims, isz, CV_8UC1, srcptr, srcstep); + Mat dst(dims, isz, CV_8UC1, dstptr, dststep); const Mat* arrays[] = { &src, &dst }; uchar* ptrs[2]; @@ -5354,8 +5354,8 @@ class OpenCLAllocator CV_FINAL : public MatAllocator isz[i] = (int)sz[i]; } - Mat src(dims, isz, CV_8U, (void*)srcptr, srcstep); - Mat dst(dims, isz, CV_8U, dstptr, dststep); + Mat src(dims, isz, CV_8UC1, (void*)srcptr, srcstep); + Mat dst(dims, isz, CV_8UC1, dstptr, dststep); const Mat* arrays[] = { &src, &dst }; uchar* ptrs[2]; @@ -5515,7 +5515,7 @@ class OpenCLAllocator CV_FINAL : public MatAllocator srcptr += srcofs[i]*(i <= dims-2 ? srcstep[i] : 1); isz[i] = (int)sz[i]; } - Mat m_src(dims, isz, CV_8U, srcptr, srcstep); + Mat m_src(dims, isz, CV_8UC1, srcptr, srcstep); uchar* dstptr = (uchar*)dst->handle; for( int i = 0; i < dims; i++ ) @@ -5523,7 +5523,7 @@ class OpenCLAllocator CV_FINAL : public MatAllocator if( dstofs ) dstptr += dstofs[i]*(i <= dims-2 ? dststep[i] : 1); } - Mat m_dst(dims, isz, CV_8U, dstptr, dststep); + Mat m_dst(dims, isz, CV_8UC1, dstptr, dststep); const Mat* arrays[] = { &m_src, &m_dst }; uchar* ptrs[2]; @@ -5703,7 +5703,7 @@ namespace cv { namespace ocl { /* // Convert OpenCL buffer memory to UMat */ -void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst) +void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, ElemType type, UMat& dst) { int d = 2; int sizes[] = { rows, cols }; @@ -5712,7 +5712,7 @@ void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int dst.release(); - dst.flags = (type & Mat::TYPE_MASK) | Mat::MAGIC_VAL; + dst.flags = static_cast(Mat::MAGIC_VAL | (type & Mat::TYPE_MASK)); dst.usageFlags = USAGE_DEFAULT; setSize(dst, d, sizes, 0, true); @@ -5765,7 +5765,7 @@ void convertFromImage(void* cl_mem_image, UMat& dst) cl_image_format fmt = { 0, 0 }; CV_OCL_CHECK(clGetImageInfo(clImage, CL_IMAGE_FORMAT, sizeof(cl_image_format), &fmt, 0)); - int depth = CV_8U; + ElemDepth depth = CV_8U; switch (fmt.image_channel_data_type) { case CL_UNORM_INT8: @@ -5800,7 +5800,7 @@ void convertFromImage(void* cl_mem_image, UMat& dst) CV_Error(cv::Error::OpenCLApiCallError, "Not supported image_channel_data_type"); } - int type = CV_8UC1; + ElemType type = CV_8UC1; switch (fmt.image_channel_order) { case CL_R: @@ -5983,7 +5983,8 @@ const char* typeToStr(int type) "double", "double2", "double3", "double4", 0, 0, 0, "double8", 0, 0, 0, 0, 0, 0, 0, "double16", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; - int cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemDepth depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } @@ -6000,7 +6001,8 @@ const char* memopTypeToStr(int type) "ulong", "ulong2", "ulong3", "ulong4", 0, 0, 0, "ulong8", 0, 0, 0, 0, 0, 0, 0, "ulong16", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; - int cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemDepth depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } @@ -6017,11 +6019,12 @@ const char* vecopTypeToStr(int type) "ulong", "ulong2", "ulong3", "ulong4", 0, 0, 0, "ulong8", 0, 0, 0, 0, 0, 0, 0, "ulong16", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" }; - int cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemDepth depth = CV_MAT_DEPTH(type); return cn > 16 ? "?" : tab[depth*16 + cn-1]; } -const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf) +const char* convertTypeStr(ElemDepth sdepth, ElemDepth ddepth, int cn, char* buf) { if( sdepth == ddepth ) return "noconvert"; @@ -6127,7 +6130,8 @@ const char* getOpenCLErrorString(int errorCode) template static std::string kerToStr(const Mat & k) { - int width = k.cols - 1, depth = k.depth(); + int width = k.cols - 1; + ElemDepth depth = k.depth(); const T * const data = k.ptr(); std::ostringstream stream; @@ -6156,12 +6160,12 @@ static std::string kerToStr(const Mat & k) return stream.str(); } -String kernelToStr(InputArray _kernel, int ddepth, const char * name) +String kernelToStr(InputArray _kernel, ElemDepth ddepth, const char * name) { Mat kernel = _kernel.getMat().reshape(1, 1); - int depth = kernel.depth(); - if (ddepth < 0) + ElemDepth depth = kernel.depth(); + if (ddepth == CV_DEPTH_AUTO) ddepth = depth; if (ddepth != depth) @@ -6183,7 +6187,9 @@ String kernelToStr(InputArray _kernel, int ddepth, const char * name) { \ CV_Assert(src.isMat() || src.isUMat()); \ Size csize = src.size(); \ - int ctype = src.type(), ccn = CV_MAT_CN(ctype), cdepth = CV_MAT_DEPTH(ctype), \ + ElemType ctype = src.type(); \ + ElemDepth cdepth = CV_MAT_DEPTH(ctype); \ + int ccn = CV_MAT_CN(ctype), \ ckercn = vectorWidths[cdepth], cwidth = ccn * csize.width; \ if (cwidth < ckercn || ckercn <= 0) \ return 1; \ @@ -6271,7 +6277,8 @@ void buildOptionsAddMatrixDescription(String& buildOptions, const String& name, { if (!buildOptions.empty()) buildOptions += " "; - int type = _m.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _m.type(); + ElemDepth depth = CV_MAT_DEPTH(type); buildOptions += format( "-D %s_T=%s -D %s_T1=%s -D %s_CN=%d -D %s_TSIZE=%d -D %s_T1SIZE=%d -D %s_DEPTH=%d", name.c_str(), ocl::typeToStr(type), @@ -6299,7 +6306,7 @@ struct Image2D::Impl clReleaseMemObject(handle); } - static cl_image_format getImageFormat(int depth, int cn, bool norm) + static cl_image_format getImageFormat(ElemDepth depth, int cn, bool norm) { cl_image_format format; static const int channelTypes[] = { CL_UNSIGNED_INT8, CL_SIGNED_INT8, CL_UNSIGNED_INT16, @@ -6350,7 +6357,9 @@ struct Image2D::Impl CV_Assert(!src.empty()); CV_Assert(ocl::Device::getDefault().imageSupport()); - int err, depth = src.depth(), cn = src.channels(); + int err; + ElemDepth depth = src.depth(); + int cn = src.channels(); CV_Assert(cn <= 4); cl_image_format format = getImageFormat(depth, cn, norm); @@ -6463,7 +6472,7 @@ bool Image2D::canCreateAlias(const UMat &m) return ret; } -bool Image2D::isFormatSupported(int depth, int cn, bool norm) +bool Image2D::isFormatSupported(ElemDepth depth, int cn, bool norm) { cl_image_format format = Impl::getImageFormat(depth, cn, norm); diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index dc122f2fd7a4..ba57f1626837 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -448,7 +448,7 @@ void cv::ogl::Buffer::Impl::unmapDevice(cudaStream_t stream) #endif // HAVE_OPENGL -cv::ogl::Buffer::Buffer() : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer() : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL throw_no_ogl(); @@ -457,7 +457,7 @@ cv::ogl::Buffer::Buffer() : rows_(0), cols_(0), type_(0) #endif } -cv::ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(int arows, int acols, ElemType atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL CV_UNUSED(arows); @@ -474,7 +474,7 @@ cv::ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bo #endif } -cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(Size asize, ElemType atype, unsigned int abufId, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL CV_UNUSED(asize); @@ -490,7 +490,7 @@ cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRel #endif } -cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_(0), cols_(0), type_(static_cast(0)) { #ifndef HAVE_OPENGL CV_UNUSED(arr); @@ -522,7 +522,7 @@ cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_ #endif } -void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, bool autoRelease) +void cv::ogl::Buffer::create(int arows, int acols, ElemType atype, Target target, bool autoRelease) { #ifndef HAVE_OPENGL CV_UNUSED(arows); @@ -576,7 +576,7 @@ void cv::ogl::Buffer::copyFrom(InputArray arr, Target target, bool autoRelease) const int kind = arr.kind(); const Size asize = arr.size(); - const int atype = arr.type(); + const ElemType atype = arr.type(); create(asize, atype, target, autoRelease); switch (kind) @@ -977,9 +977,9 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols const int kind = arr.kind(); const Size asize = arr.size(); - const int atype = arr.type(); + const ElemType atype = arr.type(); - const int depth = CV_MAT_DEPTH(atype); + const ElemDepth depth = CV_MAT_DEPTH(atype); const int cn = CV_MAT_CN(atype); CV_Assert( depth <= CV_32F ); @@ -1089,9 +1089,9 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease) const int kind = arr.kind(); const Size asize = arr.size(); - const int atype = arr.type(); + const ElemType atype = arr.type(); - const int depth = CV_MAT_DEPTH(atype); + const ElemDepth depth = CV_MAT_DEPTH(atype); const int cn = CV_MAT_CN(atype); CV_Assert( depth <= CV_32F ); @@ -1146,7 +1146,7 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease) #endif } -void cv::ogl::Texture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) const +void cv::ogl::Texture2D::copyTo(OutputArray arr, ElemDepth ddepth, bool autoRelease) const { #ifndef HAVE_OPENGL CV_UNUSED(arr); @@ -1224,7 +1224,7 @@ unsigned int cv::ogl::Texture2D::texId() const void cv::ogl::Arrays::setVertexArray(InputArray vertex) { const int cn = vertex.channels(); - const int depth = vertex.depth(); + const ElemDepth depth = vertex.depth(); CV_Assert( cn == 2 || cn == 3 || cn == 4 ); CV_Assert( depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1263,7 +1263,7 @@ void cv::ogl::Arrays::resetColorArray() void cv::ogl::Arrays::setNormalArray(InputArray normal) { const int cn = normal.channels(); - const int depth = normal.depth(); + const ElemDepth depth = normal.depth(); CV_Assert( cn == 3 ); CV_Assert( depth == CV_8S || depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1282,7 +1282,7 @@ void cv::ogl::Arrays::resetNormalArray() void cv::ogl::Arrays::setTexCoordArray(InputArray texCoord) { const int cn = texCoord.channels(); - const int depth = texCoord.depth(); + const ElemDepth depth = texCoord.depth(); CV_Assert( cn >= 1 && cn <= 4 ); CV_Assert( depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F ); @@ -1515,7 +1515,7 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala { ogl::Buffer buf = indices.getOGlBuffer(); - const int depth = buf.depth(); + const ElemDepth depth = buf.depth(); CV_Assert( buf.channels() == 1 ); CV_Assert( depth <= CV_32S ); @@ -1541,7 +1541,7 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala { Mat mat = indices.getMat(); - const int depth = mat.depth(); + const ElemDepth depth = mat.depth(); CV_Assert( mat.channels() == 1 ); CV_Assert( depth <= CV_32S ); @@ -1755,7 +1755,7 @@ void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst) NO_OPENCL_SHARING_ERROR; #else // check texture format - const int dtype = CV_8UC4; + const ElemType dtype = CV_8UC4; CV_Assert(texture.format() == Texture2D::RGBA); int textureType = dtype; @@ -1849,7 +1849,7 @@ UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags) size_t step = buffer.cols() * buffer.elemSize(); int rows = buffer.rows(); int cols = buffer.cols(); - int type = buffer.type(); + ElemType type = buffer.type(); UMat u; convertFromBuffer(clBuffer, step, rows, cols, type, u); diff --git a/modules/core/src/pca.cpp b/modules/core/src/pca.cpp index 79126a8f3601..5698f9cda353 100644 --- a/modules/core/src/pca.cpp +++ b/modules/core/src/pca.cpp @@ -94,7 +94,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp if( len <= in_count ) covar_flags |= CV_COVAR_NORMAL; - int ctype = std::max(CV_32F, data.depth()); + ElemType ctype = CV_MAKETYPE(CV_MAX_DEPTH(CV_32F, data.depth()), 1); mean.create( mean_sz, ctype ); Mat covar( count, count, ctype ); @@ -102,11 +102,11 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp if( !_mean.empty() ) { CV_Assert( _mean.size() == mean_sz ); - _mean.convertTo(mean, ctype); + _mean.convertTo(mean, CV_MAT_DEPTH(ctype)); covar_flags |= CV_COVAR_USE_AVG; } - calcCovarMatrix( data, covar, mean, covar_flags, ctype ); + calcCovarMatrix( data, covar, mean, covar_flags, CV_MAT_DEPTH(ctype) ); eigen( covar, eigenvalues, eigenvectors ); if( !(covar_flags & CV_COVAR_NORMAL) ) @@ -116,7 +116,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp Mat tmp_data, tmp_mean = repeat(mean, data.rows/mean.rows, data.cols/mean.cols); if( data.type() != ctype || tmp_mean.data == mean.data ) { - data.convertTo( tmp_data, ctype ); + data.convertTo(tmp_data, CV_MAT_DEPTH(ctype)); subtract( tmp_data, tmp_mean, tmp_data ); } else @@ -230,7 +230,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta if( len <= in_count ) covar_flags |= CV_COVAR_NORMAL; - int ctype = std::max(CV_32F, data.depth()); + ElemType ctype = CV_MAKETYPE(CV_MAX_DEPTH(CV_32F, data.depth()), 1); mean.create( mean_sz, ctype ); Mat covar( count, count, ctype ); @@ -238,11 +238,11 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta if( !_mean.empty() ) { CV_Assert( _mean.size() == mean_sz ); - _mean.convertTo(mean, ctype); + _mean.convertTo(mean, CV_MAT_DEPTH(ctype)); covar_flags |= CV_COVAR_USE_AVG; } - calcCovarMatrix( data, covar, mean, covar_flags, ctype ); + calcCovarMatrix( data, covar, mean, covar_flags, CV_MAT_DEPTH(ctype) ); eigen( covar, eigenvalues, eigenvectors ); if( !(covar_flags & CV_COVAR_NORMAL) ) @@ -252,7 +252,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta Mat tmp_data, tmp_mean = repeat(mean, data.rows/mean.rows, data.cols/mean.cols); if( data.type() != ctype || tmp_mean.data == mean.data ) { - data.convertTo( tmp_data, ctype ); + data.convertTo(tmp_data, CV_MAT_DEPTH(ctype)); subtract( tmp_data, tmp_mean, tmp_data ); } else @@ -277,7 +277,7 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, double reta // compute the cumulative energy content for each eigenvector int L; - if (ctype == CV_32F) + if (ctype == CV_32FC1) L = computeCumulativeEnergy(eigenvalues, retainedVariance); else L = computeCumulativeEnergy(eigenvalues, retainedVariance); @@ -295,10 +295,10 @@ void PCA::project(InputArray _data, OutputArray result) const CV_Assert( !mean.empty() && !eigenvectors.empty() && ((mean.rows == 1 && mean.cols == data.cols) || (mean.cols == 1 && mean.rows == data.rows))); Mat tmp_data, tmp_mean = repeat(mean, data.rows/mean.rows, data.cols/mean.cols); - int ctype = mean.type(); + ElemType ctype = mean.type(); if( data.type() != ctype || tmp_mean.data == mean.data ) { - data.convertTo( tmp_data, ctype ); + data.convertTo(tmp_data, CV_MAT_DEPTH(ctype)); subtract( tmp_data, tmp_mean, tmp_data ); } else @@ -327,7 +327,7 @@ void PCA::backProject(InputArray _data, OutputArray result) const (mean.cols == 1 && eigenvectors.rows == data.rows))); Mat tmp_data, tmp_mean; - data.convertTo(tmp_data, mean.type()); + data.convertTo(tmp_data, mean.depth()); if( mean.rows == 1 ) { tmp_mean = repeat(mean, data.rows, 1); diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 30101dce062b..da829126517d 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -641,9 +641,9 @@ int icvCalcStructSize( const char* dt, int initial_size ) return size; } -int icvDecodeSimpleFormat( const char* dt ) +ElemType icvDecodeSimpleFormat(const char* dt) { - int elem_type = -1; + ElemType elem_type = CV_TYPE_AUTO; int fmt_pairs[CV_FS_MAX_FMT_PAIRS], fmt_pair_count; fmt_pair_count = icvDecodeFormat( dt, fmt_pairs, CV_FS_MAX_FMT_PAIRS ); diff --git a/modules/core/src/persistence.hpp b/modules/core/src/persistence.hpp index aa0acabd8ec9..010a49f9a027 100644 --- a/modules/core/src/persistence.hpp +++ b/modules/core/src/persistence.hpp @@ -264,7 +264,7 @@ int icvCalcElemSize( const char* dt, int initial_size ); void CV_NORETURN icvParseError( CvFileStorage* fs, const char* func_name, const char* err_msg, const char* source_file, int source_line ); char* icvEncodeFormat( int elem_type, char* dt ); int icvDecodeFormat( const char* dt, int* fmt_pairs, int max_len ); -int icvDecodeSimpleFormat( const char* dt ); +ElemType icvDecodeSimpleFormat(const char* dt); void icvWriteFileNode( CvFileStorage* fs, const char* name, const CvFileNode* node ); void icvWriteCollection( CvFileStorage* fs, const CvFileNode* node ); void switch_to_Base64_state( CvFileStorage* fs, base64::fs::State state ); diff --git a/modules/core/src/persistence_base64.cpp b/modules/core/src/persistence_base64.cpp index 8d6e6cc7d0bf..e59267137797 100644 --- a/modules/core/src/persistence_base64.cpp +++ b/modules/core/src/persistence_base64.cpp @@ -745,7 +745,7 @@ class BinaryToCvSeqConvertor typedef size_t(*binary_to_t)(uchar const *, uchar *); struct binary_to_filenode_t { - size_t cv_type; + ElemDepth cv_type; size_t offset; binary_to_t func; }; diff --git a/modules/core/src/persistence_c.cpp b/modules/core/src/persistence_c.cpp index 7980a04bdd9e..e2994653049b 100644 --- a/modules/core/src/persistence_c.cpp +++ b/modules/core/src/persistence_c.cpp @@ -939,7 +939,7 @@ cvWriteRawData( CvFileStorage* fs, const void* _data, int len, const char* dt ) for( k = 0; k < fmt_pair_count; k++ ) { int i, count = fmt_pairs[k*2]; - int elem_type = fmt_pairs[k*2+1]; + ElemType elem_type = static_cast(fmt_pairs[k * 2 + 1]); int elem_size = CV_ELEM_SIZE(elem_type); const char* data, *ptr; @@ -950,31 +950,31 @@ cvWriteRawData( CvFileStorage* fs, const void* _data, int len, const char* dt ) { switch( elem_type ) { - case CV_8U: + case CV_8UC1: ptr = icv_itoa( *(uchar*)data, buf, 10 ); data++; break; - case CV_8S: + case CV_8SC1: ptr = icv_itoa( *(char*)data, buf, 10 ); data++; break; - case CV_16U: + case CV_16UC1: ptr = icv_itoa( *(ushort*)data, buf, 10 ); data += sizeof(ushort); break; - case CV_16S: + case CV_16SC1: ptr = icv_itoa( *(short*)data, buf, 10 ); data += sizeof(short); break; - case CV_32S: + case CV_32SC1: ptr = icv_itoa( *(int*)data, buf, 10 ); data += sizeof(int); break; - case CV_32F: + case CV_32FC1: ptr = icvFloatToString( buf, *(float*)data ); data += sizeof(float); break; - case CV_64F: + case CV_64FC1: ptr = icvDoubleToString( buf, *(double*)data ); data += sizeof(double); break; diff --git a/modules/core/src/persistence_types.cpp b/modules/core/src/persistence_types.cpp index 2f4cc254dc47..418402d6feee 100644 --- a/modules/core/src/persistence_types.cpp +++ b/modules/core/src/persistence_types.cpp @@ -72,7 +72,8 @@ static void* icvReadMat( CvFileStorage* fs, CvFileNode* node ) CvMat* mat; const char* dt; CvFileNode* data; - int rows, cols, elem_type; + int rows, cols; + ElemType elem_type; rows = cvReadIntByName( fs, node, "rows", -1 ); cols = cvReadIntByName( fs, node, "cols", -1 ); @@ -151,7 +152,8 @@ static void* icvReadMatND( CvFileStorage* fs, CvFileNode* node ) const char* dt; CvFileNode* data; CvFileNode* sizes_node; - int sizes[CV_MAX_DIM] = {0}, dims, elem_type; + int sizes[CV_MAX_DIM] = { 0 }, dims; + ElemType elem_type; int i, total_size; sizes_node = cvGetFileNodeByName( fs, node, "sizes" ); @@ -302,7 +304,8 @@ static void* icvReadSparseMat( CvFileStorage* fs, CvFileNode* node ) CvFileNode* sizes_node; CvSeqReader reader; CvSeq* elements; - int sizes[CV_MAX_DIM], dims, elem_type, cn; + int sizes[CV_MAX_DIM], dims, cn; + ElemType elem_type; int i; sizes_node = cvGetFileNodeByName( fs, node, "sizes" ); @@ -381,7 +384,8 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru const IplImage* image = (const IplImage*)struct_ptr; char dt_buf[16], *dt; cv::Size size; - int y, depth; + int y; + ElemDepth depth; assert( CV_IS_IMAGE(image) ); @@ -407,7 +411,7 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru cvEndWriteStruct( fs ); } - depth = IPL2CV_DEPTH(image->depth); + depth = static_cast(IPL2CV_DEPTH(image->depth)); dt = icvEncodeFormat(depth, dt_buf); cvWriteString( fs, "dt", dt, 0 ); @@ -435,7 +439,9 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node ) CvFileNode* roi_node; CvSeqReader reader; cv::Rect roi; - int y, width, height, elem_type, coi, depth; + int y, width, height, coi; + ElemType elem_type; + ElemDepth depth; const char* origin, *data_order; width = cvReadIntByName( fs, node, "width", 0 ); @@ -459,7 +465,7 @@ static void* icvReadImage( CvFileStorage* fs, CvFileNode* node ) CV_Error( CV_StsUnmatchedSizes, "The matrix size does not match to the number of stored elements" ); - depth = cvIplDepth(elem_type); + depth = static_cast(cvIplDepth(elem_type)); image = cvCreateImage( cvSize(width,height), depth, CV_MAT_CN(elem_type) ); roi_node = cvGetFileNodeByName( fs, node, "roi" ); diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 796edb98ec5c..cf18edf61c62 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -136,8 +136,8 @@ typedef void (*BinaryFuncC)(const uchar* src1, size_t step1, uchar* dst, size_t step, int width, int height, void*); -BinaryFunc getConvertFunc(int sdepth, int ddepth); -BinaryFunc getConvertScaleFunc(int sdepth, int ddepth); +BinaryFunc getConvertFunc(ElemDepth sdepth, ElemDepth ddepth); +BinaryFunc getConvertScaleFunc(ElemDepth sdepth, ElemDepth ddepth); BinaryFunc getCopyMaskFunc(size_t esz); /* default memory block for sparse array elements */ @@ -149,10 +149,10 @@ BinaryFunc getCopyMaskFunc(size_t esz); /* maximal average node_count/hash_size ratio beyond which hash table is resized */ #define CV_SPARSE_HASH_RATIO 3 -inline Size getContinuousSize_( int flags, int cols, int rows, int widthScale ) +inline Size getContinuousSize_( MagicFlag flags, int cols, int rows, int widthScale ) { int64 sz = (int64)cols * rows * widthScale; - return (flags & Mat::CONTINUOUS_FLAG) != 0 && + return !!(flags & static_cast(Mat::CONTINUOUS_FLAG)) && (int)sz == sz ? Size((int)sz, 1) : Size(cols * widthScale, rows); } @@ -193,7 +193,7 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2, void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool autoSteps=false ); void finalizeHdr(Mat& m); -int updateContinuityFlag(int flags, int dims, const int* size, const size_t* step); +MagicFlag updateContinuityFlag(MagicFlag flags, int dims, const int* size, const size_t* step); struct NoVec { @@ -221,7 +221,7 @@ inline bool checkScalar(const Mat& sc, int atype, _InputArray::KindFlag sckind, if( akind == _InputArray::MATX && sckind != _InputArray::MATX ) return false; return sz == Size(1, 1) || sz == Size(1, cn) || sz == Size(cn, 1) || - (sz == Size(1, 4) && sc.type() == CV_64F && cn <= 4); + (sz == Size(1, 4) && sc.type() == CV_64FC1 && cn <= 4); } inline bool checkScalar(InputArray sc, int atype, _InputArray::KindFlag sckind, _InputArray::KindFlag akind) @@ -235,7 +235,7 @@ inline bool checkScalar(InputArray sc, int atype, _InputArray::KindFlag sckind, if( akind == _InputArray::MATX && sckind != _InputArray::MATX ) return false; return sz == Size(1, 1) || sz == Size(1, cn) || sz == Size(cn, 1) || - (sz == Size(1, 4) && sc.type() == CV_64F && cn <= 4); + (sz == Size(1, 4) && sc.type() == CV_64FC1 && cn <= 4); } void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t blocksize ); diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index bcc6ff157c77..3cf12e2b9a7f 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -394,7 +394,8 @@ void RNG::fill( InputOutputArray _mat, int disttype, CV_Assert(!_mat.empty()); Mat mat = _mat.getMat(), _param1 = _param1arg.getMat(), _param2 = _param2arg.getMat(); - int depth = mat.depth(), cn = mat.channels(); + ElemDepth depth = mat.depth(); + int cn = mat.channels(); AutoBuffer _parambuf; int j, k; bool fast_int_mode = false; @@ -404,11 +405,11 @@ void RNG::fill( InputOutputArray _mat, int disttype, CV_Assert(_param1.channels() == 1 && (_param1.rows == 1 || _param1.cols == 1) && (_param1.rows + _param1.cols - 1 == cn || _param1.rows + _param1.cols - 1 == 1 || - (_param1.size() == Size(1, 4) && _param1.type() == CV_64F && cn <= 4))); + (_param1.size() == Size(1, 4) && _param1.type() == CV_64FC1 && cn <= 4))); CV_Assert( _param2.channels() == 1 && (((_param2.rows == 1 || _param2.cols == 1) && (_param2.rows + _param2.cols - 1 == cn || _param2.rows + _param2.cols - 1 == 1 || - (_param1.size() == Size(1, 4) && _param1.type() == CV_64F && cn <= 4))) || + (_param1.size() == Size(1, 4) && _param1.type() == CV_64FC1 && cn <= 4))) || (_param2.rows == cn && _param2.cols == cn && disttype == NORMAL))); Vec2i* ip = 0; @@ -428,9 +429,9 @@ void RNG::fill( InputOutputArray _mat, int disttype, double* p1 = _param1.ptr(); double* p2 = _param2.ptr(); - if( !_param1.isContinuous() || _param1.type() != CV_64F || n1 != cn ) + if (!_param1.isContinuous() || _param1.type() != CV_64FC1 || n1 != cn) { - Mat tmp(_param1.size(), CV_64F, parambuf); + Mat tmp(_param1.size(), CV_64FC1, parambuf); _param1.convertTo(tmp, CV_64F); p1 = parambuf; if( n1 < cn ) @@ -438,9 +439,9 @@ void RNG::fill( InputOutputArray _mat, int disttype, p1[j] = p1[j-n1]; } - if( !_param2.isContinuous() || _param2.type() != CV_64F || n2 != cn ) + if (!_param2.isContinuous() || _param2.type() != CV_64FC1 || n2 != cn) { - Mat tmp(_param2.size(), CV_64F, parambuf + cn); + Mat tmp(_param2.size(), CV_64FC1, parambuf + cn); _param2.convertTo(tmp, CV_64F); p2 = parambuf + cn; if( n2 < cn ) @@ -540,7 +541,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, _parambuf.allocate(MAX(n1, cn) + MAX(n2, cn)); double* parambuf = _parambuf.data(); - int ptype = depth == CV_64F ? CV_64F : CV_32F; + ElemType ptype = depth == CV_64F ? CV_64FC1 : CV_32FC1; int esz = (int)CV_ELEM_SIZE(ptype); if( _param1.isContinuous() && _param1.type() == ptype && n1 >= cn) @@ -548,7 +549,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, else { Mat tmp(_param1.size(), ptype, parambuf); - _param1.convertTo(tmp, ptype); + _param1.convertTo(tmp, CV_MAT_DEPTH(ptype)); mean = (uchar*)parambuf; } @@ -561,7 +562,7 @@ void RNG::fill( InputOutputArray _mat, int disttype, else { Mat tmp(_param2.size(), ptype, parambuf + MAX(n1, cn)); - _param2.convertTo(tmp, ptype); + _param2.convertTo(tmp, CV_MAT_DEPTH(ptype)); stddev = (uchar*)(parambuf + MAX(n1, cn)); } diff --git a/modules/core/src/split.cpp b/modules/core/src/split.cpp index 92a6bbabbed0..d98e89be5afb 100644 --- a/modules/core/src/split.cpp +++ b/modules/core/src/split.cpp @@ -220,7 +220,7 @@ void split64s(const int64* src, int64** dst, int len, int cn ) typedef void (*SplitFunc)(const uchar* src, uchar** dst, int len, int cn); -static SplitFunc getSplitFunc(int depth) +static SplitFunc getSplitFunc(ElemDepth depth) { static SplitFunc splitTab[] = { @@ -291,7 +291,8 @@ void cv::split(const Mat& src, Mat* mv) { CV_INSTRUMENT_REGION(); - int k, depth = src.depth(), cn = src.channels(); + int k, cn = src.channels(); + ElemDepth depth = src.depth(); if( cn == 1 ) { src.copyTo(mv[0]); @@ -300,7 +301,7 @@ void cv::split(const Mat& src, Mat* mv) for( k = 0; k < cn; k++ ) { - mv[k].create(src.dims, src.size, depth); + mv[k].create(src.dims, src.size, CV_MAKETYPE(depth, 1)); } CV_IPP_RUN_FAST(ipp_split(src, mv, cn)); @@ -347,7 +348,9 @@ namespace cv { static bool ocl_split( InputArray _m, OutputArrayOfArrays _mv ) { - int type = _m.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _m.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), rowsPerWI = ocl::Device::getDefault().isIntel() ? 4 : 1; String dstargs, processelem, indexdecl; @@ -367,9 +370,9 @@ static bool ocl_split( InputArray _m, OutputArrayOfArrays _mv ) return false; Size size = _m.size(); - _mv.create(cn, 1, depth); + _mv.create(cn, 1, CV_MAKETYPE(depth, 1)); for (int i = 0; i < cn; ++i) - _mv.create(size, depth, i); + _mv.create(size, CV_MAKETYPE(depth, 1), i); std::vector dst; _mv.getUMatVector(dst); @@ -401,12 +404,13 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv) return; } - CV_Assert( !_mv.fixedType() || _mv.empty() || _mv.type() == m.depth() ); + CV_Assert( !_mv.fixedType() || _mv.empty() || _mv.type() == CV_MAKETYPE(m.depth(), 1) ); - int depth = m.depth(), cn = m.channels(); - _mv.create(cn, 1, depth); + ElemDepth depth = m.depth(); + int cn = m.channels(); + _mv.create(cn, 1, CV_MAKETYPE(depth, 1)); for (int i = 0; i < cn; ++i) - _mv.create(m.dims, m.size.p, depth, i); + _mv.create(m.dims, m.size.p, CV_MAKETYPE(depth, 1), i); std::vector dst; _mv.getMatVector(dst); diff --git a/modules/core/src/stat.hpp b/modules/core/src/stat.hpp index 23ef0688e3d1..d2bf843b5ed1 100644 --- a/modules/core/src/stat.hpp +++ b/modules/core/src/stat.hpp @@ -16,7 +16,7 @@ enum { OCL_OP_SUM = 0, OCL_OP_SUM_ABS = 1, OCL_OP_SUM_SQR = 2 }; bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask = noArray(), InputArray _src2 = noArray(), bool calc2 = false, const Scalar & res2 = Scalar() ); bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minLoc, int* maxLoc, InputArray _mask, - int ddepth = -1, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL); + ElemDepth ddepth = CV_DEPTH_AUTO, bool absValues = false, InputArray _src2 = noArray(), double * maxVal2 = NULL); template Scalar ocl_part_sum(Mat m) { @@ -36,7 +36,7 @@ template Scalar ocl_part_sum(Mat m) #endif typedef int (*SumFunc)(const uchar*, const uchar* mask, uchar*, int, int); -SumFunc getSumFunc(int depth); +SumFunc getSumFunc(ElemDepth depth); } diff --git a/modules/core/src/sum.cpp b/modules/core/src/sum.cpp index 30cee85b4c12..fa3228309665 100644 --- a/modules/core/src/sum.cpp +++ b/modules/core/src/sum.cpp @@ -429,7 +429,7 @@ static int sum32f( const float* src, const uchar* mask, double* dst, int len, in static int sum64f( const double* src, const uchar* mask, double* dst, int len, int cn ) { return sum_(src, mask, dst, len, cn); } -SumFunc getSumFunc(int depth) +SumFunc getSumFunc(ElemDepth depth) { static SumFunc sumTab[] = { @@ -454,7 +454,9 @@ bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask, bool doubleSupport = dev.doubleFPConfig() > 0, haveMask = _mask.kind() != _InputArray::NONE, haveSrc2 = _src2.kind() != _InputArray::NONE; - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), kercn = cn == 1 && !haveMask ? ocl::predictOptimalVectorWidth(_src, _src2) : 1, mcn = std::max(cn, kercn); CV_Assert(!haveSrc2 || _src2.type() == type); @@ -466,8 +468,8 @@ bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask, int ngroups = dev.maxComputeUnits(), dbsize = ngroups * (calc2 ? 2 : 1); size_t wgs = dev.maxWorkGroupSize(); - int ddepth = std::max(sum_op == OCL_OP_SUM_SQR ? CV_32F : CV_32S, depth), - dtype = CV_MAKE_TYPE(ddepth, cn); + ElemDepth ddepth = CV_MAX_DEPTH(sum_op == OCL_OP_SUM_SQR ? (CV_32F) : (CV_32S), depth); + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); CV_Assert(!haveMask || _mask.type() == CV_8UC1); int wgs2_aligned = 1; @@ -552,7 +554,7 @@ static bool ipp_sum(Mat &src, Scalar &_res) if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) ) { IppiSize sz = { cols, rows }; - int type = src.type(); + ElemType type = src.type(); typedef IppStatus (CV_STDCALL* ippiSumFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm); typedef IppStatus (CV_STDCALL* ippiSumFuncNoHint)(const void*, int, IppiSize, double *); ippiSumFuncHint ippiSumHint = @@ -612,7 +614,8 @@ cv::Scalar cv::sum( InputArray _src ) Mat src = _src.getMat(); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_sum(src, _res), _res); - int k, cn = src.channels(), depth = src.depth(); + int k, cn = src.channels(); + ElemDepth depth = src.depth(); SumFunc func = getSumFunc(depth); CV_Assert( cn <= 4 && func != 0 ); diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index 5e60d2c1ba3a..24f9c4e64ad1 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -400,7 +400,7 @@ UMat Mat::getUMat(AccessFlag accessFlags, UMatUsageFlags usageFlags) const return hdr; } -void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlags) +void UMat::create(int d, const int* _sizes, ElemType _type, UMatUsageFlags _usageFlags) { this->usageFlags = _usageFlags; @@ -430,7 +430,7 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag release(); if( d == 0 ) return; - flags = (_type & CV_MAT_TYPE_MASK) | MAGIC_VAL; + flags = static_cast(MAGIC_VAL) | (_type & CV_MAT_TYPE_MASK); setSize(*this, d, _sizes, 0, true); offset = 0; @@ -460,7 +460,7 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag addref(); } -void UMat::create(const std::vector& _sizes, int _type, UMatUsageFlags _usageFlags) +void UMat::create(const std::vector& _sizes, ElemType _type, UMatUsageFlags _usageFlags) { create((int)_sizes.size(), _sizes.data(), _type, _usageFlags); } @@ -492,7 +492,7 @@ void UMat::deallocate() UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { CV_Assert( m.dims >= 2 ); if( m.dims > 2 ) @@ -512,7 +512,7 @@ UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange) CV_Assert( 0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows ); rows = _rowRange.size(); offset += step*_rowRange.start; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } if( _colRange != Range::all() && _colRange != Range(0,cols) ) @@ -520,7 +520,7 @@ UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange) CV_Assert( 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols ); cols = _colRange.size(); offset += _colRange.start*elemSize(); - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } updateContinuityFlag(); @@ -546,7 +546,7 @@ UMat::UMat(const UMat& m, const Rect& roi) if( u ) CV_XADD(&(u->urefcount), 1); if( roi.width < m.cols || roi.height < m.rows ) - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); step[0] = m.step[0]; step[1] = esz; updateContinuityFlag(); @@ -560,7 +560,7 @@ UMat::UMat(const UMat& m, const Rect& roi) UMat::UMat(const UMat& m, const Range* ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { int i, d = m.dims; @@ -578,14 +578,14 @@ UMat::UMat(const UMat& m, const Range* ranges) { size.p[i] = r.end - r.start; offset += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); } UMat::UMat(const UMat& m, const std::vector& ranges) - : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) + : flags(static_cast(MAGIC_VAL)), dims(0), rows(0), cols(0), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { int i, d = m.dims; @@ -603,7 +603,7 @@ UMat::UMat(const UMat& m, const std::vector& ranges) { size.p[i] = r.end - r.start; offset += r.start*step.p[i]; - flags |= SUBMATRIX_FLAG; + flags |= static_cast(SUBMATRIX_FLAG); } } updateContinuityFlag(); @@ -635,7 +635,7 @@ UMat UMat::diag(int d) const m.updateContinuityFlag(); if( size() != Size(1,1) ) - m.flags |= SUBMATRIX_FLAG; + m.flags |= static_cast(SUBMATRIX_FLAG); return m; } @@ -751,9 +751,9 @@ UMat UMat::diag(const UMat& d) return m; } -int UMat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const +int UMat::checkVector(int _elemChannels, ElemDepth _depth, bool _requireContinuous) const { - return (depth() == _depth || _depth <= 0) && + return (depth() == _depth || _depth <= CV_8U) && (isContinuous() || !_requireContinuous) && ((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) || (cols == _elemChannels && channels() == 1))) || @@ -882,11 +882,11 @@ void UMat::copyTo(OutputArray _dst) const } #endif - int dtype = _dst.type(); + ElemType dtype = _dst.type(); if( _dst.fixedType() && dtype != type() ) { CV_Assert( channels() == CV_MAT_CN(dtype) ); - convertTo( _dst, dtype ); + convertTo(_dst, CV_MAT_DEPTH(dtype)); return; } @@ -934,7 +934,10 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const return; } #ifdef HAVE_OPENCL - int cn = channels(), mtype = _mask.type(), mdepth = CV_MAT_DEPTH(mtype), mcn = CV_MAT_CN(mtype); + int cn = channels(); + ElemType mtype = _mask.type(); + ElemDepth mdepth = CV_MAT_DEPTH(mtype); + int mcn = CV_MAT_CN(mtype); CV_Assert( mdepth == CV_8U && (mcn == 1 || mcn == cn) ); if (ocl::useOpenCL() && _dst.isUMat() && dims <= 2) @@ -973,19 +976,20 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const src.copyTo(_dst, _mask); } -void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const +void UMat::convertTo(OutputArray _dst, ElemDepth ddepth, double alpha, double beta) const { CV_INSTRUMENT_REGION(); bool noScale = std::fabs(alpha - 1) < DBL_EPSILON && std::fabs(beta) < DBL_EPSILON; - int stype = type(), cn = CV_MAT_CN(stype); + ElemType stype = type(); + int cn = CV_MAT_CN(stype); - if( _type < 0 ) - _type = _dst.fixedType() ? _dst.type() : stype; - else - _type = CV_MAKETYPE(CV_MAT_DEPTH(_type), cn); + if (ddepth == CV_DEPTH_AUTO) + ddepth = _dst.fixedType() ? _dst.depth() : depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ + ElemType dtype = CV_MAKETYPE(ddepth, cn); - int sdepth = CV_MAT_DEPTH(stype), ddepth = CV_MAT_DEPTH(_type); + ElemDepth sdepth = CV_MAT_DEPTH(stype); if( sdepth == ddepth && noScale ) { copyTo(_dst); @@ -997,7 +1001,8 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con if( dims <= 2 && cn && _dst.isUMat() && ocl::useOpenCL() && ((needDouble && doubleSupport) || !needDouble) ) { - int wdepth = std::max(CV_32F, sdepth), rowsPerWI = 4; + ElemDepth wdepth = CV_MAX_DEPTH(CV_32F, sdepth); + int rowsPerWI = 4; char cvt[2][40]; ocl::Kernel k("convertTo", ocl::core::convert_oclsrc, @@ -1009,7 +1014,7 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con if (!k.empty()) { UMat src = *this; - _dst.create( size(), _type ); + _dst.create(size(), dtype); UMat dst = _dst.getUMat(); float alphaf = (float)alpha, betaf = (float)beta; @@ -1035,7 +1040,7 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con UMat src = *this; // Fake reference to itself. // Resolves issue 8693 in case of src == dst. Mat m = getMat(ACCESS_READ); - m.convertTo(_dst, _type, alpha, beta); + m.convertTo(_dst, CV_MAT_DEPTH(dtype), alpha, beta); } UMat& UMat::setTo(InputArray _value, InputArray _mask) @@ -1044,7 +1049,9 @@ UMat& UMat::setTo(InputArray _value, InputArray _mask) bool haveMask = !_mask.empty(); #ifdef HAVE_OPENCL - int tp = type(), cn = CV_MAT_CN(tp), d = CV_MAT_DEPTH(tp); + ElemType tp = type(); + int cn = CV_MAT_CN(tp); + ElemDepth d = CV_MAT_DEPTH(tp); if( dims <= 2 && cn <= 4 && CV_MAT_DEPTH(tp) < CV_64F && ocl::useOpenCL() ) { @@ -1130,8 +1137,9 @@ static bool ocl_dot( InputArray _src1, InputArray _src2, double & res ) { UMat src1 = _src1.getUMat().reshape(1), src2 = _src2.getUMat().reshape(1); - int type = src1.type(), depth = CV_MAT_DEPTH(type), - kercn = ocl::predictOptimalVectorWidth(src1, src2); + ElemType type = src1.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int kercn = ocl::predictOptimalVectorWidth(src1, src2); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; if ( !doubleSupport && depth == CV_64F ) @@ -1139,7 +1147,7 @@ static bool ocl_dot( InputArray _src1, InputArray _src2, double & res ) int dbsize = ocl::Device::getDefault().maxComputeUnits(); size_t wgs = ocl::Device::getDefault().maxWorkGroupSize(); - int ddepth = std::max(CV_32F, depth); + ElemDepth ddepth = CV_MAX_DEPTH(CV_32F, depth); int wgs2_aligned = 1; while (wgs2_aligned < (int)wgs) @@ -1159,7 +1167,7 @@ static bool ocl_dot( InputArray _src1, InputArray _src2, double & res ) if (k.empty()) return false; - UMat db(1, dbsize, ddepth); + UMat db(1, dbsize, CV_MAKETYPE(ddepth, 1)); ocl::KernelArg src1arg = ocl::KernelArg::ReadOnlyNoSize(src1), src2arg = ocl::KernelArg::ReadOnlyNoSize(src2), @@ -1192,42 +1200,42 @@ double UMat::dot(InputArray m) const return getMat(ACCESS_READ).dot(m); } -UMat UMat::zeros(int rows, int cols, int type) +UMat UMat::zeros(int rows, int cols, ElemType type) { return UMat(rows, cols, type, Scalar::all(0)); } -UMat UMat::zeros(Size size, int type) +UMat UMat::zeros(Size size, ElemType type) { return UMat(size, type, Scalar::all(0)); } -UMat UMat::zeros(int ndims, const int* sz, int type) +UMat UMat::zeros(int ndims, const int* sz, ElemType type) { return UMat(ndims, sz, type, Scalar::all(0)); } -UMat UMat::ones(int rows, int cols, int type) +UMat UMat::ones(int rows, int cols, ElemType type) { return UMat::ones(Size(cols, rows), type); } -UMat UMat::ones(Size size, int type) +UMat UMat::ones(Size size, ElemType type) { return UMat(size, type, Scalar(1)); } -UMat UMat::ones(int ndims, const int* sz, int type) +UMat UMat::ones(int ndims, const int* sz, ElemType type) { return UMat(ndims, sz, type, Scalar(1)); } -UMat UMat::eye(int rows, int cols, int type) +UMat UMat::eye(int rows, int cols, ElemType type) { return UMat::eye(Size(cols, rows), type); } -UMat UMat::eye(Size size, int type) +UMat UMat::eye(Size size, ElemType type) { UMat m(size, type); setIdentity(m); diff --git a/modules/core/src/va_intel.cpp b/modules/core/src/va_intel.cpp index ac74f0c5337d..15bed6afbe53 100644 --- a/modules/core/src/va_intel.cpp +++ b/modules/core/src/va_intel.cpp @@ -489,7 +489,7 @@ void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, #if !defined(HAVE_VA) NO_VA_SUPPORT_ERROR; #else // !HAVE_VA - const int stype = CV_8UC3; + const ElemType stype = CV_8UC3; int srcType = src.type(); CV_Assert(srcType == stype); @@ -593,7 +593,7 @@ void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, Out #if !defined(HAVE_VA) NO_VA_SUPPORT_ERROR; #else // !HAVE_VA - const int dtype = CV_8UC3; + const ElemType dtype = CV_8UC3; // TODO Need to specify ACCESS_WRITE here somehow to prevent useless data copying! dst.create(size, dtype); diff --git a/modules/core/test/ocl/test_arithm.cpp b/modules/core/test/ocl/test_arithm.cpp index c450f2c2e530..8f8846f2a5b1 100644 --- a/modules/core/test/ocl/test_arithm.cpp +++ b/modules/core/test/ocl/test_arithm.cpp @@ -70,9 +70,9 @@ PARAM_TEST_CASE(Lut, MatDepth, MatDepth, Channels, bool, bool) void generateTestData() { - const int src_type = CV_MAKE_TYPE(src_depth, cn); - const int lut_type = CV_MAKE_TYPE(lut_depth, same_cn ? cn : 1); - const int dst_type = CV_MAKE_TYPE(lut_depth, cn); + const ElemType src_type = CV_MAKE_TYPE(src_depth, cn); + const ElemType lut_type = CV_MAKE_TYPE(lut_depth, same_cn ? cn : 1); + const ElemType dst_type = CV_MAKE_TYPE(lut_depth, cn); Size roiSize = randomSize(1, MAX_VALUE); Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); @@ -113,7 +113,7 @@ OCL_TEST_P(Lut, Mat) PARAM_TEST_CASE(ArithmTestBase, MatDepth, Channels, bool) { - int depth; + ElemDepth depth; int cn; bool use_roi; cv::Scalar val; @@ -134,10 +134,10 @@ PARAM_TEST_CASE(ArithmTestBase, MatDepth, Channels, bool) void generateTestData(bool with_val_in_range = false) { - const int type = CV_MAKE_TYPE(depth, cn); + const ElemType type = CV_MAKE_TYPE(depth, cn); - double minV = cvtest::getMinVal(type); - double maxV = cvtest::getMaxVal(type); + double minV = cvtest::getMinVal(depth); + double maxV = cvtest::getMaxVal(depth); Size roiSize = randomSize(1, MAX_VALUE); Border src1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); @@ -583,7 +583,7 @@ OCL_TEST_P(Transpose, Mat) OCL_TEST_P(Transpose, SquareInplace) { - const int type = CV_MAKE_TYPE(depth, cn); + const ElemType type = CV_MAKE_TYPE(depth, cn); for (int j = 0; j < test_loop_times; j++) { @@ -903,7 +903,7 @@ struct RepeatTestCase : void generateTestData() { - const int type = CV_MAKE_TYPE(depth, cn); + const ElemType type = CV_MAKE_TYPE(depth, cn); nx = randomInt(1, 4); ny = randomInt(1, 4); @@ -1469,8 +1469,8 @@ OCL_TEST_P(Normalize, Mat) for (int i = 0, size = sizeof(modes) / sizeof(modes[0]); i < size; ++i) { - OCL_OFF(cv::normalize(src1_roi, dst1_roi, 10, 110, modes[i], src1_roi.type(), mask_roi)); - OCL_ON(cv::normalize(usrc1_roi, udst1_roi, 10, 110, modes[i], src1_roi.type(), umask_roi)); + OCL_OFF(cv::normalize(src1_roi, dst1_roi, 10, 110, modes[i], src1_roi.depth(), mask_roi)); + OCL_ON(cv::normalize(usrc1_roi, udst1_roi, 10, 110, modes[i], src1_roi.depth(), umask_roi)); Near(1); } @@ -1501,7 +1501,7 @@ PARAM_TEST_CASE(InRange, MatDepth, Channels, bool /*Scalar or not*/, bool /*Roi* void generateTestData() { - const int type = CV_MAKE_TYPE(depth, cn); + const ElemType type = CV_MAKE_TYPE(depth, cn); Size roiSize = randomSize(1, MAX_VALUE); Border src1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); @@ -1580,8 +1580,8 @@ PARAM_TEST_CASE(ConvertScaleAbs, MatDepth, Channels, bool) void generateTestData() { - const int stype = CV_MAKE_TYPE(depth, cn); - const int dtype = CV_MAKE_TYPE(CV_8U, cn); + const ElemType stype = CV_MAKE_TYPE(depth, cn); + const ElemType dtype = CV_MAKE_TYPE(CV_8U, cn); Size roiSize = randomSize(1, MAX_VALUE); Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); @@ -1637,8 +1637,8 @@ PARAM_TEST_CASE(ConvertFp16, Channels, bool) void generateTestData() { - const int stype = CV_MAKE_TYPE(fromHalf ? CV_32F : CV_16S, cn); - const int dtype = CV_MAKE_TYPE(fromHalf ? CV_16S : CV_32F, cn); + const ElemType stype = CV_MAKE_TYPE(fromHalf ? CV_32F : CV_16S, cn); + const ElemType dtype = CV_MAKE_TYPE(fromHalf ? CV_16S : CV_32F, cn); Size roiSize = randomSize(1, MAX_VALUE); Border srcBorder = randomBorder(0, 0); @@ -1649,7 +1649,7 @@ PARAM_TEST_CASE(ConvertFp16, Channels, bool) Mat src_i32 = cvtest::randomMat(dataRng, roiSize, CV_MAKE_TYPE(CV_32S, cn), 0, 0x7c00, false); Mat shift_i32 = cvtest::randomMat(dataRng, roiSize, src_i32.type(), -1, 1, false); // values: -1, 0 src_i32 = src_i32 + (shift_i32 * 0x8000); - src_i32.convertTo(src_roi, stype); + src_i32.convertTo(src_roi, CV_MAT_DEPTH(stype)); } Border dstBorder = randomBorder(0, 0); @@ -1715,7 +1715,7 @@ PARAM_TEST_CASE(PatchNaNs, Channels, bool) void generateTestData() { - const int type = CV_MAKE_TYPE(CV_32F, cn); + const ElemType type = CV_MAKE_TYPE(CV_32F, cn); Size roiSize = randomSize(1, 10); Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); @@ -1777,7 +1777,9 @@ OCL_TEST_P(Psnr, Mat) PARAM_TEST_CASE(Reduce, std::pair, Channels, int, bool) { - int sdepth, ddepth, cn, dim, dtype; + ElemDepth sdepth, ddepth; + int cn, dim; + ElemType dtype; bool use_roi; TEST_DECLARE_INPUT_PARAMETER(src); @@ -1795,7 +1797,7 @@ PARAM_TEST_CASE(Reduce, std::pair, Channels, int, bool) void generateTestData() { - const int stype = CV_MAKE_TYPE(sdepth, cn); + const ElemType stype = CV_MAKE_TYPE(sdepth, cn); dtype = CV_MAKE_TYPE(ddepth, cn); Size roiSize = randomSize(1, MAX_VALUE); @@ -1819,8 +1821,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, CV_REDUCE_SUM, CV_MAT_DEPTH(dtype))); + OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_SUM, CV_MAT_DEPTH(dtype))); double eps = ddepth <= CV_32S ? 1 : 7e-4; OCL_EXPECT_MATS_NEAR(dst, eps); @@ -1835,8 +1837,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, CV_REDUCE_MAX, CV_MAT_DEPTH(dtype))); + OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MAX, CV_MAT_DEPTH(dtype))); OCL_EXPECT_MATS_NEAR(dst, 0); } @@ -1850,8 +1852,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, CV_REDUCE_MIN, CV_MAT_DEPTH(dtype))); + OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_MIN, CV_MAT_DEPTH(dtype))); OCL_EXPECT_MATS_NEAR(dst, 0); } @@ -1865,8 +1867,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, CV_REDUCE_AVG, CV_MAT_DEPTH(dtype))); + OCL_ON(cv::reduce(usrc_roi, udst_roi, dim, CV_REDUCE_AVG, CV_MAT_DEPTH(dtype))); double eps = ddepth <= CV_32S ? 1 : 6e-6; OCL_EXPECT_MATS_NEAR(dst, eps); diff --git a/modules/core/test/ocl/test_channels.cpp b/modules/core/test/ocl/test_channels.cpp index dd4e8134ca71..dc6e5792698e 100644 --- a/modules/core/test/ocl/test_channels.cpp +++ b/modules/core/test/ocl/test_channels.cpp @@ -77,7 +77,7 @@ PARAM_TEST_CASE(Merge, MatDepth, int, bool) CV_Assert(nsrc >= 1 && nsrc <= 4); } - int type() + ElemType type() { return CV_MAKE_TYPE(depth, randomInt(1, 3)); } @@ -176,16 +176,16 @@ PARAM_TEST_CASE(Split, MatType, Channels, bool) { Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0); - randomSubMat(dst1, dst1_roi, roiSize, dst1Border, depth, 2, 11); + randomSubMat(dst1, dst1_roi, roiSize, dst1Border, CV_MAKE_TYPE(depth, 1), 2, 11); Border dst2Border = randomBorder(0, use_roi ? MAX_VALUE : 0); - randomSubMat(dst2, dst2_roi, roiSize, dst2Border, depth, -1540, 1740); + randomSubMat(dst2, dst2_roi, roiSize, dst2Border, CV_MAKE_TYPE(depth, 1), -1540, 1740); Border dst3Border = randomBorder(0, use_roi ? MAX_VALUE : 0); - randomSubMat(dst3, dst3_roi, roiSize, dst3Border, depth, -1540, 1740); + randomSubMat(dst3, dst3_roi, roiSize, dst3Border, CV_MAKE_TYPE(depth, 1), -1540, 1740); Border dst4Border = randomBorder(0, use_roi ? MAX_VALUE : 0); - randomSubMat(dst4, dst4_roi, roiSize, dst4Border, depth, -1540, 1740); + randomSubMat(dst4, dst4_roi, roiSize, dst4Border, CV_MAKE_TYPE(depth, 1), -1540, 1740); } UMAT_UPLOAD_INPUT_PARAMETER(src); @@ -252,7 +252,7 @@ PARAM_TEST_CASE(MixChannels, MatType, bool) } // generate number of channels and create type - int type() + ElemType type() { int cn = randomInt(1, 5); return CV_MAKE_TYPE(depth, cn); @@ -368,7 +368,8 @@ OCL_TEST_P(MixChannels, Accuracy) PARAM_TEST_CASE(InsertChannel, MatDepth, Channels, bool) { - int depth, cn, coi; + ElemDepth depth; + int cn, coi; bool use_roi; TEST_DECLARE_INPUT_PARAMETER(src); @@ -387,7 +388,7 @@ PARAM_TEST_CASE(InsertChannel, MatDepth, Channels, bool) coi = randomInt(0, cn); Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); - randomSubMat(src, src_roi, roiSize, srcBorder, depth, 2, 11); + randomSubMat(src, src_roi, roiSize, srcBorder, CV_MAKETYPE(depth, 1), 2, 11); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_MAKE_TYPE(depth, cn), 5, 16); @@ -436,7 +437,7 @@ PARAM_TEST_CASE(ExtractChannel, MatDepth, Channels, bool) randomSubMat(src, src_roi, roiSize, srcBorder, CV_MAKE_TYPE(depth, cn), 2, 11); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); - randomSubMat(dst, dst_roi, roiSize, dstBorder, depth, 5, 16); + randomSubMat(dst, dst_roi, roiSize, dstBorder, CV_MAKETYPE(depth, 1), 5, 16); UMAT_UPLOAD_INPUT_PARAMETER(src); UMAT_UPLOAD_OUTPUT_PARAMETER(dst); diff --git a/modules/core/test/ocl/test_gemm.cpp b/modules/core/test/ocl/test_gemm.cpp index f8aebead915b..8206854a4338 100644 --- a/modules/core/test/ocl/test_gemm.cpp +++ b/modules/core/test/ocl/test_gemm.cpp @@ -62,7 +62,8 @@ PARAM_TEST_CASE(Gemm, ) { bool use_roi; - int type, flags; + ElemType type; + int flags; bool atrans, btrans, ctrans; double alpha, beta; diff --git a/modules/core/test/ocl/test_matrix_expr.cpp b/modules/core/test/ocl/test_matrix_expr.cpp index 7a5ff72cb24e..a9c7510a21f9 100644 --- a/modules/core/test/ocl/test_matrix_expr.cpp +++ b/modules/core/test/ocl/test_matrix_expr.cpp @@ -17,7 +17,7 @@ namespace ocl { PARAM_TEST_CASE(UMatExpr, MatDepth, Channels) { - int type; + ElemType type; Size size; virtual void SetUp() diff --git a/modules/core/test/ocl/test_matrix_operation.cpp b/modules/core/test/ocl/test_matrix_operation.cpp index 4d874d7f9dec..50d14b07d435 100644 --- a/modules/core/test/ocl/test_matrix_operation.cpp +++ b/modules/core/test/ocl/test_matrix_operation.cpp @@ -56,7 +56,9 @@ namespace ocl { PARAM_TEST_CASE(ConvertTo, MatDepth, MatDepth, Channels, bool) { - int src_depth, cn, dstType; + ElemDepth src_depth; + int cn; + ElemType dstType; bool use_roi; TEST_DECLARE_INPUT_PARAMETER(src); @@ -93,8 +95,8 @@ OCL_TEST_P(ConvertTo, WithScale_Accuracy) double alpha = randomDouble(-4, 4), beta = randomDouble(-4, 4); - OCL_OFF(src_roi.convertTo(dst_roi, dstType, alpha, beta)); - OCL_ON(usrc_roi.convertTo(udst_roi, dstType, alpha, beta)); + OCL_OFF(src_roi.convertTo(dst_roi, CV_MAT_DEPTH(dstType), alpha, beta)); + OCL_ON(usrc_roi.convertTo(udst_roi, CV_MAT_DEPTH(dstType), alpha, beta)); double eps = CV_MAT_DEPTH(dstType) >= CV_32F ? 2e-4 : 1; OCL_EXPECT_MATS_NEAR(dst, eps); @@ -107,8 +109,8 @@ OCL_TEST_P(ConvertTo, NoScale_Accuracy) { generateTestData(); - OCL_OFF(src_roi.convertTo(dst_roi, dstType, 1, 0)); - OCL_ON(usrc_roi.convertTo(udst_roi, dstType, 1, 0)); + OCL_OFF(src_roi.convertTo(dst_roi, CV_MAT_DEPTH(dstType), 1, 0)); + OCL_ON(usrc_roi.convertTo(udst_roi, CV_MAT_DEPTH(dstType), 1, 0)); double eps = CV_MAT_DEPTH(dstType) >= CV_32F ? 2e-4 : 1; OCL_EXPECT_MATS_NEAR(dst, eps); @@ -137,7 +139,7 @@ PARAM_TEST_CASE(CopyTo, MatDepth, Channels, bool, bool) void generateTestData(bool one_cn_mask = false) { - const int type = CV_MAKE_TYPE(depth, cn); + const ElemType type = CV_MAKE_TYPE(depth, cn); Size roiSize = randomSize(1, MAX_VALUE); Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index ba351e7977a6..42f9084ba8ef 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -21,7 +21,7 @@ struct BaseElemWiseOp virtual ~BaseElemWiseOp() {} virtual void op(const vector&, Mat&, const Mat&) {} virtual void refop(const vector&, Mat&, const Mat&) {} - virtual void getValueRange(int depth, double& minval, double& maxval) + virtual void getValueRange(ElemDepth depth, double& minval, double& maxval) { minval = depth < CV_32S ? cvtest::getMinVal(depth) : depth == CV_32S ? -1000000 : -1000.; maxval = depth < CV_32S ? cvtest::getMaxVal(depth) : depth == CV_32S ? 1000000 : 1000.; @@ -32,14 +32,14 @@ struct BaseElemWiseOp cvtest::randomSize(rng, 2, ARITHM_MAX_NDIMS, ARITHM_MAX_SIZE_LOG, size); } - virtual int getRandomType(RNG& rng) + virtual ElemType getRandomType(RNG& rng) { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, ninputs > 1 ? ARITHM_MAX_CHANNELS : 4); } - virtual double getMaxErr(int depth) { return depth < CV_32F ? 1 : depth == CV_32F ? 1e-5 : 1e-12; } - virtual void generateScalars(int depth, RNG& rng) + virtual double getMaxErr(ElemDepth depth) { return depth < CV_32F ? 1 : depth == CV_32F ? 1e-5 : 1e-12; } + virtual void generateScalars(ElemDepth depth, RNG& rng) { const double m = 3.; @@ -69,15 +69,15 @@ struct BaseElemWiseOp { Mat fl, db; - db = Mat(1, 1, CV_64F, &alpha); + db = Mat(1, 1, CV_64FC1, &alpha); db.convertTo(fl, CV_32F); fl.convertTo(db, CV_64F); - db = Mat(1, 1, CV_64F, &beta); + db = Mat(1, 1, CV_64FC1, &beta); db.convertTo(fl, CV_32F); fl.convertTo(db, CV_64F); - db = Mat(1, 4, CV_64F, &gamma[0]); + db = Mat(1, 4, CV_64FC1, &gamma[0]); db.convertTo(fl, CV_32F); fl.convertTo(db, CV_64F); } @@ -97,16 +97,16 @@ struct BaseAddOp : public BaseElemWiseOp BaseAddOp(int _ninputs, int _flags, double _alpha, double _beta, Scalar _gamma=Scalar::all(0)) : BaseElemWiseOp(_ninputs, _flags, _alpha, _beta, _gamma) {} - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { Mat temp; if( !mask.empty() ) { - cvtest::add(src[0], alpha, src.size() > 1 ? src[1] : Mat(), beta, gamma, temp, src[0].type()); + cvtest::add(src[0], alpha, src.size() > 1 ? src[1] : Mat(), beta, gamma, temp, src[0].depth()); cvtest::copy(temp, dst, mask); } else - cvtest::add(src[0], alpha, src.size() > 1 ? src[1] : Mat(), beta, gamma, dst, src[0].type()); + cvtest::add(src[0], alpha, src.size() > 1 ? src[1] : Mat(), beta, gamma, dst, src[0].depth()); } }; @@ -170,7 +170,7 @@ struct ScaleAddOp : public BaseAddOp { cv::scaleAdd(src[0], alpha, src[1], dst); } - double getMaxErr(int depth) + double getMaxErr(ElemDepth depth) CV_OVERRIDE { return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-4 : 1e-12; } @@ -184,7 +184,7 @@ struct AddWeightedOp : public BaseAddOp { cv::addWeighted(src[0], alpha, src[1], beta, gamma[0], dst); } - double getMaxErr(int depth) + double getMaxErr(ElemDepth depth) CV_OVERRIDE { return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-10; } @@ -193,22 +193,22 @@ struct AddWeightedOp : public BaseAddOp struct MulOp : public BaseElemWiseOp { MulOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void getValueRange(int depth, double& minval, double& maxval) + void getValueRange(ElemDepth depth, double& minval, double& maxval) CV_OVERRIDE { minval = depth < CV_32S ? cvtest::getMinVal(depth) : depth == CV_32S ? -1000000 : -1000.; maxval = depth < CV_32S ? cvtest::getMaxVal(depth) : depth == CV_32S ? 1000000 : 1000.; minval = std::max(minval, -30000.); maxval = std::min(maxval, 30000.); } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::multiply(src[0], src[1], dst, alpha); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::multiply(src[0], src[1], dst, alpha); } - double getMaxErr(int depth) + double getMaxErr(ElemDepth depth) CV_OVERRIDE { return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-12; } @@ -217,15 +217,15 @@ struct MulOp : public BaseElemWiseOp struct DivOp : public BaseElemWiseOp { DivOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::divide(src[0], src[1], dst, alpha); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::divide(src[0], src[1], dst, alpha); } - double getMaxErr(int depth) + double getMaxErr(ElemDepth depth) CV_OVERRIDE { return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-12; } @@ -234,15 +234,15 @@ struct DivOp : public BaseElemWiseOp struct RecipOp : public BaseElemWiseOp { RecipOp() : BaseElemWiseOp(1, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::divide(alpha, src[0], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::divide(Mat(), src[0], dst, alpha); } - double getMaxErr(int depth) + double getMaxErr(ElemDepth depth) CV_OVERRIDE { return depth <= CV_32S ? 2 : depth < CV_64F ? 1e-5 : 1e-12; } @@ -251,33 +251,33 @@ struct RecipOp : public BaseElemWiseOp struct AbsDiffOp : public BaseAddOp { AbsDiffOp() : BaseAddOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, -1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { absdiff(src[0], src[1], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { - cvtest::add(src[0], 1, src[1], -1, Scalar::all(0), dst, src[0].type(), true); + cvtest::add(src[0], 1, src[1], -1, Scalar::all(0), dst, src[0].depth(), true); } }; struct AbsDiffSOp : public BaseAddOp { AbsDiffSOp() : BaseAddOp(1, FIX_ALPHA+FIX_BETA, 1, 0, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { absdiff(src[0], gamma, dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { - cvtest::add(src[0], 1, Mat(), 0, -gamma, dst, src[0].type(), true); + cvtest::add(src[0], 1, Mat(), 0, -gamma, dst, src[0].depth(), true); } }; struct LogicOp : public BaseElemWiseOp { LogicOp(char _opcode) : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK, 1, 1, Scalar::all(0)), opcode(_opcode) {} - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { if( opcode == '&' ) cv::bitwise_and(src[0], src[1], dst, mask); @@ -286,7 +286,7 @@ struct LogicOp : public BaseElemWiseOp else cv::bitwise_xor(src[0], src[1], dst, mask); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { Mat temp; if( !mask.empty() ) @@ -297,7 +297,7 @@ struct LogicOp : public BaseElemWiseOp else cvtest::logicOp(src[0], src[1], dst, opcode); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -308,7 +308,7 @@ struct LogicSOp : public BaseElemWiseOp { LogicSOp(char _opcode) : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+(_opcode != '~' ? SUPPORT_MASK : 0), 1, 1, Scalar::all(0)), opcode(_opcode) {} - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { if( opcode == '&' ) cv::bitwise_and(src[0], gamma, dst, mask); @@ -319,7 +319,7 @@ struct LogicSOp : public BaseElemWiseOp else cv::bitwise_not(src[0], dst); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { Mat temp; if( !mask.empty() ) @@ -330,7 +330,7 @@ struct LogicSOp : public BaseElemWiseOp else cvtest::logicOp(src[0], gamma, dst, opcode); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -340,15 +340,15 @@ struct LogicSOp : public BaseElemWiseOp struct MinOp : public BaseElemWiseOp { MinOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::min(src[0], src[1], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::min(src[0], src[1], dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -357,15 +357,15 @@ struct MinOp : public BaseElemWiseOp struct MaxOp : public BaseElemWiseOp { MaxOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::max(src[0], src[1], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::max(src[0], src[1], dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -374,15 +374,15 @@ struct MaxOp : public BaseElemWiseOp struct MinSOp : public BaseElemWiseOp { MinSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::min(src[0], gamma[0], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::min(src[0], gamma[0], dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -391,15 +391,15 @@ struct MinSOp : public BaseElemWiseOp struct MaxSOp : public BaseElemWiseOp { MaxSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::max(src[0], gamma[0], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::max(src[0], gamma[0], dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -408,25 +408,25 @@ struct MaxSOp : public BaseElemWiseOp struct CmpOp : public BaseElemWiseOp { CmpOp() : BaseElemWiseOp(2, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) { cmpop = 0; } - void generateScalars(int depth, RNG& rng) + void generateScalars(ElemDepth depth, RNG& rng) CV_OVERRIDE { BaseElemWiseOp::generateScalars(depth, rng); cmpop = rng.uniform(0, 6); } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::compare(src[0], src[1], dst, cmpop); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::compare(src[0], src[1], dst, cmpop); } - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 1); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -436,26 +436,26 @@ struct CmpOp : public BaseElemWiseOp struct CmpSOp : public BaseElemWiseOp { CmpSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) { cmpop = 0; } - void generateScalars(int depth, RNG& rng) + void generateScalars(ElemDepth depth, RNG& rng) CV_OVERRIDE { BaseElemWiseOp::generateScalars(depth, rng); cmpop = rng.uniform(0, 6); if( depth < CV_32F ) gamma[0] = cvRound(gamma[0]); } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::compare(src[0], gamma[0], dst, cmpop); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::compare(src[0], gamma[0], dst, cmpop); } - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 1); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -466,19 +466,19 @@ struct CmpSOp : public BaseElemWiseOp struct CopyOp : public BaseElemWiseOp { CopyOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SUPPORT_MASK+SUPPORT_MULTICHANNELMASK, 1, 1, Scalar::all(0)) { } - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { src[0].copyTo(dst, mask); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { cvtest::copy(src[0], dst, mask); } - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_16F, 1, ARITHM_MAX_CHANNELS); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -488,19 +488,19 @@ struct CopyOp : public BaseElemWiseOp struct SetOp : public BaseElemWiseOp { SetOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA+SUPPORT_MASK+SUPPORT_MULTICHANNELMASK, 1, 1, Scalar::all(0)) {} - void op(const vector&, Mat& dst, const Mat& mask) + void op(const vector&, Mat& dst, const Mat& mask) CV_OVERRIDE { dst.setTo(gamma, mask); } - void refop(const vector&, Mat& dst, const Mat& mask) + void refop(const vector&, Mat& dst, const Mat& mask) CV_OVERRIDE { cvtest::set(dst, gamma, mask); } - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_16F, 1, ARITHM_MAX_CHANNELS); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -551,7 +551,7 @@ static void inRange(const Mat& src, const Mat& lb, const Mat& rb, Mat& dst) { CV_Assert( src.type() == lb.type() && src.type() == rb.type() && src.size == lb.size && src.size == rb.size ); - dst.create( src.dims, &src.size[0], CV_8U ); + dst.create(src.dims, &src.size[0], CV_8UC1); const Mat *arrays[]={&src, &lb, &rb, &dst, 0}; Mat planes[4]; @@ -598,16 +598,17 @@ static void inRange(const Mat& src, const Mat& lb, const Mat& rb, Mat& dst) static void inRangeS(const Mat& src, const Scalar& lb, const Scalar& rb, Mat& dst) { - dst.create( src.dims, &src.size[0], CV_8U ); + dst.create(src.dims, &src.size[0], CV_8UC1); const Mat *arrays[]={&src, &dst, 0}; Mat planes[2]; NAryMatIterator it(arrays, planes); size_t total = planes[0].total(); size_t i, nplanes = it.nplanes; - int depth = src.depth(), cn = src.channels(); + ElemDepth depth = src.depth(); + int cn = src.channels(); union { double d[4]; float f[4]; int i[4];} lbuf, rbuf; - int wtype = CV_MAKETYPE(depth <= CV_32S ? CV_32S : depth, cn); + ElemType wtype = CV_MAKETYPE(depth <= CV_32S ? CV_32S : depth, cn); scalarToRawData(lb, lbuf.d, wtype, cn); scalarToRawData(rb, rbuf.d, wtype, cn); @@ -651,19 +652,19 @@ CVTEST_GUARD_SYMBOL(inRange); struct InRangeSOp : public BaseElemWiseOp { InRangeSOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::inRange(src[0], gamma, gamma1, dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { reference::inRangeS(src[0], gamma, gamma1, dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } - void generateScalars(int depth, RNG& rng) + void generateScalars(ElemDepth depth, RNG& rng) CV_OVERRIDE { BaseElemWiseOp::generateScalars(depth, rng); Scalar temp = gamma; @@ -681,7 +682,7 @@ struct InRangeSOp : public BaseElemWiseOp struct InRangeOp : public BaseElemWiseOp { InRangeOp() : BaseElemWiseOp(3, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { Mat lb, rb; cvtest::min(src[1], src[2], lb); @@ -689,7 +690,7 @@ struct InRangeOp : public BaseElemWiseOp cv::inRange(src[0], lb, rb, dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { Mat lb, rb; cvtest::min(src[1], src[2], lb); @@ -697,7 +698,7 @@ struct InRangeOp : public BaseElemWiseOp reference::inRange(src[0], lb, rb, dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -706,26 +707,26 @@ struct InRangeOp : public BaseElemWiseOp struct ConvertScaleOp : public BaseElemWiseOp { - ConvertScaleOp() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)), ddepth(0) { } - void op(const vector& src, Mat& dst, const Mat&) + ConvertScaleOp() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)), ddepth(CV_8U) { } + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { src[0].convertTo(dst, ddepth, alpha, gamma[0]); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { - cvtest::convert(src[0], dst, CV_MAKETYPE(ddepth, src[0].channels()), alpha, gamma[0]); + cvtest::convert(src[0], dst, ddepth, alpha, gamma[0]); } - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { - int srctype = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS); - ddepth = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, 1); + ElemType srctype = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS); + ddepth = CV_MAT_DEPTH(cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, 1)); return srctype; } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return ddepth <= CV_32S ? 2 : ddepth < CV_64F ? 1e-3 : 1e-12; } - void generateScalars(int depth, RNG& rng) + void generateScalars(ElemDepth depth, RNG& rng) CV_OVERRIDE { if( rng.uniform(0, 2) ) BaseElemWiseOp::generateScalars(depth, rng); @@ -735,30 +736,30 @@ struct ConvertScaleOp : public BaseElemWiseOp gamma = Scalar::all(0); } } - int ddepth; + ElemDepth ddepth; }; struct ConvertScaleFp16Op : public BaseElemWiseOp { ConvertScaleFp16Op() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)), nextRange(0) { } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { Mat m; convertFp16(src[0], m); convertFp16(m, dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::copy(src[0], dst); } - int getRandomType(RNG&) + ElemType getRandomType(RNG&) CV_OVERRIDE { // 0: FP32 -> FP16 -> FP32 // 1: FP16 -> FP32 -> FP16 - int srctype = (nextRange & 1) == 0 ? CV_32F : CV_16S; + ElemType srctype = (nextRange & 1) == 0 ? CV_32FC1 : CV_16SC1; return srctype; } - void getValueRange(int, double& minval, double& maxval) + void getValueRange(ElemDepth, double& minval, double& maxval) CV_OVERRIDE { // 0: FP32 -> FP16 -> FP32 // 1: FP16 -> FP32 -> FP16 @@ -784,11 +785,11 @@ struct ConvertScaleFp16Op : public BaseElemWiseOp } } } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0.5f; } - void generateScalars(int, RNG& rng) + void generateScalars(ElemDepth, RNG& rng) CV_OVERRIDE { nextRange = rng.next(); } @@ -798,24 +799,24 @@ struct ConvertScaleFp16Op : public BaseElemWiseOp struct ConvertScaleAbsOp : public BaseElemWiseOp { ConvertScaleAbsOp() : BaseElemWiseOp(1, FIX_BETA+REAL_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::convertScaleAbs(src[0], dst, alpha, gamma[0]); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { - cvtest::add(src[0], alpha, Mat(), 0, Scalar::all(gamma[0]), dst, CV_8UC(src[0].channels()), true); + cvtest::add(src[0], alpha, Mat(), 0, Scalar::all(gamma[0]), dst, CV_8U, true); } - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, ninputs > 1 ? ARITHM_MAX_CHANNELS : 4); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 1; } - void generateScalars(int depth, RNG& rng) + void generateScalars(ElemDepth depth, RNG& rng) CV_OVERRIDE { if( rng.uniform(0, 2) ) BaseElemWiseOp::generateScalars(depth, rng); @@ -873,23 +874,23 @@ static void setIdentity(Mat& dst, const Scalar& s) struct FlipOp : public BaseElemWiseOp { FlipOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) { flipcode = 0; } - void getRandomSize(RNG& rng, vector& size) + void getRandomSize(RNG& rng, vector& size) CV_OVERRIDE { cvtest::randomSize(rng, 2, 2, ARITHM_MAX_SIZE_LOG, size); } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::flip(src[0], dst, flipcode); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { reference::flip(src[0], dst, flipcode); } - void generateScalars(int, RNG& rng) + void generateScalars(ElemDepth, RNG& rng) CV_OVERRIDE { flipcode = rng.uniform(0, 3) - 1; } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -899,19 +900,19 @@ struct FlipOp : public BaseElemWiseOp struct TransposeOp : public BaseElemWiseOp { TransposeOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void getRandomSize(RNG& rng, vector& size) + void getRandomSize(RNG& rng, vector& size) CV_OVERRIDE { cvtest::randomSize(rng, 2, 2, ARITHM_MAX_SIZE_LOG, size); } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::transpose(src[0], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::transpose(src[0], dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -920,19 +921,19 @@ struct TransposeOp : public BaseElemWiseOp struct SetIdentityOp : public BaseElemWiseOp { SetIdentityOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA, 1, 1, Scalar::all(0)) {} - void getRandomSize(RNG& rng, vector& size) + void getRandomSize(RNG& rng, vector& size) CV_OVERRIDE { cvtest::randomSize(rng, 2, 2, ARITHM_MAX_SIZE_LOG, size); } - void op(const vector&, Mat& dst, const Mat&) + void op(const vector&, Mat& dst, const Mat&) CV_OVERRIDE { cv::setIdentity(dst, gamma); } - void refop(const vector&, Mat& dst, const Mat&) + void refop(const vector&, Mat& dst, const Mat&) CV_OVERRIDE { reference::setIdentity(dst, gamma); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -941,15 +942,15 @@ struct SetIdentityOp : public BaseElemWiseOp struct SetZeroOp : public BaseElemWiseOp { SetZeroOp() : BaseElemWiseOp(0, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - void op(const vector&, Mat& dst, const Mat&) + void op(const vector&, Mat& dst, const Mat&) CV_OVERRIDE { dst = Scalar::all(0); } - void refop(const vector&, Mat& dst, const Mat&) + void refop(const vector&, Mat& dst, const Mat&) CV_OVERRIDE { cvtest::set(dst, Scalar::all(0)); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -1019,24 +1020,24 @@ static void log(const Mat& src, Mat& dst) struct ExpOp : public BaseElemWiseOp { ExpOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS); } - void getValueRange(int depth, double& minval, double& maxval) + void getValueRange(ElemDepth depth, double& minval, double& maxval) CV_OVERRIDE { maxval = depth == CV_32F ? 50 : 100; minval = -maxval; } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { cv::exp(src[0], dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { reference::exp(src[0], dst); } - double getMaxErr(int depth) + double getMaxErr(ElemDepth depth) { return depth == CV_32F ? 1e-5 : 1e-12; } @@ -1046,28 +1047,28 @@ struct ExpOp : public BaseElemWiseOp struct LogOp : public BaseElemWiseOp { LogOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {} - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS); } - void getValueRange(int depth, double& minval, double& maxval) + void getValueRange(ElemDepth depth, double& minval, double& maxval) CV_OVERRIDE { maxval = depth == CV_32F ? 50 : 100; minval = -maxval; } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { Mat temp; reference::exp(src[0], temp); cv::log(temp, dst); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { Mat temp; reference::exp(src[0], temp); reference::log(temp, dst); } - double getMaxErr(int depth) + double getMaxErr(ElemDepth depth) CV_OVERRIDE { return depth == CV_32F ? 1e-5 : 1e-12; } @@ -1077,7 +1078,7 @@ struct LogOp : public BaseElemWiseOp namespace reference { static void cartToPolar(const Mat& mx, const Mat& my, Mat& mmag, Mat& mangle, bool angleInDegrees) { - CV_Assert( (mx.type() == CV_32F || mx.type() == CV_64F) && + CV_Assert( (mx.type() == CV_32FC1 || mx.type() == CV_64FC1) && mx.type() == my.type() && mx.size == my.size ); mmag.create( mx.dims, &mx.size[0], mx.type() ); mangle.create( mx.dims, &mx.size[0], mx.type() ); @@ -1134,11 +1135,11 @@ struct CartToPolarToCartOp : public BaseElemWiseOp context = 3; angleInDegrees = true; } - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, 1); } - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { Mat mag, angle, x, y; @@ -1150,7 +1151,7 @@ struct CartToPolarToCartOp : public BaseElemWiseOp dst.create(src[0].dims, src[0].size, CV_MAKETYPE(src[0].depth(), 4)); cv::mixChannels(msrc, 4, &dst, 1, pairs, 4); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { Mat mag, angle; reference::cartToPolar(src[0], src[1], mag, angle, angleInDegrees); @@ -1159,11 +1160,11 @@ struct CartToPolarToCartOp : public BaseElemWiseOp dst.create(src[0].dims, src[0].size, CV_MAKETYPE(src[0].depth(), 4)); cv::mixChannels(msrc, 4, &dst, 1, pairs, 4); } - void generateScalars(int, RNG& rng) + void generateScalars(ElemDepth, RNG& rng) CV_OVERRIDE { angleInDegrees = rng.uniform(0, 2) != 0; } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 1e-3; } @@ -1177,17 +1178,17 @@ struct MeanOp : public BaseElemWiseOp { context = 3; }; - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { dst.create(1, 1, CV_64FC4); dst.at(0,0) = cv::mean(src[0], mask); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { dst.create(1, 1, CV_64FC4); dst.at(0,0) = cvtest::mean(src[0], mask); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 1e-5; } @@ -1200,17 +1201,17 @@ struct SumOp : public BaseElemWiseOp { context = 3; }; - void op(const vector& src, Mat& dst, const Mat&) + void op(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { dst.create(1, 1, CV_64FC4); dst.at(0,0) = cv::sum(src[0]); } - void refop(const vector& src, Mat& dst, const Mat&) + void refop(const vector& src, Mat& dst, const Mat&) CV_OVERRIDE { dst.create(1, 1, CV_64FC4); dst.at(0,0) = cvtest::mean(src[0])*(double)src[0].total(); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 1e-5; } @@ -1221,29 +1222,29 @@ struct CountNonZeroOp : public BaseElemWiseOp { CountNonZeroOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA+SCALAR_OUTPUT+SUPPORT_MASK, 1, 1, Scalar::all(0)) {} - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, 1); } - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { Mat temp; src[0].copyTo(temp); if( !mask.empty() ) temp.setTo(Scalar::all(0), mask); - dst.create(1, 1, CV_32S); + dst.create(1, 1, CV_32SC1); dst.at(0,0) = cv::countNonZero(temp); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { Mat temp; cvtest::compare(src[0], 0, temp, CMP_NE); if( !mask.empty() ) cvtest::set(temp, Scalar::all(0), mask); - dst.create(1, 1, CV_32S); + dst.create(1, 1, CV_32SC1); dst.at(0,0) = saturate_cast(cvtest::mean(temp)[0]/255*temp.total()); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -1260,12 +1261,12 @@ struct MeanStdDevOp : public BaseElemWiseOp cn = 0; context = 7; }; - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { dst.create(1, 2, CV_64FC4); cv::meanStdDev(src[0], dst.at(0,0), dst.at(0,1), mask); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { Mat temp; cvtest::convert(src[0], temp, CV_64F); @@ -1283,7 +1284,7 @@ struct MeanStdDevOp : public BaseElemWiseOp dst.at(0,0) = mean; dst.at(0,1) = sqmean; } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { CV_Assert(cn > 0); double err = sqmeanRef[0]; @@ -1301,9 +1302,9 @@ struct NormOp : public BaseElemWiseOp context = 1; normType = 0; }; - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { - int type = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 4); + ElemType type = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 4); for(;;) { normType = rng.uniform(1, 8); @@ -1314,26 +1315,26 @@ struct NormOp : public BaseElemWiseOp } if( normType == NORM_HAMMING || normType == NORM_HAMMING2 ) { - type = CV_8U; + type = CV_8UC1; } return type; } - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { dst.create(1, 2, CV_64FC1); dst.at(0,0) = cv::norm(src[0], normType, mask); dst.at(0,1) = cv::norm(src[0], src[1], normType, mask); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { dst.create(1, 2, CV_64FC1); dst.at(0,0) = cvtest::norm(src[0], normType, mask); dst.at(0,1) = cvtest::norm(src[0], src[1], normType, mask); } - void generateScalars(int, RNG& /*rng*/) + void generateScalars(ElemDepth, RNG& /*rng*/) CV_OVERRIDE { } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 1e-6; } @@ -1347,7 +1348,7 @@ struct MinMaxLocOp : public BaseElemWiseOp { context = ARITHM_MAX_NDIMS*2 + 2; }; - int getRandomType(RNG& rng) + ElemType getRandomType(RNG& rng) CV_OVERRIDE { return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 1); } @@ -1365,7 +1366,7 @@ struct MinMaxLocOp : public BaseElemWiseOp dst.at(0,ndims*2) = minval; dst.at(0,ndims*2+1) = maxval; } - void op(const vector& src, Mat& dst, const Mat& mask) + void op(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { int ndims = src[0].dims; vector minidx(ndims), maxidx(ndims); @@ -1373,7 +1374,7 @@ struct MinMaxLocOp : public BaseElemWiseOp cv::minMaxIdx(src[0], &minval, &maxval, &minidx[0], &maxidx[0], mask); saveOutput(minidx, maxidx, minval, maxval, dst); } - void refop(const vector& src, Mat& dst, const Mat& mask) + void refop(const vector& src, Mat& dst, const Mat& mask) CV_OVERRIDE { int ndims=src[0].dims; vector minidx(ndims), maxidx(ndims); @@ -1381,7 +1382,7 @@ struct MinMaxLocOp : public BaseElemWiseOp cvtest::minMaxLoc(src[0], &minval, &maxval, &minidx, &maxidx, mask); saveOutput(minidx, maxidx, minval, maxval, dst); } - double getMaxErr(int) + double getMaxErr(ElemDepth) CV_OVERRIDE { return 0; } @@ -1401,8 +1402,8 @@ TEST_P(ElemWiseTest, accuracy) { vector size; op->getRandomSize(rng, size); - int type = op->getRandomType(rng); - int depth = CV_MAT_DEPTH(type); + ElemType type = static_cast(op->getRandomType(rng)); + ElemDepth depth = CV_MAT_DEPTH(type); bool haveMask = ((op->flags & BaseElemWiseOp::SUPPORT_MASK) != 0 || (op->flags & BaseElemWiseOp::SUPPORT_MULTICHANNELMASK) != 0) && rng.uniform(0, 4) == 0; @@ -1416,7 +1417,7 @@ TEST_P(ElemWiseTest, accuracy) if( haveMask ) { bool multiChannelMask = (op->flags & BaseElemWiseOp::SUPPORT_MULTICHANNELMASK) != 0 && rng.uniform(0, 2) == 0; - int masktype = CV_8UC(multiChannelMask ? CV_MAT_CN(type) : 1); + ElemType masktype = CV_8UC(multiChannelMask ? CV_MAT_CN(type) : 1); mask = cvtest::randomMat(rng, size, masktype, 0, 2, true); } @@ -1503,11 +1504,11 @@ TEST(Core_ArithmMask, uninitialized) for( int iter = 0; iter < 100; iter++ ) { int dims = rng.uniform(1, MAX_DIM+1); - int depth = rng.uniform(CV_8U, CV_64F+1); + ElemDepth depth = static_cast(rng.uniform(CV_8U, CV_64F + 1)); int cn = rng.uniform(1, 6); - int type = CV_MAKETYPE(depth, cn); + ElemType type = CV_MAKETYPE(depth, cn); int op = rng.uniform(0, depth < CV_32F ? 5 : 2); // don't run binary operations between floating-point values - int depth1 = op <= 1 ? CV_64F : depth; + ElemDepth depth1 = op <= 1 ? CV_64F : depth; for (int k = 0; k < MAX_DIM; k++) { sizes[k] = k < dims ? rng.uniform(1, 30) : 0; @@ -1517,7 +1518,7 @@ TEST(Core_ArithmMask, uninitialized) Mat a(dims, sizes, type), a1; Mat b(dims, sizes, type), b1; - Mat mask(dims, sizes, CV_8U); + Mat mask(dims, sizes, CV_8UC1); Mat mask1; Mat c, d; @@ -1638,8 +1639,8 @@ class SubtractOutputMatNotEmpty : public testing::TestWithParam< tuple 0 ? dst_depth : CV_16S), src1.channels())); + const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > CV_8U ? dst_depth : CV_16S), src1.channels())); cv::subtract(src1, src2, fixed_dst, cv::noArray(), dst_depth); dst = fixed_dst; dst_depth = fixed_dst.depth(); @@ -1672,7 +1673,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Mat) ASSERT_FALSE(dst.empty()); ASSERT_EQ(src1.size(), dst.size()); - ASSERT_EQ(dst_depth > 0 ? dst_depth : src1.depth(), dst.depth()); + ASSERT_EQ(dst_depth > CV_8U ? dst_depth : src1.depth(), dst.depth()); ASSERT_EQ(0, cv::countNonZero(dst.reshape(1))); } @@ -1690,7 +1691,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Mat_WithMask) } else { - const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src1.channels())); + const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > CV_8U ? dst_depth : CV_16S), src1.channels())); cv::subtract(src1, src2, fixed_dst, mask, dst_depth); dst = fixed_dst; dst_depth = fixed_dst.depth(); @@ -1698,7 +1699,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Mat_WithMask) ASSERT_FALSE(dst.empty()); ASSERT_EQ(src1.size(), dst.size()); - ASSERT_EQ(dst_depth > 0 ? dst_depth : src1.depth(), dst.depth()); + ASSERT_EQ(dst_depth > CV_8U ? dst_depth : src1.depth(), dst.depth()); ASSERT_EQ(0, cv::countNonZero(dst.reshape(1))); } @@ -1727,7 +1728,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Scalar) } else { - const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels())); + const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > CV_8U ? dst_depth : CV_16S), src.channels())); cv::subtract(src, cv::Scalar::all(16), fixed_dst, cv::noArray(), dst_depth); dst = fixed_dst; dst_depth = fixed_dst.depth(); @@ -1735,7 +1736,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Scalar) ASSERT_FALSE(dst.empty()); ASSERT_EQ(src.size(), dst.size()); - ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth()); + ASSERT_EQ(dst_depth > CV_8U ? dst_depth : src.depth(), dst.depth()); ASSERT_EQ(0, cv::countNonZero(dst.reshape(1))); } @@ -1752,7 +1753,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Scalar_WithMask) } else { - const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels())); + const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > CV_8U ? dst_depth : CV_16S), src.channels())); cv::subtract(src, cv::Scalar::all(16), fixed_dst, mask, dst_depth); dst = fixed_dst; dst_depth = fixed_dst.depth(); @@ -1760,7 +1761,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Scalar_WithMask) ASSERT_FALSE(dst.empty()); ASSERT_EQ(src.size(), dst.size()); - ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth()); + ASSERT_EQ(dst_depth > CV_8U ? dst_depth : src.depth(), dst.depth()); ASSERT_EQ(0, cv::countNonZero(dst.reshape(1))); } @@ -1776,7 +1777,7 @@ TEST_P(SubtractOutputMatNotEmpty, Scalar_Mat) } else { - const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels())); + const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > CV_8U ? dst_depth : CV_16S), src.channels())); cv::subtract(cv::Scalar::all(16), src, fixed_dst, cv::noArray(), dst_depth); dst = fixed_dst; dst_depth = fixed_dst.depth(); @@ -1784,7 +1785,7 @@ TEST_P(SubtractOutputMatNotEmpty, Scalar_Mat) ASSERT_FALSE(dst.empty()); ASSERT_EQ(src.size(), dst.size()); - ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth()); + ASSERT_EQ(dst_depth > CV_8U ? dst_depth : src.depth(), dst.depth()); ASSERT_EQ(0, cv::countNonZero(dst.reshape(1))); } @@ -1801,7 +1802,7 @@ TEST_P(SubtractOutputMatNotEmpty, Scalar_Mat_WithMask) } else { - const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels())); + const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > CV_8U ? dst_depth : CV_16S), src.channels())); cv::subtract(cv::Scalar::all(16), src, fixed_dst, mask, dst_depth); dst = fixed_dst; dst_depth = fixed_dst.depth(); @@ -1809,7 +1810,7 @@ TEST_P(SubtractOutputMatNotEmpty, Scalar_Mat_WithMask) ASSERT_FALSE(dst.empty()); ASSERT_EQ(src.size(), dst.size()); - ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth()); + ASSERT_EQ(dst_depth > CV_8U ? dst_depth : src.depth(), dst.depth()); ASSERT_EQ(0, cv::countNonZero(dst.reshape(1))); } @@ -1828,7 +1829,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Mat_3d) } else { - const cv::Mat fixed_dst(3, dims, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src1.channels())); + const cv::Mat fixed_dst(3, dims, CV_MAKE_TYPE((dst_depth > CV_8U ? dst_depth : CV_16S), src1.channels())); cv::subtract(src1, src2, fixed_dst, cv::noArray(), dst_depth); dst = fixed_dst; dst_depth = fixed_dst.depth(); @@ -1837,7 +1838,7 @@ TEST_P(SubtractOutputMatNotEmpty, Mat_Mat_3d) ASSERT_FALSE(dst.empty()); ASSERT_EQ(src1.dims, dst.dims); ASSERT_EQ(src1.size, dst.size); - ASSERT_EQ(dst_depth > 0 ? dst_depth : src1.depth(), dst.depth()); + ASSERT_EQ(dst_depth > CV_8U ? dst_depth : src1.depth(), dst.depth()); ASSERT_EQ(0, cv::countNonZero(dst.reshape(1))); } @@ -1849,7 +1850,7 @@ INSTANTIATE_TEST_CASE_P(Arithm, SubtractOutputMatNotEmpty, testing::Combine( TEST(Core_FindNonZero, regression) { - Mat img(10, 10, CV_8U, Scalar::all(0)); + Mat img(10, 10, CV_8UC1, Scalar::all(0)); vector pts, pts2(5); findNonZero(img, pts); findNonZero(img, pts2); @@ -1968,7 +1969,7 @@ TEST(Normalize, regression_6125) 249, 575, 574, 63, 12 }; - Mat src(Size(20, 1), CV_32F, initial_values); + Mat src(Size(20, 1), CV_32FC1, initial_values); float min = 0., max = 400.; normalize(src, src, 0, 400, NORM_MINMAX, CV_32F); for(int i = 0; i < 20; i++) @@ -1980,10 +1981,10 @@ TEST(Normalize, regression_6125) TEST(MinMaxLoc, regression_4955_nans) { - cv::Mat one_mat(2, 2, CV_32F, cv::Scalar(1)); + cv::Mat one_mat(2, 2, CV_32FC1, cv::Scalar(1)); cv::minMaxLoc(one_mat, NULL, NULL, NULL, NULL); - cv::Mat nan_mat(2, 2, CV_32F, cv::Scalar(std::numeric_limits::quiet_NaN())); + cv::Mat nan_mat(2, 2, CV_32FC1, cv::Scalar(std::numeric_limits::quiet_NaN())); cv::minMaxLoc(nan_mat, NULL, NULL, NULL, NULL); } diff --git a/modules/core/test/test_concatenation.cpp b/modules/core/test/test_concatenation.cpp index 201bf0e9afb9..7ab01c98e683 100644 --- a/modules/core/test/test_concatenation.cpp +++ b/modules/core/test/test_concatenation.cpp @@ -45,13 +45,13 @@ namespace opencv_test { namespace { TEST(Core_Concatenation, empty) { - const Mat mat0x5(0,5, CV_8U, Scalar::all(1)); - const Mat mat10x5(10,5, CV_8U, Scalar::all(1)); - const Mat mat20x5(20,5, CV_8U, Scalar::all(1)); + const Mat mat0x5(0, 5, CV_8UC1, Scalar::all(1)); + const Mat mat10x5(10, 5, CV_8UC1, Scalar::all(1)); + const Mat mat20x5(20, 5, CV_8UC1, Scalar::all(1)); - const Mat mat5x0(5,0, CV_8U, Scalar::all(1)); - const Mat mat5x10(5,10, CV_8U, Scalar::all(1)); - const Mat mat5x20(5,20, CV_8U, Scalar::all(1)); + const Mat mat5x0(5, 0, CV_8UC1, Scalar::all(1)); + const Mat mat5x10(5, 10, CV_8UC1, Scalar::all(1)); + const Mat mat5x20(5, 20, CV_8UC1, Scalar::all(1)); Mat result; diff --git a/modules/core/test/test_ds.cpp b/modules/core/test/test_ds.cpp index 3a1a00b8b6fc..439dbb5dabd5 100644 --- a/modules/core/test/test_ds.cpp +++ b/modules/core/test/test_ds.cpp @@ -764,7 +764,7 @@ int Core_SeqBaseTest::test_seq_ops( int iters ) if( sseq->count == sseq->max_count ) break; - elem_mat = Mat(1, elem_size, CV_8U, elem); + elem_mat = Mat(1, elem_size, CV_8UC1, elem); cvtest::randUni( rng, elem_mat, cvScalarAll(0), cvScalarAll(255) ); whence = op - 1; @@ -845,7 +845,7 @@ int Core_SeqBaseTest::test_seq_ops( int iters ) break; count = cvtest::randInt( rng ) % (sseq->max_count - sseq->count + 1); - elem_mat = Mat(1, MAX(count,1) * elem_size, CV_8U, elem); + elem_mat = Mat(1, MAX(count, 1) * elem_size, CV_8UC1, elem); cvtest::randUni( rng, elem_mat, cvScalarAll(0), cvScalarAll(255) ); whence = op - 7; @@ -1286,7 +1286,7 @@ int Core_SetTest::test_set_ops( int iters ) if( sset->free_count == 0 ) continue; - elem_mat = Mat(1, cvset->elem_size, CV_8U, &elem_buf[0]); + elem_mat = Mat(1, cvset->elem_size, CV_8UC1, &elem_buf[0]); cvtest::randUni( rng, elem_mat, cvScalarAll(0), cvScalarAll(255) ); elem = (CvSetElem*)&elem_buf[0]; @@ -1521,7 +1521,7 @@ int Core_GraphTest::test_graph_ops( int iters ) if( pure_vtx_size ) { - elem_mat = Mat(1, graph->elem_size, CV_8U, &elem_buf[0]); + elem_mat = Mat(1, graph->elem_size, CV_8UC1, &elem_buf[0]); cvtest::randUni( rng, elem_mat, cvScalarAll(0), cvScalarAll(255) ); } @@ -1631,7 +1631,7 @@ int Core_GraphTest::test_graph_ops( int iters ) if( pure_edge_size > 0 ) { - elem_mat = Mat(1, graph->edges->elem_size, CV_8U, &elem_buf[0]); + elem_mat = Mat(1, graph->edges->elem_size, CV_8UC1, &elem_buf[0]); cvtest::randUni( rng, elem_mat, cvScalarAll(0), cvScalarAll(255) ); } edge = (CvGraphEdge*)&elem_buf[0]; diff --git a/modules/core/test/test_dxt.cpp b/modules/core/test/test_dxt.cpp index dbb378aa08ec..3f6adde1b39c 100644 --- a/modules/core/test/test_dxt.cpp +++ b/modules/core/test/test_dxt.cpp @@ -137,7 +137,7 @@ static Mat initDCTWave( int n, bool inv ) { int i, k; double angle = CV_PI*0.5/n; - Mat wave(n, n, CV_64F); + Mat wave(n, n, CV_64FC1); double scale = sqrt(1./n); for( k = 0; k < n; k++ ) @@ -503,9 +503,9 @@ class CxCore_DXTBaseTest : public cvtest::ArrayTest CxCore_DXTBaseTest( bool _allow_complex=false, bool _allow_odd=false, bool _spectrum_mode=false ); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - int prepare_test_case( int test_case_idx ); - double get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + double get_success_error_level(int /*test_case_idx*/, int /*i*/, int /*j*/) CV_OVERRIDE; int flags; // transformation flags bool allow_complex; // whether input/output may be complex or not: // true for DFT and MulSpectrums, false for DCT @@ -537,11 +537,11 @@ spectrum_mode(_spectrum_mode), inplace(false), temp_dst(false) void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); - int depth = cvtest::randInt(rng)%2 + CV_32F; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2 + CV_32F); int cn = !allow_complex || !(bits & 256) ? 1 : 2; Size size; Base::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -589,7 +589,7 @@ void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx, { if( cn == 1 ) { - types[OUTPUT][0] = depth + 8; + types[OUTPUT][0] = CV_MAKETYPE(depth, 2); sizes[TEMP][0] = size; } sizes[INPUT][0] = sizes[INPUT][1] = size; @@ -597,7 +597,7 @@ void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx, } else if( /*(cn == 2 && (bits&32)) ||*/ (cn == 1 && allow_complex) ) { - types[TEMP][0] = depth + 8; // CV_??FC2 + types[TEMP][0] = CV_MAKETYPE(depth, 2); sizes[TEMP][0] = size; size = cvSize(size.width/2+1, size.height); @@ -605,7 +605,7 @@ void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx, { if( cn == 2 ) { - types[OUTPUT][0] = depth; + types[OUTPUT][0] = CV_MAKETYPE(depth, 1); sizes[INPUT][0] = size; } types[TEMP][1] = types[TEMP][0]; @@ -614,17 +614,17 @@ void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx, else { if( allow_complex ) - types[OUTPUT][0] = depth + 8; + types[OUTPUT][0] = CV_MAKETYPE(depth, 2); if( cn == 2 ) { - types[INPUT][0] = depth; + types[INPUT][0] = CV_MAKETYPE(depth, 1); types[TEMP][1] = types[TEMP][0]; sizes[TEMP][1] = size; } else { - types[TEMP][1] = depth; + types[TEMP][1] = CV_MAKETYPE(depth, 1); sizes[TEMP][1] = sizes[TEMP][0]; } temp_dst = true; @@ -677,7 +677,7 @@ class CxCore_DFTTest : public CxCore_DXTBaseTest CxCore_DFTTest(); protected: void run_func(); - void prepare_to_validation( int test_case_idx ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; }; @@ -742,7 +742,7 @@ class CxCore_DCTTest : public CxCore_DXTBaseTest CxCore_DCTTest(); protected: void run_func(); - void prepare_to_validation( int test_case_idx ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; }; @@ -782,8 +782,8 @@ class CxCore_MulSpectrumsTest : public CxCore_DXTBaseTest CxCore_MulSpectrumsTest(); protected: void run_func(); - void prepare_to_validation( int test_case_idx ); - double get_success_error_level( int test_case_idx, int i, int j ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; }; @@ -865,10 +865,10 @@ class Core_DFTComplexOutputTest : public cvtest::BaseTest int m = rng.uniform(2, 11); int n = rng.uniform(2, 11); int depth = rng.uniform(0, 2) + CV_32F; - Mat src8u(m, n, depth), src(m, n, depth), dst(m, n, CV_MAKETYPE(depth, 2)); - Mat z = Mat::zeros(m, n, depth), dstz; + Mat src8u(m, n, CV_MAKETYPE(depth, 1)), src(m, n, CV_MAKETYPE(depth, 1)), dst(m, n, CV_MAKETYPE(depth, 2)); + Mat z = Mat::zeros(m, n, CV_MAKETYPE(depth, 1)), dstz; randu(src8u, Scalar::all(0), Scalar::all(10)); - src8u.convertTo(src, src.type()); + src8u.convertTo(src, src.depth()); dst = Scalar::all(123); Mat mv[] = {src, z}, srcz; merge(mv, 2, srcz); @@ -890,7 +890,7 @@ TEST(Core_DFT, complex_output2) { for( int i = 0; i < 100; i++ ) { - int type = theRNG().uniform(0, 2) ? CV_64F : CV_32F; + ElemType type = theRNG().uniform(0, 2) ? CV_64FC1 : CV_32FC1; int m = theRNG().uniform(1, 10); int n = theRNG().uniform(1, 10); Mat x(m, n, type), out; diff --git a/modules/core/test/test_eigen.cpp b/modules/core/test/test_eigen.cpp index b2f09ea48c8c..9070e474d754 100644 --- a/modules/core/test/test_eigen.cpp +++ b/modules/core/test/test_eigen.cpp @@ -73,7 +73,7 @@ class Core_EigenTest: public cvtest::BaseTest protected: bool test_values(const cv::Mat& src); // complex test for eigen without vectors - bool check_full(int type); // compex test for symmetric matrix + bool check_full(ElemType type); // compex test for symmetric matrix virtual void run (int) = 0; // main testing method protected: @@ -220,7 +220,7 @@ void Core_EigenTest::print_information(const size_t norm_idx, const cv::Mat& src bool Core_EigenTest::check_orthogonality(const cv::Mat& U) { - int type = U.type(); + ElemType type = U.type(); double eps_vec = type == CV_32FC1 ? eps_vec_32 : eps_vec_64; cv::Mat UUt; cv::mulTransposed(U, UUt, false); @@ -280,7 +280,7 @@ bool Core_EigenTest::check_pairs_order(const cv::Mat& eigen_values) bool Core_EigenTest::test_pairs(const cv::Mat& src) { - int type = src.type(); + ElemType type = src.type(); double eps_vec = type == CV_32FC1 ? eps_vec_32 : eps_vec_64; cv::Mat eigen_values, eigen_vectors; @@ -308,10 +308,13 @@ bool Core_EigenTest::test_pairs(const cv::Mat& src) for (int i = 0; i < src.cols; ++i) { double eigenval = 0; - switch (type) + if (type == CV_32FC1) + { + eigenval = eigen_values.at(i, 0); + } + else if (type == CV_64FC1) { - case CV_32FC1: eigenval = eigen_values.at(i, 0); break; - case CV_64FC1: eigenval = eigen_values.at(i, 0); break; + eigenval = eigen_values.at(i, 0); } cv::Mat rhs_v = eigenval * eigen_vectors_t.col(i); rhs_v.copyTo(rhs.col(i)); @@ -359,7 +362,7 @@ bool Core_EigenTest::test_values(const cv::Mat& src) return true; } -bool Core_EigenTest::check_full(int type) +bool Core_EigenTest::check_full(ElemType type) { const int MAX_DEGREE = 7; @@ -393,7 +396,7 @@ static void testEigen(const Mat_& src, const Mat_& expected_eigenvalues, b SCOPED_TRACE(runSymmetric ? "cv::eigen" : "cv::eigenNonSymmetric"); int type = traits::Type::value; - const T eps = src.type() == CV_32F ? 1e-4f : 1e-6f; + const T eps = src.type() == CV_32FC1 ? 1e-4f : 1e-6f; Mat eigenvalues, eigenvectors, eigenvalues0; diff --git a/modules/core/test/test_hal_core.cpp b/modules/core/test/test_hal_core.cpp index 35fb97747897..dc541beec406 100644 --- a/modules/core/test/test_hal_core.cpp +++ b/modules/core/test/test_hal_core.cpp @@ -53,12 +53,12 @@ TEST(Core_HAL, mathfuncs) { for( int hcase = 0; hcase < 6; hcase++ ) { - int depth = hcase % 2 == 0 ? CV_32F : CV_64F; + ElemDepth depth = hcase % 2 == 0 ? CV_32F : CV_64F; double eps = depth == CV_32F ? 1e-5 : 1e-10; int nfunc = hcase / 2; int n = 100; - Mat src(1, n, depth), dst(1, n, depth), dst0(1, n, depth); + Mat src(1, n, CV_MAKETYPE(depth, 1)), dst(1, n, CV_MAKETYPE(depth, 1)), dst0(1, n, CV_MAKETYPE(depth, 1)); randu(src, 1, 10); double min_hal_t = DBL_MAX, min_ocv_t = DBL_MAX; @@ -132,7 +132,7 @@ TEST_P(HAL, mat_decomp) int hcase = GetParam(); SCOPED_TRACE(cv::format("hcase=%d", hcase)); { - int depth = hcase % 2 == 0 ? CV_32F : CV_64F; + ElemDepth depth = hcase % 2 == 0 ? CV_32F : CV_64F; int size = (hcase / 2) % 4; size = size == 0 ? 3 : size == 1 ? 4 : size == 2 ? 6 : 15; int nfunc = (hcase / 8); @@ -141,7 +141,7 @@ TEST_P(HAL, mat_decomp) if( size == 3 ) return; // TODO ??? - Mat a0(size, size, depth), a(size, size, depth), b(size, 1, depth), x(size, 1, depth), x0(size, 1, depth); + Mat a0(size, size, CV_MAKETYPE(depth, 1)), a(size, size, CV_MAKETYPE(depth, 1)), b(size, 1, CV_MAKETYPE(depth, 1)), x(size, 1, CV_MAKETYPE(depth, 1)), x0(size, 1, CV_MAKETYPE(depth, 1)); randu(a0, -1, 1); a0 = a0*a0.t(); randu(b, -1, 1); diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 33583b4d1bb0..98c11d77e6cf 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -5,10 +5,10 @@ namespace opencv_test { namespace { -static SparseMat cvTsGetRandomSparseMat(int dims, const int* sz, int type, +static SparseMat cvTsGetRandomSparseMat(int dims, const int* sz, ElemDepth type, int nzcount, double a, double b, RNG& rng) { - SparseMat m(dims, sz, type); + SparseMat m(dims, sz, CV_MAKETYPE(type, 1)); int i, j; CV_Assert(CV_MAT_CN(type) == 1); for( i = 0; i < nzcount; i++ ) @@ -114,7 +114,7 @@ class Core_IOTest : public cvtest::BaseTest double test_real = (cvtest::randInt(rng)%2?1:-1)*exp(cvtest::randReal(rng)*18-9); string test_string = "vw wv23424rt\"&<>&'@#$@$%$%&%IJUKYILFD@#$@%$&*&() "; - int depth = cvtest::randInt(rng) % (CV_64F+1); + ElemDepth depth = static_cast(cvtest::randInt(rng) % (CV_64F + 1)); int cn = cvtest::randInt(rng) % 4 + 1; Mat test_mat(cvtest::randInt(rng)%30+1, cvtest::randInt(rng)%30+1, CV_MAKETYPE(depth, cn)); @@ -145,7 +145,7 @@ class Core_IOTest : public cvtest::BaseTest edge->weight = (float)(i+1); } - depth = cvtest::randInt(rng) % (CV_64F+1); + depth = static_cast(cvtest::randInt(rng) % (CV_64F + 1)); cn = cvtest::randInt(rng) % 4 + 1; int sz[] = { static_cast(cvtest::randInt(rng)%10+1), @@ -169,7 +169,7 @@ class Core_IOTest : public cvtest::BaseTest static_cast(cvtest::randInt(rng)%10+1), static_cast(cvtest::randInt(rng)%10+1), }; - SparseMat test_sparse_mat = cvTsGetRandomSparseMat(4, ssz, cvtest::randInt(rng)%(CV_64F+1), + SparseMat test_sparse_mat = cvTsGetRandomSparseMat(4, ssz, static_cast(cvtest::randInt(rng)%(CV_64F+1)), cvtest::randInt(rng) % 10000, 0, 100, rng); fs << "test_int" << test_int << "test_real" << test_real << "test_string" << test_string; @@ -445,7 +445,7 @@ class CV_MiscIOTest : public cvtest::BaseTest vector mi, mi2, mi3, mi4; vector mv, mv2, mv3, mv4; vector vudt, vudt2, vudt3, vudt4; - Mat m(10, 9, CV_32F); + Mat m(10, 9, CV_32FC1); Mat empty; UserDefinedType udt = { 8, 3.3f }; randu(m, 0, 1); @@ -1037,7 +1037,7 @@ TEST(Core_InputOutput, filestorage_vec_vec_io) outputMats[i].resize(i+1); for(size_t j = 0; j < outputMats[i].size(); j++) { - outputMats[i][j] = Mat::eye((int)i + 1, (int)i + 1, CV_8U); + outputMats[i][j] = Mat::eye((int)i + 1, (int)i + 1, CV_8UC1); } } @@ -1086,7 +1086,7 @@ TEST(Core_InputOutput, filestorage_yaml_advanvced_type_heading) cv::FileStorage fs(content, cv::FileStorage::READ | cv::FileStorage::MEMORY); cv::Mat inputMatrix; - cv::Mat actualMatrix = cv::Mat::eye(1, 1, CV_64F); + cv::Mat actualMatrix = cv::Mat::eye(1, 1, CV_64FC1); fs["cameraMatrix"] >> inputMatrix; ASSERT_EQ(cv::norm(inputMatrix, actualMatrix, NORM_INF), 0.); diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 32b83d431b45..266355789f54 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -11,8 +11,8 @@ class Core_ReduceTest : public cvtest::BaseTest Core_ReduceTest() {} protected: void run( int); - int checkOp( const Mat& src, int dstType, int opType, const Mat& opRes, int dim ); - int checkCase( int srcType, int dstType, int dim, Size sz ); + int checkOp(const Mat& src, ElemType dstDepth, int opType, const Mat& opRes, int dim); + int checkCase(ElemType srcType, ElemType dstType, int dim, Size sz); int checkDim( int dim, Size sz ); int checkSize( Size sz ); }; @@ -66,7 +66,7 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim } } } - sum.convertTo( avg, CV_64FC1 ); + sum.convertTo( avg, CV_64F ); avg = avg * (1.0 / (dim==0 ? (double)src.rows : (double)src.cols)); } @@ -81,39 +81,39 @@ void getMatTypeStr( int type, string& str) type == CV_64FC1 ? "CV_64FC1" : "unsupported matrix type"; } -int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat& opRes, int dim ) +int Core_ReduceTest::checkOp( const Mat& src, ElemType dstType, int opType, const Mat& opRes, int dim ) { - int srcType = src.type(); + ElemType srcType = src.type(); bool support = false; if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG ) { - if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) ) + if (srcType == CV_8UC1 && (dstType == CV_32SC1 || dstType == CV_32FC1 || dstType == CV_64FC1)) support = true; - if( srcType == CV_16U && (dstType == CV_32F || dstType == CV_64F) ) + if (srcType == CV_16UC1 && (dstType == CV_32FC1 || dstType == CV_64FC1)) support = true; - if( srcType == CV_16S && (dstType == CV_32F || dstType == CV_64F) ) + if (srcType == CV_16SC1 && (dstType == CV_32FC1 || dstType == CV_64FC1)) support = true; - if( srcType == CV_32F && (dstType == CV_32F || dstType == CV_64F) ) + if (srcType == CV_32FC1 && (dstType == CV_32FC1 || dstType == CV_64FC1)) support = true; - if( srcType == CV_64F && dstType == CV_64F) + if (srcType == CV_64FC1 && dstType == CV_64FC1) support = true; } else if( opType == CV_REDUCE_MAX ) { - if( srcType == CV_8U && dstType == CV_8U ) + if (srcType == CV_8UC1 && dstType == CV_8UC1) support = true; - if( srcType == CV_32F && dstType == CV_32F ) + if (srcType == CV_32FC1 && dstType == CV_32FC1) support = true; - if( srcType == CV_64F && dstType == CV_64F ) + if (srcType == CV_64FC1 && dstType == CV_64FC1) support = true; } else if( opType == CV_REDUCE_MIN ) { - if( srcType == CV_8U && dstType == CV_8U) + if (srcType == CV_8UC1 && dstType == CV_8UC1) support = true; - if( srcType == CV_32F && dstType == CV_32F) + if (srcType == CV_32FC1 && dstType == CV_32FC1) support = true; - if( srcType == CV_64F && dstType == CV_64F) + if (srcType == CV_64FC1 && dstType == CV_64FC1) support = true; } if( !support ) @@ -122,22 +122,22 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat double eps = 0.0; if ( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG ) { - if ( dstType == CV_32F ) + if (dstType == CV_32FC1) eps = 1.e-5; - else if( dstType == CV_64F ) + else if (dstType == CV_64FC1) eps = 1.e-8; - else if ( dstType == CV_32S ) + else if (dstType == CV_32SC1) eps = 0.6; } assert( opRes.type() == CV_64FC1 ); Mat _dst, dst, diff; - cv::reduce( src, _dst, dim, opType, dstType ); - _dst.convertTo( dst, CV_64FC1 ); + cv::reduce(src, _dst, dim, opType, CV_MAT_DEPTH(dstType)); + _dst.convertTo( dst, CV_64F ); absdiff( opRes,dst,diff ); bool check = false; - if (dstType == CV_32F || dstType == CV_64F) + if (dstType == CV_32FC1 || dstType == CV_64FC1) check = countNonZero(diff>eps*dst) > 0; else check = countNonZero(diff>eps) > 0; @@ -161,7 +161,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat return cvtest::TS::OK; } -int Core_ReduceTest::checkCase( int srcType, int dstType, int dim, Size sz ) +int Core_ReduceTest::checkCase(ElemType srcType, ElemType dstType, int dim, Size sz) { int code = cvtest::TS::OK, tempCode; Mat src, sum, avg, max, min; @@ -522,7 +522,7 @@ static double getValue(SparseMat& M, const int* idx, RNG& rng) const uchar* ptr = d == 2 ? M.ptr(idx[0], idx[1], false, phv) : d == 3 ? M.ptr(idx[0], idx[1], idx[2], false, phv) : M.ptr(idx, false, phv); - return !ptr ? 0 : M.type() == CV_32F ? *(float*)ptr : M.type() == CV_64F ? *(double*)ptr : 0; + return !ptr ? 0 : M.type() == CV_32FC1 ? *(float*)ptr : M.type() == CV_64FC1 ? *(double*)ptr : 0; } static double getValue(const CvSparseMat* M, const int* idx) @@ -570,9 +570,9 @@ static void setValue(SparseMat& M, const int* idx, double value, RNG& rng) uchar* ptr = d == 2 ? M.ptr(idx[0], idx[1], true, phv) : d == 3 ? M.ptr(idx[0], idx[1], idx[2], true, phv) : M.ptr(idx, true, phv); - if( M.type() == CV_32F ) + if (M.type() == CV_32FC1) *(float*)ptr = (float)value; - else if( M.type() == CV_64F ) + else if (M.type() == CV_64FC1) *(double*)ptr = value; else CV_Error(CV_StsUnsupportedFormat, ""); @@ -614,7 +614,7 @@ void Core_ArrayOpTest::run( int /* start_from */) // dense matrix operations { int sz3[] = {5, 10, 15}; - MatND A(3, sz3, CV_32F), B(3, sz3, CV_16SC4); + MatND A(3, sz3, CV_32FC1), B(3, sz3, CV_16SC4); CvMatND matA = cvMatND(A), matB = cvMatND(B); RNG rng; rng.fill(A, CV_RAND_UNI, Scalar::all(-10), Scalar::all(10)); @@ -751,7 +751,7 @@ void Core_ArrayOpTest::run( int /* start_from */) // sparse matrix operations for( int si = 0; si < 10; si++ ) { - int depth = (unsigned)rng % 2 == 0 ? CV_32F : CV_64F; + ElemDepth depth = (unsigned)rng % 2 == 0 ? CV_32F : CV_64F; int dims = ((unsigned)rng % MAX_DIM) + 1; int i, k, size[MAX_DIM]={0}, idx[MAX_DIM]={0}; vector all_idxs; @@ -766,7 +766,7 @@ void Core_ArrayOpTest::run( int /* start_from */) size[k] = ((unsigned)rng % MAX_DIM_SZ) + 1; p *= size[k]; } - SparseMat M( dims, size, depth ); + SparseMat M(dims, size, CV_MAKETYPE(depth, 1)); map M0; int nz0 = (unsigned)rng % std::max(p/5,10); @@ -781,7 +781,7 @@ void Core_ArrayOpTest::run( int /* start_from */) _all_vals.convertTo(_all_vals_f, CV_32F); _all_vals_f.convertTo(_all_vals, CV_64F); } - _all_vals.convertTo(_all_vals2, _all_vals2.type(), 2); + _all_vals.convertTo(_all_vals2, _all_vals2.depth(), 2); if( depth == CV_32F ) { Mat _all_vals2_f; @@ -824,7 +824,7 @@ void Core_ArrayOpTest::run( int /* start_from */) Ptr M2(cvCreateSparseMat(M)); MatND Md; M.copyTo(Md); - SparseMat M3; SparseMat(Md).convertTo(M3, Md.type(), 2); + SparseMat M3; SparseMat(Md).convertTo(M3, Md.depth(), 2); int nz1 = (int)M.nzcount(), nz2 = (int)M3.nzcount(); double norm0 = cv/*test*/::norm(M, CV_C); @@ -1176,8 +1176,8 @@ TEST(Core_IOArray, submat_assignment) EXPECT_EQ( 1.0f, A(0,1) ); } -void OutputArray_create1(OutputArray m) { m.create(1, 2, CV_32S); } -void OutputArray_create2(OutputArray m) { m.create(1, 3, CV_32F); } +void OutputArray_create1(OutputArray m) { m.create(1, 2, CV_32SC1); } +void OutputArray_create2(OutputArray m) { m.create(1, 3, CV_32FC1); } TEST(Core_IOArray, submat_create) { @@ -1189,7 +1189,7 @@ TEST(Core_IOArray, submat_create) TEST(Core_Mat, issue4457_pass_null_ptr) { - ASSERT_ANY_THROW(cv::Mat mask(45, 45, CV_32F, 0)); + ASSERT_ANY_THROW(cv::Mat mask(45, 45, CV_32FC1, 0)); } TEST(Core_Mat, reshape_1942) @@ -1380,7 +1380,7 @@ TEST(Core_SVD, orthogonality) { for( int i = 0; i < 2; i++ ) { - int type = i == 0 ? CV_32F : CV_64F; + ElemType type = i == 0 ? CV_32FC1 : CV_64FC1; Mat mat_D(2, 2, type); mat_D.setTo(88.); Mat mat_U, mat_W; @@ -1395,7 +1395,7 @@ TEST(Core_SparseMat, footprint) { int n = 1000000; int sz[] = { n, n }; - SparseMat m(2, sz, CV_64F); + SparseMat m(2, sz, CV_64FC1); int nodeSize0 = (int)m.hdr->nodeSize; double dataSize0 = ((double)m.hdr->pool.size() + (double)m.hdr->hashtab.size()*sizeof(size_t))*1e-6; @@ -1499,12 +1499,12 @@ TEST(Core_Mat_vector, copyTo_roi_row) TEST(Mat, regression_5991) { int sz[] = {2,3,2}; - Mat mat(3, sz, CV_32F, Scalar(1)); + Mat mat(3, sz, CV_32FC1, Scalar(1)); ASSERT_NO_THROW(mat.convertTo(mat, CV_8U)); EXPECT_EQ(sz[0], mat.size[0]); EXPECT_EQ(sz[1], mat.size[1]); EXPECT_EQ(sz[2], mat.size[2]); - EXPECT_EQ(0, cvtest::norm(mat, Mat(3, sz, CV_8U, Scalar(1)), NORM_INF)); + EXPECT_EQ(0, cvtest::norm(mat, Mat(3, sz, CV_8UC1, Scalar(1)), NORM_INF)); } TEST(Mat, regression_9720) @@ -1548,7 +1548,7 @@ TEST(Mat, regression_6696_BigData_8Gb) TEST(Reduce, regression_should_fail_bug_4594) { - cv::Mat src = cv::Mat::eye(4, 4, CV_8U); + cv::Mat src = cv::Mat::eye(4, 4, CV_8UC1); std::vector dst; EXPECT_THROW(cv::reduce(src, dst, 0, CV_REDUCE_MIN, CV_32S), cv::Exception); @@ -1708,7 +1708,7 @@ TEST(Core_Mat_array, SplitMerge) std::array src; for (size_t i = 0; i < src.size(); ++i) { - src[i] = Mat(10, 10, CV_8U, Scalar((double)(16 * (i + 1)))); + src[i] = Mat(10, 10, CV_8UC1, Scalar((double)(16 * (i + 1)))); } Mat merged; @@ -1751,7 +1751,7 @@ TEST(Mat, from_initializer_list) Mat_ B(3, 1); B << 1, 2, 3; Mat_ C({3}, {1,2,3}); - ASSERT_EQ(A.type(), CV_32F); + ASSERT_EQ(A.type(), CV_32FC1); ASSERT_DOUBLE_EQ(cvtest::norm(A, B, NORM_INF), 0.); ASSERT_DOUBLE_EQ(cvtest::norm(A, C, NORM_INF), 0.); ASSERT_DOUBLE_EQ(cvtest::norm(B, C, NORM_INF), 0.); diff --git a/modules/core/test/test_math.cpp b/modules/core/test/test_math.cpp index c763ed80dc43..10a5fb5b4256 100644 --- a/modules/core/test/test_math.cpp +++ b/modules/core/test/test_math.cpp @@ -28,8 +28,8 @@ class Core_MathTest : public cvtest::ArrayTest Core_MathTest(); protected: void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types); - double get_success_error_level( int /*test_case_idx*/, int i, int j ); + vector >& types) CV_OVERRIDE; + double get_success_error_level(int /*test_case_idx*/, int i, int j) CV_OVERRIDE; bool test_nd; }; @@ -54,11 +54,12 @@ double Core_MathTest::get_success_error_level( int /*test_case_idx*/, int i, int void Core_MathTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types) + vector >& types) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng)%2 + CV_32F; - int cn = cvtest::randInt(rng) % 4 + 1, type = CV_MAKETYPE(depth, cn); + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2 + CV_32F); + int cn = cvtest::randInt(rng) % 4 + 1; + ElemType type = CV_MAKETYPE(depth, cn); size_t i, j; Base::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -82,11 +83,11 @@ class Core_PowTest : public Core_MathTest protected: void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - void run_func(); - void prepare_to_validation( int test_case_idx ); - double get_success_error_level( int test_case_idx, int i, int j ); + vector >& types ) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth type, Scalar& low, Scalar& high) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; double power; }; @@ -99,14 +100,15 @@ Core_PowTest::Core_PowTest() void Core_PowTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % (CV_64F+1); + int _depth = cvtest::randInt(rng) % (CV_64F + 1); + _depth += _depth == CV_8S; int cn = cvtest::randInt(rng) % 4 + 1; size_t i, j; Base::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - depth += depth == CV_8S; + ElemDepth depth = static_cast(_depth); if( depth < CV_32F || cvtest::randInt(rng)%8 == 0 ) // integer power @@ -120,7 +122,7 @@ void Core_PowTest::get_test_array_types_and_sizes( int test_case_idx, for( i = 0; i < test_array.size(); i++ ) { size_t count = test_array[i].size(); - int type = CV_MAKETYPE(depth, cn); + ElemType type = CV_MAKETYPE(depth, cn); for( j = 0; j < count; j++ ) types[i][j] = type; } @@ -130,7 +132,7 @@ void Core_PowTest::get_test_array_types_and_sizes( int test_case_idx, double Core_PowTest::get_success_error_level( int test_case_idx, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); if( depth < CV_32F ) return power == cvRound(power) && power >= 0 ? 0 : 1; else @@ -140,7 +142,7 @@ double Core_PowTest::get_success_error_level( int test_case_idx, int i, int j ) } -void Core_PowTest::get_minmax_bounds( int /*i*/, int /*j*/, int type, Scalar& low, Scalar& high ) +void Core_PowTest::get_minmax_bounds( int /*i*/, int /*j*/, ElemDepth type, Scalar& low, Scalar& high ) { double l, u = cvtest::randInt(ts->get_rng())%1000 + 1; if( power > 0 ) @@ -221,7 +223,7 @@ void Core_PowTest::prepare_to_validation( int /*test_case_idx*/ ) const Mat& a = test_mat[INPUT][0]; Mat& b = test_mat[REF_OUTPUT][0]; - int depth = a.depth(); + ElemDepth depth = a.depth(); int ncols = a.cols*a.channels(); int ipower = cvRound(power), apower = abs(ipower); int i, j; @@ -353,6 +355,8 @@ void Core_PowTest::prepare_to_validation( int /*test_case_idx*/ ) ((double*)b_data)[j] = (double)val; } break; + case CV_16F: + break; //unhandled } } } @@ -368,8 +372,8 @@ class Core_MatrixTest : public cvtest::ArrayTest protected: void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; bool allow_int; bool scalar_output; int max_cn; @@ -396,17 +400,18 @@ Core_MatrixTest::Core_MatrixTest( int in_count, int out_count, void Core_MatrixTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % (allow_int ? CV_64F+1 : 2); + int _depth = cvtest::randInt(rng) % (allow_int ? CV_64F + 1 : 2); int cn = cvtest::randInt(rng) % max_cn + 1; size_t i, j; if( allow_int ) - depth += depth == CV_8S; + _depth += _depth == CV_8S; else - depth += CV_32F; + _depth += CV_32F; + ElemDepth depth = static_cast(_depth); Base::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -414,7 +419,7 @@ void Core_MatrixTest::get_test_array_types_and_sizes( int test_case_idx, { size_t count = test_array[i].size(); int flag = (i == OUTPUT || i == REF_OUTPUT) && scalar_output; - int type = !flag ? CV_MAKETYPE(depth, cn) : CV_64FC1; + ElemType type = !flag ? CV_MAKETYPE(depth, cn) : CV_64FC1; for( j = 0; j < count; j++ ) { @@ -428,7 +433,7 @@ void Core_MatrixTest::get_test_array_types_and_sizes( int test_case_idx, double Core_MatrixTest::get_success_error_level( int test_case_idx, int i, int j ) { - int input_depth = test_mat[INPUT][0].depth(); + ElemDepth input_depth = test_mat[INPUT][0].depth(); double input_precision = input_depth < CV_32F ? 0 : input_depth == CV_32F ? 5e-5 : 5e-10; double output_precision = Base::get_success_error_level( test_case_idx, i, j ); return MAX(input_precision, output_precision); @@ -443,7 +448,7 @@ class Core_TraceTest : public Core_MatrixTest Core_TraceTest(); protected: void run_func(); - void prepare_to_validation( int test_case_idx ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; }; @@ -478,7 +483,7 @@ class Core_DotProductTest : public Core_MatrixTest Core_DotProductTest(); protected: void run_func(); - void prepare_to_validation( int test_case_idx ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; }; @@ -508,9 +513,9 @@ class Core_CrossProductTest : public Core_MatrixTest protected: void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + vector >& types) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; }; @@ -521,11 +526,12 @@ Core_CrossProductTest::Core_CrossProductTest() : Core_MatrixTest( 2, 1, false, f void Core_CrossProductTest::get_test_array_types_and_sizes( int, vector >& sizes, - vector >& types ) + vector >& types) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % 2 + CV_32F; - int cn = cvtest::randInt(rng) & 1 ? 3 : 1, type = CV_MAKETYPE(depth, cn); + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2 + CV_32F); + int cn = cvtest::randInt(rng) & 1 ? 3 : 1; + ElemType type = CV_MAKETYPE(depth, cn); Size sz; types[INPUT][0] = types[INPUT][1] = types[OUTPUT][0] = types[REF_OUTPUT][0] = type; @@ -608,11 +614,11 @@ class Core_GEMMTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_GEMMTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; int tabc_flag; double alpha, beta; }; @@ -626,7 +632,7 @@ Core_GEMMTest::Core_GEMMTest() : Core_MatrixTest( 5, 1, false, false, 2 ) } -void Core_GEMMTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_GEMMTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); Size sizeA; @@ -635,7 +641,7 @@ void Core_GEMMTest::get_test_array_types_and_sizes( int test_case_idx, vector(~CV_MAT_CN_MASK); tabc_flag = cvtest::randInt(rng) & 7; @@ -689,7 +695,7 @@ int Core_GEMMTest::prepare_test_case( int test_case_idx ) } -void Core_GEMMTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ) +void Core_GEMMTest::get_minmax_bounds( int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high ) { low = Scalar::all(-10.); high = Scalar::all(10.); @@ -718,10 +724,10 @@ class Core_MulTransposedTest : public Core_MatrixTest public: Core_MulTransposedTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; int order; }; @@ -734,17 +740,17 @@ Core_MulTransposedTest::Core_MulTransposedTest() : Core_MatrixTest( 2, 1, false, } -void Core_MulTransposedTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_MulTransposedTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); - int src_type = cvtest::randInt(rng) % 5; - int dst_type = cvtest::randInt(rng) % 2; + int _src_depth = cvtest::randInt(rng) % 5; + int _dst_depth = cvtest::randInt(rng) % 2; - src_type = src_type == 0 ? CV_8U : src_type == 1 ? CV_16U : src_type == 2 ? CV_16S : - src_type == 3 ? CV_32F : CV_64F; - dst_type = dst_type == 0 ? CV_32F : CV_64F; - dst_type = MAX( dst_type, src_type ); + ElemDepth src_depth = _src_depth == 0 ? CV_8U : _src_depth == 1 ? CV_16U : _src_depth == 2 ? CV_16S : + _src_depth == 3 ? CV_32F : CV_64F; + ElemDepth dst_depth = _dst_depth == 0 ? CV_32F : CV_64F; + dst_depth = CV_MAX_DEPTH(dst_depth, src_depth); Core_MatrixTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -760,8 +766,8 @@ void Core_MulTransposedTest::get_test_array_types_and_sizes( int test_case_idx, } sizes[TEMP][0] = sizes[INPUT][0]; - types[INPUT][0] = src_type; - types[OUTPUT][0] = types[REF_OUTPUT][0] = types[INPUT][1] = types[TEMP][0] = dst_type; + types[INPUT][0] = CV_MAKETYPE(src_depth, 1); + types[OUTPUT][0] = types[REF_OUTPUT][0] = types[INPUT][1] = types[TEMP][0] = CV_MAKETYPE(dst_depth, 1); order = (bits & 8) != 0; sizes[OUTPUT][0].width = sizes[OUTPUT][0].height = order == 0 ? @@ -770,7 +776,7 @@ void Core_MulTransposedTest::get_test_array_types_and_sizes( int test_case_idx, } -void Core_MulTransposedTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ) +void Core_MulTransposedTest::get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) { low = cvScalarAll(-10.); high = cvScalarAll(10.); @@ -796,10 +802,10 @@ void Core_MulTransposedTest::prepare_to_validation( int ) cv::repeat( delta, src.rows/delta.rows, src.cols/delta.cols, temp); delta = temp; } - cvtest::add( src, 1, delta, -1, Scalar::all(0), temp, temp.type()); + cvtest::add( src, 1, delta, -1, Scalar::all(0), temp, temp.depth()); } else - src.convertTo(temp, temp.type()); + src.convertTo(temp, temp.depth()); cvtest::gemm( temp, temp, 1., Mat(), 0, test_mat[REF_OUTPUT][0], order == 0 ? GEMM_2_T : GEMM_1_T ); } @@ -813,11 +819,11 @@ class Core_TransformTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_TransformTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; double scale; bool diagMtx; @@ -831,11 +837,13 @@ Core_TransformTest::Core_TransformTest() : Core_MatrixTest( 3, 1, true, false, 4 } -void Core_TransformTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_TransformTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); - int depth, dst_cn, mat_cols, mattype; + ElemDepth depth; + int dst_cn, mat_cols; + ElemDepth matdepth; Base::get_test_array_types_and_sizes( test_case_idx, sizes, types ); mat_cols = CV_MAT_CN(types[INPUT][0]); @@ -843,9 +851,9 @@ void Core_TransformTest::get_test_array_types_and_sizes( int test_case_idx, vect dst_cn = cvtest::randInt(rng) % 4 + 1; types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth, dst_cn); - mattype = depth < CV_32S ? CV_32F : depth == CV_64F ? CV_64F : bits & 1 ? CV_32F : CV_64F; - types[INPUT][1] = mattype; - types[INPUT][2] = CV_MAKETYPE(mattype, dst_cn); + matdepth = depth < CV_32S ? CV_32F : depth == CV_64F ? CV_64F : bits & 1 ? CV_32F : CV_64F; + types[INPUT][1] = CV_MAKETYPE(matdepth, 1); + types[INPUT][2] = CV_MAKETYPE(matdepth, dst_cn); scale = 1./((cvtest::randInt(rng)%4)*50+1); @@ -862,7 +870,7 @@ void Core_TransformTest::get_test_array_types_and_sizes( int test_case_idx, vect sizes[INPUT][2] = Size(dst_cn,1); else sizes[INPUT][2] = Size(1,dst_cn); - types[INPUT][2] &= ~CV_MAT_CN_MASK; + types[INPUT][2] &= static_cast(~CV_MAT_CN_MASK); } diagMtx = (bits & 16) != 0; @@ -876,10 +884,10 @@ int Core_TransformTest::prepare_test_case( int test_case_idx ) if( code > 0 ) { Mat& m = test_mat[INPUT][1]; - cvtest::add(m, scale, m, 0, Scalar::all(0), m, m.type() ); + cvtest::add(m, scale, m, 0, Scalar::all(0), m, m.depth()); if(diagMtx) { - Mat mask = Mat::eye(m.rows, m.cols, CV_8U)*255; + Mat mask = Mat::eye(m.rows, m.cols, CV_8UC1) * 255; mask = ~mask; m.setTo(Scalar::all(0), mask); } @@ -890,7 +898,7 @@ int Core_TransformTest::prepare_test_case( int test_case_idx ) double Core_TransformTest::get_success_error_level( int test_case_idx, int i, int j ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth <= CV_8S ? 1 : depth <= CV_32S ? 9 : Base::get_success_error_level( test_case_idx, i, j ); } @@ -914,14 +922,16 @@ class Core_TransformLargeTest : public Core_TransformTest public: typedef Core_MatrixTest Base; protected: - void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; }; -void Core_TransformLargeTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) +void Core_TransformLargeTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); - int depth, dst_cn, mat_cols, mattype; + ElemDepth depth; + int dst_cn, mat_cols; + ElemType mattype; Base::get_test_array_types_and_sizes(test_case_idx, sizes, types); for (unsigned int j = 0; j < sizes.size(); j++) { @@ -936,7 +946,7 @@ void Core_TransformLargeTest::get_test_array_types_and_sizes(int test_case_idx, dst_cn = cvtest::randInt(rng) % 4 + 1; types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth, dst_cn); - mattype = depth < CV_32S ? CV_32F : depth == CV_64F ? CV_64F : bits & 1 ? CV_32F : CV_64F; + mattype = depth < CV_32S ? CV_32FC1 : depth == CV_64F ? CV_64FC1 : bits & 1 ? CV_32FC1 : CV_64FC1; types[INPUT][1] = mattype; types[INPUT][2] = CV_MAKETYPE(mattype, dst_cn); @@ -955,7 +965,7 @@ void Core_TransformLargeTest::get_test_array_types_and_sizes(int test_case_idx, sizes[INPUT][2] = Size(dst_cn, 1); else sizes[INPUT][2] = Size(1, dst_cn); - types[INPUT][2] &= ~CV_MAT_CN_MASK; + types[INPUT][2] &= static_cast(~CV_MAT_CN_MASK); } diagMtx = (bits & 16) != 0; @@ -971,10 +981,10 @@ class Core_PerspectiveTransformTest : public Core_MatrixTest public: Core_PerspectiveTransformTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; }; @@ -983,26 +993,28 @@ Core_PerspectiveTransformTest::Core_PerspectiveTransformTest() : Core_MatrixTest } -void Core_PerspectiveTransformTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_PerspectiveTransformTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); - int depth, cn, mattype; + ElemDepth depth; + int cn; + ElemDepth matdepth; Core_MatrixTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); cn = CV_MAT_CN(types[INPUT][0]) + 1; depth = CV_MAT_DEPTH(types[INPUT][0]); types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth, cn); - mattype = depth == CV_64F ? CV_64F : bits & 1 ? CV_32F : CV_64F; - types[INPUT][1] = mattype; + matdepth = depth == CV_64F ? CV_64F : bits & 1 ? CV_32F : CV_64F; + types[INPUT][1] = CV_MAKETYPE(matdepth, 1); sizes[INPUT][1] = Size(cn + 1, cn + 1); } double Core_PerspectiveTransformTest::get_success_error_level( int test_case_idx, int i, int j ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = static_cast(test_mat[INPUT][0].depth()); return depth == CV_32F ? 1e-4 : depth == CV_64F ? 1e-8 : Core_MatrixTest::get_success_error_level(test_case_idx, i, j); } @@ -1129,10 +1141,10 @@ class Core_MahalanobisTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_MahalanobisTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; }; @@ -1145,7 +1157,7 @@ Core_MahalanobisTest::Core_MahalanobisTest() : Core_MatrixTest( 3, 1, false, tru } -void Core_MahalanobisTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_MahalanobisTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); Core_MatrixTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -1184,7 +1196,7 @@ void Core_MahalanobisTest::run_func() void Core_MahalanobisTest::prepare_to_validation( int ) { cvtest::add( test_mat[INPUT][0], 1., test_mat[INPUT][1], -1., - Scalar::all(0), test_mat[TEMP][0], test_mat[TEMP][0].type() ); + Scalar::all(0), test_mat[TEMP][0], test_mat[TEMP][0].depth() ); if( test_mat[INPUT][0].rows == 1 ) cvtest::gemm( test_mat[TEMP][0], test_mat[INPUT][2], 1., Mat(), 0., test_mat[TEMP][1], 0 ); @@ -1203,10 +1215,10 @@ class Core_CovarMatrixTest : public Core_MatrixTest public: Core_CovarMatrixTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; vector temp_hdrs; vector hdr_data; int flags, t_flag, len, count; @@ -1225,7 +1237,7 @@ Core_CovarMatrixTest::Core_CovarMatrixTest() : Core_MatrixTest( 1, 1, true, fals } -void Core_CovarMatrixTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_CovarMatrixTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); @@ -1257,7 +1269,7 @@ void Core_CovarMatrixTest::get_test_array_types_and_sizes( int test_case_idx, ve flags = (flags & ~CV_COVAR_ROWS) | CV_COVAR_COLS; if( CV_MAT_DEPTH(types[INPUT][0]) == CV_32S ) - types[INPUT][0] = (types[INPUT][0] & ~CV_MAT_DEPTH_MASK) | CV_32F; + types[INPUT][0] = (types[INPUT][0] & static_cast(~CV_MAT_DEPTH_MASK)) | CV_32FC1; sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = flags & CV_COVAR_NORMAL ? Size(len,len) : Size(count,count); sizes[INPUT_OUTPUT][0] = sizes[REF_INPUT_OUTPUT][0] = !t_flag ? Size(len,1) : Size(1,len); @@ -1265,7 +1277,7 @@ void Core_CovarMatrixTest::get_test_array_types_and_sizes( int test_case_idx, ve types[INPUT_OUTPUT][0] = types[REF_INPUT_OUTPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = types[TEMP][0] = - CV_MAT_DEPTH(types[INPUT][0]) == CV_64F || (bits & 512) ? CV_64F : CV_32F; + CV_MAT_DEPTH(types[INPUT][0]) == CV_64F || (bits & 512) ? CV_64FC1 : CV_32FC1; are_images = (bits & 1024) != 0; for( i = 0; i < (single_matrix ? 1 : count); i++ ) @@ -1345,10 +1357,10 @@ void Core_CovarMatrixTest::prepare_to_validation( int ) else vec = cvarrToMat(temp_hdrs[i]); - cvtest::add(avg, 1, vec, 1, Scalar::all(0), avg, avg.type()); + cvtest::add(avg, 1, vec, 1, Scalar::all(0), avg, avg.depth()); } - cvtest::add(avg, 1./count, avg, 0., Scalar::all(0), avg, avg.type()); + cvtest::add(avg, 1. / count, avg, 0., Scalar::all(0), avg, avg.depth()); } if( flags & CV_COVAR_SCALE ) @@ -1358,7 +1370,7 @@ void Core_CovarMatrixTest::prepare_to_validation( int ) Mat& temp0 = test_mat[TEMP][0]; cv::repeat( avg, temp0.rows/avg.rows, temp0.cols/avg.cols, temp0 ); - cvtest::add( test_mat[INPUT][0], 1, temp0, -1, Scalar::all(0), temp0, temp0.type()); + cvtest::add(test_mat[INPUT][0], 1, temp0, -1, Scalar::all(0), temp0, temp0.depth()); cvtest::gemm( temp0, temp0, scale, Mat(), 0., test_mat[REF_OUTPUT][0], t_flag ^ ((flags & CV_COVAR_NORMAL) != 0) ? CV_GEMM_A_T : CV_GEMM_B_T ); @@ -1393,12 +1405,12 @@ class Core_DetTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_DetTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; }; @@ -1410,7 +1422,7 @@ Core_DetTest::Core_DetTest() : Core_MatrixTest( 1, 1, false, true, 1 ) } -void Core_DetTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_DetTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { Base::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -1420,7 +1432,7 @@ void Core_DetTest::get_test_array_types_and_sizes( int test_case_idx, vector(0,0) = cvRealScalar(cvTsLU(&temp0, 0, 0)); } @@ -1552,12 +1564,12 @@ class Core_InvertTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_InvertTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ); - double get_success_error_level( int test_case_idx, int i, int j ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; int method, rank; double result; }; @@ -1573,7 +1585,7 @@ Core_InvertTest::Core_InvertTest() } -void Core_InvertTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_InvertTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); @@ -1630,7 +1642,7 @@ int Core_InvertTest::prepare_test_case( int test_case_idx ) -void Core_InvertTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ) +void Core_InvertTest::get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) { low = cvScalarAll(-1.); high = cvScalarAll(1.); @@ -1680,7 +1692,7 @@ void Core_InvertTest::prepare_to_validation( int ) double ratio = 0, det = cvTsSVDet( &_input, &ratio ); double threshold = (input.depth() == CV_32F ? FLT_EPSILON : DBL_EPSILON)*1000; - cvtest::convert( input, temp1, temp1.type() ); + cvtest::convert( input, temp1, temp1.depth() ); if( det < threshold || ((method == CV_LU || method == CV_CHOLESKY) && (result == 0 || ratio < threshold)) || @@ -1708,12 +1720,12 @@ class Core_SolveTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_SolveTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ); - double get_success_error_level( int test_case_idx, int i, int j ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; int method, rank; double result; }; @@ -1728,7 +1740,7 @@ Core_SolveTest::Core_SolveTest() : Core_MatrixTest( 2, 1, false, false, 1 ), met } -void Core_SolveTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_SolveTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); @@ -1781,7 +1793,7 @@ int Core_SolveTest::prepare_test_case( int test_case_idx ) } -void Core_SolveTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ) +void Core_SolveTest::get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) { low = cvScalarAll(-1.); high = cvScalarAll(1.); @@ -1811,7 +1823,7 @@ void Core_SolveTest::prepare_to_validation( int ) if( result == 0 ) { Mat& temp1 = test_mat[TEMP][1]; - cvtest::convert(input, temp1, temp1.type()); + cvtest::convert(input, temp1, temp1.depth()); dst = Scalar::all(0); CvMat _temp1 = cvMat(temp1); double det = cvTsLU( &_temp1, 0, 0 ); @@ -1819,7 +1831,7 @@ void Core_SolveTest::prepare_to_validation( int ) return; } - double threshold = (input.type() == CV_32F ? FLT_EPSILON : DBL_EPSILON)*1000; + double threshold = (input.depth() == CV_32F ? FLT_EPSILON : DBL_EPSILON) * 1000; CvMat _input = cvMat(input); double ratio = 0, det = cvTsSVDet( &_input, &ratio ); if( det < threshold || ratio < threshold ) @@ -1847,12 +1859,12 @@ class Core_SVDTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_SVDTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; int flags; bool have_u, have_v, symmetric, compact, vector_w; }; @@ -1871,7 +1883,7 @@ flags(0), have_u(false), have_v(false), symmetric(false), compact(false), vector } -void Core_SVDTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void Core_SVDTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); @@ -1967,7 +1979,7 @@ int Core_SVDTest::prepare_test_case( int test_case_idx ) } -void Core_SVDTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ) +void Core_SVDTest::get_minmax_bounds( int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high ) { low = cvScalarAll(-2.); high = cvScalarAll(2.); @@ -1975,7 +1987,7 @@ void Core_SVDTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar double Core_SVDTest::get_success_error_level( int test_case_idx, int i, int j ) { - int input_depth = CV_MAT_DEPTH(cvGetElemType( test_array[INPUT][0] )); + ElemDepth input_depth = CV_MAT_DEPTH(cvGetElemType( test_array[INPUT][0] )); double input_precision = input_depth < CV_32F ? 0 : input_depth == CV_32F ? 1e-5 : 5e-11; double output_precision = Base::get_success_error_level( test_case_idx, i, j ); return MAX(input_precision, output_precision); @@ -1993,7 +2005,7 @@ void Core_SVDTest::run_func() void Core_SVDTest::prepare_to_validation( int /*test_case_idx*/ ) { Mat& input = test_mat[INPUT][0]; - int depth = input.depth(); + ElemDepth depth = input.depth(); int i, m = input.rows, n = input.cols, min_size = MIN(m, n); Mat *src, *dst, *w; double prev = 0, threshold = depth == CV_32F ? FLT_EPSILON : DBL_EPSILON; @@ -2077,12 +2089,12 @@ class Core_SVBkSbTest : public Core_MatrixTest typedef Core_MatrixTest Base; Core_SVBkSbTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int test_case_idx) CV_OVERRIDE; int flags; bool have_b, symmetric, compact, vector_w; }; @@ -2099,7 +2111,7 @@ flags(0), have_b(false), symmetric(false), compact(false), vector_w(false) void Core_SVBkSbTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); int bits = cvtest::randInt(rng); @@ -2182,7 +2194,7 @@ int Core_SVBkSbTest::prepare_test_case( int test_case_idx ) } -void Core_SVBkSbTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high ) +void Core_SVBkSbTest::get_minmax_bounds(int /*i*/, int /*j*/, ElemDepth /*type*/, Scalar& low, Scalar& high) { low = cvScalarAll(-2.); high = cvScalarAll(2.); @@ -2206,7 +2218,7 @@ void Core_SVBkSbTest::prepare_to_validation( int ) { Mat& input = test_mat[INPUT][0]; int i, m = input.rows, n = input.cols, min_size = MIN(m, n); - bool is_float = input.type() == CV_32F; + bool is_float = input.type() == CV_32FC1; Size w_size = compact ? Size(min_size,min_size) : Size(m,n); Mat& w = test_mat[TEMP][0]; Mat wdb( w_size.height, w_size.width, CV_64FC1 ); @@ -2247,7 +2259,7 @@ void Core_SVBkSbTest::prepare_to_validation( int ) cvtest::gemm( v, t1, 1, Mat(), 0, t0, flags & CV_SVD_V_T ? CV_GEMM_A_T : 0 ); Mat& dst0 = test_mat[REF_OUTPUT][0]; - t0.convertTo(dst0, dst0.type() ); + t0.convertTo(dst0, dst0.depth()); } @@ -2349,7 +2361,7 @@ void Core_SolvePolyTest::run( int ) if( n == 3 ) { ar2.resize(n); - cv::Mat _umat2(3, 1, CV_64F, &ar2[0]), umat2 = _umat2; + cv::Mat _umat2(3, 1, CV_64FC1, &ar2[0]), umat2 = _umat2; cvFlip(&amat, &amat, 0); int nr2; if( cubic_case == 0 ) @@ -2471,9 +2483,9 @@ TEST(Core_SolvePoly, regression_5599) class Core_PhaseTest : public cvtest::BaseTest { - int t; + ElemType t; public: - Core_PhaseTest(int t_) : t(t_) {} + Core_PhaseTest(ElemType t_) : t(t_) {} ~Core_PhaseTest() {} protected: virtual void run(int) @@ -2593,7 +2605,7 @@ TYPED_TEST_P(Core_CheckRange, Negative) double max_bound = 16.0; TypeParam data[] = {5, 10, 15, 10, 10, 2, 8, 12, 14}; - cv::Mat src = cv::Mat(3,3, cv::DataDepth::value, data); + cv::Mat src = cv::Mat(3,3, CV_MAKETYPE(cv::DataDepth::value, 1), data); cv::Point bad_pt(0, 0); @@ -2625,7 +2637,7 @@ TYPED_TEST_P(Core_CheckRange, Positive) double max_bound = 16.0; TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14}; - cv::Mat src = cv::Mat(3,3, cv::DataDepth::value, data); + cv::Mat src = cv::Mat(3, 3, CV_MAKETYPE(cv::DataDepth::value, 1), data); cv::Point bad_pt(0, 0); @@ -2640,7 +2652,7 @@ TYPED_TEST_P(Core_CheckRange, Bounds) double max_bound = 1.0; TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14}; - cv::Mat src = cv::Mat(3,3, cv::DataDepth::value, data); + cv::Mat src = cv::Mat(3, 3, CV_MAKETYPE(cv::DataDepth::value, 1), data); cv::Point bad_pt(0, 0); @@ -2654,10 +2666,10 @@ TYPED_TEST_P(Core_CheckRange, Zero) double min_bound = 0.0; double max_bound = 0.1; - cv::Mat src1 = cv::Mat::zeros(3, 3, cv::DataDepth::value); + cv::Mat src1 = cv::Mat::zeros(3, 3, CV_MAKETYPE(cv::DataDepth::value, 1)); int sizes[] = {5, 6, 7}; - cv::Mat src2 = cv::Mat::zeros(3, sizes, cv::DataDepth::value); + cv::Mat src2 = cv::Mat::zeros(3, sizes, CV_MAKETYPE(cv::DataDepth::value, 1)); ASSERT_TRUE( checkRange(src1, true, NULL, min_bound, max_bound) ); ASSERT_TRUE( checkRange(src2, true, NULL, min_bound, max_bound) ); @@ -2668,10 +2680,10 @@ TYPED_TEST_P(Core_CheckRange, One) double min_bound = 1.0; double max_bound = 1.1; - cv::Mat src1 = cv::Mat::ones(3, 3, cv::DataDepth::value); + cv::Mat src1 = cv::Mat::ones(3, 3, CV_MAKETYPE(cv::DataDepth::value, 1)); int sizes[] = {5, 6, 7}; - cv::Mat src2 = cv::Mat::ones(3, sizes, cv::DataDepth::value); + cv::Mat src2 = cv::Mat::ones(3, sizes, CV_MAKETYPE(cv::DataDepth::value, 1)); ASSERT_TRUE( checkRange(src1, true, NULL, min_bound, max_bound) ); ASSERT_TRUE( checkRange(src2, true, NULL, min_bound, max_bound) ); @@ -2780,8 +2792,8 @@ TEST(Core_SVD, flt) -4.52429188e+005f, -1.37596525e+006f }; - Mat A(6, 6, CV_32F, a); - Mat B(6, 1, CV_32F, b); + Mat A(6, 6, CV_32FC1, a); + Mat B(6, 1, CV_32FC1, b); Mat X, B1; solve(A, B, X, DECOMP_SVD); B1 = A*X; @@ -2842,7 +2854,7 @@ class CV_KMeansSingularTest : public cvtest::BaseTest } else { - Mat data0(N0, dims, CV_32F); + Mat data0(N0, dims, CV_32FC1); rng.fill(data0, RNG::UNIFORM, -1, 1); Mat data; @@ -2850,7 +2862,7 @@ class CV_KMeansSingularTest : public cvtest::BaseTest switch (inVariant) { case MAT_N_DIM_C1: - data.create(N, dims, CV_32F); + data.create(N, dims, CV_32FC1); for( i = 0; i < N; i++ ) data0.row(rng.uniform(0, N0)).copyTo(data.row(i)); break; @@ -2868,7 +2880,7 @@ class CV_KMeansSingularTest : public cvtest::BaseTest break; case MAT_N_DIM_C1_NONCONT: - data.create(N, dims + 5, CV_32F); + data.create(N, dims + 5, CV_32FC1); data = data(Range(0, N), Range(0, dims)); for( i = 0; i < N; i++ ) data0.row(rng.uniform(0, N0)).copyTo(data.row(i)); @@ -2889,7 +2901,7 @@ class CV_KMeansSingularTest : public cvtest::BaseTest ASSERT_EQ(centers.rows, K); ASSERT_EQ(labels.rows, N); - Mat hist(K, 1, CV_32S, Scalar(0)); + Mat hist(K, 1, CV_32SC1, Scalar(0)); for( i = 0; i < N; i++ ) { int l = labels.at(i); @@ -2952,7 +2964,7 @@ TEST(Core_KMeans, compactness) TEST(CovariationMatrixVectorOfMat, accuracy) { unsigned int col_problem_size = 8, row_problem_size = 8, vector_size = 16; - cv::Mat src(vector_size, col_problem_size * row_problem_size, CV_32F); + cv::Mat src(vector_size, col_problem_size * row_problem_size, CV_32FC1); int singleMatFlags = CV_COVAR_ROWS; cv::Mat gold; @@ -2983,7 +2995,7 @@ TEST(CovariationMatrixVectorOfMat, accuracy) TEST(CovariationMatrixVectorOfMatWithMean, accuracy) { unsigned int col_problem_size = 8, row_problem_size = 8, vector_size = 16; - cv::Mat src(vector_size, col_problem_size * row_problem_size, CV_32F); + cv::Mat src(vector_size, col_problem_size * row_problem_size, CV_32FC1); int singleMatFlags = CV_COVAR_ROWS | CV_COVAR_USE_AVG; cv::Mat gold; @@ -3020,12 +3032,12 @@ TEST(Core_Pow, special) for( int i = 0; i < 100; i++ ) { int n = theRNG().uniform(1, 30); - Mat mtx0(1, n, CV_8S), mtx, result; + Mat mtx0(1, n, CV_8SC1), mtx, result; randu(mtx0, -5, 5); - int type = theRNG().uniform(0, 2) ? CV_64F : CV_32F; + ElemDepth type = theRNG().uniform(0, 2) ? CV_64F : CV_32F; double eps = type == CV_32F ? 1e-3 : 1e-10; - mtx0.convertTo(mtx, type); + mtx0.convertTo(mtx, CV_MAT_DEPTH(type)); // generate power from [-n, n] interval with 1/8 step - enough to check various cases. const int max_pf = 3; int pf = theRNG().uniform(0, max_pf*2+1); @@ -3070,10 +3082,10 @@ TEST(Core_Pow, special) TEST(Core_Cholesky, accuracy64f) { const int n = 5; - Mat A(n, n, CV_64F), refA; - Mat mean(1, 1, CV_64F); + Mat A(n, n, CV_64FC1), refA; + Mat mean(1, 1, CV_64FC1); *mean.ptr() = 10.0; - Mat dev(1, 1, CV_64F); + Mat dev(1, 1, CV_64FC1); *dev.ptr() = 10.0; RNG rng(10); rng.fill(A, RNG::NORMAL, mean, dev); @@ -3090,11 +3102,11 @@ TEST(Core_Cholesky, accuracy64f) TEST(Core_QR_Solver, accuracy64f) { int m = 20, n = 18; - Mat A(m, m, CV_64F); - Mat B(m, n, CV_64F); - Mat mean(1, 1, CV_64F); + Mat A(m, m, CV_64FC1); + Mat B(m, n, CV_64FC1); + Mat mean(1, 1, CV_64FC1); *mean.ptr() = 10.0; - Mat dev(1, 1, CV_64F); + Mat dev(1, 1, CV_64FC1); *dev.ptr() = 10.0; RNG rng(10); rng.fill(A, RNG::NORMAL, mean, dev); @@ -3106,8 +3118,8 @@ TEST(Core_QR_Solver, accuracy64f) solve(A, B, solutionQR, DECOMP_QR); EXPECT_LE(cvtest::norm(A*solutionQR, B, CV_RELATIVE_L2), FLT_EPSILON); - A = Mat(m, n, CV_64F); - B = Mat(m, n, CV_64F); + A = Mat(m, n, CV_64FC1); + B = Mat(m, n, CV_64FC1); rng.fill(A, RNG::NORMAL, mean, dev); rng.fill(B, RNG::NORMAL, mean, dev); @@ -3122,8 +3134,8 @@ TEST(Core_QR_Solver, accuracy64f) EXPECT_LE(cvtest::norm(solutionQR, solutionSVD, CV_RELATIVE_L2), FLT_EPSILON); //solve system with singular matrix - A = Mat(10, 10, CV_64F); - B = Mat(10, 1, CV_64F); + A = Mat(10, 10, CV_64FC1); + B = Mat(10, 1, CV_64FC1); rng.fill(A, RNG::NORMAL, mean, dev); rng.fill(B, RNG::NORMAL, mean, dev); for (int i = 0; i < A.cols; i++) diff --git a/modules/core/test/test_misc.cpp b/modules/core/test/test_misc.cpp index b98ec4ed341a..1a72dedc56cf 100644 --- a/modules/core/test/test_misc.cpp +++ b/modules/core/test/test_misc.cpp @@ -8,14 +8,14 @@ namespace opencv_test { namespace { TEST(Core_OutputArrayCreate, _1997) { struct local { - static void create(OutputArray arr, Size submatSize, int type) + static void create(OutputArray arr, Size submatSize, ElemType type) { int sizes[] = {submatSize.width, submatSize.height}; arr.create(sizeof(sizes)/sizeof(sizes[0]), sizes, type); } }; - Mat mat(Size(512, 512), CV_8U); + Mat mat(Size(512, 512), CV_8UC1); Size submatSize = Size(256, 256); ASSERT_NO_THROW(local::create( mat(Rect(Point(), submatSize)), submatSize, mat.type() )); @@ -136,7 +136,7 @@ TEST(Core_OutputArrayAssign, _Matxf_UMatd) int fixedType_handler(OutputArray dst) { - int type = CV_32FC2; // return points only {x, y} + ElemType type = CV_32FC2; // return points only {x, y} if (dst.fixedType()) { type = dst.type(); diff --git a/modules/core/test/test_operations.cpp b/modules/core/test/test_operations.cpp index e72400c7fa1c..7a4535bed408 100644 --- a/modules/core/test/test_operations.cpp +++ b/modules/core/test/test_operations.cpp @@ -122,13 +122,13 @@ bool CV_OperationsTest::TestMat() { try { - Mat one_3x1(3, 1, CV_32F, Scalar(1.0)); - Mat shi_3x1(3, 1, CV_32F, Scalar(1.2)); - Mat shi_2x1(2, 1, CV_32F, Scalar(-1)); + Mat one_3x1(3, 1, CV_32FC1, Scalar(1.0)); + Mat shi_3x1(3, 1, CV_32FC1, Scalar(1.2)); + Mat shi_2x1(2, 1, CV_32FC1, Scalar(-1)); Scalar shift = Scalar::all(15); float data[] = { sqrt(2.f)/2, -sqrt(2.f)/2, 1.f, sqrt(2.f)/2, sqrt(2.f)/2, 10.f }; - Mat rot_2x3(2, 3, CV_32F, data); + Mat rot_2x3(2, 3, CV_32FC1, data); Mat res = one_3x1 + shi_3x1 + shi_3x1 + shi_3x1; res = Mat(Mat(2 * rot_2x3) * res - shi_2x1) + shift; @@ -138,11 +138,11 @@ bool CV_OperationsTest::TestMat() cv::add(tmp, shi_3x1, tmp); cv::add(tmp, shi_3x1, tmp); cv::gemm(rot_2x3, tmp, 2, shi_2x1, -1, res2, 0); - cv::add(res2, Mat(2, 1, CV_32F, shift), res2); + cv::add(res2, Mat(2, 1, CV_32FC1, shift), res2); CHECK_DIFF(res, res2); - Mat mat4x4(4, 4, CV_32F); + Mat mat4x4(4, 4, CV_32FC1); cv::randu(mat4x4, Scalar(0), Scalar(10)); Mat roi1 = mat4x4(Rect(Point(1, 1), Size(2, 2))); @@ -151,9 +151,9 @@ bool CV_OperationsTest::TestMat() CHECK_DIFF(roi1, roi2); CHECK_DIFF(mat4x4, mat4x4(Rect(Point(0,0), mat4x4.size()))); - Mat intMat10(3, 3, CV_32S, Scalar(10)); - Mat intMat11(3, 3, CV_32S, Scalar(11)); - Mat resMat(3, 3, CV_8U, Scalar(255)); + Mat intMat10(3, 3, CV_32SC1, Scalar(10)); + Mat intMat11(3, 3, CV_32SC1, Scalar(11)); + Mat resMat(3, 3, CV_8UC1, Scalar(255)); CHECK_DIFF(resMat, intMat10 == intMat10); CHECK_DIFF(resMat, intMat10 < intMat11); @@ -172,11 +172,11 @@ bool CV_OperationsTest::TestMat() CHECK_DIFF(resMat, 10.0 != intMat11); CHECK_DIFF(resMat, intMat11 != 10.0); - Mat eye = Mat::eye(3, 3, CV_16S); - Mat maskMat4(3, 3, CV_16S, Scalar(4)); - Mat maskMat1(3, 3, CV_16S, Scalar(1)); - Mat maskMat5(3, 3, CV_16S, Scalar(5)); - Mat maskMat0(3, 3, CV_16S, Scalar(0)); + Mat eye = Mat::eye(3, 3, CV_16SC1); + Mat maskMat4(3, 3, CV_16SC1, Scalar(4)); + Mat maskMat1(3, 3, CV_16SC1, Scalar(1)); + Mat maskMat5(3, 3, CV_16SC1, Scalar(5)); + Mat maskMat0(3, 3, CV_16SC1, Scalar(0)); CHECK_DIFF(maskMat0, maskMat4 & maskMat1); CHECK_DIFF(maskMat0, Scalar(1) & maskMat4); @@ -338,9 +338,9 @@ bool CV_OperationsTest::TestMat() ///////////////////////////// float matrix_data[] = { 3, 1, -4, -5, 1, 0, 0, 1.1f, 1.5f}; - Mat mt(3, 3, CV_32F, matrix_data); + Mat mt(3, 3, CV_32FC1, matrix_data); Mat mi = mt.inv(); - Mat d1 = Mat::eye(3, 3, CV_32F); + Mat d1 = Mat::eye(3, 3, CV_32FC1); Mat d2 = d1 * 2; MatExpr mt_tr = mt.t(); MatExpr mi_tr = mi.t(); @@ -383,7 +383,7 @@ bool CV_OperationsTest::TestMat() CHECK_DIFF_FLT( (mi * mt) / 2.0, d1 / 2); Mat mt_mul_2_plus_1; - gemm(mt, d1, 2, Mat::ones(3, 3, CV_32F), 1, mt_mul_2_plus_1); + gemm(mt, d1, 2, Mat::ones(3, 3, CV_32FC1), 1, mt_mul_2_plus_1); CHECK_DIFF( (mt * 2.0 + 1.0) * mi, mt_mul_2_plus_1 * mi); // (A*alpha + beta)*B CHECK_DIFF( mi * (mt * 2.0 + 1.0), mi * mt_mul_2_plus_1); // A*(B*alpha + beta) @@ -512,7 +512,7 @@ bool CV_OperationsTest::TestTemplateMat() cv::add(tmp, shi_3x1, tmp); cv::add(tmp, shi_3x1, tmp); cv::gemm(rot_2x3, tmp, 2, shi_2x1, -1, res2, 0); - cv::add(res2, Mat(2, 1, CV_32F, shift), res2); + cv::add(res2, Mat(2, 1, CV_32FC1, shift), res2); cv::gemm(rot_2x3, one_3x1, 1, shi_2x1, 0, resS2, 0); CHECK_DIFF(res, res2); @@ -773,10 +773,10 @@ bool CV_OperationsTest::TestTemplateMat() cvtest::norm(mvf2[1], mvf[1], CV_C) == 0 ); { - Mat a(2,2,CV_32F,1.f); - Mat b(1,2,CV_32F,1.f); - Mat c = (a*b.t()).t(); - CV_Assert( cvtest::norm(c, CV_L1) == 4. ); + Mat a(2, 2, CV_32FC1, 1.f); + Mat b(1, 2, CV_32FC1, 1.f); + Mat c = (a*b.t()).t(); + CV_Assert( cvtest::norm(c, CV_L1) == 4. ); } bool badarg_catched = false; @@ -815,7 +815,7 @@ bool CV_OperationsTest::TestTemplateMat() bool CV_OperationsTest::TestMatND() { int sizes[] = { 3, 3, 3}; - cv::MatND nd(3, sizes, CV_32F); + cv::MatND nd(3, sizes, CV_32FC1); return true; } @@ -985,7 +985,7 @@ bool CV_OperationsTest::operations1() throw test_excep(); } - Mat A(1, 32, CV_32F), B; + Mat A(1, 32, CV_32FC1), B; for( int i = 0; i < A.cols; i++ ) A.at(i) = (float)(i <= 12 ? i : 24 - i); cv::transpose(A, B); @@ -1006,13 +1006,13 @@ bool CV_OperationsTest::operations1() Matx33f b(1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f); Mat c; - cv::add(Mat::zeros(3, 3, CV_32F), b, c); + cv::add(Mat::zeros(3, 3, CV_32FC1), b, c); CV_Assert( cvtest::norm(b, c, CV_C) == 0 ); - cv::add(Mat::zeros(3, 3, CV_64F), b, c, noArray(), c.type()); + cv::add(Mat::zeros(3, 3, CV_64FC1), b, c, noArray(), c.depth()); CV_Assert( cvtest::norm(b, c, CV_C) == 0 ); - cv::add(Mat::zeros(6, 1, CV_64F), 1, c, noArray(), c.type()); + cv::add(Mat::zeros(6, 1, CV_64FC1), 1, c, noArray(), c.depth()); CV_Assert( cvtest::norm(Matx61f(1.f, 1.f, 1.f, 1.f, 1.f, 1.f), c, CV_C) == 0 ); vector pt2d(3); @@ -1085,7 +1085,7 @@ bool CV_OperationsTest::TestSVD() U=decomp.u; Vt=decomp.vt; W=decomp.w; - Mat I = Mat::eye(3, 3, CV_32F); + Mat I = Mat::eye(3, 3, CV_32FC1); if( cvtest::norm(U*U.t(), I, CV_C) > FLT_EPSILON || cvtest::norm(Vt*Vt.t(), I, CV_C) > FLT_EPSILON || @@ -1236,7 +1236,7 @@ TEST(Core_SparseMat, iterations) { CV_SparseMatTest test; test.safe_run(); } TEST(MatTestRoi, adjustRoiOverflow) { - Mat m(15, 10, CV_32S); + Mat m(15, 10, CV_32SC1); Mat roi(m, cv::Range(2, 10), cv::Range(3,6)); int rowsInROI = roi.rows; roi.adjustROI(1, 0, 0, 0); @@ -1254,7 +1254,7 @@ CV_ENUM(SortOrder, SORT_ASCENDING, SORT_DESCENDING) PARAM_TEST_CASE(sortIdx, MatDepth, SortRowCol, SortOrder, Size, bool) { - int type; + ElemType type; Size size; int flags; bool use_roi; @@ -1264,7 +1264,7 @@ PARAM_TEST_CASE(sortIdx, MatDepth, SortRowCol, SortOrder, Size, bool) virtual void SetUp() { - int depth = GET_PARAM(0); + ElemDepth depth = GET_PARAM(0); int rowFlags = GET_PARAM(1); int orderFlags = GET_PARAM(2); size = GET_PARAM(3); @@ -1281,7 +1281,7 @@ PARAM_TEST_CASE(sortIdx, MatDepth, SortRowCol, SortOrder, Size, bool) randomSubMat(src, src_roi, size, srcBorder, type, -100, 100); Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); - randomSubMat(dst, dst_roi, size, dstBorder, CV_32S, 5, 16); + randomSubMat(dst, dst_roi, size, dstBorder, CV_32SC1, 5, 16); } template @@ -1315,7 +1315,7 @@ PARAM_TEST_CASE(sortIdx, MatDepth, SortRowCol, SortOrder, Size, bool) ASSERT_EQ(size, dst_roi.size()); bool isColumn = (flags & SORT_EVERY_COLUMN) == SORT_EVERY_COLUMN; size_t N = isColumn ? src_roi.cols : src_roi.rows; - Mat values_row((int)N, 1, type), idx_row((int)N, 1, CV_32S); + Mat values_row((int)N, 1, type), idx_row((int)N, 1, CV_32SC1); for (size_t i = 0; i < N; i++) { SCOPED_TRACE(cv::format("row/col=%d", (int)i)); @@ -1337,7 +1337,7 @@ PARAM_TEST_CASE(sortIdx, MatDepth, SortRowCol, SortOrder, Size, bool) case CV_32S: check_(values_row, idx_row); break; case CV_32F: check_(values_row, idx_row); break; case CV_64F: check_(values_row, idx_row); break; - default: ASSERT_FALSE(true) << "Unsupported type: " << type; + default: ASSERT_FALSE(true) << "Unsupported type: " << static_cast(type); } } } diff --git a/modules/core/test/test_rand.cpp b/modules/core/test/test_rand.cpp index 49062ff7c72b..80ba08977a57 100644 --- a/modules/core/test/test_rand.cpp +++ b/modules/core/test/test_rand.cpp @@ -38,7 +38,7 @@ static double chi2_p95(int n) bool Core_RandTest::check_pdf(const Mat& hist, double scale, int dist_type, double& refval, double& realval) { - Mat hist0(hist.size(), CV_32F); + Mat hist0(hist.size(), CV_32FC1); const int* H = hist.ptr(); float* H0 = hist0.ptr(); int i, hsz = hist.cols; @@ -105,10 +105,10 @@ void Core_RandTest::run( int ) progress = update_progress( progress, idx, test_case_count, 0 ); ts->update_context( this, idx, false ); - int depth = cvtest::randInt(rng) % (CV_64F+1); + ElemDepth depth = static_cast(cvtest::randInt(rng) % (CV_64F + 1)); int c, cn = (cvtest::randInt(rng) % 4) + 1; - int type = CV_MAKETYPE(depth, cn); - int dist_type = cvtest::randInt(rng) % (CV_RAND_NORMAL+1); + ElemType type = CV_MAKETYPE(depth, cn); + ElemType dist_type = static_cast(cvtest::randInt(rng) % (CV_RAND_NORMAL + 1)); int i, k, SZ = N/cn; Scalar A, B; @@ -159,7 +159,7 @@ void Core_RandTest::run( int ) } A[c] = a; B[c] = b; - hist[c].create(1, hsz, CV_32S); + hist[c].create(1, hsz, CV_32SC1); } cv::RNG saved_rng = tested_rng; @@ -315,8 +315,8 @@ class Core_RandRangeTest : public cvtest::BaseTest protected: void run(int) { - Mat a(Size(1280, 720), CV_8U, Scalar(20)); - Mat af(Size(1280, 720), CV_32F, Scalar(20)); + Mat a(Size(1280, 720), CV_8UC1, Scalar(20)); + Mat af(Size(1280, 720), CV_32FC1, Scalar(20)); theRNG().fill(a, RNG::UNIFORM, -DBL_MAX, DBL_MAX); theRNG().fill(af, RNG::UNIFORM, -DBL_MAX, DBL_MAX); int n0 = 0, n255 = 0, nx = 0; diff --git a/modules/core/test/test_umat.cpp b/modules/core/test/test_umat.cpp index a4f32db712b7..de635bb8f80e 100644 --- a/modules/core/test/test_umat.cpp +++ b/modules/core/test/test_umat.cpp @@ -58,7 +58,7 @@ PARAM_TEST_CASE(UMatBasicTests, int, int, Size, bool) { Mat a; UMat ua; - int type; + ElemType type; int depth; int cn; Size size; @@ -168,7 +168,7 @@ TEST_P(UMatBasicTests, base) sz[i] = randomInt(1,45); total *= (size_t)sz[i]; } - int new_type = CV_MAKE_TYPE(randomInt(CV_8S,CV_64F),randomInt(1,4)); + ElemType new_type = CV_MAKE_TYPE(randomInt(CV_8S,CV_64F),randomInt(1,4)); ub = UMat(dims, sz, new_type); ASSERT_EQ(ub.total(), total); } @@ -268,12 +268,12 @@ INSTANTIATE_TEST_CASE_P(UMat, UMatBasicTests, Combine(testing::Values(CV_8U, CV_ //////////////////////////////////////////////////////////////// Reshape //////////////////////////////////////////////////////////////////////// -PARAM_TEST_CASE(UMatTestReshape, int, int, Size, bool) +PARAM_TEST_CASE(UMatTestReshape, MatDepth, int, Size, bool) { Mat a; UMat ua, ub; - int type; - int depth; + ElemType type; + ElemDepth depth; int cn; Size size; bool useRoi; @@ -423,12 +423,12 @@ TEST(UMatTestReshape, reshape_ndims_4) ////////////////////////////////////////////////////////////////// ROI testing /////////////////////////////////////////////////////////////// -PARAM_TEST_CASE(UMatTestRoi, int, int, Size) +PARAM_TEST_CASE(UMatTestRoi, MatDepth, int, Size) { Mat a, roi_a; UMat ua, roi_ua; - int type; - int depth; + ElemType type; + ElemDepth depth; int cn; Size size; Size roi_size; @@ -498,7 +498,7 @@ INSTANTIATE_TEST_CASE_P(UMat, UMatTestRoi, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANN TEST(UMatTestRoi, adjustRoiOverflow) { - UMat m(15, 10, CV_32S); + UMat m(15, 10, CV_32SC1); UMat roi(m, cv::Range(2, 10), cv::Range(3,6)); int rowsInROI = roi.rows; roi.adjustROI(1, 0, 0, 0); @@ -512,12 +512,12 @@ TEST(UMatTestRoi, adjustRoiOverflow) /////////////////////////////////////////////////////////////// Size //////////////////////////////////////////////////////////////////// -PARAM_TEST_CASE(UMatTestSizeOperations, int, int, Size, bool) +PARAM_TEST_CASE(UMatTestSizeOperations, MatDepth, int, Size, bool) { Mat a, b, roi_a, roi_b; UMat ua, ub, roi_ua, roi_ub; - int type; - int depth; + ElemType type; + ElemDepth depth; int cn; Size size; Size roi_size; @@ -561,12 +561,12 @@ INSTANTIATE_TEST_CASE_P(UMat, UMatTestSizeOperations, Combine(OCL_ALL_DEPTHS, OC ///////////////////////////////////////////////////////////////// UMat operations //////////////////////////////////////////////////////////////////////////// -PARAM_TEST_CASE(UMatTestUMatOperations, int, int, Size, bool) +PARAM_TEST_CASE(UMatTestUMatOperations, MatDepth, int, Size, bool) { Mat a, b; UMat ua, ub; - int type; - int depth; + ElemType type; + ElemDepth depth; int cn; Size size; Size roi_size; @@ -612,7 +612,7 @@ INSTANTIATE_TEST_CASE_P(UMat, UMatTestUMatOperations, Combine(OCL_ALL_DEPTHS, OC PARAM_TEST_CASE(getUMat, int, int, Size, bool) { - int type; + ElemType type; Size size; virtual void SetUp() @@ -1102,7 +1102,7 @@ TEST(UMat, unmap_in_class) Mat m = input.getMat(); { Mat dst; - m.convertTo(dst, CV_32FC1); + m.convertTo(dst, CV_32F); // some additional CPU-based per-pixel processing into dst intermediateResult = dst.getUMat(ACCESS_READ); // this violates lifetime of base(dst) / derived (intermediateResult) objects. Use copyTo? std::cout << "data processed..." << std::endl; @@ -1167,14 +1167,14 @@ OCL_TEST(UMat, DISABLED_OCL_ThreadSafe_CleanupCallback_1_VeryLongTest) for (int j = 0; j < 100; j++) { const Size srcSize(320, 240); - const int type = CV_8UC1; - const int dtype = CV_16UC1; + const ElemType type = CV_8UC1; + const ElemType dtype = CV_16UC1; Mat src(srcSize, type, Scalar::all(0)); Mat dst_ref(srcSize, dtype); // Generate reference data as additional check - OCL_OFF(src.convertTo(dst_ref, dtype)); + OCL_OFF(src.convertTo(dst_ref, CV_MAT_DEPTH(dtype))); cv::ocl::setUseOpenCL(true); // restore OpenCL state UMat dst(srcSize, dtype); @@ -1183,7 +1183,7 @@ OCL_TEST(UMat, DISABLED_OCL_ThreadSafe_CleanupCallback_1_VeryLongTest) for(int k = 0; k < 10000; k++) { UMat tmpUMat = src.getUMat(ACCESS_RW); - tmpUMat.convertTo(dst, dtype); + tmpUMat.convertTo(dst, CV_MAT_DEPTH(dtype)); ::cv::ocl::finish(); // force kernel to complete to start cleanup sooner } @@ -1203,8 +1203,8 @@ OCL_TEST(UMat, DISABLED_OCL_ThreadSafe_CleanupCallback_2_VeryLongTest) for (int j = 0; j < 100; j++) { const Size srcSize(320, 240); - const int type = CV_8UC1; - const int dtype = CV_16UC1; + const ElemType type = CV_8UC1; + const ElemType dtype = CV_16UC1; // This test is only relevant for OCL UMat dst(srcSize, dtype); @@ -1215,7 +1215,7 @@ OCL_TEST(UMat, DISABLED_OCL_ThreadSafe_CleanupCallback_2_VeryLongTest) Mat src(srcSize, type, Scalar::all(0)); // Declare src inside loop now to catch its destruction on stack { UMat tmpUMat = src.getUMat(ACCESS_RW); - tmpUMat.convertTo(dst, dtype); + tmpUMat.convertTo(dst, CV_MAT_DEPTH(dtype)); } ::cv::ocl::finish(); // force kernel to complete to start cleanup sooner } @@ -1358,12 +1358,12 @@ TEST(UMat, testWrongLifetime_Mat) TEST(UMat, DISABLED_regression_5991) { int sz[] = {2,3,2}; - UMat mat(3, sz, CV_32F, Scalar(1)); + UMat mat(3, sz, CV_32FC1, Scalar(1)); ASSERT_NO_THROW(mat.convertTo(mat, CV_8U)); EXPECT_EQ(sz[0], mat.size[0]); EXPECT_EQ(sz[1], mat.size[1]); EXPECT_EQ(sz[2], mat.size[2]); - EXPECT_EQ(0, cvtest::norm(mat.getMat(ACCESS_READ), Mat(3, sz, CV_8U, Scalar(1)), NORM_INF)); + EXPECT_EQ(0, cvtest::norm(mat.getMat(ACCESS_READ), Mat(3, sz, CV_8UC1, Scalar(1)), NORM_INF)); } TEST(UMat, testTempObjects_Mat_issue_8693) @@ -1377,8 +1377,8 @@ TEST(UMat, testTempObjects_Mat_issue_8693) reduce(srcUMat, srcUMat, 0, CV_REDUCE_SUM); reduce(srcMat, srcMat, 0, CV_REDUCE_SUM); - srcUMat.convertTo(srcUMat, CV_64FC1); - srcMat.convertTo(srcMat, CV_64FC1); + srcUMat.convertTo(srcUMat, CV_64F); + srcMat.convertTo(srcMat, CV_64F); EXPECT_EQ(0, cvtest::norm(srcUMat.getMat(ACCESS_READ), srcMat, NORM_INF)); } diff --git a/modules/dnn/include/opencv2/dnn/dnn.hpp b/modules/dnn/include/opencv2/dnn/dnn.hpp index cff78ba7f680..b558f23c5189 100644 --- a/modules/dnn/include/opencv2/dnn/dnn.hpp +++ b/modules/dnn/include/opencv2/dnn/dnn.hpp @@ -837,7 +837,7 @@ CV__DNN_INLINE_NS_BEGIN */ CV_EXPORTS_W Mat blobFromImage(InputArray image, double scalefactor=1.0, const Size& size = Size(), const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, - int ddepth=CV_32F); + ElemDepth ddepth = CV_32F); /** @brief Creates 4-dimensional blob from image. * @details This is an overloaded member function, provided for convenience. @@ -845,7 +845,7 @@ CV__DNN_INLINE_NS_BEGIN */ CV_EXPORTS void blobFromImage(InputArray image, OutputArray blob, double scalefactor=1.0, const Size& size = Size(), const Scalar& mean = Scalar(), - bool swapRB=false, bool crop=false, int ddepth=CV_32F); + bool swapRB = false, bool crop = false, ElemDepth ddepth = CV_32F); /** @brief Creates 4-dimensional blob from series of images. Optionally resizes and @@ -867,7 +867,7 @@ CV__DNN_INLINE_NS_BEGIN */ CV_EXPORTS_W Mat blobFromImages(InputArrayOfArrays images, double scalefactor=1.0, Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, - int ddepth=CV_32F); + ElemDepth ddepth = CV_32F); /** @brief Creates 4-dimensional blob from series of images. * @details This is an overloaded member function, provided for convenience. @@ -876,7 +876,7 @@ CV__DNN_INLINE_NS_BEGIN CV_EXPORTS void blobFromImages(InputArrayOfArrays images, OutputArray blob, double scalefactor=1.0, Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, - int ddepth=CV_32F); + ElemDepth ddepth = CV_32F); /** @brief Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure * (std::vector). diff --git a/modules/dnn/perf/perf_convolution.cpp b/modules/dnn/perf/perf_convolution.cpp index be742ea48b2d..e7921c96ce2a 100644 --- a/modules/dnn/perf/perf_convolution.cpp +++ b/modules/dnn/perf/perf_convolution.cpp @@ -600,7 +600,7 @@ PERF_TEST_P_(Conv, conv) Size inSize(inputShape[3], inputShape[2]); int sz[] = {outChannels, inChannels / groups, kernel.height, kernel.width}; - Mat weights(4, &sz[0], CV_32F); + Mat weights(4, &sz[0], CV_32FC1); randu(weights, -1.0f, 1.0f); LayerParams lp; @@ -627,12 +627,12 @@ PERF_TEST_P_(Conv, conv) lp.blobs.push_back(weights); if (hasBias) { - Mat bias(1, outChannels, CV_32F); + Mat bias(1, outChannels, CV_32FC1); randu(bias, -1.0f, 1.0f); lp.blobs.push_back(bias); } int inpSz[] = {1, inChannels, inSize.height, inSize.width}; - Mat input(4, &inpSz[0], CV_32F); + Mat input(4, &inpSz[0], CV_32FC1); randu(input, -1.0f, 1.0f); Net net; diff --git a/modules/dnn/perf/perf_net.cpp b/modules/dnn/perf/perf_net.cpp index 192604b86191..2c1d6a508585 100644 --- a/modules/dnn/perf/perf_net.cpp +++ b/modules/dnn/perf/perf_net.cpp @@ -234,7 +234,7 @@ PERF_TEST_P_(DNNTestNetwork, YOLOv3) throw SkipTestException(""); Mat sample = imread(findDataFile("dnn/dog416.png", false)); Mat inp; - sample.convertTo(inp, CV_32FC3); + sample.convertTo(inp, CV_32F); processNet("dnn/yolov3.cfg", "dnn/yolov3.weights", "", inp / 255); } diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp index c09b5b20a07a..e09992d845f8 100644 --- a/modules/dnn/src/caffe/caffe_importer.cpp +++ b/modules/dnn/src/caffe/caffe_importer.cpp @@ -249,14 +249,14 @@ class CaffeImporter MatShape shape; blobShapeFromProto(pbBlob, shape); - dstBlob.create((int)shape.size(), &shape[0], CV_32F); + dstBlob.create((int)shape.size(), &shape[0], CV_32FC1); if (pbBlob.data_size()) { // Single precision floats. CV_Assert(pbBlob.data_size() == (int)dstBlob.total()); CV_DbgAssert(pbBlob.GetDescriptor()->FindFieldByLowercaseName("data")->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT); - Mat(dstBlob.dims, &dstBlob.size[0], CV_32F, (void*)pbBlob.data().data()).copyTo(dstBlob); + Mat(dstBlob.dims, &dstBlob.size[0], CV_32FC1, (void*)pbBlob.data().data()).copyTo(dstBlob); } else { diff --git a/modules/dnn/src/darknet/darknet_io.cpp b/modules/dnn/src/darknet/darknet_io.cpp index 815b84f651d7..e8747ca61d15 100644 --- a/modules/dnn/src/darknet/darknet_io.cpp +++ b/modules/dnn/src/darknet/darknet_io.cpp @@ -355,7 +355,7 @@ namespace cv { region_param.set("softmax_tree", softmax_tree); region_param.set("softmax", softmax); - cv::Mat biasData_mat = cv::Mat(1, anchors * 2, CV_32F, biasData).clone(); + cv::Mat biasData_mat = cv::Mat(1, anchors * 2, CV_32FC1, biasData).clone(); region_param.blobs.push_back(biasData_mat); darknet::LayerParameter lp; @@ -390,7 +390,7 @@ namespace cv { usedAnchors[i * 2 + 1] = anchors[mask[i] * 2 + 1]; } - cv::Mat biasData_mat = cv::Mat(1, numAnchors * 2, CV_32F, &usedAnchors[0]).clone(); + cv::Mat biasData_mat = cv::Mat(1, numAnchors * 2, CV_32FC1, &usedAnchors[0]).clone(); region_param.blobs.push_back(biasData_mat); darknet::LayerParameter lp; @@ -715,13 +715,13 @@ namespace cv { size_t const weights_size = filters * current_channels * kernel_size * kernel_size; int sizes_weights[] = { filters, current_channels, kernel_size, kernel_size }; cv::Mat weightsBlob; - weightsBlob.create(4, sizes_weights, CV_32F); + weightsBlob.create(4, sizes_weights, CV_32FC1); CV_Assert(weightsBlob.isContinuous()); - cv::Mat meanData_mat(1, filters, CV_32F); // mean - cv::Mat stdData_mat(1, filters, CV_32F); // variance - cv::Mat weightsData_mat(1, filters, CV_32F);// scale - cv::Mat biasData_mat(1, filters, CV_32F); // bias + cv::Mat meanData_mat(1, filters, CV_32FC1); // mean + cv::Mat stdData_mat(1, filters, CV_32FC1); // variance + cv::Mat weightsData_mat(1, filters, CV_32FC1);// scale + cv::Mat biasData_mat(1, filters, CV_32FC1); // bias ifile.read(reinterpret_cast(biasData_mat.ptr()), sizeof(float)*filters); if (use_batch_normalize) { diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 65db785c196d..0dbaad4c8243 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -101,7 +101,7 @@ namespace } Mat blobFromImage(InputArray image, double scalefactor, const Size& size, - const Scalar& mean, bool swapRB, bool crop, int ddepth) + const Scalar& mean, bool swapRB, bool crop, ElemDepth ddepth) { CV_TRACE_FUNCTION(); Mat blob; @@ -110,7 +110,7 @@ Mat blobFromImage(InputArray image, double scalefactor, const Size& size, } void blobFromImage(InputArray image, OutputArray blob, double scalefactor, - const Size& size, const Scalar& mean, bool swapRB, bool crop, int ddepth) + const Size& size, const Scalar& mean, bool swapRB, bool crop, ElemDepth ddepth) { CV_TRACE_FUNCTION(); std::vector images(1, image.getMat()); @@ -118,7 +118,7 @@ void blobFromImage(InputArray image, OutputArray blob, double scalefactor, } Mat blobFromImages(InputArrayOfArrays images, double scalefactor, Size size, - const Scalar& mean, bool swapRB, bool crop, int ddepth) + const Scalar& mean, bool swapRB, bool crop, ElemDepth ddepth) { CV_TRACE_FUNCTION(); Mat blob; @@ -127,10 +127,10 @@ Mat blobFromImages(InputArrayOfArrays images, double scalefactor, Size size, } void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalefactor, - Size size, const Scalar& mean_, bool swapRB, bool crop, int ddepth) + Size size, const Scalar& mean_, bool swapRB, bool crop, ElemDepth ddepth) { CV_TRACE_FUNCTION(); - CV_CheckType(ddepth, ddepth == CV_32F || ddepth == CV_8U, "Blob depth should be CV_32F or CV_8U"); + CV_CheckDepth(ddepth, ddepth == CV_32F || ddepth == CV_8U, "Blob depth should be CV_32F or CV_8U"); if (ddepth == CV_8U) { CV_CheckEQ(scalefactor, 1.0, "Scaling is not supported for CV_8U blob depth"); @@ -178,7 +178,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef if (nch == 3 || nch == 4) { int sz[] = { (int)nimages, nch, image0.rows, image0.cols }; - blob_.create(4, sz, ddepth); + blob_.create(4, sz, CV_MAKETYPE(ddepth, 1)); Mat blob = blob_.getMat(); Mat ch[4]; @@ -191,7 +191,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef CV_Assert(image.size() == image0.size()); for( int j = 0; j < nch; j++ ) - ch[j] = Mat(image.rows, image.cols, ddepth, blob.ptr((int)i, j)); + ch[j] = Mat(image.rows, image.cols, CV_MAKETYPE(ddepth,1 ), blob.ptr((int)i, j)); if(swapRB) std::swap(ch[0], ch[2]); split(image, ch); @@ -201,7 +201,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef { CV_Assert(nch == 1); int sz[] = { (int)nimages, 1, image0.rows, image0.cols }; - blob_.create(4, sz, ddepth); + blob_.create(4, sz, CV_MAKETYPE(ddepth, 1)); Mat blob = blob_.getMat(); for( i = 0; i < nimages; i++ ) @@ -212,7 +212,7 @@ void blobFromImages(InputArrayOfArrays images_, OutputArray blob_, double scalef CV_Assert(image.dims == 2 && (nch == 1)); CV_Assert(image.size() == image0.size()); - image.copyTo(Mat(image.rows, image.cols, ddepth, blob.ptr((int)i, 0))); + image.copyTo(Mat(image.rows, image.cols, CV_MAKETYPE(ddepth, 1), blob.ptr((int)i, 0))); } } } @@ -229,7 +229,7 @@ void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_) CV_Assert(blob_.depth() == CV_32F); CV_Assert(blob_.dims == 4); - images_.create(cv::Size(1, blob_.size[0]), blob_.depth()); + images_.create(cv::Size(1, blob_.size[0]), CV_MAKETYPE(blob_.depth(), 1)); std::vector vectorOfChannels(blob_.size[1]); for (int n = 0; n < blob_.size[0]; ++n) @@ -748,7 +748,7 @@ struct BlobManager { // if dst already has been allocated with total(shape) elements, // it won't be recreated and pointer of dst.data remains the same. - dst.create(shape, use_half ? CV_16S : CV_32F); + dst.create(shape, use_half ? CV_16SC1 : CV_32FC1); addHost(lp, dst); } } @@ -2024,7 +2024,7 @@ struct Net::Impl if (preferableBackend == DNN_BACKEND_OPENCV && preferableTarget == DNN_TARGET_OPENCL_FP16) { - layers[0].outputBlobs[i].create(inp.dims, inp.size, CV_16S); + layers[0].outputBlobs[i].create(inp.dims, inp.size, CV_16SC1); } inputShapes.push_back(shape(inp)); } @@ -3253,11 +3253,11 @@ void Layer::forward_fallback(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs.resize(orig_outputs.size()); for (size_t i = 0; i < orig_outputs.size(); i++) - outputs[i].create(shape(orig_outputs[i]), CV_32F); + outputs[i].create(shape(orig_outputs[i]), CV_32FC1); internals.resize(orig_internals.size()); for (size_t i = 0; i < orig_internals.size(); i++) - internals[i].create(shape(orig_internals[i]), CV_32F); + internals[i].create(shape(orig_internals[i]), CV_32FC1); forward(inputs, outputs, internals); diff --git a/modules/dnn/src/layers/batch_norm_layer.cpp b/modules/dnn/src/layers/batch_norm_layer.cpp index 6762ff85468c..bdea8c3c7e0c 100644 --- a/modules/dnn/src/layers/batch_norm_layer.cpp +++ b/modules/dnn/src/layers/batch_norm_layer.cpp @@ -44,7 +44,7 @@ class BatchNormLayerImpl CV_FINAL : public BatchNormLayer size_t n = blobs[0].total(); CV_Assert(blobs[1].total() == n && blobs[0].isContinuous() && blobs[1].isContinuous() && - blobs[0].type() == CV_32F && blobs[1].type() == CV_32F); + blobs[0].type() == CV_32FC1 && blobs[1].type() == CV_32FC1); float varMeanScale = 1.f; if (!hasWeights && !hasBias && blobs.size() > 2 && useGlobalStats) { @@ -61,14 +61,14 @@ class BatchNormLayerImpl CV_FINAL : public BatchNormLayer { CV_Assert((size_t)weightsBlobIndex < blobs.size()); const Mat& w = blobs[weightsBlobIndex]; - CV_Assert(w.isContinuous() && w.type() == CV_32F && w.total() == (size_t)n); + CV_Assert(w.isContinuous() && w.type() == CV_32FC1 && w.total() == (size_t)n); } if( hasBias ) { CV_Assert((size_t)biasBlobIndex < blobs.size()); const Mat& b = blobs[weightsBlobIndex]; - CV_Assert(b.isContinuous() && b.type() == CV_32F && b.total() == (size_t)n); + CV_Assert(b.isContinuous() && b.type() == CV_32FC1 && b.total() == (size_t)n); } const float* meanData = blobs[0].ptr(); @@ -76,8 +76,8 @@ class BatchNormLayerImpl CV_FINAL : public BatchNormLayer const float* weightsData = hasWeights ? blobs[weightsBlobIndex].ptr() : 0; const float* biasData = hasBias ? blobs[biasBlobIndex].ptr() : 0; - weights_.create(1, (int)n, CV_32F); - bias_.create(1, (int)n, CV_32F); + weights_.create(1, (int)n, CV_32FC1); + bias_.create(1, (int)n, CV_32FC1); float* dstWeightsData = weights_.ptr(); float* dstBiasData = bias_.ptr(); @@ -262,8 +262,8 @@ class BatchNormLayerImpl CV_FINAL : public BatchNormLayer { float w = weights_.at(n); float b = bias_.at(n); - Mat inpBlobPlane(rows, cols, CV_32F, inpBlob.ptr(num, n)); - Mat outBlobPlane(rows, cols, CV_32F, outBlob.ptr(num, n)); + Mat inpBlobPlane(rows, cols, CV_32FC1, inpBlob.ptr(num, n)); + Mat outBlobPlane(rows, cols, CV_32FC1, outBlob.ptr(num, n)); inpBlobPlane.convertTo(outBlobPlane, CV_32F, w, b); } } diff --git a/modules/dnn/src/layers/concat_layer.cpp b/modules/dnn/src/layers/concat_layer.cpp index 92e5421db9f2..9fea1a77ee53 100644 --- a/modules/dnn/src/layers/concat_layer.cpp +++ b/modules/dnn/src/layers/concat_layer.cpp @@ -128,14 +128,14 @@ class ConcatLayerImpl CV_FINAL : public ConcatLayer for( i = 0; i < ninputs; i++ ) { Mat& inp = inputs[i]; - CV_Assert( inp.isContinuous() && (inp.type() == CV_32F || inp.type() == CV_16S) && + CV_Assert( inp.isContinuous() && (inp.type() == CV_32FC1 || inp.type() == CV_16SC1) && inp.dims == 4 && inp.size[0] == output.size[0] && inp.size[2] == output.size[2] && inp.size[3] == output.size[3] ); nchannels += inp.size[1]; } CV_Assert( nchannels == output.size[1] ); - CV_Assert( output.isContinuous() && (output.type() == CV_32F || output.type() == CV_16S) ); + CV_Assert( output.isContinuous() && (output.type() == CV_32FC1 || output.type() == CV_16SC1) ); cc.chptrs.resize(nchannels*batchsz); diff --git a/modules/dnn/src/layers/convolution_layer.cpp b/modules/dnn/src/layers/convolution_layer.cpp index a948c6ef9d6f..78970b4de7c3 100644 --- a/modules/dnn/src/layers/convolution_layer.cpp +++ b/modules/dnn/src/layers/convolution_layer.cpp @@ -98,7 +98,7 @@ class BaseConvolutionLayerImpl : public ConvolutionLayer CV_Assert(blobs[0].dims == 4 && blobs[0].size[3] == kernel.width && blobs[0].size[2] == kernel.height); const Mat &input = inputs[0]; - CV_Assert(input.dims == 4 && (input.type() == CV_32F || input.type() == CV_64F || input.type() == CV_16S)); + CV_Assert(input.dims == 4 && (input.type() == CV_32FC1 || input.type() == CV_64FC1 || input.type() == CV_16SC1)); for (size_t i = 0; i < inputs.size(); i++) { CV_Assert(inputs[i].type() == input.type()); @@ -321,8 +321,8 @@ class ConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl if (activ_power->scale != 1.f || activ_power->shift != 0.f) { const int outCh = blobs[0].size[0]; - fuseWeights(Mat(1, outCh, CV_32F, Scalar(activ_power->scale)), - Mat(1, outCh, CV_32F, Scalar(activ_power->shift))); + fuseWeights(Mat(1, outCh, CV_32FC1, Scalar(activ_power->scale)), + Mat(1, outCh, CV_32FC1, Scalar(activ_power->shift))); } power = activ_power->power; @@ -356,8 +356,8 @@ class ConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl // (conv(I) + b1 ) * w + b2 // means to replace convolution's weights to [w*conv(I)] and bias to [b1 * w + b2] const int outCn = weightsMat.size[0]; - Mat w = w_.total() == 1 ? Mat(1, outCn, CV_32F, Scalar(w_.at(0))) : w_; - Mat b = b_.total() == 1 ? Mat(1, outCn, CV_32F, Scalar(b_.at(0))) : b_; + Mat w = w_.total() == 1 ? Mat(1, outCn, CV_32FC1, Scalar(w_.at(0))) : w_; + Mat b = b_.total() == 1 ? Mat(1, outCn, CV_32FC1, Scalar(b_.at(0))) : b_; CV_Assert_N(!weightsMat.empty(), biasvec.size() == outCn + 2, w.empty() || outCn == w.total(), b.empty() || outCn == b.total()); @@ -482,7 +482,7 @@ class ConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl } if (hasBias() || fusedBias) { - Mat biasesMat({outCn}, CV_32F, &biasvec[0]); + Mat biasesMat({outCn}, CV_32FC1, &biasvec[0]); ieLayer->_biases = wrapToInfEngineBlob(biasesMat, {(size_t)outCn}, InferenceEngine::Layout::C); } return Ptr(new InfEngineBackendNode(ieLayer)); @@ -929,7 +929,7 @@ class ConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl if( !activ_chprelu.empty() ) { const Mat& m = activ_chprelu->blobs[0]; - CV_Assert(m.isContinuous() && m.type() == CV_32F && (int)m.total() == outCn); + CV_Assert(m.isContinuous() && m.type() == CV_32FC1 && (int)m.total() == outCn); const float* mdata = m.ptr(); reluslope.resize(outCn+2); std::copy(mdata, mdata + outCn, reluslope.begin()); @@ -1041,7 +1041,7 @@ class ConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl if( !activ_chprelu.empty() ) { const Mat& m = activ_chprelu->blobs[0]; - CV_Assert(m.isContinuous() && m.type() == CV_32F && (int)m.total() == outCn); + CV_Assert(m.isContinuous() && m.type() == CV_32FC1 && (int)m.total() == outCn); const float* mdata = m.ptr(); reluslope.resize(outCn+2); std::copy(mdata, mdata + outCn, reluslope.begin()); @@ -1453,7 +1453,7 @@ class DeConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl { transpose(blobs[0].reshape(1, inpCn), umat_weights); umat_biases = hasBias() ? blobs[1].reshape(1, outCn).getUMat(ACCESS_READ) : - UMat::zeros(outCn, 1, CV_32F); + UMat::zeros(outCn, 1, CV_32FC1); } String buildopt = format("-DT=%s ", ocl::typeToStr(inputs[0].type())); @@ -1552,7 +1552,7 @@ class DeConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl if( weightsMat.empty() ) { transpose(blobs[0].reshape(1, inpCn), weightsMat); - biasesMat = hasBias() ? blobs[1].reshape(1, outCn) : Mat::zeros(outCn, 1, CV_32F); + biasesMat = hasBias() ? blobs[1].reshape(1, outCn) : Mat::zeros(outCn, 1, CV_32FC1); } for (size_t ii = 0; ii < outputs.size(); ii++) diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp index d94cdc02a5b2..6180c131700a 100644 --- a/modules/dnn/src/layers/detection_output_layer.cpp +++ b/modules/dnn/src/layers/detection_output_layer.cpp @@ -232,7 +232,7 @@ class DetectionOutputLayerImpl CV_FINAL : public DetectionOutputLayer const cv::String& code_type, const bool variance_encoded_in_target, const bool clip, std::vector& all_decode_bboxes) { - UMat outmat = UMat(loc_mat.dims, loc_mat.size, CV_32F); + UMat outmat = UMat(loc_mat.dims, loc_mat.size, CV_32FC1); size_t nthreads = loc_mat.total(); String kernel_name; @@ -295,7 +295,7 @@ class DetectionOutputLayerImpl CV_FINAL : public DetectionOutputLayer { int shape[] = { numClasses, numPredsPerClass }; for (int i = 0; i < num; i++) - confPreds.push_back(Mat(2, shape, CV_32F)); + confPreds.push_back(Mat(2, shape, CV_32FC1)); shape[0] = num * numPredsPerClass; shape[1] = inp1.total() / shape[0]; @@ -373,7 +373,7 @@ class DetectionOutputLayerImpl CV_FINAL : public DetectionOutputLayer return true; } int outputShape[] = {1, 1, (int)numKept, 7}; - UMat umat = UMat(4, outputShape, CV_32F); + UMat umat = UMat(4, outputShape, CV_32FC1); { Mat mat = umat.getMat(ACCESS_WRITE); float* outputsData = mat.ptr(); @@ -492,7 +492,7 @@ class DetectionOutputLayerImpl CV_FINAL : public DetectionOutputLayer return; } int outputShape[] = {1, 1, (int)numKept, 7}; - outputs[0].create(4, outputShape, CV_32F); + outputs[0].create(4, outputShape, CV_32FC1); float* outputsData = outputs[0].ptr(); size_t count = 0; @@ -898,7 +898,7 @@ class DetectionOutputLayerImpl CV_FINAL : public DetectionOutputLayer { int shape[] = { numClasses, numPredsPerClass }; for (int i = 0; i < num; i++) - confPreds.push_back(Mat(2, shape, CV_32F)); + confPreds.push_back(Mat(2, shape, CV_32FC1)); for (int i = 0; i < num; ++i, confData += numPredsPerClass * numClasses) { diff --git a/modules/dnn/src/layers/elementwise_layers.cpp b/modules/dnn/src/layers/elementwise_layers.cpp index c042f5fc559e..d45e2a1f0820 100644 --- a/modules/dnn/src/layers/elementwise_layers.cpp +++ b/modules/dnn/src/layers/elementwise_layers.cpp @@ -202,7 +202,7 @@ class ElementWiseLayer : public Func::Layer const Mat &src = inputs[i]; Mat &dst = outputs[i]; CV_Assert(src.size == dst.size && src.type() == dst.type() && - src.isContinuous() && dst.isContinuous() && src.type() == CV_32F); + src.isContinuous() && dst.isContinuous() && src.type() == CV_32FC1); const int nstripes = getNumThreads(); PBody body(func, src, dst, nstripes); @@ -956,8 +956,8 @@ struct PowerFunctor { if (power == 1.0f) { - _scale = Mat(1, 1, CV_32F, Scalar(scale)); - _shift = Mat(1, 1, CV_32F, Scalar(shift)); + _scale = Mat(1, 1, CV_32FC1, Scalar(scale)); + _shift = Mat(1, 1, CV_32FC1, Scalar(shift)); } } @@ -983,7 +983,7 @@ struct ChannelsPReLUFunctor void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const { - CV_Assert(scale.isContinuous() && scale.type() == CV_32F); + CV_Assert(scale.isContinuous() && scale.type() == CV_32FC1); const float* scaleptr = scale.ptr(); CV_Assert( 0 <= cn0 && cn0 < cn1 && cn1 <= (int)scale.total() ); diff --git a/modules/dnn/src/layers/fully_connected_layer.cpp b/modules/dnn/src/layers/fully_connected_layer.cpp index d2c609cf77cc..be0ce0387418 100644 --- a/modules/dnn/src/layers/fully_connected_layer.cpp +++ b/modules/dnn/src/layers/fully_connected_layer.cpp @@ -155,7 +155,7 @@ class FullyConnectedLayerImpl CV_FINAL : public InnerProductLayer CV_Assert( srcMat.dims == 2 && srcMat.cols == weights.cols && dstMat.rows == srcMat.rows && dstMat.cols == weights.rows && srcMat.type() == weights.type() && weights.type() == dstMat.type() && - srcMat.type() == CV_32F && + srcMat.type() == CV_32FC1 && (biasMat.empty() || (biasMat.type() == srcMat.type() && biasMat.isContinuous() && (int)biasMat.total() == dstMat.cols)) ); diff --git a/modules/dnn/src/layers/lrn_layer.cpp b/modules/dnn/src/layers/lrn_layer.cpp index 5af2359bb8c7..711d77f714d6 100644 --- a/modules/dnn/src/layers/lrn_layer.cpp +++ b/modules/dnn/src/layers/lrn_layer.cpp @@ -300,7 +300,7 @@ class LRNLayerImpl CV_FINAL : public LRNLayer sqrBoxFilter_(src, dst); - dst.convertTo(dst, dst.type(), alpha/sizeNormFactor, bias); + dst.convertTo(dst, dst.depth(), alpha/sizeNormFactor, bias); cv::pow(dst, beta, dst); cv::divide(src, dst, dst); } diff --git a/modules/dnn/src/layers/mvn_layer.cpp b/modules/dnn/src/layers/mvn_layer.cpp index 2edbffb90fe4..01a34cd915bc 100644 --- a/modules/dnn/src/layers/mvn_layer.cpp +++ b/modules/dnn/src/layers/mvn_layer.cpp @@ -132,8 +132,8 @@ class MVNLayerImpl CV_FINAL : public MVNLayer int newRows = total(shape(inpMat), 0, splitDim); MatShape s = shape(newRows, inpMat.total() / newRows); - UMat meanMat = UMat(s[0], 1, (use_half) ? CV_16S : CV_32F); - UMat tmpMat = UMat(s[0], s[1], CV_32F); + UMat meanMat = UMat(s[0], 1, (use_half) ? CV_16SC1 : CV_32FC1); + UMat tmpMat = UMat(s[0], s[1], CV_32FC1); float alpha = 1.0f / s[1]; String buildopt = "-DNUM=4" + opts; @@ -203,10 +203,10 @@ class MVNLayerImpl CV_FINAL : public MVNLayer int newRows = total(shape(inpMat), 0, splitDim); MatShape s = shape(newRows, inpMat.total() / newRows); - UMat oneMat = UMat::ones(s[1], 1, CV_32F); - UMat meanMat = UMat(s[0], 1, CV_32F); - UMat devMat = UMat(s[0], 1, CV_32F); - UMat tmpMat = UMat(s[0], s[1], CV_32F); + UMat oneMat = UMat::ones(s[1], 1, CV_32FC1); + UMat meanMat = UMat(s[0], 1, CV_32FC1); + UMat devMat = UMat(s[0], 1, CV_32FC1); + UMat tmpMat = UMat(s[0], s[1], CV_32FC1); float alpha = 1.0f / s[1]; bool ret = ocl4dnn::ocl4dnnGEMV(ocl4dnn::CblasNoTrans, s[0], s[1], alpha, @@ -340,7 +340,7 @@ class MVNLayerImpl CV_FINAL : public MVNLayer normalizationScale = alpha; normalizationShift = -mean[0] * alpha; } - inpRow.convertTo(outRow, outRow.type(), normalizationScale, normalizationShift); + inpRow.convertTo(outRow, outRow.depth(), normalizationScale, normalizationShift); } } } diff --git a/modules/dnn/src/layers/normalize_bbox_layer.cpp b/modules/dnn/src/layers/normalize_bbox_layer.cpp index 694d3d1039e1..e0c748c0f943 100644 --- a/modules/dnn/src/layers/normalize_bbox_layer.cpp +++ b/modules/dnn/src/layers/normalize_bbox_layer.cpp @@ -216,8 +216,8 @@ class NormalizeBBoxLayerImpl CV_FINAL : public NormalizeBBoxLayer size_t planeSize = inp0.total() / (num * numPlanes); for (size_t n = 0; n < num; ++n) { - Mat src = Mat(numPlanes, planeSize, CV_32F, (void*)inpData); - Mat dst = Mat(numPlanes, planeSize, CV_32F, (void*)outData); + Mat src = Mat(numPlanes, planeSize, CV_32FC1, (void*)inpData); + Mat dst = Mat(numPlanes, planeSize, CV_32FC1, (void*)outData); cv::pow(abs(src), pnorm, buffer); if (planeSize == 1) diff --git a/modules/dnn/src/layers/permute_layer.cpp b/modules/dnn/src/layers/permute_layer.cpp index 65e4f049e38e..edc4b9db2b9a 100644 --- a/modules/dnn/src/layers/permute_layer.cpp +++ b/modules/dnn/src/layers/permute_layer.cpp @@ -344,7 +344,7 @@ class PermuteLayerImpl CV_FINAL : public PermuteLayer CV_Assert(out.dims == numAxes && out.size == outputs[0].size); CV_Assert(inp.isContinuous() && out.isContinuous()); - CV_Assert(inp.type() == CV_32F && out.type() == CV_32F); + CV_Assert(inp.type() == CV_32FC1 && out.type() == CV_32FC1); if( numAxes == 4 ) { diff --git a/modules/dnn/src/layers/pooling_layer.cpp b/modules/dnn/src/layers/pooling_layer.cpp index 0b4b0ae850dc..daae9f25d787 100644 --- a/modules/dnn/src/layers/pooling_layer.cpp +++ b/modules/dnn/src/layers/pooling_layer.cpp @@ -330,7 +330,7 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer { CV_Assert_N( src.isContinuous(), dst.isContinuous(), - src.type() == CV_32F, src.type() == dst.type(), + src.type() == CV_32FC1, src.type() == dst.type(), src.dims == 4, dst.dims == 4, ((poolingType == ROI || poolingType == PSROI) && dst.size[0] ==rois.size[0] || src.size[0] == dst.size[0]), poolingType == PSROI || src.size[1] == dst.size[1], diff --git a/modules/dnn/src/layers/prior_box_layer.cpp b/modules/dnn/src/layers/prior_box_layer.cpp index fde41201d544..f2c4c0460c6a 100644 --- a/modules/dnn/src/layers/prior_box_layer.cpp +++ b/modules/dnn/src/layers/prior_box_layer.cpp @@ -458,7 +458,7 @@ class PriorBoxLayerImpl CV_FINAL : public PriorBoxLayer outputPtr = outputs[0].ptr(0, 1); if(_variance.size() == 1) { - Mat secondChannel(1, outputs[0].size[2], CV_32F, outputPtr); + Mat secondChannel(1, outputs[0].size[2], CV_32FC1, outputPtr); secondChannel.setTo(Scalar::all(_variance[0])); } else diff --git a/modules/dnn/src/layers/recurrent_layers.cpp b/modules/dnn/src/layers/recurrent_layers.cpp index 6a6cf0ce81c5..f45bcf573392 100644 --- a/modules/dnn/src/layers/recurrent_layers.cpp +++ b/modules/dnn/src/layers/recurrent_layers.cpp @@ -66,9 +66,9 @@ static void tanh(const Mat &src, Mat &dst) { dst.create(src.dims, (const int*)src.size, src.type()); - if (src.type() == CV_32F) + if (src.type() == CV_32FC1) tanh(src, dst); - else if (src.type() == CV_64F) + else if (src.type() == CV_64FC1) tanh(src, dst); else CV_Error(Error::StsUnsupportedFormat, "Function supports only floating point types"); @@ -374,7 +374,7 @@ class RNNLayerImpl : public RNNLayer { int numX, numH, numO; int numSamples, numTimestamps, numSamplesTotal; - int dtype; + ElemType dtype; Mat Whh, Wxh, bh; Mat Who, bo; bool produceH; @@ -382,7 +382,7 @@ class RNNLayerImpl : public RNNLayer public: RNNLayerImpl(const LayerParams& params) - : numX(0), numH(0), numO(0), numSamples(0), numTimestamps(0), numSamplesTotal(0), dtype(0) + : numX(0), numH(0), numO(0), numSamples(0), numTimestamps(0), numSamplesTotal(0), dtype(CV_8UC1) { setParamsFrom(params); type = "RNN"; @@ -459,7 +459,7 @@ class RNNLayerImpl : public RNNLayer CV_Assert(inp0.dims >= 2); CV_Assert(inp0.total(2) == numX); - dtype = CV_32F; + dtype = CV_32FC1; CV_Assert(inp0.type() == dtype); numTimestamps = inp0.size[0]; numSamples = inp0.size[1]; diff --git a/modules/dnn/src/layers/scale_layer.cpp b/modules/dnn/src/layers/scale_layer.cpp index b554c2274a36..541526626661 100644 --- a/modules/dnn/src/layers/scale_layer.cpp +++ b/modules/dnn/src/layers/scale_layer.cpp @@ -110,8 +110,8 @@ class ScaleLayerImpl CV_FINAL : public ScaleLayer { float w = weightsData ? weightsData[j] : 1; float b = biasesData ? biasesData[j] : 0; - Mat inpSlice(1, spatialSize, CV_32F, inpData); - Mat outSlice(1, spatialSize, CV_32F, outData); + Mat inpSlice(1, spatialSize, CV_32FC1, inpData); + Mat outSlice(1, spatialSize, CV_32FC1, outData); inpSlice.convertTo(outSlice, CV_32F, w, b); inpData += spatialSize; outData += spatialSize; @@ -122,8 +122,8 @@ class ScaleLayerImpl CV_FINAL : public ScaleLayer { for (int i = 0; i < numSlices; ++i) { - Mat inpSlice(1, numWeights, CV_32F, inpData); - Mat outSlice(1, numWeights, CV_32F, outData); + Mat inpSlice(1, numWeights, CV_32FC1, inpData); + Mat outSlice(1, numWeights, CV_32FC1, outData); if (!weights.empty()) { multiply(inpSlice, weights, outSlice); diff --git a/modules/dnn/src/layers/softmax_layer.cpp b/modules/dnn/src/layers/softmax_layer.cpp index 9f7a0ac9206b..fe15309a7576 100644 --- a/modules/dnn/src/layers/softmax_layer.cpp +++ b/modules/dnn/src/layers/softmax_layer.cpp @@ -209,7 +209,7 @@ class SoftMaxLayerImpl CV_FINAL : public SoftmaxLayer size_t outerSize = src.total(0, axis), channels = src.size[axis], innerSize = src.total(axis + 1); - CV_Assert(src.type() == CV_32F); + CV_Assert(src.type() == CV_32FC1); CV_Assert(src.isContinuous() && dst.isContinuous()); const float *srcPtr = src.ptr(); diff --git a/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp b/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp index 68e89d569448..c0b3816beb42 100644 --- a/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp +++ b/modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp @@ -719,7 +719,7 @@ bool OCL4DNNConvSpatial::swizzleWeight(const UMat &weight, UMat swizzled_weights_tmp; if (use_half_) - swizzled_weights_tmp.create(shape(swizzled_weights_umat), CV_32F); + swizzled_weights_tmp.create(shape(swizzled_weights_umat), CV_32FC1); if (!interleave) { cl_uint argIdx = 0; diff --git a/modules/dnn/src/ocl4dnn/src/ocl4dnn_inner_product.cpp b/modules/dnn/src/ocl4dnn/src/ocl4dnn_inner_product.cpp index ee7a2c7b0121..bc18a0488822 100644 --- a/modules/dnn/src/ocl4dnn/src/ocl4dnn_inner_product.cpp +++ b/modules/dnn/src/ocl4dnn/src/ocl4dnn_inner_product.cpp @@ -99,7 +99,7 @@ bool OCL4DNNInnerProduct::Forward(const UMat& bottom, if (use_half_ && bias_term_) { - UMat biasOneMat = UMat::ones(M_, 1, CV_32F); + UMat biasOneMat = UMat::ones(M_, 1, CV_32FC1); UMat newbias, tmpTop; convertFp16(bias, newbias); diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 9c49a06596a8..c7bed64069fa 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -68,11 +68,11 @@ static InferenceEngine::DataPtr wrapToInfEngineDataNode(const Mat& m, const std: { std::vector reversedShape(&m.size[0], &m.size[0] + m.dims); std::reverse(reversedShape.begin(), reversedShape.end()); - if (m.type() == CV_32F) + if (m.type() == CV_32FC1) return InferenceEngine::DataPtr( new InferenceEngine::Data(name, reversedShape, InferenceEngine::Precision::FP32, estimateLayout(m)) ); - else if (m.type() == CV_8U) + else if (m.type() == CV_8UC1) return InferenceEngine::DataPtr( new InferenceEngine::Data(name, reversedShape, InferenceEngine::Precision::U8, estimateLayout(m)) ); @@ -83,10 +83,10 @@ static InferenceEngine::DataPtr wrapToInfEngineDataNode(const Mat& m, const std: InferenceEngine::Blob::Ptr wrapToInfEngineBlob(const Mat& m, const std::vector& shape, InferenceEngine::Layout layout) { - if (m.type() == CV_32F) + if (m.type() == CV_32FC1) return InferenceEngine::make_shared_blob(InferenceEngine::Precision::FP32, layout, shape, (float*)m.data); - else if (m.type() == CV_8U) + else if (m.type() == CV_8UC1) return InferenceEngine::make_shared_blob(InferenceEngine::Precision::U8, layout, shape, (uint8_t*)m.data); else @@ -527,7 +527,7 @@ Mat infEngineBlobToMat(const InferenceEngine::Blob::Ptr& blob) // NOTE: Inference Engine sizes are reversed. std::vector dims = blob->dims(); std::vector size(dims.rbegin(), dims.rend()); - return Mat(size, CV_32F, (void*)blob->buffer()); + return Mat(size, CV_32FC1, (void*)blob->buffer()); } InfEngineBackendLayer::InfEngineBackendLayer(const InferenceEngine::DataPtr& output_) diff --git a/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp b/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp index 28c0f4de21b7..bdfa22cadadc 100644 --- a/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp +++ b/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp @@ -754,7 +754,7 @@ Mat getTensorContent(const tensorflow::TensorProto &tensor) const RepeatedField& field = tensor.half_val(); CV_Assert(!field.empty()); Mat ints(1, field.size(), CV_32SC1, (void*)field.data()); - ints.convertTo(halfs, CV_16UC1); + ints.convertTo(halfs, CV_16U); } // Reinterpret as a signed shorts just for a convertFp16 call. Mat halfsSigned(halfs.size(), CV_16SC1, halfs.data); diff --git a/modules/dnn/src/tensorflow/tf_importer.cpp b/modules/dnn/src/tensorflow/tf_importer.cpp index 145af366f8f9..0812f72989da 100644 --- a/modules/dnn/src/tensorflow/tf_importer.cpp +++ b/modules/dnn/src/tensorflow/tf_importer.cpp @@ -106,7 +106,7 @@ void parseTensor(const tensorflow::TensorProto &tensor, Mat &dstBlob) swap(shape[1], shape[2]); // NCHW } - dstBlob.create(shape, CV_32F); + dstBlob.create(shape, CV_32FC1); Mat tensorContent = getTensorContent(tensor); int size = tensorContent.total(); @@ -461,7 +461,7 @@ void TFImporter::kernelFromTensor(const tensorflow::TensorProto &tensor, Mat &ds swap(shape[1], shape[3]); // IOHW swap(shape[0], shape[1]); // OIHW - dstBlob.create(shape, CV_32F); + dstBlob.create(shape, CV_32FC1); Mat tensorContent = getTensorContent(tensor); int size = tensorContent.total(); @@ -595,7 +595,7 @@ static void addConstNodes(tensorflow::GraphDef& net, std::map& cons float minVal = qMin.at(0); float rangeScale = (qMax.at(0) - minVal) / 255; CV_Assert(rangeScale >= 0); - content.convertTo(content, CV_32FC1, rangeScale, + content.convertTo(content, CV_32F, rangeScale, rangeScale * cvRound(minVal / rangeScale)); tensor->set_dtype(tensorflow::DT_FLOAT); @@ -898,8 +898,8 @@ void TFImporter::populateNet(Net dstNet) const int slice = height * width * inCh; for (int i = 0; i < outCh; i += 2) { - cv::Mat src(1, slice, CV_32F, layerParams.blobs[0].ptr(i)); - cv::Mat dst(1, slice, CV_32F, layerParams.blobs[0].ptr(i + 1)); + cv::Mat src(1, slice, CV_32FC1, layerParams.blobs[0].ptr(i)); + cv::Mat dst(1, slice, CV_32FC1, layerParams.blobs[0].ptr(i + 1)); std::swap_ranges(src.begin(), src.end(), dst.begin()); } } @@ -1506,8 +1506,8 @@ void TFImporter::populateNet(Net dstNet) if (layerParams.blobs.size() == 2) CV_Error(Error::StsNotImplemented, "Cannot determine number " "of parameters for batch normalization layer."); - mean = Mat::zeros(1, layerParams.blobs[3].total(), CV_32F); - std = Mat::ones(1, layerParams.blobs[3].total(), CV_32F); + mean = Mat::zeros(1, layerParams.blobs[3].total(), CV_32FC1); + std = Mat::ones(1, layerParams.blobs[3].total(), CV_32FC1); // Add an extra layer: Mean-Variance normalization LayerParams mvnParams; diff --git a/modules/dnn/src/torch/torch_importer.cpp b/modules/dnn/src/torch/torch_importer.cpp index 6c1909380576..a9e53febd09c 100644 --- a/modules/dnn/src/torch/torch_importer.cpp +++ b/modules/dnn/src/torch/torch_importer.cpp @@ -232,25 +232,25 @@ struct TorchImporter CV_Error(Error::StsNotImplemented, "Unknown type \"" + typeStr + "\" of torch class \"" + str + "\""); } - return -1; + return CV_DEPTH_AUTO; } - static int parseTensorType(const String &className) + static ElemDepth parseTensorType(const String &className) { return parseTorchType(className, "Tensor"); } - static int parseStorageType(const String &className) + static ElemDepth parseStorageType(const String &className) { return parseTorchType(className, "Storage"); } - void readTorchStorage(int index, int type = -1) + void readTorchStorage(int index, ElemDepth depth = CV_DEPTH_AUTO) { long size = readLong(); Mat storageMat; - switch (type) + switch (depth) { case TYPE_FLOAT: storageMat.create(1, size, CV_32F); @@ -385,7 +385,7 @@ struct TorchImporter } } - void readTorchTensor(int indexTensor, int typeTensor) + void readTorchTensor(int indexTensor, ElemDepth depthTensor) { int ndims = readInt(); AutoBuffer sizes(ndims); @@ -408,10 +408,10 @@ struct TorchImporter if (readedIndexes.count(indexStorage) == 0) { String className = readTorchClassName(); - int typeStorage = parseStorageType(className); - CV_Assert(typeStorage >= 0 && typeTensor == typeStorage); + ElemDepth typeStorage = parseStorageType(className); + CV_Assert(typeStorage >= 0 && depthTensor == typeStorage); readTorchStorage(indexStorage, typeStorage); - typeTensor = storages[indexStorage].type(); + depthTensor = storages[indexStorage].depth(); readedIndexes.insert(indexStorage); } @@ -427,15 +427,15 @@ struct TorchImporter for (int i = ndims - 1; i >= 0; i--) { isizes[i] = (int)sizes[i]; - ssteps[i] = (size_t)steps[i] * CV_ELEM_SIZE(typeTensor); + ssteps[i] = (size_t)steps[i] * CV_ELEM_SIZE(depthTensor); } //allocate Blob - Mat srcMat(ndims, isizes.data(), typeTensor , storages[indexStorage].ptr() + offset*CV_ELEM_SIZE(typeTensor), ssteps.data()); - int dstType = CV_32F; + Mat srcMat(ndims, isizes.data(), CV_MAKETYPE(depthTensor, 1), storages[indexStorage].ptr() + offset*CV_ELEM_SIZE(depthTensor), ssteps.data()); + ElemDepth dstDepth = CV_32F; Mat blob; - srcMat.convertTo(blob, dstType); + srcMat.convertTo(blob, dstDepth); tensors.insert(std::make_pair(indexTensor, blob)); } @@ -477,7 +477,7 @@ struct TorchImporter if (dbgPrint) std::cout << "Class: " << className << std::endl; - int type; + ElemDepth type; if ( (type = parseTensorType(className)) >= 0 ) //is Tensor { readTorchTensor(index, type); @@ -649,7 +649,7 @@ struct TorchImporter else { CV_Assert(scalarParams.has("nOutput")); - layerParams.blobs.push_back(Mat::zeros(1, scalarParams.get("nOutput"), CV_32F)); + layerParams.blobs.push_back(Mat::zeros(1, scalarParams.get("nOutput"), CV_32FC1)); } if (tensorParams.count("running_var")) @@ -665,7 +665,7 @@ struct TorchImporter else { CV_Assert(scalarParams.has("nOutput")); - layerParams.blobs.push_back(Mat::ones(1, scalarParams.get("nOutput"), CV_32F)); + layerParams.blobs.push_back(Mat::ones(1, scalarParams.get("nOutput"), CV_32FC1)); } if (tensorParams.count("weight")) diff --git a/modules/dnn/test/npy_blob.cpp b/modules/dnn/test/npy_blob.cpp index a966801af67e..573dca694ea4 100644 --- a/modules/dnn/test/npy_blob.cpp +++ b/modules/dnn/test/npy_blob.cpp @@ -84,7 +84,7 @@ Mat blobFromNPY(const std::string& path) CV_Assert(getFortranOrder(header) == "False"); std::vector shape = getShape(header); - Mat blob(shape, CV_32F); + Mat blob(shape, CV_32FC1); ifs.read((char*)blob.data, blob.total() * blob.elemSize()); CV_Assert((size_t)ifs.gcount() == blob.total() * blob.elemSize()); diff --git a/modules/dnn/test/test_backends.cpp b/modules/dnn/test/test_backends.cpp index a42cc4c174ec..af218dce4cc9 100644 --- a/modules/dnn/test/test_backends.cpp +++ b/modules/dnn/test/test_backends.cpp @@ -62,7 +62,7 @@ class DNNTestNetwork : public DNNTestLayer float* inpData = (float*)inp.data; for (int i = 0; i < inp.size[0] * inp.size[1]; ++i) { - Mat slice(inp.size[2], inp.size[3], CV_32F, inpData); + Mat slice(inp.size[2], inp.size[3], CV_32FC1, inpData); cv::flip(slice, slice, 1); inpData += slice.total(); } diff --git a/modules/dnn/test/test_caffe_importer.cpp b/modules/dnn/test/test_caffe_importer.cpp index b6da2f189c4a..142111f69b36 100644 --- a/modules/dnn/test/test_caffe_importer.cpp +++ b/modules/dnn/test/test_caffe_importer.cpp @@ -385,7 +385,7 @@ TEST_P(Test_Caffe_nets, Colorization) net.setPreferableTarget(target); net.getLayer(net.getLayerId("class8_ab"))->blobs.push_back(kernel); - net.getLayer(net.getLayerId("conv8_313_rh"))->blobs.push_back(Mat(1, 313, CV_32F, 2.606)); + net.getLayer(net.getLayerId("conv8_313_rh"))->blobs.push_back(Mat(1, 313, CV_32FC1, 2.606)); net.setInput(inp); Mat out = net.forward(); diff --git a/modules/dnn/test/test_common.hpp b/modules/dnn/test/test_common.hpp index deb30689816a..18fbac05f6fc 100644 --- a/modules/dnn/test/test_common.hpp +++ b/modules/dnn/test/test_common.hpp @@ -179,8 +179,8 @@ static inline void normAssertDetections(cv::Mat ref, cv::Mat out, const char *co out = out.reshape(1, out.total() / 7); cv::Mat refClassIds, testClassIds; - ref.col(1).convertTo(refClassIds, CV_32SC1); - out.col(1).convertTo(testClassIds, CV_32SC1); + ref.col(1).convertTo(refClassIds, CV_32S); + out.col(1).convertTo(testClassIds, CV_32S); std::vector refScores(ref.col(2)), testScores(out.col(2)); std::vector refBoxes = matToBoxes(ref.colRange(3, 7)); std::vector testBoxes = matToBoxes(out.colRange(3, 7)); diff --git a/modules/dnn/test/test_halide_layers.cpp b/modules/dnn/test/test_halide_layers.cpp index e9b219fafec8..ba206a6486c9 100644 --- a/modules/dnn/test/test_halide_layers.cpp +++ b/modules/dnn/test/test_halide_layers.cpp @@ -70,7 +70,7 @@ TEST_P(Test_Halide_layers, Padding) lp.name = "testLayer"; int sz[] = {1 + (int)rng(10), 1 + (int)rng(10), 1 + (int)rng(10), 1 + (int)rng(10)}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(lp, input, backend, target); } } @@ -109,7 +109,7 @@ TEST_P(Convolution, Accuracy) skipCheck = true; int sz[] = {outChannels, inChannels / group, kernel.height, kernel.width}; - Mat weights(4, &sz[0], CV_32F); + Mat weights(4, &sz[0], CV_32FC1); randu(weights, -1.0f, 1.0f); LayerParams lp; @@ -129,12 +129,12 @@ TEST_P(Convolution, Accuracy) lp.blobs.push_back(weights); if (hasBias) { - Mat bias(1, outChannels, CV_32F); + Mat bias(1, outChannels, CV_32FC1); randu(bias, -1.0f, 1.0f); lp.blobs.push_back(bias); } int inpSz[] = {1, inChannels, inSize.height, inSize.width}; - Mat input(4, &inpSz[0], CV_32F); + Mat input(4, &inpSz[0], CV_32FC1); test(lp, input, backendId, targetId, skipCheck); if (skipCheck) throw SkipTestException("Skip checks in unstable test"); @@ -176,7 +176,7 @@ TEST_P(Deconvolution, Accuracy) throw SkipTestException(""); int sz[] = {inChannels, outChannels / group, kernel.height, kernel.width}; - Mat weights(4, &sz[0], CV_32F); + Mat weights(4, &sz[0], CV_32FC1); randu(weights, -1.0f, 1.0f); LayerParams lp; @@ -198,12 +198,12 @@ TEST_P(Deconvolution, Accuracy) lp.blobs.push_back(weights); if (hasBias) { - Mat bias(1, outChannels, CV_32F); + Mat bias(1, outChannels, CV_32FC1); randu(bias, -1.0f, 1.0f); lp.blobs.push_back(bias); } int inpSz[] = {1, inChannels, inSize.height, inSize.width}; - Mat input(4, &inpSz[0], CV_32F); + Mat input(4, &inpSz[0], CV_32FC1); test(lp, input, backendId, targetId); } @@ -249,7 +249,7 @@ TEST_P(LRN, Accuracy) lp.name = "testLayer"; int sz[] = {1, inChannels, inSize.height, inSize.width}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(lp, input, backendId, targetId); } @@ -293,7 +293,7 @@ TEST_P(AvePooling, Accuracy) lp.name = "testLayer"; int sz[] = {1, inChannels, inHeight, inWidth}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(lp, input, backendId, targetId); } @@ -331,7 +331,7 @@ TEST_P(MaxPooling, Accuracy) lp.name = "testLayer"; int sz[] = {1, inChannels, inSize.height, inSize.width}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(lp, input, backendId, targetId); } @@ -359,10 +359,10 @@ TEST_P(FullyConnected, Accuracy) if (backendId == DNN_BACKEND_INFERENCE_ENGINE) throw SkipTestException(""); - Mat weights(outChannels, inChannels * inSize.height * inSize.width, CV_32F); + Mat weights(outChannels, inChannels * inSize.height * inSize.width, CV_32FC1); randu(weights, -1.0f, 1.0f); - Mat bias(1, outChannels, CV_32F); + Mat bias(1, outChannels, CV_32FC1); randu(bias, -1.0f, 1.0f); LayerParams lp; @@ -374,7 +374,7 @@ TEST_P(FullyConnected, Accuracy) lp.name = "testLayer"; int sz[] = {1, inChannels, inSize.height, inSize.width}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(lp, input, backendId, targetId); } @@ -400,7 +400,7 @@ TEST_P(SoftMax, Accuracy) lp.name = "testLayer"; int sz[] = {1, inChannels, 1, 1}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(lp, input, backendId, targetId); } @@ -447,7 +447,7 @@ TEST_P(Test_Halide_layers, MaxPoolUnpool) net.connect(poolId, 1, unpoolId, 1); int sz[] = {1, 1, 4, 4}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(input, net, backend, target); } @@ -474,7 +474,7 @@ void testInPlaceActivation(LayerParams& lp, Backend backendId, Target targetId) net.addLayerToPrev(lp.name, lp.type, lp); int sz[] = {1, kNumChannels, 10, 10}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(input, net, backendId, targetId); } @@ -496,9 +496,9 @@ TEST_P(BatchNorm, Accuracy) lp.blobs.reserve(4); for (int i = 0; i < 3; ++i) - lp.blobs.push_back(Mat(1, kNumChannels, CV_32F)); + lp.blobs.push_back(Mat(1, kNumChannels, CV_32FC1)); if (hasBias || hasWeights) - lp.blobs.push_back(Mat(1, kNumChannels, CV_32F)); + lp.blobs.push_back(Mat(1, kNumChannels, CV_32FC1)); for (int i = 0; i < lp.blobs.size(); ++i) randu(lp.blobs[i], 0.0f, 1.0f); @@ -578,7 +578,7 @@ TEST_P(Test_Halide_layers, ChannelsPReLU) LayerParams lp; lp.type = "ChannelsPReLU"; lp.name = "testLayer"; - lp.blobs.push_back(Mat(1, kNumChannels, CV_32F)); + lp.blobs.push_back(Mat(1, kNumChannels, CV_32FC1)); randu(lp.blobs[0], -1.0f, 1.0f); testInPlaceActivation(lp, backend, target); @@ -595,11 +595,11 @@ TEST_P(Scale, Accuracy) lp.set("bias_term", hasBias); lp.type = "Scale"; lp.name = "testLayer"; - lp.blobs.push_back(Mat(1, kNumChannels, CV_32F)); + lp.blobs.push_back(Mat(1, kNumChannels, CV_32FC1)); randu(lp.blobs[0], -1.0f, 1.0f); if (hasBias) { - lp.blobs.push_back(Mat(1, kNumChannels, CV_32F)); + lp.blobs.push_back(Mat(1, kNumChannels, CV_32FC1)); randu(lp.blobs[1], -1.0f, 1.0f); } testInPlaceActivation(lp, backendId, targetId); @@ -636,7 +636,7 @@ TEST_P(Concat, Accuracy) break; int sz[] = {numChannels[i], inSize[0], 1, 1}; - Mat weights(4, &sz[0], CV_32F); + Mat weights(4, &sz[0], CV_32FC1); randu(weights, -1.0f, 1.0f); LayerParams convParam; @@ -666,7 +666,7 @@ TEST_P(Concat, Accuracy) } int sz[] = {1, inSize[0], inSize[1], inSize[2]}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(input, net, backendId, targetId); } @@ -700,7 +700,7 @@ TEST_P(Eltwise, Accuracy) for (int i = 0; i < numConv; ++i) { int sz[] = {inSize[0], inSize[0], 1, 1}; - Mat weights(4, &sz[0], CV_32F); + Mat weights(4, &sz[0], CV_32FC1); randu(weights, -1.0f, 1.0f); LayerParams convParam; @@ -740,7 +740,7 @@ TEST_P(Eltwise, Accuracy) } int sz[] = {1, inSize[0], inSize[1], inSize[2]}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); test(input, net, backendId, targetId); } @@ -780,7 +780,7 @@ TEST(MixedBackends_Halide_Default_Halide, Accuracy) net.addLayerToPrev(lrn2.name, lrn2.type, lrn2); int sz[] = {4, 3, 5, 6}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); randu(input, -1.0f, 1.0f); net.setInput(input); net.setPreferableBackend(DNN_BACKEND_OPENCV); diff --git a/modules/dnn/test/test_ie_models.cpp b/modules/dnn/test/test_ie_models.cpp index 01ecb729860a..bb10873148f1 100644 --- a/modules/dnn/test/test_ie_models.cpp +++ b/modules/dnn/test/test_ie_models.cpp @@ -38,7 +38,7 @@ static inline void genData(const std::vector& dims, Mat& m, Blob::Ptr& d std::vector reversedDims(dims.begin(), dims.end()); std::reverse(reversedDims.begin(), reversedDims.end()); - m.create(reversedDims, CV_32F); + m.create(reversedDims, CV_32FC1); randu(m, -1, 1); dataPtr = make_shared_blob(Precision::FP32, dims, (float*)m.data); diff --git a/modules/dnn/test/test_layers.cpp b/modules/dnn/test/test_layers.cpp index be0e37e29448..db8b17a9572d 100644 --- a/modules/dnn/test/test_layers.cpp +++ b/modules/dnn/test/test_layers.cpp @@ -73,11 +73,11 @@ void runLayer(Ptr layer, std::vector &inpBlobs, std::vector &ou layer->getMemoryShapes(inputs, 0, outputs, internals); for (size_t i = 0; i < outputs.size(); i++) { - outp.push_back(Mat(outputs[i], CV_32F)); + outp.push_back(Mat(outputs[i], CV_32FC1)); } for (size_t i = 0; i < internals.size(); i++) { - intp.push_back(Mat(internals[i], CV_32F)); + intp.push_back(Mat(internals[i], CV_32FC1)); } layer->finalize(inp, outp); @@ -175,7 +175,7 @@ void testReshape(const MatShape& inputShape, const MatShape& targetShape, params.set("dim", DictValue::arrayInt(&mask[0], mask.size())); } - Mat inp(inputShape.size(), &inputShape[0], CV_32F); + Mat inp(inputShape.size(), &inputShape[0], CV_32FC1); std::vector inpVec(1, inp); std::vector outVec, intVec; @@ -270,7 +270,7 @@ TEST_P(Test_Caffe_layers, Fused_Concat) net.connect(interLayer, 0, id, 1); } int shape[] = {1, 2, 3, 4}; - Mat input(4, shape, CV_32F); + Mat input(4, shape, CV_32FC1); randu(input, 0.0f, 1.0f); // [0, 1] to make AbsVal an identity transformation. net.setInput(input); @@ -333,7 +333,7 @@ TEST_P(Test_Caffe_layers, Reshape_Split_Slice) net.setPreferableBackend(backend); net.setPreferableTarget(target); - Mat input(6, 12, CV_32F); + Mat input(6, 12, CV_32FC1); RNG rng(0); rng.fill(input, RNG::UNIFORM, -1, 1); @@ -381,9 +381,9 @@ class Layer_LSTM_Test : public ::testing::Test numInp = total(inpShape_); numOut = total(outShape_); - Wh = Mat::ones(4 * numOut, numOut, CV_32F); - Wx = Mat::ones(4 * numOut, numInp, CV_32F); - b = Mat::ones(4 * numOut, 1, CV_32F); + Wh = Mat::ones(4 * numOut, numOut, CV_32FC1); + Wx = Mat::ones(4 * numOut, numInp, CV_32FC1); + b = Mat::ones(4 * numOut, 1, CV_32FC1); LayerParams lp; lp.blobs.resize(3); @@ -409,12 +409,12 @@ TEST_F(Layer_LSTM_Test, get_set_test) init(inpShape, outShape, true, false); layer->setOutShape(outShape); - Mat C((int)outResShape.size(), &outResShape[0], CV_32F); + Mat C((int)outResShape.size(), &outResShape[0], CV_32FC1); randu(C, -1., 1.); Mat H = C.clone(); randu(H, -1., 1.); - Mat inp((int)inpResShape.size(), &inpResShape[0], CV_32F); + Mat inp((int)inpResShape.size(), &inpResShape[0], CV_32FC1); randu(inp, -1., 1.); inputs.push_back(inp); @@ -487,11 +487,11 @@ class Layer_RNN_Test : public ::testing::Test nH = 64; nO = 100; - Whh = Mat::ones(nH, nH, CV_32F); - Wxh = Mat::ones(nH, nX, CV_32F); - bh = Mat::ones(nH, 1, CV_32F); - Who = Mat::ones(nO, nH, CV_32F); - bo = Mat::ones(nO, 1, CV_32F); + Whh = Mat::ones(nH, nH, CV_32FC1); + Wxh = Mat::ones(nH, nX, CV_32FC1); + bh = Mat::ones(nH, 1, CV_32FC1); + Who = Mat::ones(nO, nH, CV_32FC1); + bo = Mat::ones(nO, 1, CV_32FC1); layer = RNNLayer::create(LayerParams()); layer->setProduceHiddenOutput(true); @@ -502,7 +502,7 @@ class Layer_RNN_Test : public ::testing::Test TEST_F(Layer_RNN_Test, get_set_test) { int sz[] = { nT, nS, 1, nX }; - Mat inp(4, sz, CV_32F); + Mat inp(4, sz, CV_32FC1); randu(inp, -1., 1.); inputs.push_back(inp); runLayer(layer, inputs, outputs); @@ -590,7 +590,7 @@ TEST_P(Scale_untrainable, Accuracy) weightsShape[1] = 1; // #inpChannels / group weightsShape[2] = 1; // height weightsShape[3] = 1; // width - Mat weights(weightsShape, CV_32F); + Mat weights(weightsShape, CV_32FC1); weights.setTo(1); lp.blobs.push_back(weights); net.addLayerToPrev(lp.name, lp.type, lp); @@ -602,8 +602,8 @@ TEST_P(Scale_untrainable, Accuracy) int id = net.addLayerToPrev(lp.name, lp.type, lp); net.connect(0, 1, id, 1); - Mat input(4, inpShape, CV_32F); - Mat weights(weightsDims, &inpShape[axis], CV_32F); + Mat input(4, inpShape, CV_32FC1); + Mat weights(weightsDims, &inpShape[axis], CV_32FC1); randu(input, -1, 1); randu(weights, -1, 1); @@ -616,7 +616,7 @@ TEST_P(Scale_untrainable, Accuracy) net.setPreferableBackend(DNN_BACKEND_OPENCV); Mat out = net.forward(); - Mat ref(input.dims, input.size, CV_32F); + Mat ref(input.dims, input.size, CV_32FC1); float* inpData = (float*)input.data; float* refData = (float*)ref.data; float* weightsData = (float*)weights.data; @@ -670,8 +670,8 @@ TEST_P(Crop, Accuracy) int id = net.addLayerToPrev(lp.name, lp.type, lp); net.connect(0, 1, id, 1); - Mat inpImage(4, inpShape, CV_32F); - Mat sizImage(4, sizShape, CV_32F); + Mat inpImage(4, inpShape, CV_32FC1); + Mat sizImage(4, sizShape, CV_32FC1); randu(inpImage, -1, 1); randu(sizImage, -1, 1); @@ -711,7 +711,7 @@ TEST_P(Crop, Accuracy) for (int i = axis; i < 4; i++) crop_range[i] = Range(offsetVal, sizShape[i] + offsetVal); - Mat ref(sizImage.dims, sizImage.size, CV_32F); + Mat ref(sizImage.dims, sizImage.size, CV_32FC1); inpImage(&crop_range[0]).copyTo(ref); normAssert(out, ref); } @@ -774,7 +774,7 @@ TEST_P(Test_Caffe_layers, PriorBox_squares) Net net; int id = net.addLayerToPrev(lp.name, lp.type, lp); net.connect(0, 0, id, 1); // The second input is an input image. Shapes are used for boxes normalization. - Mat inp(1, 2, CV_32F); + Mat inp(1, 2, CV_32FC1); randu(inp, -1, 1); net.setInput(blobFromImage(inp)); net.setPreferableBackend(backend); @@ -829,7 +829,7 @@ TEST_P(Layer_Test_DWconv_Prelu, Accuracy) weightsShape[1] = kernel_depth; // #inpChannels / group weightsShape[2] = 3; // height weightsShape[3] = 3; // width - Mat weights(weightsShape, CV_32F, Scalar(1)); + Mat weights(weightsShape, CV_32FC1, Scalar(1)); //assign weights for (int i = 0; i < weightsShape[0]; ++i) @@ -848,7 +848,7 @@ TEST_P(Layer_Test_DWconv_Prelu, Accuracy) lp.blobs.push_back(weights); //assign bias - Mat bias(1, num_output, CV_32F, Scalar(1)); + Mat bias(1, num_output, CV_32FC1, Scalar(1)); for (int i = 0; i < 1; ++i) { for (int j = 0; j < num_output; ++j) @@ -863,7 +863,7 @@ TEST_P(Layer_Test_DWconv_Prelu, Accuracy) LayerParams lpr; lpr.name = "dw_relu"; lpr.type = "PReLU"; - Mat weightsp(1, num_output, CV_32F, Scalar(1)); + Mat weightsp(1, num_output, CV_32FC1, Scalar(1)); //assign weights for (int i = 0; i < 1; ++i) @@ -890,7 +890,7 @@ TEST_P(Layer_Test_DWconv_Prelu, Accuracy) outShape[1] = num_output; // outChannels outShape[2] = 14; // height outShape[3] = 14; // width - Mat target(outShape, CV_32F, Scalar(1)); + Mat target(outShape, CV_32FC1, Scalar(1)); for (int i = 0; i < outShape[0]; ++i) { for (int j = 0; j < outShape[1]; ++j) @@ -938,7 +938,7 @@ TEST(Layer_Test_Convolution_DLDT, setInput_uint8) { Mat inp = blobFromNPY(_tf("blob.npy")); - Mat inputs[] = {Mat(inp.dims, inp.size, CV_8U), Mat()}; + Mat inputs[] = {Mat(inp.dims, inp.size, CV_8UC1), Mat()}; randu(inputs[0], 0, 255); inputs[0].convertTo(inputs[1], CV_32F); @@ -996,7 +996,7 @@ TEST_P(Test_DLDT_two_inputs, as_IR) Mat out = net.forward(); Mat ref; - cv::add(firstInp, secondInp, ref, Mat(), CV_32F); + cv::add(firstInp, secondInp, ref, Mat(), CV_32FC1); normAssert(out, ref); } @@ -1064,7 +1064,7 @@ TEST(Test_DLDT, fused_output) lp.set("bias_term", false); lp.type = "Convolution"; lp.name = "testConv"; - lp.blobs.push_back(Mat({kNumChannels, 1, 1, 1}, CV_32F, Scalar(1))); + lp.blobs.push_back(Mat({kNumChannels, 1, 1, 1}, CV_32FC1, Scalar(1))); net.addLayerToPrev(lp.name, lp.type, lp); } { @@ -1072,7 +1072,7 @@ TEST(Test_DLDT, fused_output) lp.set("bias_term", false); lp.type = "Scale"; lp.name = "testScale"; - lp.blobs.push_back(Mat({kNumChannels}, CV_32F, Scalar(1))); + lp.blobs.push_back(Mat({kNumChannels}, CV_32FC1, Scalar(1))); net.addLayerToPrev(lp.name, lp.type, lp); } { @@ -1098,7 +1098,7 @@ TEST(Test_DLDT, multiple_networks) lp.set("bias_term", false); lp.type = "Convolution"; lp.name = format("testConv_%d", i); - lp.blobs.push_back(Mat({1, 1, 1, 1}, CV_32F, Scalar(1 + i))); + lp.blobs.push_back(Mat({1, 1, 1, 1}, CV_32FC1, Scalar(1 + i))); nets[i].addLayerToPrev(lp.name, lp.type, lp); nets[i].setPreferableBackend(DNN_BACKEND_INFERENCE_ENGINE); nets[i].setInput(Mat({1, 1, 1, 1}, CV_32FC1, Scalar(1))); @@ -1261,10 +1261,10 @@ TEST(Layer_Test_PoolingIndices, Accuracy) lp.type = "Pooling"; net.addLayerToPrev(lp.name, lp.type, lp); - Mat inp(10, 10, CV_8U); + Mat inp(10, 10, CV_8UC1); randu(inp, 0, 255); - Mat maxValues(5, 5, CV_32F, Scalar(-1)), indices(5, 5, CV_32F, Scalar(-1)); + Mat maxValues(5, 5, CV_32FC1, Scalar(-1)), indices(5, 5, CV_32FC1, Scalar(-1)); for (int y = 0; y < 10; ++y) { int dstY = y / 2; @@ -1306,7 +1306,7 @@ TEST_P(Layer_Test_ShuffleChannel, Accuracy) net.addLayerToPrev(lp.name, lp.type, lp); const int inpShape[] = {inpShapeVec[0], inpShapeVec[1], inpShapeVec[2], inpShapeVec[3]}; - Mat inp(4, inpShape, CV_32F); + Mat inp(4, inpShape, CV_32FC1); randu(inp, 0, 255); net.setInput(inp); @@ -1344,7 +1344,7 @@ TEST(Layer_Test_Convolution, relu_fusion) lp.name = "testConv"; int weightsShape[] = {1, 1, 1, 1}; - Mat weights(4, &weightsShape[0], CV_32F, Scalar(1)); + Mat weights(4, &weightsShape[0], CV_32FC1, Scalar(1)); lp.blobs.push_back(weights); net.addLayerToPrev(lp.name, lp.type, lp); } @@ -1355,7 +1355,7 @@ TEST(Layer_Test_Convolution, relu_fusion) net.addLayerToPrev(lp.name, lp.type, lp); } int sz[] = {1, 1, 2, 3}; - Mat input(4, &sz[0], CV_32F); + Mat input(4, &sz[0], CV_32FC1); randu(input, -1.0, -0.1); net.setInput(input); net.setPreferableBackend(DNN_BACKEND_OPENCV); diff --git a/modules/dnn/test/test_misc.cpp b/modules/dnn/test/test_misc.cpp index acf8dae4276c..e3cf8f645fe1 100644 --- a/modules/dnn/test/test_misc.cpp +++ b/modules/dnn/test/test_misc.cpp @@ -16,7 +16,7 @@ TEST(blobFromImage_4ch, Regression) { Mat ch[4]; for(int i = 0; i < 4; i++) - ch[i] = Mat::ones(10, 10, CV_8U)*i; + ch[i] = Mat::ones(10, 10, CV_8UC1)*i; Mat img; merge(ch, 4, img); @@ -24,7 +24,7 @@ TEST(blobFromImage_4ch, Regression) for(int i = 0; i < 4; i++) { - ch[i] = Mat(img.rows, img.cols, CV_32F, blob.ptr(0, i)); + ch[i] = Mat(img.rows, img.cols, CV_32FC1, blob.ptr(0, i)); ASSERT_DOUBLE_EQ(cvtest::norm(ch[i], cv::NORM_INF), i); } } @@ -33,7 +33,7 @@ TEST(blobFromImage, allocated) { int size[] = {1, 3, 4, 5}; Mat img(size[2], size[3], CV_32FC(size[1])); - Mat blob(4, size, CV_32F); + Mat blob(4, size, CV_32FC1); void* blobData = blob.data; dnn::blobFromImage(img, blob, 1.0 / 255, Size(), Scalar(), false, false); ASSERT_EQ(blobData, blob.data); @@ -147,12 +147,12 @@ TEST(LayerFactory, custom_layers) LayerFactory::unregisterLayer("CustomType"); } -typedef testing::TestWithParam > > setInput; +typedef testing::TestWithParam > > setInput; TEST_P(setInput, normalization) { const float kScale = get<0>(GetParam()); const Scalar kMean = get<1>(GetParam()); - const int dtype = get<2>(GetParam()); + const ElemType dtype = get<2>(GetParam()); const int backend = get<0>(get<3>(GetParam())); const int target = get<1>(get<3>(GetParam())); const bool kSwapRB = true; @@ -172,7 +172,7 @@ TEST_P(setInput, normalization) net.setPreferableBackend(backend); net.setPreferableTarget(target); - Mat blob = blobFromImage(inp, 1.0, Size(), Scalar(), kSwapRB, /*crop*/false, dtype); + Mat blob = blobFromImage(inp, 1.0, Size(), Scalar(), kSwapRB, /*crop*/false, CV_MAT_DEPTH(dtype)); ASSERT_EQ(blob.type(), dtype); net.setInput(blob, "", kScale, kMean); Mat out = net.forward(); diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index b10c1388f32a..f03cb81ecd77 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -633,7 +633,7 @@ TEST(Test_TensorFlow, Mask_RCNN) const int numDetections = outDetections.size[2]; int masksSize[] = {1, numDetections, outMasks.size[2], outMasks.size[3]}; - Mat masks(4, &masksSize[0], CV_32F); + Mat masks(4, &masksSize[0], CV_32FC1); std::vector srcRanges(4, cv::Range::all()); std::vector dstRanges(4, cv::Range::all()); diff --git a/modules/dnn/test/test_torch_importer.cpp b/modules/dnn/test/test_torch_importer.cpp index dd7d975af66b..c6324c195b1e 100644 --- a/modules/dnn/test/test_torch_importer.cpp +++ b/modules/dnn/test/test_torch_importer.cpp @@ -274,7 +274,7 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy) Mat sample = imread(findDataFile("cv/shared/lena.png", false)); Mat sampleF32(sample.size(), CV_32FC3); - sample.convertTo(sampleF32, sampleF32.type()); + sample.convertTo(sampleF32, sampleF32.depth()); sampleF32 /= 255; resize(sampleF32, sampleF32, Size(96, 96), 0, 0, INTER_NEAREST); diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index 254a82f40c20..43362f9d0fbb 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -201,7 +201,7 @@ class CV_EXPORTS_W Feature2D : public virtual Algorithm bool useProvidedKeypoints=false ); CV_WRAP virtual int descriptorSize() const; - CV_WRAP virtual int descriptorType() const; + CV_WRAP virtual ElemType descriptorType() const; CV_WRAP virtual int defaultNorm() const; CV_WRAP void write( const String& fileName ) const; @@ -1418,7 +1418,7 @@ class CV_EXPORTS_W BOWImgDescriptorExtractor /** @brief Returns an image descriptor type. */ - CV_WRAP int descriptorType() const; + CV_WRAP ElemType descriptorType() const; protected: Mat vocabulary; diff --git a/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp b/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp index 439140a5ff5f..a2b0d63283df 100644 --- a/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp +++ b/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp @@ -55,11 +55,11 @@ namespace ocl { typedef Size_MatType BruteForceMatcherFixture; -OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_32FC1) ) ) +OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM(CV_32FC1) ) ) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -76,11 +76,11 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, ::testing::Combine(OCL_PERF_ENU SANITY_CHECK_MATCHES(matches, 1e-3); } -OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_32FC1) ) ) +OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM(CV_32FC1) ) ) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -100,11 +100,11 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, ::testing::Combine(OCL_PERF_ } -OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM((MatType)CV_32FC1) ) ) +OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, ::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_PERF_ENUM(CV_32FC1) ) ) { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); diff --git a/modules/features2d/perf/perf_batchDistance.cpp b/modules/features2d/perf/perf_batchDistance.cpp index ae0e6296babb..0741989edd63 100644 --- a/modules/features2d/perf/perf_batchDistance.cpp +++ b/modules/features2d/perf/perf_batchDistance.cpp @@ -15,7 +15,7 @@ typedef perf::TestBaseWithParam Norm_CrossCheck; typedef tuple Source_CrossCheck_t; typedef perf::TestBaseWithParam Source_CrossCheck; -void generateData( Mat& query, Mat& train, const int sourceType ); +void generateData( Mat& query, Mat& train, const ElemType sourceType ); PERF_TEST_P(Norm_Destination_CrossCheck, batchDistance_8U, testing::Combine(testing::Values((int)NORM_L1, (int)NORM_L2SQR), @@ -25,7 +25,7 @@ PERF_TEST_P(Norm_Destination_CrossCheck, batchDistance_8U, ) { NormType normType = get<0>(GetParam()); - int destinationType = get<1>(GetParam()); + ElemType destinationType = get<1>(GetParam()); bool isCrossCheck = get<2>(GetParam()); int knn = isCrossCheck ? 1 : 0; @@ -34,7 +34,7 @@ PERF_TEST_P(Norm_Destination_CrossCheck, batchDistance_8U, Mat dist; Mat ndix; - generateData(queryDescriptors, trainDescriptors, CV_8U); + generateData(queryDescriptors, trainDescriptors, CV_8UC1); TEST_CYCLE() { @@ -61,11 +61,11 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_Dest_32S, Mat dist; Mat ndix; - generateData(queryDescriptors, trainDescriptors, CV_8U); + generateData(queryDescriptors, trainDescriptors, CV_8UC1); TEST_CYCLE() { - batchDistance(queryDescriptors, trainDescriptors, dist, CV_32S, (isCrossCheck) ? ndix : noArray(), + batchDistance(queryDescriptors, trainDescriptors, dist, CV_32SC1, (isCrossCheck) ? ndix : noArray(), normType, knn, Mat(), 0, isCrossCheck); } @@ -79,7 +79,7 @@ PERF_TEST_P(Source_CrossCheck, batchDistance_L2, ) ) { - int sourceType = get<0>(GetParam()); + ElemType sourceType = get<0>(GetParam()); bool isCrossCheck = get<1>(GetParam()); int knn = isCrossCheck ? 1 : 0; @@ -93,7 +93,7 @@ PERF_TEST_P(Source_CrossCheck, batchDistance_L2, declare.time(50); TEST_CYCLE() { - batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(), + batchDistance(queryDescriptors, trainDescriptors, dist, CV_32FC1, (isCrossCheck) ? ndix : noArray(), NORM_L2, knn, Mat(), 0, isCrossCheck); } @@ -116,12 +116,12 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_32F, Mat dist; Mat ndix; - generateData(queryDescriptors, trainDescriptors, CV_32F); + generateData(queryDescriptors, trainDescriptors, CV_32FC1); declare.time(100); TEST_CYCLE() { - batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(), + batchDistance(queryDescriptors, trainDescriptors, dist, CV_32FC1, (isCrossCheck) ? ndix : noArray(), normType, knn, Mat(), 0, isCrossCheck); } @@ -129,7 +129,7 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_32F, if (isCrossCheck) SANITY_CHECK(ndix); } -void generateData( Mat& query, Mat& train, const int sourceType ) +void generateData( Mat& query, Mat& train, const ElemType sourceType ) { const int dim = 500; const int queryDescCount = 300; // must be even number because we split train data in some cases in two @@ -140,7 +140,7 @@ void generateData( Mat& query, Mat& train, const int sourceType ) // Descriptor vector elements are integer values. Mat buf( queryDescCount, dim, CV_32SC1 ); rng.fill( buf, RNG::UNIFORM, Scalar::all(0), Scalar(3) ); - buf.convertTo( query, sourceType ); + buf.convertTo( query, CV_MAT_DEPTH(sourceType) ); // Generate train descriptors as follows: // copy each query descriptor to train set countFactor times @@ -148,7 +148,7 @@ void generateData( Mat& query, Mat& train, const int sourceType ) // in ascending order. General boundaries of the perturbation // are (0.f, 1.f). train.create( query.rows*countFactor, query.cols, sourceType ); - float step = (sourceType == CV_8U ? 256.f : 1.f) / countFactor; + float step = (sourceType == CV_8UC1 ? 256.f : 1.f) / countFactor; for( int qIdx = 0; qIdx < query.rows; qIdx++ ) { Mat queryDescriptor = query.row(qIdx); diff --git a/modules/features2d/src/agast.cpp b/modules/features2d/src/agast.cpp index e99ceec4160c..76d6a6d92a2c 100644 --- a/modules/features2d/src/agast.cpp +++ b/modules/features2d/src/agast.cpp @@ -7961,7 +7961,7 @@ class AgastFeatureDetector_Impl CV_FINAL : public AgastFeatureDetector Mat mask = _mask.getMat(), grayImage; UMat ugrayImage; _InputArray gray = _image; - if( _image.type() != CV_8U ) + if( _image.type() != CV_8UC1 ) { _OutputArray ogray = _image.isUMat() ? _OutputArray(ugrayImage) : _OutputArray(grayImage); cvtColor( _image, ogray, COLOR_BGR2GRAY ); diff --git a/modules/features2d/src/akaze.cpp b/modules/features2d/src/akaze.cpp index 623738eed4e2..eb8961e0a126 100644 --- a/modules/features2d/src/akaze.cpp +++ b/modules/features2d/src/akaze.cpp @@ -127,20 +127,20 @@ namespace cv } // returns the descriptor type - int descriptorType() const CV_OVERRIDE + ElemType descriptorType() const CV_OVERRIDE { switch (descriptor) { case DESCRIPTOR_KAZE: case DESCRIPTOR_KAZE_UPRIGHT: - return CV_32F; + return CV_32FC1; case DESCRIPTOR_MLDB: case DESCRIPTOR_MLDB_UPRIGHT: - return CV_8U; + return CV_8UC1; default: - return -1; + return CV_TYPE_AUTO; } } diff --git a/modules/features2d/src/bagofwords.cpp b/modules/features2d/src/bagofwords.cpp index c2d6b754fd23..d6461480bfdd 100644 --- a/modules/features2d/src/bagofwords.cpp +++ b/modules/features2d/src/bagofwords.cpp @@ -167,7 +167,7 @@ int BOWImgDescriptorExtractor::descriptorSize() const return vocabulary.empty() ? 0 : vocabulary.rows; } -int BOWImgDescriptorExtractor::descriptorType() const +ElemType BOWImgDescriptorExtractor::descriptorType() const { return CV_32FC1; } diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp index 4038279d75ef..d383c0f6b071 100644 --- a/modules/features2d/src/brisk.cpp +++ b/modules/features2d/src/brisk.cpp @@ -70,9 +70,9 @@ class BRISK_Impl CV_FINAL : public BRISK return strings_; } - int descriptorType() const CV_OVERRIDE + ElemType descriptorType() const CV_OVERRIDE { - return CV_8U; + return CV_8UC1; } int defaultNorm() const CV_OVERRIDE @@ -707,7 +707,7 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma cv::Mat descriptors; if (doDescriptors) { - _descriptors.create((int)ksize, strings_, CV_8U); + _descriptors.create((int)ksize, strings_, CV_8UC1); descriptors = _descriptors.getMat(); descriptors.setTo(0); } @@ -2100,19 +2100,19 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode) { if (mode == CommonParams::HALFSAMPLE) { - img_.create(layer.img().rows / 2, layer.img().cols / 2, CV_8U); + img_.create(layer.img().rows / 2, layer.img().cols / 2, CV_8UC1); halfsample(layer.img(), img_); scale_ = layer.scale() * 2; offset_ = 0.5f * scale_ - 0.5f; } else { - img_.create(2 * (layer.img().rows / 3), 2 * (layer.img().cols / 3), CV_8U); + img_.create(2 * (layer.img().rows / 3), 2 * (layer.img().cols / 3), CV_8UC1); twothirdsample(layer.img(), img_); scale_ = layer.scale() * 1.5f; offset_ = 0.5f * scale_ - 0.5f; } - scores_ = cv::Mat::zeros(img_.rows, img_.cols, CV_8U); + scores_ = cv::Mat::zeros(img_.rows, img_.cols, CV_8UC1); oast_9_16_ = AgastFeatureDetector::create(1, false, AgastFeatureDetector::OAST_9_16); makeAgastOffsets(pixel_5_8_, (int)img_.step, AgastFeatureDetector::AGAST_5_8); makeAgastOffsets(pixel_9_16_, (int)img_.step, AgastFeatureDetector::OAST_9_16); diff --git a/modules/features2d/src/draw.cpp b/modules/features2d/src/draw.cpp index 2132d17b421a..40000bf38e98 100644 --- a/modules/features2d/src/draw.cpp +++ b/modules/features2d/src/draw.cpp @@ -146,12 +146,12 @@ static void _prepareImgAndDrawKeypoints( InputArray img1, const std::vector& keypoints, if (fastKptKernel.empty()) return false; - UMat kp1(1, maxKeypoints*2+1, CV_32S); + UMat kp1(1, maxKeypoints * 2 + 1, CV_32SC1); UMat ucounter1(kp1, Rect(0,0,1,1)); ucounter1.setTo(Scalar::all(0)); @@ -319,7 +319,7 @@ static bool ocl_FAST( InputArray _img, std::vector& keypoints, } else { - UMat kp2(1, maxKeypoints*3+1, CV_32S); + UMat kp2(1, maxKeypoints * 3 + 1, CV_32SC1); UMat ucounter2 = kp2(Rect(0,0,1,1)); ucounter2.setTo(Scalar::all(0)); @@ -531,7 +531,7 @@ class FastFeatureDetector_Impl CV_FINAL : public FastFeatureDetector Mat mask = _mask.getMat(), grayImage; UMat ugrayImage; _InputArray gray = _image; - if( _image.type() != CV_8U ) + if( _image.type() != CV_8UC1 ) { _OutputArray ogray = _image.isUMat() ? _OutputArray(ugrayImage) : _OutputArray(grayImage); cvtColor( _image, ogray, COLOR_BGR2GRAY ); diff --git a/modules/features2d/src/feature2d.cpp b/modules/features2d/src/feature2d.cpp index 0114f87ba7c0..28a026f5a309 100644 --- a/modules/features2d/src/feature2d.cpp +++ b/modules/features2d/src/feature2d.cpp @@ -179,9 +179,9 @@ int Feature2D::descriptorSize() const return 0; } -int Feature2D::descriptorType() const +ElemType Feature2D::descriptorType() const { - return CV_32F; + return CV_32FC1; } int Feature2D::defaultNorm() const diff --git a/modules/features2d/src/gftt.cpp b/modules/features2d/src/gftt.cpp index 11ed29f39ddc..6c91a8d9b94f 100644 --- a/modules/features2d/src/gftt.cpp +++ b/modules/features2d/src/gftt.cpp @@ -91,7 +91,7 @@ class GFTTDetector_Impl CV_FINAL : public GFTTDetector if (_image.isUMat()) { UMat ugrayImage; - if( _image.type() != CV_8U ) + if( _image.type() != CV_8UC1 ) cvtColor( _image, ugrayImage, COLOR_BGR2GRAY ); else ugrayImage = _image.getUMat(); @@ -102,7 +102,7 @@ class GFTTDetector_Impl CV_FINAL : public GFTTDetector else { Mat image = _image.getMat(), grayImage = image; - if( image.type() != CV_8U ) + if( image.type() != CV_8UC1 ) cvtColor( image, grayImage, COLOR_BGR2GRAY ); goodFeaturesToTrack( grayImage, corners, nfeatures, qualityLevel, minDistance, _mask, diff --git a/modules/features2d/src/kaze.cpp b/modules/features2d/src/kaze.cpp index 0d841b7f7b88..0e963cafcf71 100644 --- a/modules/features2d/src/kaze.cpp +++ b/modules/features2d/src/kaze.cpp @@ -94,9 +94,9 @@ namespace cv } // returns the descriptor type - int descriptorType() const CV_OVERRIDE + ElemType descriptorType() const CV_OVERRIDE { - return CV_32F; + return CV_32FC1; } // returns the default norm type diff --git a/modules/features2d/src/kaze/AKAZEFeatures.cpp b/modules/features2d/src/kaze/AKAZEFeatures.cpp index 4b1029e83311..8753a8e5653b 100644 --- a/modules/features2d/src/kaze/AKAZEFeatures.cpp +++ b/modules/features2d/src/kaze/AKAZEFeatures.cpp @@ -311,7 +311,7 @@ compute_kcontrast(InputArray Lx_, InputArray Ly_, float perc, int nbins) Mat Ly = Ly_.getMat(); // temporary square roots of dot product - Mat modgs (Lx.rows - 2, Lx.cols - 2, CV_32F); + Mat modgs (Lx.rows - 2, Lx.cols - 2, CV_32FC1); const int total = modgs.cols * modgs.rows; float *modg = modgs.ptr(); float hmax = 0.0f; @@ -1194,7 +1194,7 @@ void AKAZEFeatures::Compute_Descriptors(std::vector& kpts, OutputArray // Allocate memory for the matrix with the descriptors int descriptor_size = 64; - int descriptor_type = CV_32FC1; + ElemType descriptor_type = CV_32FC1; if (options_.descriptor >= AKAZE::DESCRIPTOR_MLDB_UPRIGHT) { int descriptor_bits = (options_.descriptor_size == 0) diff --git a/modules/features2d/src/kaze/KAZEFeatures.cpp b/modules/features2d/src/kaze/KAZEFeatures.cpp index 58f0937f0038..49004ca30a43 100644 --- a/modules/features2d/src/kaze/KAZEFeatures.cpp +++ b/modules/features2d/src/kaze/KAZEFeatures.cpp @@ -58,14 +58,14 @@ void KAZEFeatures::Allocate_Memory_Evolution(void) { for (int j = 0; j <= options_.nsublevels - 1; j++) { TEvolution aux; - aux.Lx = Mat::zeros(options_.img_height, options_.img_width, CV_32F); - aux.Ly = Mat::zeros(options_.img_height, options_.img_width, CV_32F); - aux.Lxx = Mat::zeros(options_.img_height, options_.img_width, CV_32F); - aux.Lxy = Mat::zeros(options_.img_height, options_.img_width, CV_32F); - aux.Lyy = Mat::zeros(options_.img_height, options_.img_width, CV_32F); - aux.Lt = Mat::zeros(options_.img_height, options_.img_width, CV_32F); - aux.Lsmooth = Mat::zeros(options_.img_height, options_.img_width, CV_32F); - aux.Ldet = Mat::zeros(options_.img_height, options_.img_width, CV_32F); + aux.Lx = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); + aux.Ly = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); + aux.Lxx = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); + aux.Lxy = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); + aux.Lyy = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); + aux.Lt = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); + aux.Lsmooth = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); + aux.Ldet = Mat::zeros(options_.img_height, options_.img_width, CV_32FC1); aux.esigma = options_.soffset*pow((float)2.0f, (float)(j) / (float)(options_.nsublevels)+i); aux.etime = 0.5f*(aux.esigma*aux.esigma); aux.sigma_size = cvRound(aux.esigma); @@ -108,8 +108,8 @@ int KAZEFeatures::Create_Nonlinear_Scale_Space(const Mat &img) Compute_KContrast(evolution_[0].Lt, options_.kcontrast_percentille); // Allocate memory for the flow and step images - Mat Lflow = Mat::zeros(evolution_[0].Lt.rows, evolution_[0].Lt.cols, CV_32F); - Mat Lstep = Mat::zeros(evolution_[0].Lt.rows, evolution_[0].Lt.cols, CV_32F); + Mat Lflow = Mat::zeros(evolution_[0].Lt.rows, evolution_[0].Lt.cols, CV_32FC1); + Mat Lstep = Mat::zeros(evolution_[0].Lt.rows, evolution_[0].Lt.cols, CV_32FC1); // Now generate the rest of evolution levels for (size_t i = 1; i < evolution_.size(); i++) @@ -398,9 +398,9 @@ void KAZEFeatures::Do_Subpixel_Refinement(std::vector &kpts) { int x = 0, y = 0; float Dx = 0.0, Dy = 0.0, Ds = 0.0, dsc = 0.0; float Dxx = 0.0, Dyy = 0.0, Dss = 0.0, Dxy = 0.0, Dxs = 0.0, Dys = 0.0; - Mat A = Mat::zeros(3, 3, CV_32F); - Mat b = Mat::zeros(3, 1, CV_32F); - Mat dst = Mat::zeros(3, 1, CV_32F); + Mat A = Mat::zeros(3, 3, CV_32FC1); + Mat b = Mat::zeros(3, 1, CV_32FC1); + Mat dst = Mat::zeros(3, 1, CV_32FC1); vector kpts_(kpts); diff --git a/modules/features2d/src/kaze/nldiffusion_functions.cpp b/modules/features2d/src/kaze/nldiffusion_functions.cpp index 59939a2bbf48..a1043a818245 100644 --- a/modules/features2d/src/kaze/nldiffusion_functions.cpp +++ b/modules/features2d/src/kaze/nldiffusion_functions.cpp @@ -238,9 +238,9 @@ float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbi std::vector hist(nbins, 0); // Create the matrices - Mat gaussian = Mat::zeros(img.rows, img.cols, CV_32F); - Mat Lx = Mat::zeros(img.rows, img.cols, CV_32F); - Mat Ly = Mat::zeros(img.rows, img.cols, CV_32F); + Mat gaussian = Mat::zeros(img.rows, img.cols, CV_32FC1); + Mat Lx = Mat::zeros(img.rows, img.cols, CV_32FC1); + Mat Ly = Mat::zeros(img.rows, img.cols, CV_32FC1); // Perform the Gaussian convolution gaussian_2D_convolution(img, gaussian, ksize_x, ksize_y, gscale); @@ -332,12 +332,12 @@ void compute_derivative_kernels(cv::OutputArray _kx, cv::OutputArray _ky, int dx // The standard Scharr kernel if (scale == 1) { - getDerivKernels(_kx, _ky, dx, dy, 0, true, CV_32F); + getDerivKernels(_kx, _ky, dx, dy, 0, true, CV_32FC1); return; } - _kx.create(ksize, 1, CV_32F, -1, true); - _ky.create(ksize, 1, CV_32F, -1, true); + _kx.create(ksize, 1, CV_32FC1, -1, true); + _ky.create(ksize, 1, CV_32FC1, -1, true); Mat kx = _kx.getMat(); Mat ky = _ky.getMat(); std::vector kerI; @@ -357,7 +357,7 @@ void compute_derivative_kernels(cv::OutputArray _kx, cv::OutputArray _ky, int dx kerI[0] = -1, kerI[ksize / 2] = 0, kerI[ksize - 1] = 1; } - Mat temp(kernel->rows, kernel->cols, CV_32F, &kerI[0]); + Mat temp(kernel->rows, kernel->cols, CV_32FC1, &kerI[0]); temp.copyTo(*kernel); } } diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index 3a2d48c21bae..4adab1a80c5d 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -63,7 +63,7 @@ namespace cv /////////////////////// ocl functions for BFMatcher /////////////////////////// #ifdef HAVE_OPENCL -static void ensureSizeIsEnough(int rows, int cols, int type, UMat &m) +static void ensureSizeIsEnough(int rows, int cols, ElemType type, UMat &m) { if (m.type() == type && m.rows >= rows && m.cols >= cols) m = m(Rect(0, 0, cols, rows)); @@ -80,8 +80,8 @@ static bool ocl_matchSingle(InputArray query, InputArray train, const int query_rows = query.rows(); const int query_cols = query.cols(); - ensureSizeIsEnough(1, query_rows, CV_32S, trainIdx); - ensureSizeIsEnough(1, query_rows, CV_32F, distance); + ensureSizeIsEnough(1, query_rows, CV_32SC1, trainIdx); + ensureSizeIsEnough(1, query_rows, CV_32FC1, distance); ocl::Device devDef = ocl::Device::getDefault(); @@ -100,7 +100,7 @@ static bool ocl_matchSingle(InputArray query, InputArray train, else if (query_cols <= 128 && !is_cpu) max_desc_len = 128 / kercn; - int depth = query.depth(); + ElemDepth depth = query.depth(); cv::String opts; opts = cv::format("-D T=%s -D TN=%s -D kercn=%d %s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d", ocl::typeToStr(depth), ocl::typeToStr(CV_MAKETYPE(depth, kercn)), kercn, depth == CV_32F ? "-D T_FLOAT" : "", distType, block_size, max_desc_len); @@ -200,7 +200,7 @@ static bool ocl_knnMatchSingle(InputArray query, InputArray train, UMat &trainId else if (query_cols <= 128 && !is_cpu) max_desc_len = 128 / kercn; - int depth = query.depth(); + ElemDepth depth = query.depth(); cv::String opts; opts = cv::format("-D T=%s -D TN=%s -D kercn=%d %s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d", ocl::typeToStr(depth), ocl::typeToStr(CV_MAKETYPE(depth, kercn)), kercn, depth == CV_32F ? "-D T_FLOAT" : "", distType, block_size, max_desc_len); @@ -309,7 +309,7 @@ static bool ocl_radiusMatchSingle(InputArray query, InputArray train, kercn = 4; int block_size = 16; - int depth = query.depth(); + ElemDepth depth = query.depth(); cv::String opts; opts = cv::format("-D T=%s -D TN=%s -D kercn=%d %s -D DIST_TYPE=%d -D BLOCK_SIZE=%d", ocl::typeToStr(depth), ocl::typeToStr(CV_MAKETYPE(depth, kercn)), kercn, depth == CV_32F ? "-D T_FLOAT" : "", distType, block_size); @@ -428,7 +428,7 @@ void DescriptorMatcher::DescriptorCollection::set( const std::vector& descr startIdxs.resize( imageCount ); int dim = -1; - int type = -1; + ElemType type = CV_TYPE_AUTO; startIdxs[0] = 0; for( size_t i = 1; i < imageCount; i++ ) { @@ -843,8 +843,8 @@ void BFMatcher::knnMatchImpl( InputArray _queryDescriptors, std::vector( dists.at(i,j) ); else dist = std::sqrt(dists.at(i,j)); diff --git a/modules/features2d/src/mser.cpp b/modules/features2d/src/mser.cpp index 85187f7c811a..0bb7472b8613 100755 --- a/modules/features2d/src/mser.cpp +++ b/modules/features2d/src/mser.cpp @@ -1048,7 +1048,7 @@ void MSER_Impl::detectRegions( InputArray _src, vector >& msers, v Size size = src.size(); - if( src.type() == CV_8U ) + if( src.type() == CV_8UC1 ) { int level_size[256]; if( !src.isContinuous() ) diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index ac0655fe127a..562ad410134f 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -54,7 +54,7 @@ template inline void copyVectorToUMat(const std::vector<_Tp>& v, O if(v.empty()) um.release(); else - Mat(1, (int)(v.size()*sizeof(v[0])), CV_8U, (void*)&v[0]).copyTo(um); + Mat(1, (int)(v.size()*sizeof(v[0])), CV_8UC1, (void*)&v[0]).copyTo(um); } #ifdef HAVE_OPENCL @@ -691,7 +691,7 @@ class ORB_Impl CV_FINAL : public ORB // returns the descriptor size in bytes int descriptorSize() const CV_OVERRIDE; // returns the descriptor type - int descriptorType() const CV_OVERRIDE; + ElemType descriptorType() const CV_OVERRIDE; // returns the default norm type int defaultNorm() const CV_OVERRIDE; @@ -717,9 +717,9 @@ int ORB_Impl::descriptorSize() const return kBytes; } -int ORB_Impl::descriptorType() const +ElemType ORB_Impl::descriptorType() const { - return CV_8U; + return CV_8UC1; } int ORB_Impl::defaultNorm() const @@ -863,7 +863,7 @@ static void computeKeyPoints(const Mat& imagePyramid, return; } Mat responses; - UMat ukeypoints, uresponses(1, nkeypoints, CV_32F); + UMat ukeypoints, uresponses(1, nkeypoints, CV_32FC1); // Select best features using the Harris cornerness (better scoring than FAST) if( scoreType == ORB_Impl::HARRIS_SCORE ) @@ -1035,9 +1035,9 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask, } bufSize.height = level_ofs.y + level_dy; - imagePyramid.create(bufSize, CV_8U); + imagePyramid.create(bufSize, CV_8UC1); if( !mask.empty() ) - maskPyramid.create(bufSize, CV_8U); + maskPyramid.create(bufSize, CV_8UC1); Mat prevImg = image, prevMask = mask; @@ -1133,7 +1133,7 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask, return; } - _descriptors.create(nkeypoints, dsize, CV_8U); + _descriptors.create(nkeypoints, dsize, CV_8UC1); std::vector pattern; const int npoints = 512; diff --git a/modules/features2d/test/ocl/test_brute_force_matcher.cpp b/modules/features2d/test/ocl/test_brute_force_matcher.cpp index 5f884e0c8c91..d974052273d7 100644 --- a/modules/features2d/test/ocl/test_brute_force_matcher.cpp +++ b/modules/features2d/test/ocl/test_brute_force_matcher.cpp @@ -81,7 +81,7 @@ PARAM_TEST_CASE(BruteForceMatcher, int, int) // Descriptor vector elements are integer values. queryBuf.create(queryDescCount, dim, CV_32SC1); rng.fill(queryBuf, cv::RNG::UNIFORM, cv::Scalar::all(0), cv::Scalar::all(3)); - queryBuf.convertTo(queryBuf, CV_32FC1); + queryBuf.convertTo(queryBuf, CV_32F); // Generate train descriptors as follows: // copy each query descriptor to train set countFactor times diff --git a/modules/features2d/test/test_agast.cpp b/modules/features2d/test/test_agast.cpp index 64fa7507141f..2d455ef2362a 100644 --- a/modules/features2d/test/test_agast.cpp +++ b/modules/features2d/test/test_agast.cpp @@ -90,8 +90,8 @@ void CV_AgastTest::run( int ) cv::circle(image2, kp.pt, cvRound(kp.size/2), Scalar(255, 0, 0)); } - Mat kps1(1, (int)(keypoints1.size() * sizeof(KeyPoint)), CV_8U, &keypoints1[0]); - Mat kps2(1, (int)(keypoints2.size() * sizeof(KeyPoint)), CV_8U, &keypoints2[0]); + Mat kps1(1, (int)(keypoints1.size() * sizeof(KeyPoint)), CV_8UC1, &keypoints1[0]); + Mat kps2(1, (int)(keypoints2.size() * sizeof(KeyPoint)), CV_8UC1, &keypoints2[0]); FileStorage fs(xml, FileStorage::READ); if (!fs.isOpened()) diff --git a/modules/features2d/test/test_akaze.cpp b/modules/features2d/test/test_akaze.cpp index aafa8a754583..e162d932e8e9 100644 --- a/modules/features2d/test/test_akaze.cpp +++ b/modules/features2d/test/test_akaze.cpp @@ -8,7 +8,7 @@ namespace opencv_test { namespace { TEST(Features2d_AKAZE, detect_and_compute_split) { - Mat testImg(100, 100, CV_8U); + Mat testImg(100, 100, CV_8UC1); RNG rng(101); rng.fill(testImg, RNG::UNIFORM, Scalar(0), Scalar(255), true); diff --git a/modules/features2d/test/test_descriptors_regression.impl.hpp b/modules/features2d/test/test_descriptors_regression.impl.hpp index e60b5a069109..7d6e2dd96cd4 100644 --- a/modules/features2d/test/test_descriptors_regression.impl.hpp +++ b/modules/features2d/test/test_descriptors_regression.impl.hpp @@ -30,7 +30,8 @@ static Mat readMatFromBin( const string& filename ) if( f ) { CV_Assert(4 == sizeof(int)); - int rows, cols, type, dataSize; + int rows, cols, dataSize; + ElemType type; size_t elements_read1 = fread( (void*)&rows, sizeof(int), 1, f ); size_t elements_read2 = fread( (void*)&cols, sizeof(int), 1, f ); size_t elements_read3 = fread( (void*)&type, sizeof(int), 1, f ); diff --git a/modules/features2d/test/test_fast.cpp b/modules/features2d/test/test_fast.cpp index 2fc5602be5aa..43ad1dd49a21 100644 --- a/modules/features2d/test/test_fast.cpp +++ b/modules/features2d/test/test_fast.cpp @@ -90,8 +90,8 @@ void CV_FastTest::run( int ) cv::circle(image2, kp.pt, cvRound(kp.size/2), Scalar(255, 0, 0)); } - Mat kps1(1, (int)(keypoints1.size() * sizeof(KeyPoint)), CV_8U, &keypoints1[0]); - Mat kps2(1, (int)(keypoints2.size() * sizeof(KeyPoint)), CV_8U, &keypoints2[0]); + Mat kps1(1, (int)(keypoints1.size() * sizeof(KeyPoint)), CV_8UC1, &keypoints1[0]); + Mat kps2(1, (int)(keypoints2.size() * sizeof(KeyPoint)), CV_8UC1, &keypoints2[0]); FileStorage fs(xml, FileStorage::READ); if (!fs.isOpened()) diff --git a/modules/features2d/test/test_matchers_algorithmic.cpp b/modules/features2d/test/test_matchers_algorithmic.cpp index 96921518c430..fb2b29ea69cf 100644 --- a/modules/features2d/test/test_matchers_algorithmic.cpp +++ b/modules/features2d/test/test_matchers_algorithmic.cpp @@ -168,7 +168,7 @@ void CV_DescriptorMatcherTest::generateData( Mat& query, Mat& train ) // Descriptor vector elements are integer values. Mat buf( queryDescCount, dim, CV_32SC1 ); rng.fill( buf, RNG::UNIFORM, Scalar::all(0), Scalar(3) ); - buf.convertTo( query, CV_32FC1 ); + buf.convertTo( query, CV_32F ); // Generate train descriptors as follows: // copy each query descriptor to train set countFactor times diff --git a/modules/features2d/test/test_mser.cpp b/modules/features2d/test/test_mser.cpp index d0691083d1f2..275aaa98743e 100644 --- a/modules/features2d/test/test_mser.cpp +++ b/modules/features2d/test/test_mser.cpp @@ -87,7 +87,7 @@ TEST(Features2d_MSER, cases) 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; Mat big_image = imread(cvtest::TS::ptr()->get_data_path() + "mser/puzzle.png", 0); - Mat small_image(14, 26, CV_8U, buf); + Mat small_image(14, 26, CV_8UC1, buf); static const int thresharr[] = { 0, 70, 120, 180, 255 }; const int kDelta = 5; diff --git a/modules/flann/include/opencv2/flann.hpp b/modules/flann/include/opencv2/flann.hpp index 22c6ffcf19d8..6ea508eef1e8 100644 --- a/modules/flann/include/opencv2/flann.hpp +++ b/modules/flann/include/opencv2/flann.hpp @@ -287,7 +287,7 @@ void GenericIndex::knnSearch(const Mat& queries, Mat& indices, Mat& di CV_Assert(queries.isContinuous()); ::cvflann::Matrix m_queries((ElementType*)queries.ptr(0), queries.rows, queries.cols); - CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.type() == CV_32SC1); CV_Assert(indices.isContinuous()); ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); @@ -319,7 +319,7 @@ int GenericIndex::radiusSearch(const Mat& query, Mat& indices, Mat& di CV_Assert(query.isContinuous()); ::cvflann::Matrix m_query((ElementType*)query.ptr(0), query.rows, query.cols); - CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.type() == CV_32SC1); CV_Assert(indices.isContinuous()); ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); @@ -389,7 +389,7 @@ class Index_ CV_Assert(queries.isContinuous()); ::cvflann::Matrix m_queries((ElementType*)queries.ptr(0), queries.rows, queries.cols); - CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.type() == CV_32SC1); CV_Assert(indices.isContinuous()); ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); @@ -417,7 +417,7 @@ class Index_ CV_Assert(query.isContinuous()); ::cvflann::Matrix m_query((ElementType*)query.ptr(0), query.rows, query.cols); - CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.type() == CV_32SC1); CV_Assert(indices.isContinuous()); ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); diff --git a/modules/flann/src/miniflann.cpp b/modules/flann/src/miniflann.cpp index 1cbe57f8870c..44a3ed4f706a 100644 --- a/modules/flann/src/miniflann.cpp +++ b/modules/flann/src/miniflann.cpp @@ -481,11 +481,11 @@ void runKnnSearch_(void* index, const Mat& query, Mat& indices, Mat& dists, typedef typename Distance::ElementType ElementType; typedef typename Distance::ResultType DistanceType; int type = DataType::type; - int dtype = DataType::type; + ElemType dtype = DataType::type; IndexType* index_ = (IndexType*)index; CV_Assert((size_t)knn <= index_->size()); - CV_Assert(query.type() == type && indices.type() == CV_32S && dists.type() == dtype); + CV_Assert(query.type() == type && indices.type() == CV_32SC1 && dists.type() == dtype); CV_Assert(query.isContinuous() && indices.isContinuous() && dists.isContinuous()); ::cvflann::Matrix _query((ElementType*)query.data, query.rows, query.cols); @@ -510,8 +510,8 @@ int runRadiusSearch_(void* index, const Mat& query, Mat& indices, Mat& dists, typedef typename Distance::ElementType ElementType; typedef typename Distance::ResultType DistanceType; int type = DataType::type; - int dtype = DataType::type; - CV_Assert(query.type() == type && indices.type() == CV_32S && dists.type() == dtype); + ElemType dtype = DataType::type; + CV_Assert(query.type() == type && indices.type() == CV_32SC1 && dists.type() == dtype); CV_Assert(query.isContinuous() && indices.isContinuous() && dists.isContinuous()); ::cvflann::Matrix _query((ElementType*)query.data, query.rows, query.cols); @@ -533,22 +533,22 @@ int runRadiusSearch(void* index, const Mat& query, Mat& indices, Mat& dists, static void createIndicesDists(OutputArray _indices, OutputArray _dists, Mat& indices, Mat& dists, int rows, - int minCols, int maxCols, int dtype) + int minCols, int maxCols, ElemType dtype) { if( _indices.needed() ) { indices = _indices.getMat(); - if( !indices.isContinuous() || indices.type() != CV_32S || + if (!indices.isContinuous() || indices.type() != CV_32SC1 || indices.rows != rows || indices.cols < minCols || indices.cols > maxCols ) { if( !indices.isContinuous() ) _indices.release(); - _indices.create( rows, minCols, CV_32S ); + _indices.create(rows, minCols, CV_32SC1); indices = _indices.getMat(); } } else - indices.create( rows, minCols, CV_32S ); + indices.create(rows, minCols, CV_32SC1); if( _dists.needed() ) { @@ -573,7 +573,7 @@ void Index::knnSearch(InputArray _query, OutputArray _indices, CV_INSTRUMENT_REGION(); Mat query = _query.getMat(), indices, dists; - int dtype = distType == FLANN_DIST_HAMMING ? CV_32S : CV_32F; + ElemType dtype = distType == FLANN_DIST_HAMMING ? CV_32SC1 : CV_32FC1; createIndicesDists( _indices, _dists, indices, dists, query.rows, knn, knn, dtype ); @@ -617,7 +617,7 @@ int Index::radiusSearch(InputArray _query, OutputArray _indices, CV_INSTRUMENT_REGION(); Mat query = _query.getMat(), indices, dists; - int dtype = distType == FLANN_DIST_HAMMING ? CV_32S : CV_32F; + ElemType dtype = distType == FLANN_DIST_HAMMING ? CV_32SC1 : CV_32FC1; CV_Assert( maxResults > 0 ); createIndicesDists( _indices, _dists, indices, dists, query.rows, maxResults, INT_MAX, dtype ); diff --git a/modules/highgui/test/test_gui.cpp b/modules/highgui/test/test_gui.cpp index 59f7d85abad9..d2f7b4b66268 100644 --- a/modules/highgui/test/test_gui.cpp +++ b/modules/highgui/test/test_gui.cpp @@ -63,7 +63,7 @@ void CV_HighGuiOnlyGuiTest::run( int /*start_from */) namedWindow("Win"); ts->printf(ts->LOG, "GUI 2\n"); - Mat m(256, 256, CV_8U); + Mat m(256, 256, CV_8UC1); m = Scalar(128); ts->printf(ts->LOG, "GUI 3\n"); diff --git a/modules/imgcodecs/src/grfmt_base.cpp b/modules/imgcodecs/src/grfmt_base.cpp index b7032c172375..40014e27514c 100644 --- a/modules/imgcodecs/src/grfmt_base.cpp +++ b/modules/imgcodecs/src/grfmt_base.cpp @@ -50,7 +50,7 @@ namespace cv BaseImageDecoder::BaseImageDecoder() { m_width = m_height = 0; - m_type = -1; + m_type = CV_TYPE_AUTO; m_buf_supported = false; m_scale_denom = 1; } @@ -100,7 +100,7 @@ BaseImageEncoder::BaseImageEncoder() m_buf_supported = false; } -bool BaseImageEncoder::isFormatSupported( int depth ) const +bool BaseImageEncoder::isFormatSupported( ElemDepth depth ) const { return depth == CV_8U; } diff --git a/modules/imgcodecs/src/grfmt_base.hpp b/modules/imgcodecs/src/grfmt_base.hpp index 7d75636cf59e..de5b35ce8b45 100644 --- a/modules/imgcodecs/src/grfmt_base.hpp +++ b/modules/imgcodecs/src/grfmt_base.hpp @@ -63,7 +63,7 @@ class BaseImageDecoder int width() const { return m_width; } int height() const { return m_height; } - virtual int type() const { return m_type; } + virtual ElemType type() const { return m_type; } virtual bool setSource( const String& filename ); virtual bool setSource( const Mat& buf ); @@ -81,7 +81,7 @@ class BaseImageDecoder protected: int m_width; // width of the image ( filled by readHeader ) int m_height; // height of the image ( filled by readHeader ) - int m_type; + ElemType m_type; int m_scale_denom; String m_filename; String m_signature; @@ -96,7 +96,7 @@ class BaseImageEncoder public: BaseImageEncoder(); virtual ~BaseImageEncoder() {} - virtual bool isFormatSupported( int depth ) const; + virtual bool isFormatSupported( ElemDepth depth ) const; virtual bool setDestination( const String& filename ); virtual bool setDestination( std::vector& buf ); diff --git a/modules/imgcodecs/src/grfmt_exr.cpp b/modules/imgcodecs/src/grfmt_exr.cpp index 1eceb4f5cd38..29f7632a0e21 100644 --- a/modules/imgcodecs/src/grfmt_exr.cpp +++ b/modules/imgcodecs/src/grfmt_exr.cpp @@ -111,7 +111,7 @@ void ExrDecoder::close() } -int ExrDecoder::type() const +ElemType ExrDecoder::type() const { return CV_MAKETYPE((m_isfloat ? CV_32F : CV_32S), m_iscolor ? 3 : 1); } @@ -559,7 +559,7 @@ ExrEncoder::~ExrEncoder() } -bool ExrEncoder::isFormatSupported( int depth ) const +bool ExrEncoder::isFormatSupported( ElemDepth depth ) const { return ( CV_MAT_DEPTH(depth) == CV_32F ); } @@ -568,7 +568,7 @@ bool ExrEncoder::isFormatSupported( int depth ) const bool ExrEncoder::write( const Mat& img, const std::vector& params ) { int width = img.cols, height = img.rows; - int depth = img.depth(); + ElemDepth depth = img.depth(); CV_Assert( depth == CV_32F ); int channels = img.channels(); CV_Assert( channels == 3 || channels == 1 ); diff --git a/modules/imgcodecs/src/grfmt_exr.hpp b/modules/imgcodecs/src/grfmt_exr.hpp index ec08028e2204..2de2a7873417 100644 --- a/modules/imgcodecs/src/grfmt_exr.hpp +++ b/modules/imgcodecs/src/grfmt_exr.hpp @@ -70,7 +70,7 @@ class ExrDecoder CV_FINAL : public BaseImageDecoder ExrDecoder(); ~ExrDecoder() CV_OVERRIDE; - int type() const CV_OVERRIDE; + ElemType type() const CV_OVERRIDE; bool readData( Mat& img ) CV_OVERRIDE; bool readHeader() CV_OVERRIDE; void close(); @@ -109,7 +109,7 @@ class ExrEncoder CV_FINAL : public BaseImageEncoder ExrEncoder(); ~ExrEncoder() CV_OVERRIDE; - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; ImageEncoder newEncoder() const CV_OVERRIDE; }; diff --git a/modules/imgcodecs/src/grfmt_gdal.cpp b/modules/imgcodecs/src/grfmt_gdal.cpp index 17581b576aec..fb1bcf48e165 100644 --- a/modules/imgcodecs/src/grfmt_gdal.cpp +++ b/modules/imgcodecs/src/grfmt_gdal.cpp @@ -61,7 +61,7 @@ namespace cv{ /** * Convert GDAL Palette Interpretation to OpenCV Pixel Type */ -int gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp, GDALDataType const& gdalType ){ +ElemType gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp, GDALDataType const& gdalType ){ switch( paletteInterp ){ @@ -74,7 +74,7 @@ int gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp, G if( gdalType == GDT_Int32 ){ return CV_32SC1; } if( gdalType == GDT_Float32 ){ return CV_32FC1; } if( gdalType == GDT_Float64 ){ return CV_64FC1; } - return -1; + return CV_TYPE_AUTO; /// RGB case GPI_RGB: @@ -85,12 +85,12 @@ int gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp, G if( gdalType == GDT_Int32 ){ return CV_32SC3; } if( gdalType == GDT_Float32 ){ return CV_32FC3; } if( gdalType == GDT_Float64 ){ return CV_64FC3; } - return -1; + return CV_TYPE_AUTO; /// otherwise default: - return -1; + return CV_TYPE_AUTO; } } @@ -98,7 +98,7 @@ int gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp, G /** * Convert gdal type to opencv type */ -int gdal2opencv( const GDALDataType& gdalType, const int& channels ){ +ElemType gdal2opencv( const GDALDataType& gdalType, const int& channels ){ switch( gdalType ){ @@ -128,7 +128,7 @@ int gdal2opencv( const GDALDataType& gdalType, const int& channels ){ default: std::cout << "Unknown GDAL Data Type" << std::endl; std::cout << "Type: " << GDALGetDataTypeName(gdalType) << std::endl; - return -1; + return CV_TYPE_AUTO; } } @@ -488,7 +488,7 @@ bool GdalDecoder::readHeader(){ } // check if we have a color palette - int tempType; + ElemType tempType; if( m_dataset->GetRasterBand(1)->GetColorInterpretation() == GCI_PaletteIndex ){ // remember that we have a color palette @@ -505,7 +505,7 @@ bool GdalDecoder::readHeader(){ tempType = gdalPaletteInterpretation2OpenCV( m_dataset->GetRasterBand(1)->GetColorTable()->GetPaletteInterpretation(), m_dataset->GetRasterBand(1)->GetRasterDataType() ); - if( tempType == -1 ){ + if( tempType == CV_TYPE_AUTO ){ return false; } m_type = tempType; diff --git a/modules/imgcodecs/src/grfmt_gdal.hpp b/modules/imgcodecs/src/grfmt_gdal.hpp index 47b360f855b5..0dba4fbd0287 100644 --- a/modules/imgcodecs/src/grfmt_gdal.hpp +++ b/modules/imgcodecs/src/grfmt_gdal.hpp @@ -70,13 +70,13 @@ double range_cast( const GDALDataType& gdalType, /** * Convert GDAL Palette Interpretation to OpenCV Pixel Type */ -int gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp, +ElemType gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp, GDALDataType const& gdalType ); /** * Convert a GDAL Raster Type to OpenCV Type */ -int gdal2opencv( const GDALDataType& gdalType, const int& channels ); +ElemType gdal2opencv( const GDALDataType& gdalType, const int& channels ); /** * Write an image to pixel diff --git a/modules/imgcodecs/src/grfmt_hdr.cpp b/modules/imgcodecs/src/grfmt_hdr.cpp index a274b2233c98..2cfc08fc1b9a 100644 --- a/modules/imgcodecs/src/grfmt_hdr.cpp +++ b/modules/imgcodecs/src/grfmt_hdr.cpp @@ -94,9 +94,9 @@ bool HdrDecoder::readData(Mat& _img) fclose(file); file = NULL; if(_img.depth() == img.depth()) { - img.convertTo(_img, _img.type()); + img.convertTo(_img, _img.depth()); } else { - img.convertTo(_img, _img.type(), 255); + img.convertTo(_img, _img.depth(), 255); } return true; } @@ -139,7 +139,7 @@ bool HdrEncoder::write( const Mat& input_img, const std::vector& params ) input_img.copyTo(img); } if(img.depth() != CV_32F) { - img.convertTo(img, CV_32FC3, 1/255.0f); + img.convertTo(img, CV_32F, 1/255.0f); } CV_Assert(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE); FILE *fout = fopen(m_filename.c_str(), "wb"); @@ -163,7 +163,7 @@ ImageEncoder HdrEncoder::newEncoder() const return makePtr(); } -bool HdrEncoder::isFormatSupported( int depth ) const { +bool HdrEncoder::isFormatSupported( ElemDepth depth ) const { return depth != CV_64F; } diff --git a/modules/imgcodecs/src/grfmt_hdr.hpp b/modules/imgcodecs/src/grfmt_hdr.hpp index fa29fbe0d2d9..d28f14749e20 100644 --- a/modules/imgcodecs/src/grfmt_hdr.hpp +++ b/modules/imgcodecs/src/grfmt_hdr.hpp @@ -80,7 +80,7 @@ class HdrEncoder CV_FINAL : public BaseImageEncoder ~HdrEncoder() CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; ImageEncoder newEncoder() const CV_OVERRIDE; - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; protected: }; diff --git a/modules/imgcodecs/src/grfmt_jpeg.cpp b/modules/imgcodecs/src/grfmt_jpeg.cpp index 917c72eae3ae..6ef7e08764ef 100644 --- a/modules/imgcodecs/src/grfmt_jpeg.cpp +++ b/modules/imgcodecs/src/grfmt_jpeg.cpp @@ -196,7 +196,7 @@ void JpegDecoder::close() } m_width = m_height = 0; - m_type = -1; + m_type = CV_TYPE_AUTO; } ImageDecoder JpegDecoder::newDecoder() const diff --git a/modules/imgcodecs/src/grfmt_jpeg2000.cpp b/modules/imgcodecs/src/grfmt_jpeg2000.cpp index be280e285a27..a8cd4107db04 100644 --- a/modules/imgcodecs/src/grfmt_jpeg2000.cpp +++ b/modules/imgcodecs/src/grfmt_jpeg2000.cpp @@ -134,7 +134,7 @@ bool Jpeg2KDecoder::readHeader() { int depth_i = jas_image_cmptprec( image, i ); CV_Assert(depth == 0 || depth == depth_i); // component data type mismatch - depth = MAX(depth, depth_i); + depth = CV_MAX_DEPTH(depth, depth_i); if( jas_image_cmpttype( image, i ) > 2 ) continue; int sgnd = jas_image_cmptsgnd(image, i); @@ -461,7 +461,7 @@ ImageEncoder Jpeg2KEncoder::newEncoder() const return makePtr(); } -bool Jpeg2KEncoder::isFormatSupported( int depth ) const +bool Jpeg2KEncoder::isFormatSupported( ElemDepth depth ) const { return depth == CV_8U || depth == CV_16U; } @@ -470,8 +470,9 @@ bool Jpeg2KEncoder::isFormatSupported( int depth ) const bool Jpeg2KEncoder::write( const Mat& _img, const std::vector& ) { int width = _img.cols, height = _img.rows; - int depth = _img.depth(), channels = _img.channels(); - depth = depth == CV_8U ? 8 : 16; + ElemDepth depth = _img.depth(); + int channels = _img.channels(); + int prec_depth = depth == CV_8U ? 8 : 16; if( channels > 3 || channels < 1 ) return false; @@ -485,7 +486,7 @@ bool Jpeg2KEncoder::write( const Mat& _img, const std::vector& ) component_info[i].vstep = 1; component_info[i].width = width; component_info[i].height = height; - component_info[i].prec = depth; + component_info[i].prec = prec_depth; component_info[i].sgnd = 0; } jas_image_t *img = jas_image_create( channels, component_info, (channels == 1) ? JAS_CLRSPC_SGRAY : JAS_CLRSPC_SRGB ); @@ -502,7 +503,7 @@ bool Jpeg2KEncoder::write( const Mat& _img, const std::vector& ) } bool result; - if( depth == 8 ) + if (prec_depth == 8) result = writeComponent8u( img, _img ); else result = writeComponent16u( img, _img ); diff --git a/modules/imgcodecs/src/grfmt_jpeg2000.hpp b/modules/imgcodecs/src/grfmt_jpeg2000.hpp index 586f16f0fa80..acbfbea9b167 100644 --- a/modules/imgcodecs/src/grfmt_jpeg2000.hpp +++ b/modules/imgcodecs/src/grfmt_jpeg2000.hpp @@ -79,7 +79,7 @@ class Jpeg2KEncoder CV_FINAL : public BaseImageEncoder Jpeg2KEncoder(); virtual ~Jpeg2KEncoder(); - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; ImageEncoder newEncoder() const CV_OVERRIDE; diff --git a/modules/imgcodecs/src/grfmt_pam.cpp b/modules/imgcodecs/src/grfmt_pam.cpp index d1a2161733a9..c15e2393649e 100644 --- a/modules/imgcodecs/src/grfmt_pam.cpp +++ b/modules/imgcodecs/src/grfmt_pam.cpp @@ -638,7 +638,7 @@ ImageEncoder PAMEncoder::newEncoder() const } -bool PAMEncoder::isFormatSupported( int depth ) const +bool PAMEncoder::isFormatSupported( ElemDepth depth ) const { return depth == CV_8U || depth == CV_16U; } diff --git a/modules/imgcodecs/src/grfmt_pam.hpp b/modules/imgcodecs/src/grfmt_pam.hpp index f9b2614b28fe..2c20b7c1a32e 100644 --- a/modules/imgcodecs/src/grfmt_pam.hpp +++ b/modules/imgcodecs/src/grfmt_pam.hpp @@ -90,7 +90,7 @@ class PAMEncoder CV_FINAL : public BaseImageEncoder PAMEncoder(); virtual ~PAMEncoder() CV_OVERRIDE; - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; ImageEncoder newEncoder() const CV_OVERRIDE; diff --git a/modules/imgcodecs/src/grfmt_pfm.cpp b/modules/imgcodecs/src/grfmt_pfm.cpp index 0e4385b0099e..ad89c96d76db 100644 --- a/modules/imgcodecs/src/grfmt_pfm.cpp +++ b/modules/imgcodecs/src/grfmt_pfm.cpp @@ -149,7 +149,7 @@ bool PFMDecoder::readData(Mat& mat) CV_Assert(fabs(m_scale_factor) > 0.0f); buffer *= 1.f / fabs(m_scale_factor); - buffer.convertTo(mat, mat.type()); + buffer.convertTo(mat, mat.depth()); return true; } @@ -183,7 +183,7 @@ PFMEncoder::~PFMEncoder() { } -bool PFMEncoder::isFormatSupported(int depth) const +bool PFMEncoder::isFormatSupported(ElemDepth depth) const { // any depth will be converted into 32-bit float. CV_UNUSED(depth); @@ -193,6 +193,7 @@ bool PFMEncoder::isFormatSupported(int depth) const bool PFMEncoder::write(const Mat& img, const std::vector& params) { CV_UNUSED(params); + CV_Assert(img.channels() == 3 || img.channels() == 1); WLByteStream strm; if (m_buf) { @@ -206,22 +207,11 @@ bool PFMEncoder::write(const Mat& img, const std::vector& params) } Mat float_img; + img.convertTo(float_img, CV_32F); strm.putByte('P'); - switch (img.channels()) { - case 1: - strm.putByte('f'); - img.convertTo(float_img, CV_32FC1); - break; - case 3: - strm.putByte('F'); - img.convertTo(float_img, CV_32FC3); - break; - default: - CV_Error(Error::StsBadArg, "Expected 1 or 3 channel image."); - } + strm.putByte(img.channels() == 1 ? 'f' : 'F'); strm.putByte('\n'); - write_anything(strm, float_img.cols); strm.putByte(' '); write_anything(strm, float_img.rows); diff --git a/modules/imgcodecs/src/grfmt_pfm.hpp b/modules/imgcodecs/src/grfmt_pfm.hpp index 9284f605155d..6374cccced1a 100644 --- a/modules/imgcodecs/src/grfmt_pfm.hpp +++ b/modules/imgcodecs/src/grfmt_pfm.hpp @@ -41,7 +41,7 @@ class PFMEncoder CV_FINAL : public BaseImageEncoder PFMEncoder(); virtual ~PFMEncoder() CV_OVERRIDE; - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; ImageEncoder newEncoder() const CV_OVERRIDE diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp index f26262282a3d..ce70f7511e4a 100644 --- a/modules/imgcodecs/src/grfmt_png.cpp +++ b/modules/imgcodecs/src/grfmt_png.cpp @@ -308,7 +308,7 @@ PngEncoder::~PngEncoder() } -bool PngEncoder::isFormatSupported( int depth ) const +bool PngEncoder::isFormatSupported( ElemDepth depth ) const { return depth == CV_8U || depth == CV_16U; } @@ -342,7 +342,8 @@ bool PngEncoder::write( const Mat& img, const std::vector& params ) png_infop info_ptr = 0; FILE * volatile f = 0; int y, width = img.cols, height = img.rows; - int depth = img.depth(), channels = img.channels(); + ElemDepth depth = img.depth(); + int channels = img.channels(); volatile bool result = false; AutoBuffer buffer; diff --git a/modules/imgcodecs/src/grfmt_png.hpp b/modules/imgcodecs/src/grfmt_png.hpp index 3d8d1a764ae7..aa549d4e0c43 100644 --- a/modules/imgcodecs/src/grfmt_png.hpp +++ b/modules/imgcodecs/src/grfmt_png.hpp @@ -84,7 +84,7 @@ class PngEncoder CV_FINAL : public BaseImageEncoder PngEncoder(); virtual ~PngEncoder(); - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; ImageEncoder newEncoder() const CV_OVERRIDE; diff --git a/modules/imgcodecs/src/grfmt_pxm.cpp b/modules/imgcodecs/src/grfmt_pxm.cpp index b41fd95edcf9..2a18f329443d 100644 --- a/modules/imgcodecs/src/grfmt_pxm.cpp +++ b/modules/imgcodecs/src/grfmt_pxm.cpp @@ -395,7 +395,7 @@ PxMEncoder::~PxMEncoder() { } -bool PxMEncoder::isFormatSupported(int depth) const +bool PxMEncoder::isFormatSupported(ElemDepth depth) const { if (mode_ == PXM_TYPE_PBM) return depth == CV_8U; @@ -407,7 +407,8 @@ bool PxMEncoder::write(const Mat& img, const std::vector& params) bool isBinary = true; int width = img.cols, height = img.rows; - int _channels = img.channels(), depth = (int)img.elemSize1()*8; + int _channels = img.channels(); + size_t depth = img.elemSize1() * 8; int channels = _channels > 1 ? 3 : 1; int fileStep = width*(int)img.elemSize(); int x, y; @@ -443,7 +444,7 @@ bool PxMEncoder::write(const Mat& img, const std::vector& params) { if( !strm.open(*m_buf) ) return false; - int t = CV_MAKETYPE(img.depth(), channels); + ElemType t = CV_MAKETYPE(img.depth(), channels); m_buf->reserve( alignSize(256 + (isBinary ? fileStep*height : ((t == CV_8UC1 ? 4 : t == CV_8UC3 ? 4*3+2 : t == CV_16UC1 ? 6 : 6*3+2)*width+1)*height), 256)); diff --git a/modules/imgcodecs/src/grfmt_pxm.hpp b/modules/imgcodecs/src/grfmt_pxm.hpp index 6404e96ef17f..e551a9762fe8 100644 --- a/modules/imgcodecs/src/grfmt_pxm.hpp +++ b/modules/imgcodecs/src/grfmt_pxm.hpp @@ -90,7 +90,7 @@ class PxMEncoder CV_FINAL : public BaseImageEncoder PxMEncoder(PxMMode mode); virtual ~PxMEncoder() CV_OVERRIDE; - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; ImageEncoder newEncoder() const CV_OVERRIDE diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index 69dc4261ac1c..906bd45a8be6 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -623,7 +623,7 @@ ImageEncoder TiffEncoder::newEncoder() const return makePtr(); } -bool TiffEncoder::isFormatSupported( int depth ) const +bool TiffEncoder::isFormatSupported( ElemDepth depth ) const { return depth == CV_8U || depth == CV_16U || depth == CV_32F; } @@ -761,7 +761,7 @@ bool TiffEncoder::writeLibTiff( const std::vector& img_vec, const std::vect const Mat& img = img_vec[page]; int channels = img.channels(); int width = img.cols, height = img.rows; - int depth = img.depth(); + ElemDepth depth = img.depth(); int bitsPerChannel = -1; switch (depth) @@ -978,7 +978,7 @@ bool TiffEncoder::writemulti(const std::vector& img_vec, const std::vector< bool TiffEncoder::write( const Mat& img, const std::vector& params) { - int depth = img.depth(); + ElemDepth depth = img.depth(); if(img.type() == CV_32FC3) { diff --git a/modules/imgcodecs/src/grfmt_tiff.hpp b/modules/imgcodecs/src/grfmt_tiff.hpp index cd1b55ed0275..525ab0d41d8b 100644 --- a/modules/imgcodecs/src/grfmt_tiff.hpp +++ b/modules/imgcodecs/src/grfmt_tiff.hpp @@ -125,7 +125,7 @@ class TiffEncoder CV_FINAL : public BaseImageEncoder TiffEncoder(); virtual ~TiffEncoder() CV_OVERRIDE; - bool isFormatSupported( int depth ) const CV_OVERRIDE; + bool isFormatSupported( ElemDepth depth ) const CV_OVERRIDE; bool write( const Mat& img, const std::vector& params ) CV_OVERRIDE; diff --git a/modules/imgcodecs/src/loadsave.cpp b/modules/imgcodecs/src/loadsave.cpp index 77b0ff124a8d..f462274b9959 100644 --- a/modules/imgcodecs/src/loadsave.cpp +++ b/modules/imgcodecs/src/loadsave.cpp @@ -463,7 +463,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) Size size = validateInputImageSize(Size(decoder->width(), decoder->height())); // grab the decoded type - int type = decoder->type(); + ElemType type = decoder->type(); if( (flags & IMREAD_LOAD_GDAL) != IMREAD_LOAD_GDAL && flags != IMREAD_UNCHANGED ) { if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 ) @@ -583,7 +583,7 @@ imreadmulti_(const String& filename, int flags, std::vector& mats) for (;;) { // grab the decoded type - int type = decoder->type(); + ElemType type = decoder->type(); if( (flags & IMREAD_LOAD_GDAL) != IMREAD_LOAD_GDAL && flags != IMREAD_UNCHANGED ) { if ((flags & CV_LOAD_IMAGE_ANYDEPTH) == 0) @@ -810,7 +810,7 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 ) // established the required input image size Size size = validateInputImageSize(Size(decoder->width(), decoder->height())); - int type = decoder->type(); + ElemType type = decoder->type(); if( (flags & IMREAD_LOAD_GDAL) != IMREAD_LOAD_GDAL && flags != IMREAD_UNCHANGED ) { if( (flags & CV_LOAD_IMAGE_ANYDEPTH) == 0 ) @@ -1014,7 +1014,7 @@ CV_IMPL IplImage* cvDecodeImage( const CvMat* _buf, int iscolor ) { CV_Assert( _buf && CV_IS_MAT_CONT(_buf->type) ); - cv::Mat buf(1, _buf->rows*_buf->cols*CV_ELEM_SIZE(_buf->type), CV_8U, _buf->data.ptr); + cv::Mat buf(1, _buf->rows*_buf->cols*CV_ELEM_SIZE(_buf->type), CV_8UC1, _buf->data.ptr); return (IplImage*)cv::imdecode_(buf, iscolor, cv::LOAD_IMAGE ); } @@ -1022,7 +1022,7 @@ CV_IMPL CvMat* cvDecodeImageM( const CvMat* _buf, int iscolor ) { CV_Assert( _buf && CV_IS_MAT_CONT(_buf->type) ); - cv::Mat buf(1, _buf->rows*_buf->cols*CV_ELEM_SIZE(_buf->type), CV_8U, _buf->data.ptr); + cv::Mat buf(1, _buf->rows*_buf->cols*CV_ELEM_SIZE(_buf->type), CV_8UC1, _buf->data.ptr); return (CvMat*)cv::imdecode_(buf, iscolor, cv::LOAD_CVMAT ); } @@ -1048,7 +1048,7 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params ) i > 0 ? std::vector(_params, _params+i) : std::vector() ); if( !code ) return 0; - CvMat* _buf = cvCreateMat(1, (int)buf.size(), CV_8U); + CvMat* _buf = cvCreateMat(1, (int)buf.size(), CV_8UC1); memcpy( _buf->data.ptr, &buf[0], buf.size() ); return _buf; diff --git a/modules/imgcodecs/src/utils.cpp b/modules/imgcodecs/src/utils.cpp index 6aeb63106028..349af6cce10f 100644 --- a/modules/imgcodecs/src/utils.cpp +++ b/modules/imgcodecs/src/utils.cpp @@ -629,7 +629,7 @@ cvConvertImage( const CvArr* srcarr, CvArr* dstarr, int flags ) if( !CV_ARE_DEPTHS_EQ( src, dst )) { - int src_depth = CV_MAT_DEPTH(src->type); + ElemDepth src_depth = CV_MAT_DEPTH(src->type); double scale = src_depth <= CV_8S ? 1 : src_depth <= CV_32S ? 1./256 : 255; double shift = src_depth == CV_8S || src_depth == CV_16S ? 128 : 0; diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp index 1b1eaa743e8a..5255bca8be78 100644 --- a/modules/imgcodecs/test/test_grfmt.cpp +++ b/modules/imgcodecs/test/test_grfmt.cpp @@ -185,7 +185,7 @@ TEST_P(Imgcodecs_ExtSize, write_imageseq) } else if (ext == ".pfm") { - img_gt.convertTo(img_gt, CV_MAKETYPE(CV_32F, img.channels())); + img_gt.convertTo(img_gt, CV_32F); double n = cvtest::norm(img, img_gt, NORM_L2); EXPECT_LT(n, 1.); EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, img_gt); diff --git a/modules/imgcodecs/test/test_png.cpp b/modules/imgcodecs/test/test_png.cpp index ba4794632b65..425ef21c7b79 100644 --- a/modules/imgcodecs/test/test_png.cpp +++ b/modules/imgcodecs/test/test_png.cpp @@ -24,7 +24,7 @@ TEST(Imgcodecs_Png, write_big) TEST(Imgcodecs_Png, encode) { vector buff; - Mat img_gt = Mat::zeros(1000, 1000, CV_8U); + Mat img_gt = Mat::zeros(1000, 1000, CV_8UC1); vector param; param.push_back(IMWRITE_PNG_COMPRESSION); param.push_back(3); //default(3) 0-9. diff --git a/modules/imgcodecs/test/test_read_write.cpp b/modules/imgcodecs/test/test_read_write.cpp index 8176b52ccf61..7261ff57debd 100644 --- a/modules/imgcodecs/test/test_read_write.cpp +++ b/modules/imgcodecs/test/test_read_write.cpp @@ -64,7 +64,7 @@ TEST_P(Imgcodecs_Image, read_write) const double thresDbell = 32; Mat image = imread(_name); - image.convertTo(image, CV_8UC3); + image.convertTo(image, CV_8U); ASSERT_FALSE(image.empty()); imwrite(full_name, image); diff --git a/modules/imgcodecs/test/test_tiff.cpp b/modules/imgcodecs/test/test_tiff.cpp index 1f5ab2401a06..0ce34a0e3451 100644 --- a/modules/imgcodecs/test/test_tiff.cpp +++ b/modules/imgcodecs/test/test_tiff.cpp @@ -83,7 +83,7 @@ TEST(Imgcodecs_Tiff, write_read_16bit_big_little_endian) EXPECT_EQ(1, img.rows); EXPECT_EQ(2, img.cols); - EXPECT_EQ(CV_16U, img.type()); + EXPECT_EQ(CV_16UC1, img.type()); EXPECT_EQ(sizeof(ushort), img.elemSize()); EXPECT_EQ(1, img.channels()); EXPECT_EQ(0xDEAD, img.at(0,0)); @@ -112,7 +112,7 @@ TEST(Imgcodecs_Tiff, decode_tile_remainder) cv::Mat tiled16 = imread(root + "readwrite/tiled_16.tif", -1); ASSERT_FALSE(tiled16.empty()); ASSERT_TRUE(tiled16.elemSize() == 6); - tiled16.convertTo(tiled8, CV_8UC3, 1./256.); + tiled16.convertTo(tiled8, CV_8U, 1./256.); ASSERT_PRED_FORMAT2(cvtest::MatComparator(2, 0), img, tiled8); // What about 32, 64 bit? } diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 7f3d1515e580..8048566ea269 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -1331,7 +1331,7 @@ You may also use the higher-level GaussianBlur. @param ktype Type of filter coefficients. It can be CV_32F or CV_64F . @sa sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur */ -CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype = CV_64F ); +CV_EXPORTS_W Mat getGaussianKernel(int ksize, double sigma, ElemType ktype = CV_64FC1); /** @brief Returns filter coefficients for computing spatial image derivatives. @@ -1353,7 +1353,7 @@ all the fractional bits, you may want to set normalize=false . */ CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky, int dx, int dy, int ksize, - bool normalize = false, int ktype = CV_32F ); + bool normalize = false, ElemType ktype = CV_32FC1); /** @brief Returns Gabor filter coefficients. @@ -1369,7 +1369,7 @@ Filter](http://en.wikipedia.org/wiki/Gabor_filter). @param ktype Type of filter coefficients. It can be CV_32F or CV_64F . */ CV_EXPORTS_W Mat getGaborKernel( Size ksize, double sigma, double theta, double lambd, - double gamma, double psi = CV_PI*0.5, int ktype = CV_64F ); + double gamma, double psi = CV_PI*0.5, ElemType ktype = CV_64FC1 ); //! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation. static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); } @@ -1483,7 +1483,7 @@ algorithms, and so on). If you need to compute pixel sums over variable-size win @param src input image. @param dst output image of the same size and type as src. -@param ddepth the output image depth (-1 to use src.depth()). +@param ddepth the output image depth (CV_DEPTH_AUTO to use src.depth()). @param ksize blurring kernel size. @param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel center. @@ -1491,7 +1491,7 @@ center. @param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes @sa blur, bilateralFilter, GaussianBlur, medianBlur, integral */ -CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth, +CV_EXPORTS_W void boxFilter(InputArray src, OutputArray dst, ElemDepth ddepth, Size ksize, Point anchor = Point(-1,-1), bool normalize = true, int borderType = BORDER_DEFAULT ); @@ -1506,7 +1506,7 @@ variance and standard deviation around the neighborhood of a pixel. @param _src input image @param _dst output image of the same size and type as _src -@param ddepth the output image depth (-1 to use src.depth()) +@param ddepth the output image depth (CV_DEPTH_AUTO to use src.depth()) @param ksize kernel size @param anchor kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel center. @@ -1514,7 +1514,7 @@ center. @param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes @sa boxFilter */ -CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth, +CV_EXPORTS_W void sqrBoxFilter(InputArray _src, OutputArray _dst, ElemDepth ddepth, Size ksize, Point anchor = Point(-1, -1), bool normalize = true, int borderType = BORDER_DEFAULT ); @@ -1571,7 +1571,7 @@ is at the kernel center. @param borderType pixel extrapolation method, see #BorderTypes @sa sepFilter2D, dft, matchTemplate */ -CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth, +CV_EXPORTS_W void filter2D(InputArray src, OutputArray dst, ElemDepth ddepth, InputArray kernel, Point anchor = Point(-1,-1), double delta = 0, int borderType = BORDER_DEFAULT ); @@ -1592,7 +1592,7 @@ is at the kernel center. @param borderType Pixel extrapolation method, see #BorderTypes @sa filter2D, Sobel, GaussianBlur, boxFilter, blur */ -CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth, +CV_EXPORTS_W void sepFilter2D(InputArray src, OutputArray dst, ElemDepth ddepth, InputArray kernelX, InputArray kernelY, Point anchor = Point(-1,-1), double delta = 0, int borderType = BORDER_DEFAULT ); @@ -1645,7 +1645,7 @@ applied (see #getDerivKernels for details). @param borderType pixel extrapolation method, see #BorderTypes @sa Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar */ -CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth, +CV_EXPORTS_W void Sobel(InputArray src, OutputArray dst, ElemDepth ddepth, int dx, int dy, int ksize = 3, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT ); @@ -1694,7 +1694,7 @@ applied (see #getDerivKernels for details). @param borderType pixel extrapolation method, see #BorderTypes @sa cartToPolar */ -CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth, +CV_EXPORTS_W void Scharr(InputArray src, OutputArray dst, ElemDepth ddepth, int dx, int dy, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT ); @@ -1725,7 +1725,7 @@ applied. See #getDerivKernels for details. @param borderType Pixel extrapolation method, see #BorderTypes @sa Sobel, Scharr */ -CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth, +CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, ElemDepth ddepth, int ksize = 1, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT ); @@ -2380,7 +2380,7 @@ nearest-neighbor or for a more complex interpolation. */ CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2, OutputArray dstmap1, OutputArray dstmap2, - int dstmap1type, bool nninterpolation = false ); + ElemType dstmap1type, bool nninterpolation = false); /** @brief Calculates an affine matrix of 2D rotation. @@ -2665,11 +2665,11 @@ CV_EXPORTS_W void warpPolar(InputArray src, OutputArray dst, Size dsize, //! @{ /** @overload */ -CV_EXPORTS_W void integral( InputArray src, OutputArray sum, int sdepth = -1 ); +CV_EXPORTS_W void integral( InputArray src, OutputArray sum, ElemDepth sdepth = CV_DEPTH_AUTO ); /** @overload */ CV_EXPORTS_AS(integral2) void integral( InputArray src, OutputArray sum, - OutputArray sqsum, int sdepth = -1, int sqdepth = -1 ); + OutputArray sqsum, ElemDepth sdepth = CV_DEPTH_AUTO, ElemDepth sqdepth = CV_DEPTH_AUTO ); /** @brief Calculates the integral of an image. @@ -2707,7 +2707,7 @@ CV_64F. */ CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum, OutputArray sqsum, OutputArray tilted, - int sdepth = -1, int sqdepth = -1 ); + ElemDepth sdepth = CV_DEPTH_AUTO, ElemDepth sqdepth = CV_DEPTH_AUTO); //! @} imgproc_misc @@ -2846,7 +2846,7 @@ An example is shown below: @param winSize The window size specifications (both width and height must be > 1) @param type Created array type */ -CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type); +CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, ElemType type); //! @} imgproc_motion @@ -3078,12 +3078,12 @@ is assumed. In cvInitUndistortMap R assumed to be an identity matrix. */ CV_EXPORTS_W void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, - Size size, int m1type, OutputArray map1, OutputArray map2 ); + Size size, ElemType m1type, OutputArray map1, OutputArray map2); //! initializes maps for #remap for wide-angle CV_EXPORTS_W float initWideAngleProjMap( InputArray cameraMatrix, InputArray distCoeffs, Size imageSize, int destImageWidth, - int m1type, OutputArray map1, OutputArray map2, + ElemType m1type, OutputArray map1, OutputArray map2, int projType = PROJ_SPHERICAL_EQRECT, double alpha = 0); /** @brief Returns the default new camera matrix. diff --git a/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp b/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp index ac20725e6341..514915739f79 100644 --- a/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp +++ b/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp @@ -63,7 +63,7 @@ struct CV_EXPORTS Morph //! @endcond //--------------------------- -CV_EXPORTS void filter2D(int stype, int dtype, int kernel_type, +CV_EXPORTS void filter2D(ElemType stype, ElemType dtype, ElemType kernel_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -75,7 +75,7 @@ CV_EXPORTS void filter2D(int stype, int dtype, int kernel_type, double delta, int borderType, bool isSubmatrix); -CV_EXPORTS void sepFilter2D(int stype, int dtype, int ktype, +CV_EXPORTS void sepFilter2D(ElemType stype, ElemType dtype, ElemType ktype, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -86,7 +86,7 @@ CV_EXPORTS void sepFilter2D(int stype, int dtype, int ktype, int anchor_x, int anchor_y, double delta, int borderType); -CV_EXPORTS void morph(int op, int src_type, int dst_type, +CV_EXPORTS void morph(int op, ElemType src_type, ElemType dst_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -98,17 +98,17 @@ CV_EXPORTS void morph(int op, int src_type, int dst_type, int iterations, bool isSubmatrix); -CV_EXPORTS void resize(int src_type, +CV_EXPORTS void resize(ElemType src_type, const uchar * src_data, size_t src_step, int src_width, int src_height, uchar * dst_data, size_t dst_step, int dst_width, int dst_height, double inv_scale_x, double inv_scale_y, int interpolation); -CV_EXPORTS void warpAffine(int src_type, +CV_EXPORTS void warpAffine(ElemType src_type, const uchar * src_data, size_t src_step, int src_width, int src_height, uchar * dst_data, size_t dst_step, int dst_width, int dst_height, const double M[6], int interpolation, int borderType, const double borderValue[4]); -CV_EXPORTS void warpPerspective(int src_type, +CV_EXPORTS void warpPerspective(ElemType src_type, const uchar * src_data, size_t src_step, int src_width, int src_height, uchar * dst_data, size_t dst_step, int dst_width, int dst_height, const double M[9], int interpolation, int borderType, const double borderValue[4]); @@ -116,7 +116,7 @@ CV_EXPORTS void warpPerspective(int src_type, CV_EXPORTS void cvtBGRtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, int dcn, bool swapBlue); + ElemDepth depth, int scn, int dcn, bool swapBlue); CV_EXPORTS void cvtBGRtoBGR5x5(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, @@ -131,12 +131,12 @@ CV_EXPORTS void cvtBGR5x5toBGR(const uchar * src_data, size_t src_step, CV_EXPORTS void cvtBGRtoGray(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue); + ElemDepth depth, int scn, bool swapBlue); CV_EXPORTS void cvtGraytoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn); + ElemDepth depth, int dcn); CV_EXPORTS void cvtBGR5x5toGray(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, @@ -150,42 +150,42 @@ CV_EXPORTS void cvtGraytoBGR5x5(const uchar * src_data, size_t src_step, CV_EXPORTS void cvtBGRtoYUV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue, bool isCbCr); + ElemDepth depth, int scn, bool swapBlue, bool isCbCr); CV_EXPORTS void cvtYUVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue, bool isCbCr); + ElemDepth depth, int dcn, bool swapBlue, bool isCbCr); CV_EXPORTS void cvtBGRtoXYZ(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue); + ElemDepth depth, int scn, bool swapBlue); CV_EXPORTS void cvtXYZtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue); + ElemDepth depth, int dcn, bool swapBlue); CV_EXPORTS void cvtBGRtoHSV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue, bool isFullRange, bool isHSV); + ElemDepth depth, int scn, bool swapBlue, bool isFullRange, bool isHSV); CV_EXPORTS void cvtHSVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV); + ElemDepth depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV); CV_EXPORTS void cvtBGRtoLab(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue, bool isLab, bool srgb); + ElemDepth depth, int scn, bool swapBlue, bool isLab, bool srgb); CV_EXPORTS void cvtLabtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue, bool isLab, bool srgb); + ElemDepth depth, int dcn, bool swapBlue, bool isLab, bool srgb); CV_EXPORTS void cvtTwoPlaneYUVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, @@ -227,7 +227,7 @@ CV_EXPORTS void cvtMultipliedRGBAtoRGBA(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height); -CV_EXPORTS void integral(int depth, int sdepth, int sqdepth, +CV_EXPORTS void integral(ElemDepth depth, ElemDepth sdepth, ElemDepth sqdepth, const uchar* src, size_t srcstep, uchar* sum, size_t sumstep, uchar* sqsum, size_t sqsumstep, diff --git a/modules/imgproc/perf/opencl/perf_3vs4.cpp b/modules/imgproc/perf/opencl/perf_3vs4.cpp index 69ecc402b0a3..96df859c23e3 100644 --- a/modules/imgproc/perf/opencl/perf_3vs4.cpp +++ b/modules/imgproc/perf/opencl/perf_3vs4.cpp @@ -30,7 +30,8 @@ OCL_PERF_TEST_P(_3vs4_Fixture, Resize, { _3vs4Params params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), depth = CV_MAT_DEPTH(type); + const ElemType type = get<1>(params); + const ElemDepth depth = CV_MAT_DEPTH(type); const int mode = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -48,8 +49,8 @@ OCL_PERF_TEST_P(_3vs4_Fixture, Resize, for (int i = 0; i < 3; ++i) { - dsts[i] = UMat(srcSize, depth); - srcs[i] = UMat(srcSize, depth); + dsts[i] = UMat(srcSize, CV_MAKETYPE(depth, 1)); + srcs[i] = UMat(srcSize, CV_MAKETYPE(depth, 1)); } OCL_TEST_CYCLE() @@ -64,7 +65,7 @@ OCL_PERF_TEST_P(_3vs4_Fixture, Resize, } else if (mode == Convert) { - int type4 = CV_MAKE_TYPE(depth, 4); + ElemType type4 = CV_MAKE_TYPE(depth, 4); UMat src4(srcSize, type4), dst4(srcSize, type4); OCL_TEST_CYCLE() @@ -83,7 +84,8 @@ OCL_PERF_TEST_P(_3vs4_Fixture, Subtract, { _3vs4Params params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), depth = CV_MAT_DEPTH(type); + const ElemType type = get<1>(params); + const ElemDepth depth = CV_MAT_DEPTH(type); const int mode = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -102,8 +104,8 @@ OCL_PERF_TEST_P(_3vs4_Fixture, Subtract, for (int i = 0; i < 3; ++i) { - dsts[i] = UMat(srcSize, depth); - srcs[i] = UMat(srcSize, depth); + dsts[i] = UMat(srcSize, CV_MAKETYPE(depth, 1)); + srcs[i] = UMat(srcSize, CV_MAKETYPE(depth, 1)); } OCL_TEST_CYCLE() @@ -118,7 +120,7 @@ OCL_PERF_TEST_P(_3vs4_Fixture, Subtract, } else if (mode == Convert) { - int type4 = CV_MAKE_TYPE(depth, 4); + ElemType type4 = CV_MAKE_TYPE(depth, 4); UMat src4(srcSize, type4), dst4(srcSize, type4); OCL_TEST_CYCLE() diff --git a/modules/imgproc/perf/opencl/perf_accumulate.cpp b/modules/imgproc/perf/opencl/perf_accumulate.cpp index 0e29baa45dfd..2c705697cb4d 100644 --- a/modules/imgproc/perf/opencl/perf_accumulate.cpp +++ b/modules/imgproc/perf/opencl/perf_accumulate.cpp @@ -60,7 +60,9 @@ OCL_PERF_TEST_P(AccumulateFixture, Accumulate, { Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn); + const ElemType srcType = get<1>(params); + int cn = CV_MAT_CN(srcType); + ElemType dstType = CV_32FC(cn); checkDeviceMaxMemoryAllocSize(srcSize, dstType); @@ -81,7 +83,9 @@ OCL_PERF_TEST_P(AccumulateSquareFixture, AccumulateSquare, { Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn); + const ElemType srcType = get<1>(params); + int cn = CV_MAT_CN(srcType); + ElemType dstType = CV_32FC(cn); checkDeviceMaxMemoryAllocSize(srcSize, dstType); @@ -102,7 +106,9 @@ OCL_PERF_TEST_P(AccumulateProductFixture, AccumulateProduct, { Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn); + const ElemType srcType = get<1>(params); + int cn = CV_MAT_CN(srcType); + ElemType dstType = CV_32FC(cn); checkDeviceMaxMemoryAllocSize(srcSize, dstType); @@ -123,7 +129,9 @@ OCL_PERF_TEST_P(AccumulateWeightedFixture, AccumulateWeighted, { Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int srcType = get<1>(params), cn = CV_MAT_CN(srcType), dstType = CV_32FC(cn); + const ElemType srcType = get<1>(params); + int cn = CV_MAT_CN(srcType); + ElemType dstType = CV_32FC(cn); checkDeviceMaxMemoryAllocSize(srcSize, dstType); diff --git a/modules/imgproc/perf/opencl/perf_blend.cpp b/modules/imgproc/perf/opencl/perf_blend.cpp index 4a42fd12a867..fda7d75a8e80 100644 --- a/modules/imgproc/perf/opencl/perf_blend.cpp +++ b/modules/imgproc/perf/opencl/perf_blend.cpp @@ -60,7 +60,7 @@ OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, ::testing::Combine(OCL_TEST_SIZ { Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int srcType = get<1>(params); + const ElemType srcType = get<1>(params); const double eps = CV_MAT_DEPTH(srcType) <= CV_32S ? 1.0 : 0.2; checkDeviceMaxMemoryAllocSize(srcSize, srcType); diff --git a/modules/imgproc/perf/opencl/perf_filters.cpp b/modules/imgproc/perf/opencl/perf_filters.cpp index ab065d9751b7..978b5110dcf3 100644 --- a/modules/imgproc/perf/opencl/perf_filters.cpp +++ b/modules/imgproc/perf/opencl/perf_filters.cpp @@ -64,7 +64,8 @@ OCL_PERF_TEST_P(BlurFixture, Blur, { const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = get<2>(params), bordertype = BORDER_CONSTANT; + const ElemType type = get<1>(params); + const int ksize = get<2>(params), bordertype = BORDER_CONSTANT; const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -88,7 +89,8 @@ OCL_PERF_TEST_P(SqrBoxFilterFixture, SqrBoxFilter, { const SqrBoxFilterParams params = GetParam(); const Size srcSize = get<0>(params), ksize = get<2>(params); - const int type = get<1>(params), depth = CV_MAT_DEPTH(type), + const ElemType type = get<1>(params); + const ElemDepth depth = CV_MAT_DEPTH(type), ddepth = depth == CV_8U ? CV_32S : CV_32F; const double eps = ddepth == CV_32S ? 0 : 5e-5; @@ -111,7 +113,8 @@ OCL_PERF_TEST_P(LaplacianFixture, Laplacian, { const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = get<2>(params); + const ElemType type = get<1>(params); + const int ksize = get<2>(params); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 2e-5; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -119,7 +122,7 @@ OCL_PERF_TEST_P(LaplacianFixture, Laplacian, UMat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize, 1); + OCL_TEST_CYCLE() cv::Laplacian(src, dst, CV_DEPTH_AUTO, ksize, 1); SANITY_CHECK(dst, eps); } @@ -133,7 +136,8 @@ OCL_PERF_TEST_P(ErodeFixture, Erode, { const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = get<2>(params); + const ElemType type = get<1>(params); + const int ksize = get<2>(params); const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -155,7 +159,8 @@ OCL_PERF_TEST_P(DilateFixture, Dilate, { const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = get<2>(params); + const ElemType type = get<1>(params); + const int ksize = get<2>(params); const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -180,7 +185,8 @@ OCL_PERF_TEST_P(MorphologyExFixture, MorphologyEx, { const MorphologyExParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), op = get<2>(params), ksize = get<3>(params); + const ElemType type = get<1>(params); + const int op = get<2>(params), ksize = get<3>(params); const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize)); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -202,14 +208,15 @@ OCL_PERF_TEST_P(SobelFixture, Sobel, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), dx = 1, dy = 1; + const ElemType type = get<1>(params); + const int dx = 1, dy = 1; checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2); UMat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() cv::Sobel(src, dst, -1, dx, dy); + OCL_TEST_CYCLE() cv::Sobel(src, dst, CV_DEPTH_AUTO, dx, dy); SANITY_CHECK(dst, 1e-6); } @@ -223,7 +230,8 @@ OCL_PERF_TEST_P(ScharrFixture, Scharr, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), dx = 1, dy = 0; + const ElemType type = get<1>(params); + const int dx = 1, dy = 0; const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; checkDeviceMaxMemoryAllocSize(srcSize, type, sizeof(float) * 2); @@ -231,7 +239,7 @@ OCL_PERF_TEST_P(ScharrFixture, Scharr, UMat src(srcSize, type), dst(srcSize, type); declare.in(src, WARMUP_RNG).out(dst); - OCL_TEST_CYCLE() cv::Scharr(src, dst, -1, dx, dy); + OCL_TEST_CYCLE() cv::Scharr(src, dst, CV_DEPTH_AUTO, dx, dy); SANITY_CHECK(dst, eps); } @@ -245,7 +253,8 @@ OCL_PERF_TEST_P(GaussianBlurFixture, GaussianBlur, { const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = get<2>(params); + const ElemType type = get<1>(params); + const int ksize = get<2>(params); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 2 + DBL_EPSILON : 3e-4; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -267,7 +276,8 @@ OCL_PERF_TEST_P(Filter2DFixture, Filter2D, { const FilterParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), ksize = get<2>(params); + const ElemType type = get<1>(params); + const int ksize = get<2>(params); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -277,7 +287,7 @@ OCL_PERF_TEST_P(Filter2DFixture, Filter2D, declare.in(src, WARMUP_RNG).in(kernel).out(dst); randu(kernel, -3.0, 3.0); - OCL_TEST_CYCLE() cv::filter2D(src, dst, -1, kernel); + OCL_TEST_CYCLE() cv::filter2D(src, dst, CV_DEPTH_AUTO, kernel); SANITY_CHECK(dst, eps); } diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp index 4b61976553da..a649892e2999 100644 --- a/modules/imgproc/perf/opencl/perf_imgproc.cpp +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -133,7 +133,8 @@ OCL_PERF_TEST_P(CopyMakeBorderFixture, CopyMakeBorder, { const CopyMakeBorderParamType params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), borderType = get<2>(params); + const ElemType type = get<1>(params); + const int borderType = get<2>(params); checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -156,7 +157,8 @@ OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), borderType = BORDER_REFLECT; + const ElemType type = get<1>(params); + const int borderType = BORDER_REFLECT; const int blockSize = 7, apertureSize = 1 + 2 * 3; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -178,7 +180,8 @@ OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), borderType = BORDER_REFLECT; + const ElemType type = get<1>(params); + const int borderType = BORDER_REFLECT; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -199,7 +202,8 @@ OCL_PERF_TEST_P(PreCornerDetectFixture, PreCornerDetect, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), borderType = BORDER_REFLECT; + const ElemType type = get<1>(params); + const int borderType = BORDER_REFLECT; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -220,11 +224,11 @@ OCL_PERF_TEST_P(IntegralFixture, Integral1, ::testing::Combine(OCL_TEST_SIZES, O { const IntegralParams params = GetParam(); const Size srcSize = get<0>(params); - const int ddepth = get<1>(params); + const ElemDepth ddepth = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, ddepth); - UMat src(srcSize, CV_8UC1), dst(srcSize + Size(1, 1), ddepth); + UMat src(srcSize, CV_8UC1), dst(srcSize + Size(1, 1), CV_MAKETYPE(ddepth, 1)); declare.in(src, WARMUP_RNG).out(dst); OCL_TEST_CYCLE() cv::integral(src, dst, ddepth); @@ -236,11 +240,11 @@ OCL_PERF_TEST_P(IntegralFixture, Integral2, ::testing::Combine(OCL_TEST_SIZES, O { const IntegralParams params = GetParam(); const Size srcSize = get<0>(params); - const int ddepth = get<1>(params); + const ElemDepth ddepth = get<1>(params); checkDeviceMaxMemoryAllocSize(srcSize, ddepth); - UMat src(srcSize, CV_8UC1), sum(srcSize + Size(1, 1), ddepth), sqsum(srcSize + Size(1, 1), CV_32F); + UMat src(srcSize, CV_8UC1), sum(srcSize + Size(1, 1), CV_MAKETYPE(ddepth, 1)), sqsum(srcSize + Size(1, 1), CV_32FC1); declare.in(src, WARMUP_RNG).out(sum, sqsum); OCL_TEST_CYCLE() cv::integral(src, sum, sqsum, ddepth, CV_32F); @@ -261,7 +265,7 @@ OCL_PERF_TEST_P(ThreshFixture, Threshold, { const ThreshParams params = GetParam(); const Size srcSize = get<0>(params); - const int srcType = get<1>(params); + const ElemType srcType = get<1>(params); const int threshType = get<2>(params); const double maxValue = 220.0, threshold = 50; diff --git a/modules/imgproc/perf/opencl/perf_imgwarp.cpp b/modules/imgproc/perf/opencl/perf_imgwarp.cpp index d13b54bdced0..60a95ba388ea 100644 --- a/modules/imgproc/perf/opencl/perf_imgwarp.cpp +++ b/modules/imgproc/perf/opencl/perf_imgwarp.cpp @@ -67,11 +67,12 @@ OCL_PERF_TEST_P(WarpAffineFixture, WarpAffine, { cos(CV_PI / 6), -sin(CV_PI / 6), 100.0 }, { sin(CV_PI / 6), cos(CV_PI / 6) , -100.0 } }; - Mat M(2, 3, CV_64F, (void *)coeffs); + Mat M(2, 3, CV_64FC1, (void *)coeffs); const WarpAffineParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), interpolation = get<2>(params); + const ElemType type = get<1>(params); + const int interpolation = get<2>(params); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : interpolation == INTER_CUBIC ? 2e-3 : 1e-4; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -99,11 +100,12 @@ OCL_PERF_TEST_P(WarpPerspectiveFixture, WarpPerspective, {sin(CV_PI / 6), cos(CV_PI / 6), -100.0}, {0.0, 0.0, 1.0} }; - Mat M(3, 3, CV_64F, (void *)coeffs); + Mat M(3, 3, CV_64FC1, (void *)coeffs); const WarpPerspectiveParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), interpolation = get<2>(params); + const ElemType type = get<1>(params); + const int interpolation = get<2>(params); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4; checkDeviceMaxMemoryAllocSize(srcSize, type); @@ -128,7 +130,8 @@ OCL_PERF_TEST_P(ResizeFixture, Resize, { const ResizeParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), interType = get<2>(params); + const ElemType type = get<1>(params); + const int interType = get<2>(params); double scale = get<3>(params); const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale)); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4; @@ -152,7 +155,7 @@ OCL_PERF_TEST_P(ResizeAreaFixture, Resize, { const ResizeAreaParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); double scale = get<2>(params); const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale)); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4; @@ -176,7 +179,7 @@ OCL_PERF_TEST_P(ResizeLinearExactFixture, Resize, { const ResizeAreaParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); double scale = get<2>(params); const Size dstSize(cvRound(srcSize.width * scale), cvRound(srcSize.height * scale)); const double eps = 1e-4; @@ -203,7 +206,8 @@ OCL_PERF_TEST_P(RemapFixture, Remap, { const RemapParams params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), interpolation = get<2>(params), borderMode = BORDER_CONSTANT; + const ElemType type = get<1>(params); + const int interpolation = get<2>(params), borderMode = BORDER_CONSTANT; //const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-4; checkDeviceMaxMemoryAllocSize(srcSize, type); diff --git a/modules/imgproc/perf/opencl/perf_matchTemplate.cpp b/modules/imgproc/perf/opencl/perf_matchTemplate.cpp index 735735f002f3..53fd9fabe000 100644 --- a/modules/imgproc/perf/opencl/perf_matchTemplate.cpp +++ b/modules/imgproc/perf/opencl/perf_matchTemplate.cpp @@ -23,10 +23,10 @@ OCL_PERF_TEST_P(ImgSize_TmplSize_Method_MatType, MatchTemplate, const ImgSize_TmplSize_Method_MatType_t params = GetParam(); const Size imgSz = get<0>(params), tmplSz = get<1>(params); const int method = get<2>(params); - int type = get<3>(GetParam()); + ElemType type = get<3>(GetParam()); UMat img(imgSz, type), tmpl(tmplSz, type); - UMat result(imgSz - tmplSz + Size(1, 1), CV_32F); + UMat result(imgSz - tmplSz + Size(1, 1), CV_32FC1); declare.in(img, tmpl, WARMUP_RNG).out(result); @@ -52,11 +52,11 @@ OCL_PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params), templSize(5, 5); - const int type = get<1>(params); + const ElemType type = get<1>(params); UMat src(srcSize, type), templ(templSize, type); const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1); - UMat dst(dstSize, CV_32F); + UMat dst(dstSize, CV_32FC1); declare.in(src, templ, WARMUP_RNG).out(dst); diff --git a/modules/imgproc/perf/opencl/perf_pyramid.cpp b/modules/imgproc/perf/opencl/perf_pyramid.cpp index 15710bc686a4..dc1adbde0ea4 100644 --- a/modules/imgproc/perf/opencl/perf_pyramid.cpp +++ b/modules/imgproc/perf/opencl/perf_pyramid.cpp @@ -61,7 +61,7 @@ OCL_PERF_TEST_P(PyrDownFixture, PyrDown, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const Size dstSize((srcSize.height + 1) >> 1, (srcSize.width + 1) >> 1); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; @@ -85,7 +85,7 @@ OCL_PERF_TEST_P(PyrUpFixture, PyrUp, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); const Size dstSize(srcSize.height << 1, srcSize.width << 1); const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; @@ -109,7 +109,8 @@ OCL_PERF_TEST_P(BuildPyramidFixture, BuildPyramid, { const Size_MatType_t params = GetParam(); const Size srcSize = get<0>(params); - const int type = get<1>(params), maxLevel = 5; + const ElemType type = get<1>(params); + const int maxLevel = 5; const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5; checkDeviceMaxMemoryAllocSize(srcSize, type); diff --git a/modules/imgproc/perf/perf_accumulate.cpp b/modules/imgproc/perf/perf_accumulate.cpp index f9cd80af714e..eaaa21964a62 100644 --- a/modules/imgproc/perf/perf_accumulate.cpp +++ b/modules/imgproc/perf/perf_accumulate.cpp @@ -22,7 +22,7 @@ PERF_TEST_P( Size_MatType, Accumulate, #endif { Size sz = get<0>(GetParam()); - int dstType = get<1>(GetParam()); + ElemType dstType = get<1>(GetParam()); Mat src(sz, CV_8UC1); Mat dst(sz, dstType); @@ -52,7 +52,7 @@ PERF_TEST_P( Size_MatType, AccumulateSquare, #endif { Size sz = get<0>(GetParam()); - int dstType = get<1>(GetParam()); + ElemType dstType = get<1>(GetParam()); Mat src(sz, CV_8UC1); Mat dst(sz, dstType); @@ -82,7 +82,7 @@ PERF_TEST_P( Size_MatType, AccumulateWeighted, #endif { Size sz = get<0>(GetParam()); - int dstType = get<1>(GetParam()); + ElemType dstType = get<1>(GetParam()); Mat src(sz, CV_8UC1); Mat dst(sz, dstType); diff --git a/modules/imgproc/perf/perf_bilateral.cpp b/modules/imgproc/perf/perf_bilateral.cpp index ed6a741e0865..2f076602f4f3 100644 --- a/modules/imgproc/perf/perf_bilateral.cpp +++ b/modules/imgproc/perf/perf_bilateral.cpp @@ -5,20 +5,19 @@ namespace opencv_test { -CV_ENUM(Mat_Type, CV_8UC1, CV_8UC3, CV_32FC1, CV_32FC3) - -typedef TestBaseWithParam< tuple > TestBilateralFilter; +typedef TestBaseWithParam< tuple > TestBilateralFilter; PERF_TEST_P( TestBilateralFilter, BilateralFilter, Combine( Values( szVGA, sz1080p ), // image size Values( 3, 5 ), // d - Mat_Type::all() // image type + Values(CV_8UC1, CV_8UC3, CV_32FC1, CV_32FC3) // image type ) ) { Size sz; - int d, type; + int d; + ElemType type; const double sigmaColor = 1., sigmaSpace = 1.; sz = get<0>(GetParam()); diff --git a/modules/imgproc/perf/perf_blur.cpp b/modules/imgproc/perf/perf_blur.cpp index 7503eb932188..d7469751d60f 100644 --- a/modules/imgproc/perf/perf_blur.cpp +++ b/modules/imgproc/perf/perf_blur.cpp @@ -17,7 +17,7 @@ PERF_TEST_P(Size_MatType_kSize, medianBlur, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); int ksize = get<2>(GetParam()); Mat src(size, type); @@ -54,7 +54,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, gaussianBlur3x3, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); BorderType3x3 btype = get<2>(GetParam()); Mat src(size, type); @@ -76,7 +76,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, blur3x3, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); BorderType3x3 btype = get<2>(GetParam()); Mat src(size, type); @@ -98,7 +98,7 @@ PERF_TEST_P(Size_MatType_BorderType, blur16x16, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); BorderType btype = get<2>(GetParam()); double eps = 1e-3; @@ -123,7 +123,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, box3x3, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); BorderType3x3 btype = get<2>(GetParam()); Mat src(size, type); @@ -131,7 +131,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, box3x3, declare.in(src, WARMUP_RNG).out(dst); - TEST_CYCLE() boxFilter(src, dst, -1, Size(3,3), Point(-1,-1), false, btype); + TEST_CYCLE() boxFilter(src, dst, CV_DEPTH_AUTO, Size(3, 3), Point(-1, -1), false, btype); SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } @@ -153,7 +153,7 @@ PERF_TEST_P(Size_ksize_BorderType, box_CV8U_CV16U, declare.in(src, WARMUP_RNG).out(dst); - TEST_CYCLE() boxFilter(src, dst, CV_16UC1, Size(ksize, ksize), Point(-1,-1), false, btype); + TEST_CYCLE() boxFilter(src, dst, CV_16U, Size(ksize, ksize), Point(-1,-1), false, btype); SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } @@ -167,7 +167,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, box3x3_inplace, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); BorderType3x3 btype = get<2>(GetParam()); Mat src(size, type); @@ -179,7 +179,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, box3x3_inplace, { src.copyTo(dst); startTimer(); - boxFilter(dst, dst, -1, Size(3,3), Point(-1,-1), false, btype); + boxFilter(dst, dst, CV_DEPTH_AUTO, Size(3, 3), Point(-1, -1), false, btype); stopTimer(); } @@ -195,7 +195,7 @@ PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); BorderType btype = get<2>(GetParam()); Mat src(size, type); @@ -217,7 +217,7 @@ PERF_TEST_P(Size_MatType_BorderType, blur5x5, ) { Size size = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); BorderType btype = get<2>(GetParam()); Mat src(size, type); diff --git a/modules/imgproc/perf/perf_distanceTransform.cpp b/modules/imgproc/perf/perf_distanceTransform.cpp index e88779c8add8..3ec4c287b5b0 100644 --- a/modules/imgproc/perf/perf_distanceTransform.cpp +++ b/modules/imgproc/perf/perf_distanceTransform.cpp @@ -7,10 +7,9 @@ namespace opencv_test { CV_ENUM(DistanceType, DIST_L1, DIST_L2 , DIST_C) CV_ENUM(MaskSize, DIST_MASK_3, DIST_MASK_5, DIST_MASK_PRECISE) -CV_ENUM(DstType, CV_8U, CV_32F) CV_ENUM(LabelType, DIST_LABEL_CCOMP, DIST_LABEL_PIXEL) -typedef tuple SrcSize_DistType_MaskSize_DstType; +typedef tuple SrcSize_DistType_MaskSize_DstType; typedef tuple SrcSize_DistType_MaskSize_LabelType; typedef perf::TestBaseWithParam DistanceTransform_Test; typedef perf::TestBaseWithParam DistanceTransform_NeedLabels_Test; @@ -20,16 +19,16 @@ PERF_TEST_P(DistanceTransform_Test, distanceTransform, testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)), DistanceType::all(), MaskSize::all(), - DstType::all() + Values(CV_8U, CV_32F) ) ) { Size srcSize = get<0>(GetParam()); int distanceType = get<1>(GetParam()); int maskSize = get<2>(GetParam()); - int dstType = get<3>(GetParam()); + ElemType dstType = get<3>(GetParam()); - Mat src(srcSize, CV_8U); + Mat src(srcSize, CV_8UC1); Mat dst(srcSize, dstType); declare @@ -58,9 +57,9 @@ PERF_TEST_P(DistanceTransform_NeedLabels_Test, distanceTransform_NeedLabels, int maskSize = get<2>(GetParam()); int labelType = get<3>(GetParam()); - Mat src(srcSize, CV_8U); - Mat label(srcSize, CV_32S); - Mat dst(srcSize, CV_32F); + Mat src(srcSize, CV_8UC1); + Mat label(srcSize, CV_32SC1); + Mat dst(srcSize, CV_32FC1); declare .in(src, WARMUP_RNG) diff --git a/modules/imgproc/perf/perf_filter2d.cpp b/modules/imgproc/perf/perf_filter2d.cpp index 6095eaad2f04..4e275c9f159e 100644 --- a/modules/imgproc/perf/perf_filter2d.cpp +++ b/modules/imgproc/perf/perf_filter2d.cpp @@ -34,7 +34,7 @@ PERF_TEST_P( TestFilter2d, Filter2d, declare.in(src, WARMUP_RNG).out(dst).time(20); - TEST_CYCLE() cv::filter2D(src, dst, CV_8UC4, kernel, Point(1, 1), 0., borderMode); + TEST_CYCLE() cv::filter2D(src, dst, CV_8U, kernel, Point(1, 1), 0., borderMode); SANITY_CHECK(dst, 1); } @@ -61,7 +61,7 @@ PERF_TEST_P(TestFilter2d, Filter2d_ovx, declare.in(src, WARMUP_RNG).out(dst).time(20); - TEST_CYCLE() cv::filter2D(src, dst, CV_16SC1, kernel, Point(kSize / 2, kSize / 2), 0., borderMode); + TEST_CYCLE() cv::filter2D(src, dst, CV_16S, kernel, Point(kSize / 2, kSize / 2), 0., borderMode); SANITY_CHECK(dst, 1); } diff --git a/modules/imgproc/perf/perf_floodfill.cpp b/modules/imgproc/perf/perf_floodfill.cpp index 4a02ec8a5890..8b72dacb0c48 100644 --- a/modules/imgproc/perf/perf_floodfill.cpp +++ b/modules/imgproc/perf/perf_floodfill.cpp @@ -9,7 +9,7 @@ namespace opencv_test { -typedef tuple Size_Source_Fl_t; +typedef tuple Size_Source_Fl_t; typedef perf::TestBaseWithParam Size_Source_Fl; PERF_TEST_P(Size_Source_Fl, floodFill1, Combine( @@ -29,7 +29,7 @@ PERF_TEST_P(Size_Source_Fl, floodFill1, Combine( int connectivity = get<2>(GetParam()); int colorType = get<3>(GetParam()); int modeType = get<4>(GetParam()); - int imdepth = get<5>(GetParam()); + ElemDepth imdepth = get<5>(GetParam()); Mat image0 = imread(filename, colorType); diff --git a/modules/imgproc/perf/perf_histogram.cpp b/modules/imgproc/perf/perf_histogram.cpp index eca97e3c541b..e37b55306fdd 100644 --- a/modules/imgproc/perf/perf_histogram.cpp +++ b/modules/imgproc/perf/perf_histogram.cpp @@ -103,7 +103,7 @@ PERF_TEST_P(MatSize, equalizeHist, ) { Size size = GetParam(); - Mat source(size.height, size.width, CV_8U); + Mat source(size.height, size.width, CV_8UC1); Mat destination; declare.in(source, WARMUP_RNG); diff --git a/modules/imgproc/perf/perf_integral.cpp b/modules/imgproc/perf/perf_integral.cpp index 4b2ba971483b..0ab2fcbcb555 100644 --- a/modules/imgproc/perf/perf_integral.cpp +++ b/modules/imgproc/perf/perf_integral.cpp @@ -17,11 +17,11 @@ PERF_TEST_P(Size_MatType_OutMatDepth, integral, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); - int sdepth = get<2>(GetParam()); + ElemType matType = get<1>(GetParam()); + ElemDepth sdepth = get<2>(GetParam()); Mat src(sz, matType); - Mat sum(sz, sdepth); + Mat sum(sz, CV_MAKETYPE(sdepth, 1)); declare.in(src, WARMUP_RNG).out(sum); @@ -39,12 +39,12 @@ PERF_TEST_P(Size_MatType_OutMatDepth, integral_sqsum, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); - int sdepth = get<2>(GetParam()); + ElemType matType = get<1>(GetParam()); + ElemDepth sdepth = get<2>(GetParam()); Mat src(sz, matType); - Mat sum(sz, sdepth); - Mat sqsum(sz, sdepth); + Mat sum(sz, CV_MAKETYPE(sdepth, 1)); + Mat sqsum(sz, CV_MAKETYPE(sdepth, 1)); declare.in(src, WARMUP_RNG).out(sum, sqsum); declare.time(100); @@ -64,13 +64,13 @@ PERF_TEST_P( Size_MatType_OutMatDepth, integral_sqsum_tilted, ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); - int sdepth = get<2>(GetParam()); + ElemType matType = get<1>(GetParam()); + ElemDepth sdepth = get<2>(GetParam()); Mat src(sz, matType); - Mat sum(sz, sdepth); - Mat sqsum(sz, sdepth); - Mat tilted(sz, sdepth); + Mat sum(sz, CV_MAKETYPE(sdepth, 1)); + Mat sqsum(sz, CV_MAKETYPE(sdepth, 1)); + Mat tilted(sz, CV_MAKETYPE(sdepth, 1)); declare.in(src, WARMUP_RNG).out(sum, sqsum, tilted); declare.time(100); diff --git a/modules/imgproc/perf/perf_matchTemplate.cpp b/modules/imgproc/perf/perf_matchTemplate.cpp index 9a50c4cc5d01..5c292e3f3a20 100644 --- a/modules/imgproc/perf/perf_matchTemplate.cpp +++ b/modules/imgproc/perf/perf_matchTemplate.cpp @@ -27,7 +27,7 @@ PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateSmall, Mat img(imgSz, CV_8UC1); Mat tmpl(tmplSz, CV_8UC1); - Mat result(imgSz - tmplSz + Size(1,1), CV_32F); + Mat result(imgSz - tmplSz + Size(1,1), CV_32FC1); declare .in(img, WARMUP_RNG) @@ -61,7 +61,7 @@ PERF_TEST_P(ImgSize_TmplSize_Method, matchTemplateBig, Mat img(imgSz, CV_8UC1); Mat tmpl(tmplSz, CV_8UC1); - Mat result(imgSz - tmplSz + Size(1,1), CV_32F); + Mat result(imgSz - tmplSz + Size(1,1), CV_32FC1); declare .in(img, WARMUP_RNG) diff --git a/modules/imgproc/perf/perf_moments.cpp b/modules/imgproc/perf/perf_moments.cpp index 7f52e70b7690..02cd7422390a 100644 --- a/modules/imgproc/perf/perf_moments.cpp +++ b/modules/imgproc/perf/perf_moments.cpp @@ -24,13 +24,13 @@ PERF_TEST_P(MomentsFixture_val, Moments1, const bool binaryImage = get<2>(params); cv::Moments m; - Mat src(srcSize, srcDepth); + Mat src(srcSize, CV_MAKETYPE(srcDepth, 1)); declare.in(src, WARMUP_RNG); TEST_CYCLE() m = cv::moments(src, binaryImage); int len = (int)sizeof(cv::Moments) / sizeof(double); - cv::Mat mat(1, len, CV_64F, (void*)&m); + cv::Mat mat(1, len, CV_64FC1, (void*)&m); //adding 1 to moments to avoid accidental tests fail on values close to 0 mat += 1; diff --git a/modules/imgproc/perf/perf_morph.cpp b/modules/imgproc/perf/perf_morph.cpp index dc9e975a21fb..0461113a06a7 100644 --- a/modules/imgproc/perf/perf_morph.cpp +++ b/modules/imgproc/perf/perf_morph.cpp @@ -11,7 +11,7 @@ namespace opencv_test { PERF_TEST_P(Size_MatType, erode, TYPICAL_MATS_MORPH) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat src(sz, type); Mat dst(sz, type); @@ -27,7 +27,7 @@ PERF_TEST_P(Size_MatType, erode, TYPICAL_MATS_MORPH) PERF_TEST_P(Size_MatType, dilate, TYPICAL_MATS_MORPH) { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); Mat src(sz, type); Mat dst(sz, type); diff --git a/modules/imgproc/perf/perf_pyramids.cpp b/modules/imgproc/perf/perf_pyramids.cpp index 22c3fa906451..8c646070b95c 100644 --- a/modules/imgproc/perf/perf_pyramids.cpp +++ b/modules/imgproc/perf/perf_pyramids.cpp @@ -12,7 +12,7 @@ PERF_TEST_P(Size_MatType, pyrDown, testing::Combine( ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5; perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE; @@ -33,7 +33,7 @@ PERF_TEST_P(Size_MatType, pyrDown_ovx, testing::Combine( ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5; perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE; @@ -54,7 +54,7 @@ PERF_TEST_P(Size_MatType, pyrUp, testing::Combine( ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5; perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE; @@ -75,7 +75,7 @@ PERF_TEST_P(Size_MatType, buildPyramid, testing::Combine( ) { Size sz = get<0>(GetParam()); - int matType = get<1>(GetParam()); + ElemType matType = get<1>(GetParam()); int maxLevel = 5; const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5; perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE; diff --git a/modules/imgproc/perf/perf_remap.cpp b/modules/imgproc/perf/perf_remap.cpp index bd2129d233e4..0df223208bed 100644 --- a/modules/imgproc/perf/perf_remap.cpp +++ b/modules/imgproc/perf/perf_remap.cpp @@ -19,7 +19,8 @@ PERF_TEST_P( TestRemap, Remap, ) { Size sz; - int src_type, map1_type, inter_type; + ElemType src_type, map1_type; + int inter_type; sz = get<0>(GetParam()); src_type = get<1>(GetParam()); diff --git a/modules/imgproc/perf/perf_resize.cpp b/modules/imgproc/perf/perf_resize.cpp index 07051085039a..85f0e9e8d760 100644 --- a/modules/imgproc/perf/perf_resize.cpp +++ b/modules/imgproc/perf/perf_resize.cpp @@ -21,7 +21,7 @@ PERF_TEST_P(MatInfo_Size_Size, resizeUpLinear, ) ) { - int matType = get<0>(GetParam()); + ElemType matType = get<0>(GetParam()); Size from = get<1>(GetParam()); Size to = get<2>(GetParam()); @@ -63,7 +63,7 @@ PERF_TEST_P(MatInfo_Size_Size, resizeDownLinear, ) ) { - int matType = get<0>(GetParam()); + ElemType matType = get<0>(GetParam()); Size from = get<1>(GetParam()); Size to = get<2>(GetParam()); @@ -92,7 +92,7 @@ PERF_TEST_P(MatInfo_Size_Scale, ResizeAreaFast, ) ) { - int matType = get<0>(GetParam()); + ElemType matType = get<0>(GetParam()); Size from = get<1>(GetParam()); int scale = get<2>(GetParam()); @@ -122,7 +122,7 @@ PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea, ) ) { - int matType = get<0>(GetParam()); + ElemType matType = get<0>(GetParam()); Size from = get<1>(GetParam()); double scale = get<2>(GetParam()); @@ -150,7 +150,7 @@ PERF_TEST_P(MatInfo_Size_Scale_NN, ResizeNN, ) ) { - int matType = get<0>(GetParam()); + ElemType matType = get<0>(GetParam()); Size from = get<1>(GetParam()); double scale = get<2>(GetParam()); diff --git a/modules/imgproc/perf/perf_sepfilters.cpp b/modules/imgproc/perf/perf_sepfilters.cpp index 480aab9f2014..3b9612fe4e25 100644 --- a/modules/imgproc/perf/perf_sepfilters.cpp +++ b/modules/imgproc/perf/perf_sepfilters.cpp @@ -13,22 +13,22 @@ CV_ENUM(BorderType3x3ROI, BORDER_DEFAULT, BORDER_REPLICATE|BORDER_ISOLATED, BORD CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT101) CV_ENUM(BorderTypeROI, BORDER_DEFAULT, BORDER_REPLICATE|BORDER_ISOLATED, BORDER_CONSTANT|BORDER_ISOLATED, BORDER_REFLECT|BORDER_ISOLATED, BORDER_REFLECT101|BORDER_ISOLATED) -typedef tuple, BorderType3x3> Size_MatType_dx_dy_Border3x3_t; -typedef perf::TestBaseWithParam Size_MatType_dx_dy_Border3x3; +typedef tuple, BorderType3x3> Size_MatDepth_dx_dy_Border3x3_t; +typedef perf::TestBaseWithParam Size_MatDepth_dx_dy_Border3x3; -typedef tuple, BorderType3x3ROI> Size_MatType_dx_dy_Border3x3ROI_t; -typedef perf::TestBaseWithParam Size_MatType_dx_dy_Border3x3ROI; +typedef tuple, BorderType3x3ROI> Size_MatDepth_dx_dy_Border3x3ROI_t; +typedef perf::TestBaseWithParam Size_MatDepth_dx_dy_Border3x3ROI; -typedef tuple, BorderType> Size_MatType_dx_dy_Border5x5_t; -typedef perf::TestBaseWithParam Size_MatType_dx_dy_Border5x5; +typedef tuple, BorderType> Size_MatDepth_dx_dy_Border5x5_t; +typedef perf::TestBaseWithParam Size_MatDepth_dx_dy_Border5x5; -typedef tuple, BorderTypeROI> Size_MatType_dx_dy_Border5x5ROI_t; -typedef perf::TestBaseWithParam Size_MatType_dx_dy_Border5x5ROI; +typedef tuple, BorderTypeROI> Size_MatDepth_dx_dy_Border5x5ROI_t; +typedef perf::TestBaseWithParam Size_MatDepth_dx_dy_Border5x5ROI; /**************** Sobel ********************/ -PERF_TEST_P(Size_MatType_dx_dy_Border3x3, sobelFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border3x3, sobelFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -38,13 +38,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, sobelFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderType3x3 border = get<3>(GetParam()); - Mat src(size, CV_8U); - Mat dst(size, ddepth); + Mat src(size, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); declare.in(src, WARMUP_RNG).out(dst); @@ -53,7 +53,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, sobelFilter, SANITY_CHECK(dst); } -PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, sobelFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border3x3ROI, sobelFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -63,13 +63,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, sobelFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderType3x3ROI border = get<3>(GetParam()); - Mat src(size.height + 10, size.width + 10, CV_8U); - Mat dst(size, ddepth); + Mat src(size.height + 10, size.width + 10, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); warmup(src, WARMUP_RNG); src = src(Range(5, 5 + size.height), Range(5, 5 + size.width)); @@ -81,7 +81,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, sobelFilter, SANITY_CHECK(dst); } -PERF_TEST_P(Size_MatType_dx_dy_Border5x5, sobelFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border5x5, sobelFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -91,13 +91,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border5x5, sobelFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderType border = get<3>(GetParam()); - Mat src(size, CV_8U); - Mat dst(size, ddepth); + Mat src(size, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); declare.in(src, WARMUP_RNG).out(dst); @@ -106,7 +106,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border5x5, sobelFilter, SANITY_CHECK(dst); } -PERF_TEST_P(Size_MatType_dx_dy_Border5x5ROI, sobelFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border5x5ROI, sobelFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -116,13 +116,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border5x5ROI, sobelFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderTypeROI border = get<3>(GetParam()); - Mat src(size.height + 10, size.width + 10, CV_8U); - Mat dst(size, ddepth); + Mat src(size.height + 10, size.width + 10, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); warmup(src, WARMUP_RNG); src = src(Range(5, 5 + size.height), Range(5, 5 + size.width)); @@ -136,7 +136,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border5x5ROI, sobelFilter, /**************** Scharr ********************/ -PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border3x3, scharrFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -146,13 +146,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderType3x3 border = get<3>(GetParam()); - Mat src(size, CV_8U); - Mat dst(size, ddepth); + Mat src(size, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); declare.in(src, WARMUP_RNG).out(dst); @@ -161,7 +161,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrFilter, SANITY_CHECK(dst); } -PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border3x3ROI, scharrFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -171,13 +171,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderType3x3ROI border = get<3>(GetParam()); - Mat src(size.height + 10, size.width + 10, CV_8U); - Mat dst(size, ddepth); + Mat src(size.height + 10, size.width + 10, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); warmup(src, WARMUP_RNG); src = src(Range(5, 5 + size.height), Range(5, 5 + size.width)); @@ -189,7 +189,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrFilter, SANITY_CHECK(dst); } -PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrViaSobelFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border3x3, scharrViaSobelFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -199,13 +199,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrViaSobelFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderType3x3 border = get<3>(GetParam()); - Mat src(size, CV_8U); - Mat dst(size, ddepth); + Mat src(size, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); declare.in(src, WARMUP_RNG).out(dst); @@ -214,7 +214,7 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3, scharrViaSobelFilter, SANITY_CHECK(dst); } -PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrViaSobelFilter, +PERF_TEST_P(Size_MatDepth_dx_dy_Border3x3ROI, scharrViaSobelFilter, testing::Combine( testing::Values(FILTER_SRC_SIZES), testing::Values(CV_16S, CV_32F), @@ -224,13 +224,13 @@ PERF_TEST_P(Size_MatType_dx_dy_Border3x3ROI, scharrViaSobelFilter, ) { Size size = get<0>(GetParam()); - int ddepth = get<1>(GetParam()); + ElemDepth ddepth = get<1>(GetParam()); int dx = get<0>(get<2>(GetParam())); int dy = get<1>(get<2>(GetParam())); BorderType3x3ROI border = get<3>(GetParam()); - Mat src(size.height + 10, size.width + 10, CV_8U); - Mat dst(size, ddepth); + Mat src(size.height + 10, size.width + 10, CV_8UC1); + Mat dst(size, CV_MAKETYPE(ddepth, 1)); warmup(src, WARMUP_RNG); src = src(Range(5, 5 + size.height), Range(5, 5 + size.width)); diff --git a/modules/imgproc/perf/perf_threshold.cpp b/modules/imgproc/perf/perf_threshold.cpp index ab1d14fbf8bd..165d40fa97c4 100644 --- a/modules/imgproc/perf/perf_threshold.cpp +++ b/modules/imgproc/perf/perf_threshold.cpp @@ -20,7 +20,7 @@ PERF_TEST_P(Size_MatType_ThreshType, threshold, { Size sz = get<0>(GetParam()); - int type = get<1>(GetParam()); + ElemType type = get<1>(GetParam()); ThreshType threshType = get<2>(GetParam()); Mat src(sz, type); @@ -80,7 +80,7 @@ PERF_TEST_P(Size_AdaptThreshType_AdaptThreshMethod_BlockSize_Delta, adaptiveThre double maxValue = theRNG().uniform(1, 254); - int type = CV_8UC1; + ElemType type = CV_8UC1; Mat src_full(cv::Size(sz.width + 2, sz.height + 2), type); Mat src = src_full(cv::Rect(1, 1, sz.width, sz.height)); diff --git a/modules/imgproc/perf/perf_warp.cpp b/modules/imgproc/perf/perf_warp.cpp index cb974e9f09fd..a25f4b693d23 100644 --- a/modules/imgproc/perf/perf_warp.cpp +++ b/modules/imgproc/perf/perf_warp.cpp @@ -164,7 +164,8 @@ PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear, ) { Size size; - int borderMode, interType, type; + int borderMode, interType; + ElemType type; size = get<0>(GetParam()); interType = get<1>(GetParam()); borderMode = get<2>(GetParam()); @@ -210,7 +211,7 @@ PERF_TEST_P( TestRemap, remap, ) ) { - int type = get<0>(GetParam()); + ElemType type = get<0>(GetParam()); Size size = get<1>(GetParam()); int interpolationType = get<2>(GetParam()); int borderMode = get<3>(GetParam()); @@ -219,8 +220,8 @@ PERF_TEST_P( TestRemap, remap, unsigned int width = size.width; Mat source(height, width, type); Mat destination; - Mat map_x(height, width, CV_32F); - Mat map_y(height, width, CV_32F); + Mat map_x(height, width, CV_32FC1); + Mat map_y(height, width, CV_32FC1); declare.in(source, WARMUP_RNG); diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp index 39e942e8cd61..00829a3620cf 100644 --- a/modules/imgproc/src/accum.cpp +++ b/modules/imgproc/src/accum.cpp @@ -88,7 +88,7 @@ static AccWFunc accWTab[] = (AccWFunc)accW_64f }; -inline int getAccTabIdx(int sdepth, int ddepth) +inline int getAccTabIdx(ElemDepth sdepth, ElemDepth ddepth) { return sdepth == CV_8U && ddepth == CV_32F ? 0 : sdepth == CV_8U && ddepth == CV_64F ? 1 : @@ -117,7 +117,10 @@ static bool ocl_accumulate( InputArray _src, InputArray _src2, InputOutputArray const ocl::Device & dev = ocl::Device::getDefault(); bool haveMask = !_mask.empty(), doubleSupport = dev.doubleFPConfig() > 0; - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype), ddepth = _dst.depth(); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + ElemDepth ddepth = _dst.depth(); int kercn = haveMask ? cn : ocl::predictOptimalVectorWidthMax(_src, _src2, _dst), rowsPerWI = dev.isIntel() ? 4 : 1; if (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F)) @@ -172,8 +175,11 @@ static bool ipp_accumulate(InputArray _src, InputOutputArray _dst, InputArray _m { CV_INSTRUMENT_REGION_IPP(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); @@ -309,11 +315,15 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); + int dcn = CV_MAT_CN(dtype); CV_Assert( _src.sameSize(_dst) && dcn == scn ); - CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); + CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8UC1) ); CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), ocl_accumulate(_src, noArray(), _dst, 0.0, _mask, ACCUMULATE)) @@ -347,8 +357,11 @@ static bool ipp_accumulate_square(InputArray _src, InputOutputArray _dst, InputA { CV_INSTRUMENT_REGION_IPP(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); @@ -408,11 +421,15 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); + int dcn = CV_MAT_CN(dtype); CV_Assert( _src.sameSize(_dst) && dcn == scn ); - CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); + CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8UC1) ); CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), ocl_accumulate(_src, noArray(), _dst, 0.0, _mask, ACCUMULATE_SQUARE)) @@ -446,8 +463,11 @@ static bool ipp_accumulate_product(InputArray _src1, InputArray _src2, { CV_INSTRUMENT_REGION_IPP(); - int stype = _src1.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); + ElemType stype = _src1.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); Mat src1 = _src1.getMat(), src2 = _src2.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); @@ -513,12 +533,16 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2, { CV_INSTRUMENT_REGION(); - int stype = _src1.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); + ElemType stype = _src1.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); + int dcn = CV_MAT_CN(dtype); CV_Assert( _src1.sameSize(_src2) && stype == _src2.type() ); CV_Assert( _src1.sameSize(_dst) && dcn == scn ); - CV_Assert( _mask.empty() || (_src1.sameSize(_mask) && _mask.type() == CV_8U) ); + CV_Assert( _mask.empty() || (_src1.sameSize(_mask) && _mask.type() == CV_8UC1) ); CV_OCL_RUN(_src1.dims() <= 2 && _dst.isUMat(), ocl_accumulate(_src1, _src2, _dst, 0.0, _mask, ACCUMULATE_PRODUCT)) @@ -549,8 +573,11 @@ static bool ipp_accumulate_weighted( InputArray _src, InputOutputArray _dst, { CV_INSTRUMENT_REGION_IPP(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); @@ -613,11 +640,15 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst, { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); - int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int scn = CV_MAT_CN(stype); + ElemType dtype = _dst.type(); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); + int dcn = CV_MAT_CN(dtype); CV_Assert( _src.sameSize(_dst) && dcn == scn ); - CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); + CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8UC1) ); CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), ocl_accumulate(_src, noArray(), _dst, alpha, _mask, ACCUMULATE_WEIGHTED)) diff --git a/modules/imgproc/src/blend.cpp b/modules/imgproc/src/blend.cpp index 1a4ad0d5255b..544215a9f18a 100644 --- a/modules/imgproc/src/blend.cpp +++ b/modules/imgproc/src/blend.cpp @@ -349,7 +349,9 @@ class BlendLinearInvoker : static bool ocl_blendLinear( InputArray _src1, InputArray _src2, InputArray _weights1, InputArray _weights2, OutputArray _dst ) { - int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src1.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); char cvt[30]; ocl::Kernel k("blendLinear", ocl::imgproc::blend_linear_oclsrc, @@ -377,7 +379,8 @@ void cv::blendLinear( InputArray _src1, InputArray _src2, InputArray _weights1, { CV_INSTRUMENT_REGION(); - int type = _src1.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src1.type(); + ElemDepth depth = CV_MAT_DEPTH(type); Size size = _src1.size(); CV_Assert(depth == CV_8U || depth == CV_32F); diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 6b54807db6d9..59c09f017154 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -199,7 +199,7 @@ static bool ocl_Canny(InputArray _src, const UMat& dx_, const UMat& dy_, OutputA return false; UMat src = _src.getUMat(); - map.create(size, CV_32S); + map.create(size, CV_32SC1); with_sobel.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnlyNoSize(map), (float) low, (float) high); @@ -242,7 +242,7 @@ static bool ocl_Canny(InputArray _src, const UMat& dx_, const UMat& dy_, OutputA if (without_sobel.empty()) return false; - map.create(size, CV_32S); + map.create(size, CV_32SC1); without_sobel.args(ocl::KernelArg::ReadOnlyNoSize(dx), ocl::KernelArg::ReadOnlyNoSize(dy), ocl::KernelArg::WriteOnly(map), low, high); @@ -951,7 +951,7 @@ void Canny( InputArray _src, OutputArray _dst, // we don't support inplace parameters in case with RGB/BGR src CV_Assert((_dst.getObj() != _src.getObj() || _src.type() == CV_8UC1) && "Inplace parameters are not supported"); - _dst.create(size, CV_8U); + _dst.create(size, CV_8UC1); if (!L2gradient && (aperture_size & CV_CANNY_L2_GRADIENT) == CV_CANNY_L2_GRADIENT) { @@ -1066,7 +1066,7 @@ void Canny( InputArray _dx, InputArray _dy, OutputArray _dst, CV_OCL_RUN(_dst.isUMat(), ocl_Canny(UMat(), _dx.getUMat(), _dy.getUMat(), _dst, (float)low_thresh, (float)high_thresh, 0, L2gradient, _dx.channels(), size)) - _dst.create(size, CV_8U); + _dst.create(size, CV_8UC1); Mat dst = _dst.getMat(); Mat dx = _dx.getMat(); @@ -1125,7 +1125,7 @@ void cvCanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size ) { cv::Mat src = cv::cvarrToMat(image), dst = cv::cvarrToMat(edges); - CV_Assert( src.size == dst.size && src.depth() == CV_8U && dst.type() == CV_8U ); + CV_Assert( src.size == dst.size && src.depth() == CV_8U && dst.type() == CV_8UC1 ); cv::Canny(src, dst, threshold1, threshold2, aperture_size & 255, (aperture_size & CV_CANNY_L2_GRADIENT) != 0); diff --git a/modules/imgproc/src/color.hpp b/modules/imgproc/src/color.hpp index a327aafefd11..c150381da78f 100644 --- a/modules/imgproc/src/color.hpp +++ b/modules/imgproc/src/color.hpp @@ -253,8 +253,9 @@ struct CvtHelper { CV_Assert(!_src.empty()); - int stype = _src.type(); - scn = CV_MAT_CN(stype), depth = CV_MAT_DEPTH(stype); + ElemType stype = _src.type(); + scn = CV_MAT_CN(stype); + depth = CV_MAT_DEPTH(stype); CV_Check(scn, VScn::contains(scn), "Invalid number of channels in input image"); CV_Check(dcn, VDcn::contains(dcn), "Invalid number of channels in output image"); @@ -284,7 +285,8 @@ struct CvtHelper dst = _dst.getMat(); } Mat src, dst; - int depth, scn; + ElemDepth depth; + int scn; Size dstSz; }; @@ -299,7 +301,7 @@ struct OclHelper src = _src.getUMat(); Size sz = src.size(), dstSz; int scn = src.channels(); - int depth = src.depth(); + ElemDepth depth = src.depth(); CV_Assert( VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) ); switch (sizePolicy) @@ -491,7 +493,7 @@ bool CvtColorIPPLoop(const uchar * src_data, size_t src_step, uchar * dst_data, template -bool CvtColorIPPLoopCopy(const uchar * src_data, size_t src_step, int src_type, uchar * dst_data, size_t dst_step, int width, int height, const Cvt& cvt) +bool CvtColorIPPLoopCopy(const uchar * src_data, size_t src_step, ElemType src_type, uchar * dst_data, size_t dst_step, int width, int height, const Cvt& cvt) { Mat temp; Mat src(Size(width, height), src_type, const_cast(src_data), src_step); @@ -543,7 +545,7 @@ struct IPPReorderFunctor struct IPPReorderGeneralFunctor { - IPPReorderGeneralFunctor(ippiReorderFunc _func1, ippiGeneralFunc _func2, int _order0, int _order1, int _order2, int _depth) : + IPPReorderGeneralFunctor(ippiReorderFunc _func1, ippiGeneralFunc _func2, int _order0, int _order1, int _order2, ElemDepth _depth) : ippiColorConvertReorder(_func1), ippiColorConvertGeneral(_func2), depth(_depth) { order[0] = _order0; @@ -566,13 +568,13 @@ struct IPPReorderGeneralFunctor ippiReorderFunc ippiColorConvertReorder; ippiGeneralFunc ippiColorConvertGeneral; int order[4]; - int depth; + ElemDepth depth; }; struct IPPGeneralReorderFunctor { - IPPGeneralReorderFunctor(ippiGeneralFunc _func1, ippiReorderFunc _func2, int _order0, int _order1, int _order2, int _depth) : + IPPGeneralReorderFunctor(ippiGeneralFunc _func1, ippiReorderFunc _func2, int _order0, int _order1, int _order2, ElemDepth _depth) : ippiColorConvertGeneral(_func1), ippiColorConvertReorder(_func2), depth(_depth) { order[0] = _order0; @@ -595,7 +597,7 @@ struct IPPGeneralReorderFunctor ippiGeneralFunc ippiColorConvertGeneral; ippiReorderFunc ippiColorConvertReorder; int order[4]; - int depth; + ElemDepth depth; }; extern ippiReorderFunc ippiSwapChannelsC3C4RTab[8]; diff --git a/modules/imgproc/src/color_hsv.cpp b/modules/imgproc/src/color_hsv.cpp index f0a4c87558b4..66f255511b38 100644 --- a/modules/imgproc/src/color_hsv.cpp +++ b/modules/imgproc/src/color_hsv.cpp @@ -1237,7 +1237,7 @@ namespace hal void cvtBGRtoHSV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue, bool isFullRange, bool isHSV) + ElemDepth depth, int scn, bool swapBlue, bool isFullRange, bool isHSV) { CV_INSTRUMENT_REGION(); @@ -1324,7 +1324,7 @@ void cvtBGRtoHSV(const uchar * src_data, size_t src_step, void cvtHSVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV) + ElemDepth depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV) { CV_INSTRUMENT_REGION(); diff --git a/modules/imgproc/src/color_lab.cpp b/modules/imgproc/src/color_lab.cpp index 0fff89358cac..14847c3d5593 100644 --- a/modules/imgproc/src/color_lab.cpp +++ b/modules/imgproc/src/color_lab.cpp @@ -1146,7 +1146,9 @@ static ushort LabCbrtTab_b[LAB_CBRT_TAB_SIZE_B]; static const bool enableBitExactness = true; static const bool enableRGB2LabInterpolation = true; +#if CV_SIMD128 static const bool enablePackedLab = true; +#endif enum { lab_lut_shift = 5, @@ -1163,8 +1165,10 @@ static const int minABvalue = -8145; static const int *abToXZ_b; // Luv constants static const bool enableRGB2LuvInterpolation = true; +#if CV_SIMD128 static const bool enablePackedRGB2Luv = true; static const bool enablePackedLuv2RGB = true; +#endif static const softfloat uLow(-134), uHigh(220), uRange(uHigh-uLow); static const softfloat vLow(-140), vHigh(122), vRange(vHigh-vLow); @@ -4092,7 +4096,7 @@ namespace hal void cvtBGRtoXYZ(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue) + ElemDepth depth, int scn, bool swapBlue) { CV_INSTRUMENT_REGION(); @@ -4143,7 +4147,7 @@ void cvtBGRtoXYZ(const uchar * src_data, size_t src_step, void cvtXYZtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue) + ElemDepth depth, int dcn, bool swapBlue) { CV_INSTRUMENT_REGION(); @@ -4194,8 +4198,8 @@ void cvtXYZtoBGR(const uchar * src_data, size_t src_step, // 8u, 32f void cvtBGRtoLab(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, - int width, int height, - int depth, int scn, bool swapBlue, bool isLab, bool srgb) + int width, int height, + ElemDepth depth, int scn, bool swapBlue, bool isLab, bool srgb) { CV_INSTRUMENT_REGION(); @@ -4292,7 +4296,7 @@ void cvtBGRtoLab(const uchar * src_data, size_t src_step, void cvtLabtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue, bool isLab, bool srgb) + ElemDepth depth, int dcn, bool swapBlue, bool isLab, bool srgb) { CV_INSTRUMENT_REGION(); diff --git a/modules/imgproc/src/color_rgb.cpp b/modules/imgproc/src/color_rgb.cpp index 746bce14b3e4..06142ef6d8a8 100644 --- a/modules/imgproc/src/color_rgb.cpp +++ b/modules/imgproc/src/color_rgb.cpp @@ -1368,8 +1368,8 @@ namespace hal // 8u, 16u, 32f void cvtBGRtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, - int width, int height, - int depth, int scn, int dcn, bool swapBlue) + int width, int height, + ElemDepth depth, int scn, int dcn, bool swapBlue) { CV_INSTRUMENT_REGION(); @@ -1458,7 +1458,7 @@ void cvtBGR5x5toBGR(const uchar * src_data, size_t src_step, void cvtBGRtoGray(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue) + ElemDepth depth, int scn, bool swapBlue) { CV_INSTRUMENT_REGION(); @@ -1507,7 +1507,7 @@ void cvtBGRtoGray(const uchar * src_data, size_t src_step, void cvtGraytoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn) + ElemDepth depth, int dcn) { CV_INSTRUMENT_REGION(); diff --git a/modules/imgproc/src/color_yuv.cpp b/modules/imgproc/src/color_yuv.cpp index f12a92e36ee9..34fb6b7be076 100644 --- a/modules/imgproc/src/color_yuv.cpp +++ b/modules/imgproc/src/color_yuv.cpp @@ -2266,7 +2266,7 @@ namespace hal void cvtBGRtoYUV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int scn, bool swapBlue, bool isCbCr) + ElemDepth depth, int scn, bool swapBlue, bool isCbCr) { CV_INSTRUMENT_REGION(); @@ -2319,7 +2319,7 @@ void cvtBGRtoYUV(const uchar * src_data, size_t src_step, void cvtYUVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, - int depth, int dcn, bool swapBlue, bool isCbCr) + ElemDepth depth, int dcn, bool swapBlue, bool isCbCr) { CV_INSTRUMENT_REGION(); @@ -2688,8 +2688,8 @@ void cvtColorTwoPlaneYUV2BGR( InputArray _src, OutputArray _dst, int dcn, bool s void cvtColorTwoPlaneYUV2BGRpair( InputArray _ysrc, InputArray _uvsrc, OutputArray _dst, int dcn, bool swapb, int uidx ) { - int stype = _ysrc.type(); - int depth = CV_MAT_DEPTH(stype); + ElemType stype = _ysrc.type(); + ElemDepth depth = CV_MAT_DEPTH(stype); Size ysz = _ysrc.size(), uvs = _uvsrc.size(); CV_Assert( dcn == 3 || dcn == 4 ); CV_Assert( depth == CV_8U ); diff --git a/modules/imgproc/src/colormap.cpp b/modules/imgproc/src/colormap.cpp index 8658595300bb..c2f28951faec 100644 --- a/modules/imgproc/src/colormap.cpp +++ b/modules/imgproc/src/colormap.cpp @@ -126,8 +126,9 @@ static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi) case CV_32SC1: return interp1_(x,Y,xi); break; case CV_32FC1: return interp1_(x,Y,xi); break; case CV_64FC1: return interp1_(x,Y,xi); break; + default: + CV_Error(Error::StsUnsupportedFormat, ""); } - CV_Error(Error::StsUnsupportedFormat, ""); } namespace colormap diff --git a/modules/imgproc/src/connectedcomponents.cpp b/modules/imgproc/src/connectedcomponents.cpp index 10095842b2e6..683a03f1f064 100644 --- a/modules/imgproc/src/connectedcomponents.cpp +++ b/modules/imgproc/src/connectedcomponents.cpp @@ -3991,7 +3991,7 @@ int cv::connectedComponents(InputArray img_, OutputArray _labels, int connectivi int cv::connectedComponents(InputArray img_, OutputArray _labels, int connectivity, int ltype, int ccltype){ const cv::Mat img = img_.getMat(); - _labels.create(img.size(), CV_MAT_DEPTH(ltype)); + _labels.create(img.size(), CV_MAKETYPE(CV_MAT_DEPTH(ltype), 1)); cv::Mat labels = _labels.getMat(); connectedcomponents::NoOp sop; if (ltype == CV_16U){ @@ -4016,7 +4016,7 @@ int cv::connectedComponentsWithStats(InputArray img_, OutputArray _labels, Outpu OutputArray centroids, int connectivity, int ltype, int ccltype) { const cv::Mat img = img_.getMat(); - _labels.create(img.size(), CV_MAT_DEPTH(ltype)); + _labels.create(img.size(), CV_MAKETYPE(CV_MAT_DEPTH(ltype),1)); cv::Mat labels = _labels.getMat(); connectedcomponents::CCStatsOp sop(statsv, centroids); if (ltype == CV_16U){ diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp index f1c3338340b3..51d533cf056a 100644 --- a/modules/imgproc/src/contours.cpp +++ b/modules/imgproc/src/contours.cpp @@ -301,7 +301,7 @@ cvStartFindContours_Impl( void* _img, CvMemStorage* storage, } /* converts all pixels to 0 or 1 */ - if( CV_MAT_TYPE(mat->type) != CV_32S ) + if( CV_MAT_TYPE(mat->type) != CV_32SC1 ) cvThreshold( mat, mat, 0, 1, CV_THRESH_BINARY ); return scanner; @@ -1909,7 +1909,7 @@ void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours, } Seq all_contours(cvTreeToNodeSeq( _ccontours, sizeof(CvSeq), storage )); int i, total = (int)all_contours.size(); - _contours.create(total, 1, 0, -1, true); + _contours.create(total, 1, static_cast(0), -1, true); SeqIterator it = all_contours.begin(); for( i = 0; i < total; i++, ++it ) { diff --git a/modules/imgproc/src/convhull.cpp b/modules/imgproc/src/convhull.cpp index e288f6a62631..c21c6fdef341 100644 --- a/modules/imgproc/src/convhull.cpp +++ b/modules/imgproc/src/convhull.cpp @@ -142,7 +142,7 @@ void convexHull( InputArray _points, OutputArray _hull, bool clockwise, bool ret return; } - returnPoints = !_hull.fixedType() ? returnPoints : _hull.type() != CV_32S; + returnPoints = !_hull.fixedType() ? returnPoints : _hull.type() != CV_32SC1; bool is_float = depth == CV_32F; AutoBuffer _pointer(total); @@ -253,7 +253,7 @@ void convexHull( InputArray _points, OutputArray _hull, bool clockwise, bool ret } if( !returnPoints ) - Mat(nout, 1, CV_32S, hullbuf).copyTo(_hull); + Mat(nout, 1, CV_32SC1, hullbuf).copyTo(_hull); else { _hull.create(nout, 1, CV_MAKETYPE(depth, 2)); diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index cd370aeae0f4..0923db3355fe 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -254,7 +254,7 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size, bool haveSimd = hasSIMD128(); #endif - int depth = src.depth(); + ElemDepth depth = src.depth(); double scale = (double)(1 << ((aperture_size > 0 ? aperture_size : 3) - 1)) * block_size; if( aperture_size < 0 ) scale *= 2.0; @@ -335,7 +335,7 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size, #ifdef HAVE_OPENCL -static bool extractCovData(InputArray _src, UMat & Dx, UMat & Dy, int depth, +static bool extractCovData(InputArray _src, UMat & Dx, UMat & Dy, ElemDepth depth, float scale, int aperture_size, int borderType) { UMat src = _src.getUMat(); @@ -403,7 +403,8 @@ static bool ocl_cornerMinEigenValVecs(InputArray _src, OutputArray _dst, int blo borderType == BORDER_REFLECT || borderType == BORDER_REFLECT_101) ) return false; - int type = _src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); if ( !(type == CV_8UC1 || type == CV_32FC1) ) return false; @@ -448,7 +449,7 @@ static bool ocl_cornerMinEigenValVecs(InputArray _src, OutputArray _dst, int blo return cornelKernel.run(2, globalsize, localsize, false); } -static bool ocl_preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int borderType, int depth ) +static bool ocl_preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int borderType, ElemDepth depth ) { UMat Dx, Dy, D2x, D2y, Dxy; @@ -593,7 +594,9 @@ static bool ipp_cornerHarris( Mat &src, Mat &dst, int blockSize, int ksize, doub CV_INSTRUMENT_REGION_IPP(); { - int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + int type = src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int borderTypeNI = borderType & ~BORDER_ISOLATED; bool isolated = (borderType & BORDER_ISOLATED) != 0; @@ -672,7 +675,7 @@ void cv::cornerEigenValsAndVecs( InputArray _src, OutputArray _dst, int blockSiz Mat src = _src.getMat(); Size dsz = _dst.size(); - int dtype = _dst.type(); + ElemType dtype = _dst.type(); if( dsz.height != src.rows || dsz.width*CV_MAT_CN(dtype) != src.cols*6 || CV_MAT_DEPTH(dtype) != CV_32F ) _dst.create( src.size(), CV_32FC(6) ); diff --git a/modules/imgproc/src/cornersubpix.cpp b/modules/imgproc/src/cornersubpix.cpp index 1e0841271f5f..e87107a89571 100644 --- a/modules/imgproc/src/cornersubpix.cpp +++ b/modules/imgproc/src/cornersubpix.cpp @@ -65,7 +65,7 @@ void cv::cornerSubPix( InputArray _image, InputOutputArray _corners, CV_Assert( src.cols >= win.width*2 + 5 && src.rows >= win.height*2 + 5 ); CV_Assert( src.channels() == 1 ); - Mat maskm(win_h, win_w, CV_32F), subpix_buf(win_h+2, win_w+2, CV_32F); + Mat maskm(win_h, win_w, CV_32FC1), subpix_buf(win_h + 2, win_w + 2, CV_32FC1); float* mask = maskm.ptr(); for( i = 0; i < win_h; i++ ) diff --git a/modules/imgproc/src/demosaicing.cpp b/modules/imgproc/src/demosaicing.cpp index 684ff026d109..fa0f101324db 100644 --- a/modules/imgproc/src/demosaicing.cpp +++ b/modules/imgproc/src/demosaicing.cpp @@ -1665,7 +1665,8 @@ void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn) Mat src = _src.getMat(), dst; Size sz = src.size(); - int scn = src.channels(), depth = src.depth(); + int scn = src.channels(); + ElemDepth depth = src.depth(); CV_Assert(depth == CV_8U || depth == CV_16U); CV_Assert(!src.empty()); diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index b4c61cad4dab..9e097b33b025 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -54,11 +54,11 @@ namespace cv { static void getScharrKernels( OutputArray _kx, OutputArray _ky, - int dx, int dy, bool normalize, int ktype ) + int dx, int dy, bool normalize, ElemType ktype ) { const int ksize = 3; - CV_Assert( ktype == CV_32F || ktype == CV_64F ); + CV_Assert(ktype == CV_32FC1 || ktype == CV_64FC1); _kx.create(ksize, 1, ktype, -1, true); _ky.create(ksize, 1, ktype, -1, true); Mat kx = _kx.getMat(); @@ -77,15 +77,15 @@ static void getScharrKernels( OutputArray _kx, OutputArray _ky, else if( order == 1 ) kerI[0] = -1, kerI[1] = 0, kerI[2] = 1; - Mat temp(kernel->rows, kernel->cols, CV_32S, &kerI[0]); + Mat temp(kernel->rows, kernel->cols, CV_32SC1, &kerI[0]); double scale = !normalize || order == 1 ? 1. : 1./32; - temp.convertTo(*kernel, ktype, scale); + temp.convertTo(*kernel, CV_MAT_DEPTH(ktype), scale); } } static void getSobelKernels( OutputArray _kx, OutputArray _ky, - int dx, int dy, int _ksize, bool normalize, int ktype ) + int dx, int dy, int _ksize, bool normalize, ElemType ktype ) { int i, j, ksizeX = _ksize, ksizeY = _ksize; if( ksizeX == 1 && dx > 0 ) @@ -93,7 +93,7 @@ static void getSobelKernels( OutputArray _kx, OutputArray _ky, if( ksizeY == 1 && dy > 0 ) ksizeY = 3; - CV_Assert( ktype == CV_32F || ktype == CV_64F ); + CV_Assert(ktype == CV_32FC1 || ktype == CV_64FC1); _kx.create(ksizeX, 1, ktype, -1, true); _ky.create(ksizeY, 1, ktype, -1, true); @@ -155,16 +155,16 @@ static void getSobelKernels( OutputArray _kx, OutputArray _ky, } } - Mat temp(kernel->rows, kernel->cols, CV_32S, &kerI[0]); + Mat temp(kernel->rows, kernel->cols, CV_32SC1, &kerI[0]); double scale = !normalize ? 1. : 1./(1 << (ksize-order-1)); - temp.convertTo(*kernel, ktype, scale); + temp.convertTo(*kernel, CV_MAT_DEPTH(ktype), scale); } } } void cv::getDerivKernels( OutputArray kx, OutputArray ky, int dx, int dy, - int ksize, bool normalize, int ktype ) + int ksize, bool normalize, ElemType ktype ) { if( ksize <= 0 ) getScharrKernels( kx, ky, dx, dy, normalize, ktype ); @@ -173,11 +173,11 @@ void cv::getDerivKernels( OutputArray kx, OutputArray ky, int dx, int dy, } -cv::Ptr cv::createDerivFilter(int srcType, int dstType, +cv::Ptr cv::createDerivFilter(ElemType srcType, ElemType dstType, int dx, int dy, int ksize, int borderType ) { Mat kx, ky; - getDerivKernels( kx, ky, dx, dy, ksize, false, CV_32F ); + getDerivKernels( kx, ky, dx, dy, ksize, false, CV_32FC1 ); return createSeparableLinearFilter(srcType, dstType, kx, ky, Point(-1,-1), 0, borderType ); } @@ -354,11 +354,13 @@ static bool ipp_Deriv(InputArray _src, OutputArray _dst, int dx, int dy, int ksi #ifdef HAVE_OPENCL namespace cv { -static bool ocl_sepFilter3x3_8UC1(InputArray _src, OutputArray _dst, int ddepth, + static bool ocl_sepFilter3x3_8UC1(InputArray _src, OutputArray _dst, ElemDepth ddepth, InputArray _kernelX, InputArray _kernelY, double delta, int borderType) { const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if ( !(dev.isIntel() && (type == CV_8UC1) && (ddepth == CV_8U) && (_src.offset() == 0) && (_src.step() % 4 == 0) && @@ -372,7 +374,7 @@ static bool ocl_sepFilter3x3_8UC1(InputArray _src, OutputArray _dst, int ddepth, if (kernelY.cols % 2 != 1) return false; - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; Size size = _src.size(); @@ -411,18 +413,20 @@ static bool ocl_sepFilter3x3_8UC1(InputArray _src, OutputArray _dst, int ddepth, } #endif -void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, +void cv::Sobel(InputArray _src, OutputArray _dst, ElemDepth ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType ) { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); - if (ddepth < 0) + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; - int dtype = CV_MAKE_TYPE(ddepth, cn); + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); _dst.create( _src.size(), dtype ); - int ktype = std::max(CV_32F, std::max(ddepth, sdepth)); + ElemType ktype = CV_MAKETYPE(CV_MAX_DEPTH(CV_32F, ddepth, sdepth), 1); Mat kx, ky; getDerivKernels( kx, ky, dx, dy, ksize, false, ktype ); @@ -463,18 +467,20 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, } -void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, +void cv::Scharr(InputArray _src, OutputArray _dst, ElemDepth ddepth, int dx, int dy, double scale, double delta, int borderType ) { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); - if (ddepth < 0) + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; - int dtype = CV_MAKETYPE(ddepth, cn); + ElemType dtype = CV_MAKETYPE(ddepth, cn); _dst.create( _src.size(), dtype ); - int ktype = std::max(CV_32F, std::max(ddepth, sdepth)); + ElemType ktype = CV_MAKETYPE(CV_MAX_DEPTH(CV_32F, ddepth, sdepth), 1); Mat kx, ky; getScharrKernels( kx, ky, dx, dy, false, ktype ); @@ -520,15 +526,16 @@ namespace cv { static bool ocl_Laplacian5(InputArray _src, OutputArray _dst, const Mat & kd, const Mat & ks, double scale, double delta, - int borderType, int depth, int ddepth) + int borderType, ElemDepth depth, ElemDepth ddepth) { const size_t tileSizeX = 16; const size_t tileSizeYmin = 8; const ocl::Device dev = ocl::Device::getDefault(); - int stype = _src.type(); - int sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype), esz = CV_ELEM_SIZE(stype); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype), esz = CV_ELEM_SIZE(stype); bool doubleSupport = dev.doubleFPConfig() > 0; if (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F)) @@ -563,8 +570,8 @@ static bool ocl_Laplacian5(InputArray _src, OutputArray _dst, { Size size = _src.size(), wholeSize; Point origin; - int dtype = CV_MAKE_TYPE(ddepth, cn); - int wdepth = CV_32F; + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); + ElemDepth wdepth = CV_32F; size_t tileSizeY = tileSizeYmax; while ((tileSizeX * tileSizeY > wgs) || (LAPLACIAN_LOCAL_MEM(tileSizeX, tileSizeY, kernelX.cols, loc_mem_cn * 4) > lmsz)) @@ -615,7 +622,8 @@ static bool ocl_Laplacian5(InputArray _src, OutputArray _dst, } int iscale = cvRound(scale), idelta = cvRound(delta); bool floatCoeff = std::fabs(delta - idelta) > DBL_EPSILON || std::fabs(scale - iscale) > DBL_EPSILON; - int wdepth = std::max(depth, floatCoeff ? CV_32F : CV_32S), kercn = 1; + ElemDepth wdepth = CV_MAX_DEPTH(depth, floatCoeff ? CV_32F : CV_32S); + int kercn = 1; if (!doubleSupport && wdepth == CV_64F) return false; @@ -654,11 +662,13 @@ static bool ocl_Laplacian5(InputArray _src, OutputArray _dst, return k.run(2, globalsize, NULL, false); } -static bool ocl_Laplacian3_8UC1(InputArray _src, OutputArray _dst, int ddepth, +static bool ocl_Laplacian3_8UC1(InputArray _src, OutputArray _dst, ElemDepth ddepth, InputArray _kernel, double delta, int borderType) { const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if ( !(dev.isIntel() && (type == CV_8UC1) && (ddepth == CV_8U) && (borderType != BORDER_WRAP) && @@ -668,7 +678,7 @@ static bool ocl_Laplacian3_8UC1(InputArray _src, OutputArray _dst, int ddepth, Mat kernel = _kernel.getMat().reshape(1, 1); - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; Size size = _src.size(); @@ -780,13 +790,15 @@ static bool ipp_Laplacian(InputArray _src, OutputArray _dst, int ksize, double s #endif -void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize, +void cv::Laplacian( InputArray _src, OutputArray _dst, ElemDepth ddepth, int ksize, double scale, double delta, int borderType ) { CV_INSTRUMENT_REGION(); - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); - if (ddepth < 0) + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; _dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) ); @@ -798,7 +810,7 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize, { 2, 0, 2, 0, -8, 0, 2, 0, 2 } }; - Mat kernel(3, 3, CV_32F, K[ksize == 3]); + Mat kernel(3, 3, CV_32FC1, K[ksize == 3]); if( scale != 1 ) kernel *= scale; @@ -815,7 +827,7 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize, { 0, 1, 0, 1, -4, 1, 0, 1, 0 }, { 2, 0, 2, 0, -8, 0, 2, 0, 2 } }; - Mat kernel(3, 3, CV_32F, K[ksize == 3]); + Mat kernel(3, 3, CV_32FC1, K[ksize == 3]); if( scale != 1 ) kernel *= scale; @@ -823,9 +835,9 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize, } else { - int ktype = std::max(CV_32F, std::max(ddepth, sdepth)); - int wdepth = sdepth == CV_8U && ksize <= 5 ? CV_16S : sdepth <= CV_32F ? CV_32F : CV_64F; - int wtype = CV_MAKETYPE(wdepth, cn); + ElemType ktype = CV_MAKETYPE(CV_MAX_DEPTH(CV_32F, ddepth, sdepth), 1); + ElemDepth wdepth = sdepth == CV_8U && ksize <= 5 ? CV_16S : sdepth <= CV_32F ? CV_32F : CV_64F; + ElemType wtype = CV_MAKETYPE(wdepth, cn); Mat kd, ks; getSobelKernels( kd, ks, 2, 0, ksize, false, ktype ); diff --git a/modules/imgproc/src/distransform.cpp b/modules/imgproc/src/distransform.cpp index b4c6ad6486e6..39801d001e80 100644 --- a/modules/imgproc/src/distransform.cpp +++ b/modules/imgproc/src/distransform.cpp @@ -723,14 +723,14 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe CV_Assert( src.type() == CV_8UC1); - _dst.create( src.size(), CV_32F); + _dst.create(src.size(), CV_32FC1); Mat dst = _dst.getMat(); if( need_labels ) { CV_Assert( labelType == DIST_LABEL_PIXEL || labelType == DIST_LABEL_CCOMP ); - _labels.create(src.size(), CV_32S); + _labels.create(src.size(), CV_32SC1); labels = _labels.getMat(); maskSize = CV_DIST_MASK_5; } diff --git a/modules/imgproc/src/emd.cpp b/modules/imgproc/src/emd.cpp index 20ab6feafbc8..d6a2d7729b69 100644 --- a/modules/imgproc/src/emd.cpp +++ b/modules/imgproc/src/emd.cpp @@ -1161,7 +1161,7 @@ float cv::EMD( InputArray _signature1, InputArray _signature2, CvMat _ccost = cvMat(cost), _cflow; if( _flow.needed() ) { - _flow.create(signature1.rows, signature2.rows, CV_32F); + _flow.create(signature1.rows, signature2.rows, CV_32FC1); flow = _flow.getMat(); flow = Scalar::all(0); _cflow = cvMat(flow); diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp index 772764414590..ccbbb7209835 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/imgproc/src/featureselect.cpp @@ -85,7 +85,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners, Size imgsize = _image.size(); size_t total, i, j, ncorners = 0, possibleCornersCount = - std::max(1024, static_cast(imgsize.area() * 0.1)); + CV_MAX_DEPTH(1024, (imgsize.area() * 0.1)); bool haveMask = !_mask.empty(); UMat corners_buffer(1, (int)possibleCornersCount + 1, CV_32FC2); CV_Assert(sizeof(Corner) == corners_buffer.elemSize()); @@ -257,7 +257,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners, } } - Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); return true; } @@ -330,7 +330,7 @@ static bool openvx_harris(Mat image, OutputArray _corners, keypoints.push_back(Point2f((float)kp.x, (float)kp.y)); } - Mat(keypoints).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(keypoints).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); #ifdef VX_VERSION_1_1 //we should take user memory back before release @@ -508,7 +508,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners, } } - Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); } CV_IMPL void diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index 5fd3f3eb957c..6587de1caede 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -72,7 +72,7 @@ BaseFilter::~BaseFilter() {} void BaseFilter::reset() {} FilterEngine::FilterEngine() - : srcType(-1), dstType(-1), bufType(-1), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0), + : srcType(CV_TYPE_AUTO), dstType(CV_TYPE_AUTO), bufType(CV_TYPE_AUTO), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0), rowBorderType(BORDER_REPLICATE), columnBorderType(BORDER_REPLICATE), borderElemSize(0), bufStep(0), startY(0), startY0(0), endY(0), rowCount(0), dstY(0) { @@ -82,10 +82,10 @@ FilterEngine::FilterEngine() FilterEngine::FilterEngine( const Ptr& _filter2D, const Ptr& _rowFilter, const Ptr& _columnFilter, - int _srcType, int _dstType, int _bufType, + ElemType _srcType, ElemType _dstType, ElemType _bufType, int _rowBorderType, int _columnBorderType, const Scalar& _borderValue ) - : srcType(-1), dstType(-1), bufType(-1), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0), + : srcType(CV_TYPE_AUTO), dstType(CV_TYPE_AUTO), bufType(CV_TYPE_AUTO), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0), rowBorderType(BORDER_REPLICATE), columnBorderType(BORDER_REPLICATE), borderElemSize(0), bufStep(0), startY(0), startY0(0), endY(0), rowCount(0), dstY(0) { @@ -101,7 +101,7 @@ FilterEngine::~FilterEngine() void FilterEngine::init( const Ptr& _filter2D, const Ptr& _rowFilter, const Ptr& _columnFilter, - int _srcType, int _dstType, int _bufType, + ElemType _srcType, ElemType _dstType, ElemType _bufType, int _rowBorderType, int _columnBorderType, const Scalar& _borderValue ) { @@ -152,7 +152,7 @@ void FilterEngine::init( const Ptr& _filter2D, if( rowBorderType == BORDER_CONSTANT || columnBorderType == BORDER_CONSTANT ) { constBorderValue.resize(srcElemSize*borderLength); - int srcType1 = CV_MAKETYPE(CV_MAT_DEPTH(srcType), MIN(CV_MAT_CN(srcType), 4)); + ElemType srcType1 = CV_MAKETYPE(CV_MAT_DEPTH(srcType), MIN(CV_MAT_CN(srcType), 4)); scalarToRawData(_borderValue, &constBorderValue[0], srcType1, borderLength*CV_MAT_CN(srcType)); } @@ -3593,16 +3593,16 @@ template struct FixedPtCastEx } -cv::Ptr cv::getLinearRowFilter( int srcType, int bufType, +cv::Ptr cv::getLinearRowFilter(ElemType srcType, ElemType bufType, InputArray _kernel, int anchor, int symmetryType ) { Mat kernel = _kernel.getMat(); - int sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(bufType); + ElemDepth sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(bufType); int cn = CV_MAT_CN(srcType); CV_Assert( cn == CV_MAT_CN(bufType) && - ddepth >= std::max(sdepth, CV_32S) && - kernel.type() == ddepth ); + ddepth >= CV_MAX_DEPTH(sdepth, CV_32S) && + kernel.type() == CV_MAKETYPE(ddepth, 1) ); int ksize = kernel.rows + kernel.cols - 1; if( (symmetryType & (KERNEL_SYMMETRICAL|KERNEL_ASYMMETRICAL)) != 0 && ksize <= 5 ) @@ -3645,17 +3645,17 @@ cv::Ptr cv::getLinearRowFilter( int srcType, int bufType, } -cv::Ptr cv::getLinearColumnFilter( int bufType, int dstType, +cv::Ptr cv::getLinearColumnFilter(ElemType bufType, ElemType dstType, InputArray _kernel, int anchor, int symmetryType, double delta, int bits ) { Mat kernel = _kernel.getMat(); - int sdepth = CV_MAT_DEPTH(bufType), ddepth = CV_MAT_DEPTH(dstType); + ElemDepth sdepth = CV_MAT_DEPTH(bufType), ddepth = CV_MAT_DEPTH(dstType); int cn = CV_MAT_CN(dstType); CV_Assert( cn == CV_MAT_CN(bufType) && - sdepth >= std::max(ddepth, CV_32S) && - kernel.type() == sdepth ); + sdepth >= CV_MAX_DEPTH(ddepth, CV_32S) && + kernel.type() == CV_MAKETYPE(sdepth, 1)); if( !(symmetryType & (KERNEL_SYMMETRICAL|KERNEL_ASYMMETRICAL)) ) { @@ -3741,7 +3741,7 @@ cv::Ptr cv::getLinearColumnFilter( int bufType, int dstTyp cv::Ptr cv::createSeparableLinearFilter( - int _srcType, int _dstType, + ElemType _srcType, ElemType _dstType, InputArray __rowKernel, InputArray __columnKernel, Point _anchor, double _delta, int _rowBorderType, int _columnBorderType, @@ -3750,7 +3750,7 @@ cv::Ptr cv::createSeparableLinearFilter( Mat _rowKernel = __rowKernel.getMat(), _columnKernel = __columnKernel.getMat(); _srcType = CV_MAT_TYPE(_srcType); _dstType = CV_MAT_TYPE(_dstType); - int sdepth = CV_MAT_DEPTH(_srcType), ddepth = CV_MAT_DEPTH(_dstType); + ElemDepth sdepth = CV_MAT_DEPTH(_srcType), ddepth = CV_MAT_DEPTH(_dstType); int cn = CV_MAT_CN(_srcType); CV_Assert( cn == CV_MAT_CN(_dstType) ); int rsize = _rowKernel.rows + _rowKernel.cols - 1; @@ -3765,7 +3765,7 @@ cv::Ptr cv::createSeparableLinearFilter( _columnKernel.rows == 1 ? Point(_anchor.y, 0) : Point(0, _anchor.y)); Mat rowKernel, columnKernel; - int bdepth = std::max(CV_32F,std::max(sdepth, ddepth)); + ElemDepth bdepth = CV_MAX_DEPTH(CV_32F, sdepth, ddepth); int bits = 0; if( sdepth == CV_8U && @@ -3786,17 +3786,17 @@ cv::Ptr cv::createSeparableLinearFilter( } else { - if( _rowKernel.type() != bdepth ) + if( _rowKernel.type() != CV_MAKETYPE(bdepth, 1) ) _rowKernel.convertTo( rowKernel, bdepth ); else rowKernel = _rowKernel; - if( _columnKernel.type() != bdepth ) + if (_columnKernel.type() != CV_MAKETYPE(bdepth, 1)) _columnKernel.convertTo( columnKernel, bdepth ); else columnKernel = _columnKernel; } - int _bufType = CV_MAKETYPE(bdepth, cn); + ElemType _bufType = CV_MAKETYPE(bdepth, cn); Ptr _rowFilter = getLinearRowFilter( _srcType, _bufType, rowKernel, _anchor.x, rtype); Ptr _columnFilter = getLinearColumnFilter( @@ -3971,14 +3971,17 @@ static int _prepareKernelFilter2D(std::vector & data, const Mat & kernel) return size_y_aligned; } -static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth, +static bool ocl_filter2D(InputArray _src, OutputArray _dst, ElemDepth ddepth, InputArray _kernel, Point anchor, double delta, int borderType ) { - int type = _src.type(), sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - ddepth = ddepth < 0 ? sdepth : ddepth; - int dtype = CV_MAKE_TYPE(ddepth, cn), wdepth = std::max(std::max(sdepth, ddepth), CV_32F), - wtype = CV_MAKE_TYPE(wdepth, cn); + ElemType type = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ddepth = ddepth == CV_DEPTH_AUTO ? sdepth : ddepth; + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); + ElemDepth wdepth = CV_MAX_DEPTH(sdepth, ddepth, CV_32F); + ElemType wtype = CV_MAKE_TYPE(wdepth, cn); if (cn > 4) return false; @@ -4157,12 +4160,15 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth, const int shift_bits = 8; static bool ocl_sepRowFilter2D(const UMat & src, UMat & buf, const Mat & kernelX, int anchor, - int borderType, int ddepth, bool fast8uc1, bool int_arithm) + int borderType, ElemDepth ddepth, bool fast8uc1, bool int_arithm) { - int type = src.type(), cn = CV_MAT_CN(type), sdepth = CV_MAT_DEPTH(type); + ElemType type = src.type(); + int cn = CV_MAT_CN(type); + ElemDepth sdepth = CV_MAT_DEPTH(type); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; Size bufSize = buf.size(); - int buf_type = buf.type(), bdepth = CV_MAT_DEPTH(buf_type); + int buf_type = buf.type(); + ElemDepth bdepth = CV_MAT_DEPTH(buf_type); if (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F)) return false; @@ -4239,9 +4245,12 @@ static bool ocl_sepColFilter2D(const UMat & buf, UMat & dst, const Mat & kernelY #endif size_t globalsize[2] = { 0, 0 }; - int dtype = dst.type(), cn = CV_MAT_CN(dtype), ddepth = CV_MAT_DEPTH(dtype); + ElemType dtype = dst.type(); + int cn = CV_MAT_CN(dtype); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); Size sz = dst.size(); - int buf_type = buf.type(), bdepth = CV_MAT_DEPTH(buf_type); + int buf_type = buf.type(); + ElemDepth bdepth = CV_MAT_DEPTH(buf_type); globalsize[1] = DIVUP(sz.height, localsize[1]) * localsize[1]; globalsize[0] = DIVUP(sz.width, localsize[0]) * localsize[0]; @@ -4274,13 +4283,16 @@ const int optimizedSepFilterLocalHeight = 8; static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst, Mat row_kernel, Mat col_kernel, - double delta, int borderType, int ddepth, int bdepth, bool int_arithm) + double delta, int borderType, ElemDepth ddepth, ElemDepth bdepth, bool int_arithm) { Size size = _src.size(), wholeSize; Point origin; - int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype), - esz = CV_ELEM_SIZE(stype), wdepth = std::max(std::max(sdepth, ddepth), bdepth), - dtype = CV_MAKE_TYPE(ddepth, cn); + ElemType stype = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype), + esz = CV_ELEM_SIZE(stype); + ElemDepth wdepth = CV_MAX_DEPTH(sdepth, ddepth, bdepth); + ElemType dtype = CV_MAKE_TYPE(ddepth, cn); size_t src_step = _src.step(), src_offset = _src.offset(); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -4333,14 +4345,16 @@ static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst, return k.run(2, gt2, lt2, false); } -bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, +bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, ElemDepth ddepth, InputArray _kernelX, InputArray _kernelY, Point anchor, double delta, int borderType ) { const ocl::Device & d = ocl::Device::getDefault(); Size imgSize = _src.size(); - int type = _src.type(), sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if (cn > 4) return false; @@ -4351,7 +4365,7 @@ bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, if (kernelY.cols % 2 != 1) return false; - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; if (anchor.x < 0) @@ -4364,7 +4378,7 @@ bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, int ctype = getKernelType(kernelY, kernelY.rows == 1 ? Point(anchor.y, 0) : Point(0, anchor.y)); - int bdepth = CV_32F; + ElemDepth bdepth = CV_32F; bool int_arithm = false; if( sdepth == CV_8U && ddepth == CV_8U && rtype == KERNEL_SMOOTH+KERNEL_SYMMETRICAL && @@ -4418,13 +4432,14 @@ bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, } -cv::Ptr cv::getLinearFilter(int srcType, int dstType, +cv::Ptr cv::getLinearFilter(ElemType srcType, ElemType dstType, InputArray filter_kernel, Point anchor, double delta, int bits) { Mat _kernel = filter_kernel.getMat(); - int sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(dstType); - int cn = CV_MAT_CN(srcType), kdepth = _kernel.depth(); + ElemDepth sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(dstType); + int cn = CV_MAT_CN(srcType); + ElemDepth kdepth = _kernel.depth(); CV_Assert( cn == CV_MAT_CN(dstType) && ddepth >= sdepth ); anchor = normalizeAnchor(anchor, _kernel.size()); @@ -4440,10 +4455,10 @@ cv::Ptr cv::getLinearFilter(int srcType, int dstType, kdepth = sdepth == CV_64F || ddepth == CV_64F ? CV_64F : CV_32F; Mat kernel; - if( _kernel.type() == kdepth ) + if (_kernel.type() == CV_MAKETYPE(kdepth, 1)) kernel = _kernel; else - _kernel.convertTo(kernel, kdepth, _kernel.type() == CV_32S ? 1./(1 << bits) : 1.); + _kernel.convertTo(kernel, kdepth, _kernel.type() == CV_32SC1 ? 1./(1 << bits) : 1.); if( sdepth == CV_8U && ddepth == CV_8U ) return makePtr, FilterVec_8u> > @@ -4494,7 +4509,7 @@ cv::Ptr cv::getLinearFilter(int srcType, int dstType, } -cv::Ptr cv::createLinearFilter( int _srcType, int _dstType, +cv::Ptr cv::createLinearFilter(ElemType _srcType, ElemType _dstType, InputArray filter_kernel, Point _anchor, double _delta, int _rowBorderType, int _columnBorderType, @@ -4509,8 +4524,8 @@ cv::Ptr cv::createLinearFilter( int _srcType, int _dstType, Mat kernel = _kernel; int bits = 0; - /*int sdepth = CV_MAT_DEPTH(_srcType), ddepth = CV_MAT_DEPTH(_dstType); - int ktype = _kernel.depth() == CV_32S ? KERNEL_INTEGER : getKernelType(_kernel, _anchor); + /*ElemDepth sdepth = CV_MAT_DEPTH(_srcType), ddepth = CV_MAT_DEPTH(_dstType); + ElemType ktype = _kernel.depth() == CV_32S ? KERNEL_INTEGER : getKernelType(_kernel, _anchor); if( sdepth == CV_8U && (ddepth == CV_8U || ddepth == CV_16S) && _kernel.rows*_kernel.cols <= (1 << 10) ) { @@ -4533,7 +4548,7 @@ cv::Ptr cv::createLinearFilter( int _srcType, int _dstType, using namespace cv; -static bool replacementFilter2D(int stype, int dtype, int kernel_type, +static bool replacementFilter2D(ElemType stype, ElemType dtype, int kernel_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -4558,7 +4573,7 @@ static bool replacementFilter2D(int stype, int dtype, int kernel_type, } #ifdef HAVE_IPP -static bool ippFilter2D(int stype, int dtype, int kernel_type, +static bool ippFilter2D(ElemType stype, ElemType dtype, int kernel_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -4644,7 +4659,7 @@ static bool ippFilter2D(int stype, int dtype, int kernel_type, } #endif -static bool dftFilter2D(int stype, int dtype, int kernel_type, +static bool dftFilter2D(ElemType stype, ElemType dtype, ElemType kernel_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int full_width, int full_height, @@ -4656,8 +4671,8 @@ static bool dftFilter2D(int stype, int dtype, int kernel_type, { { #if CV_SSE2 - int sdepth = CV_MAT_DEPTH(stype); - int ddepth = CV_MAT_DEPTH(dtype); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); int dft_filter_size = ((sdepth == CV_8U && (ddepth == CV_8U || ddepth == CV_16S)) || (sdepth == CV_32F && ddepth == CV_32F)) && checkHardwareSupport(CV_CPU_SSE3) ? 130 : 50; #else CV_UNUSED(stype); @@ -4676,7 +4691,7 @@ static bool dftFilter2D(int stype, int dtype, int kernel_type, Mat temp; int src_channels = CV_MAT_CN(stype); int dst_channels = CV_MAT_CN(dtype); - int ddepth = CV_MAT_DEPTH(dtype); + ElemDepth ddepth = CV_MAT_DEPTH(dtype); // crossCorr doesn't accept non-zero delta with multiple channels if (src_channels != 1 && delta != 0) { // The semantics of filter2D require that the delta be applied @@ -4695,7 +4710,7 @@ static bool dftFilter2D(int stype, int dtype, int kernel_type, anchor, 0, borderType); add(temp, delta, temp); if (temp.data != dst_data) { - temp.convertTo(dst, dst.type()); + temp.convertTo(dst, dst.depth()); } } else { if (src_data != dst_data) @@ -4711,7 +4726,7 @@ static bool dftFilter2D(int stype, int dtype, int kernel_type, return true; } -static void ocvFilter2D(int stype, int dtype, int kernel_type, +static void ocvFilter2D(ElemType stype, ElemType dtype, int kernel_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -4723,7 +4738,7 @@ static void ocvFilter2D(int stype, int dtype, int kernel_type, double delta, int borderType) { int borderTypeValue = borderType & ~BORDER_ISOLATED; - Mat kernel = Mat(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step); + Mat kernel = Mat(Size(kernel_width, kernel_height), CV_MAKETYPE(kernel_type, 1), kernel_data, kernel_step); Ptr f = createLinearFilter(stype, dtype, kernel, Point(anchor_x, anchor_y), delta, borderTypeValue); Mat src(Size(width, height), stype, src_data, src_step); @@ -4731,7 +4746,7 @@ static void ocvFilter2D(int stype, int dtype, int kernel_type, f->apply(src, dst, Size(full_width, full_height), Point(offset_x, offset_y)); } -static bool replacementSepFilter(int stype, int dtype, int ktype, +static bool replacementSepFilter(ElemType stype, ElemType dtype, ElemType ktype, uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int full_width, int full_height, int offset_x, int offset_y, @@ -4754,7 +4769,7 @@ static bool replacementSepFilter(int stype, int dtype, int ktype, return success; } -static void ocvSepFilter(int stype, int dtype, int ktype, +static void ocvSepFilter(ElemType stype, ElemType dtype, ElemType ktype, uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int full_width, int full_height, int offset_x, int offset_y, @@ -4795,7 +4810,7 @@ CV_DEPRECATED Ptr SepFilter2D::create(int , int , int , double , int ) { return Ptr(); } -void filter2D(int stype, int dtype, int kernel_type, +void filter2D(ElemType stype, ElemType dtype, ElemType kernel_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -4857,7 +4872,7 @@ void filter2D(int stype, int dtype, int kernel_type, //--------------------------------------------------------------- -void sepFilter2D(int stype, int dtype, int ktype, +void sepFilter2D(ElemType stype, ElemType dtype, ElemType ktype, uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int full_width, int full_height, int offset_x, int offset_y, @@ -4891,7 +4906,7 @@ void sepFilter2D(int stype, int dtype, int ktype, // Main interface //================================================================ -void cv::filter2D( InputArray _src, OutputArray _dst, int ddepth, +void cv::filter2D(InputArray _src, OutputArray _dst, ElemDepth ddepth, InputArray _kernel, Point anchor0, double delta, int borderType ) { @@ -4902,7 +4917,7 @@ void cv::filter2D( InputArray _src, OutputArray _dst, int ddepth, Mat src = _src.getMat(), kernel = _kernel.getMat(); - if( ddepth < 0 ) + if( ddepth == CV_DEPTH_AUTO ) ddepth = src.depth(); _dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) ); @@ -4922,7 +4937,7 @@ void cv::filter2D( InputArray _src, OutputArray _dst, int ddepth, delta, borderType, src.isSubmatrix()); } -void cv::sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, +void cv::sepFilter2D(InputArray _src, OutputArray _dst, ElemDepth ddepth, InputArray _kernelX, InputArray _kernelY, Point anchor, double delta, int borderType ) { @@ -4933,7 +4948,7 @@ void cv::sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, Mat src = _src.getMat(), kernelX = _kernelX.getMat(), kernelY = _kernelY.getMat(); - if( ddepth < 0 ) + if( ddepth == CV_DEPTH_AUTO ) ddepth = src.depth(); _dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) ); diff --git a/modules/imgproc/src/filter.hpp b/modules/imgproc/src/filter.hpp index 93f3f177e674..42a3fd946e25 100644 --- a/modules/imgproc/src/filter.hpp +++ b/modules/imgproc/src/filter.hpp @@ -52,7 +52,7 @@ namespace cv #endif #ifdef HAVE_OPENCL - bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth, + bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, ElemDepth ddepth, InputArray _kernelX, InputArray _kernelY, Point anchor, double delta, int borderType ); #endif diff --git a/modules/imgproc/src/filterengine.hpp b/modules/imgproc/src/filterengine.hpp index 019c1d5d2dd2..d3f179c78c74 100644 --- a/modules/imgproc/src/filterengine.hpp +++ b/modules/imgproc/src/filterengine.hpp @@ -156,7 +156,7 @@ class BaseFilter \code void laplace_f(const Mat& src, Mat& dst) { - CV_Assert( src.type() == CV_32F ); + CV_Assert( src.type() == CV_32FC1 ); // make sure the destination array has the proper size and type dst.create(src.size(), src.type()); @@ -216,7 +216,7 @@ class FilterEngine FilterEngine(const Ptr& _filter2D, const Ptr& _rowFilter, const Ptr& _columnFilter, - int srcType, int dstType, int bufType, + ElemType srcType, ElemType dstType, ElemType bufType, int _rowBorderType = BORDER_REPLICATE, int _columnBorderType = -1, const Scalar& _borderValue = Scalar()); @@ -226,7 +226,7 @@ class FilterEngine void init(const Ptr& _filter2D, const Ptr& _rowFilter, const Ptr& _columnFilter, - int srcType, int dstType, int bufType, + ElemType srcType, ElemType dstType, ElemType bufType, int _rowBorderType = BORDER_REPLICATE, int _columnBorderType = -1, const Scalar& _borderValue = Scalar()); @@ -247,9 +247,9 @@ class FilterEngine int remainingInputRows() const; int remainingOutputRows() const; - int srcType; - int dstType; - int bufType; + ElemType srcType; + ElemType dstType; + ElemType bufType; Size ksize; Point anchor; int maxWidth; @@ -283,24 +283,24 @@ class FilterEngine int getKernelType(InputArray kernel, Point anchor); //! returns the primitive row filter with the specified kernel -Ptr getLinearRowFilter(int srcType, int bufType, +Ptr getLinearRowFilter(ElemType srcType, ElemType bufType, InputArray kernel, int anchor, int symmetryType); //! returns the primitive column filter with the specified kernel -Ptr getLinearColumnFilter(int bufType, int dstType, +Ptr getLinearColumnFilter(ElemType bufType, ElemType dstType, InputArray kernel, int anchor, int symmetryType, double delta = 0, int bits = 0); //! returns 2D filter with the specified kernel -Ptr getLinearFilter(int srcType, int dstType, +Ptr getLinearFilter(ElemType srcType, ElemType dstType, InputArray kernel, Point anchor = Point(-1,-1), double delta = 0, int bits = 0); //! returns the separable linear filter engine -Ptr createSeparableLinearFilter(int srcType, int dstType, +Ptr createSeparableLinearFilter(ElemType srcType, ElemType dstType, InputArray rowKernel, InputArray columnKernel, Point anchor = Point(-1,-1), double delta = 0, int rowBorderType = BORDER_DEFAULT, @@ -308,31 +308,31 @@ Ptr createSeparableLinearFilter(int srcType, int dstType, const Scalar& borderValue = Scalar()); //! returns the non-separable linear filter engine -Ptr createLinearFilter(int srcType, int dstType, +Ptr createLinearFilter(ElemType srcType, ElemType dstType, InputArray kernel, Point _anchor = Point(-1,-1), double delta = 0, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, const Scalar& borderValue = Scalar()); //! returns the Gaussian filter engine -Ptr createGaussianFilter( int type, Size ksize, +Ptr createGaussianFilter( ElemType type, Size ksize, double sigma1, double sigma2 = 0, int borderType = BORDER_DEFAULT); //! returns filter engine for the generalized Sobel operator -Ptr createDerivFilter( int srcType, int dstType, +Ptr createDerivFilter(ElemType srcType, ElemType dstType, int dx, int dy, int ksize, int borderType = BORDER_DEFAULT ); //! returns horizontal 1D box filter -Ptr getRowSumFilter(int srcType, int sumType, +Ptr getRowSumFilter(ElemType srcType, ElemType sumType, int ksize, int anchor = -1); //! returns vertical 1D box filter -Ptr getColumnSumFilter( int sumType, int dstType, +Ptr getColumnSumFilter(ElemType sumType, ElemType dstType, int ksize, int anchor = -1, double scale = 1); //! returns box filter engine -Ptr createBoxFilter( int srcType, int dstType, Size ksize, +Ptr createBoxFilter(ElemType srcType, ElemType dstType, Size ksize, Point anchor = Point(-1,-1), bool normalize = true, int borderType = BORDER_DEFAULT); @@ -349,7 +349,7 @@ Ptr getMorphologyFilter(int op, int type, InputArray kernel, Point anchor = Point(-1,-1)); //! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported. -CV_EXPORTS Ptr createMorphologyFilter(int op, int type, InputArray kernel, +CV_EXPORTS Ptr createMorphologyFilter(int op, ElemType type, InputArray kernel, Point anchor = Point(-1,-1), int rowBorderType = BORDER_CONSTANT, int columnBorderType = -1, const Scalar& borderValue = morphologyDefaultBorderValue()); @@ -366,7 +366,7 @@ static inline Point normalizeAnchor( Point anchor, Size ksize ) void preprocess2DKernel( const Mat& kernel, std::vector& coords, std::vector& coeffs ); void crossCorr( const Mat& src, const Mat& templ, Mat& dst, - Size corrsize, int ctype, + Size corrsize, ElemType ctype, Point anchor=Point(0,0), double delta=0, int borderType=BORDER_REFLECT_101 ); diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index 2816795bc60d..c5b73c5707c5 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -483,7 +483,7 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, Size size = img.size(); int type = img.type(); - int depth = img.depth(); + ElemDepth depth = img.depth(); int cn = img.channels(); if ( (cn != 1) && (cn != 3) ) @@ -553,7 +553,7 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, else { CV_Assert( mask.rows == size.height+2 && mask.cols == size.width+2 ); - CV_Assert( mask.type() == CV_8U ); + CV_Assert( mask.type() == CV_8UC1 ); } memset( mask.ptr(), 1, mask.cols ); diff --git a/modules/imgproc/src/gabor.cpp b/modules/imgproc/src/gabor.cpp index 0f2da7f2cd2f..144b0bc88be2 100644 --- a/modules/imgproc/src/gabor.cpp +++ b/modules/imgproc/src/gabor.cpp @@ -49,7 +49,7 @@ */ cv::Mat cv::getGaborKernel( Size ksize, double sigma, double theta, - double lambd, double gamma, double psi, int ktype ) + double lambd, double gamma, double psi, ElemType ktype ) { double sigma_x = sigma; double sigma_y = sigma/gamma; @@ -70,7 +70,7 @@ cv::Mat cv::getGaborKernel( Size ksize, double sigma, double theta, xmin = -xmax; ymin = -ymax; - CV_Assert( ktype == CV_32F || ktype == CV_64F ); + CV_Assert(ktype == CV_32FC1 || ktype == CV_64FC1); Mat kernel(ymax - ymin + 1, xmax - xmin + 1, ktype); double scale = 1; @@ -85,7 +85,7 @@ cv::Mat cv::getGaborKernel( Size ksize, double sigma, double theta, double yr = -x*s + y*c; double v = scale*std::exp(ex*xr*xr + ey*yr*yr)*cos(cscale*xr + psi); - if( ktype == CV_32F ) + if (ktype == CV_32FC1) kernel.at(ymax - y, xmax - x) = (float)v; else kernel.at(ymax - y, xmax - x) = v; diff --git a/modules/imgproc/src/geometry.cpp b/modules/imgproc/src/geometry.cpp index c338431b4f07..54fb2e9a6c9a 100644 --- a/modules/imgproc/src/geometry.cpp +++ b/modules/imgproc/src/geometry.cpp @@ -99,7 +99,7 @@ double cv::pointPolygonTest( InputArray _contour, Point2f pt, bool measureDist ) double result = 0; Mat contour = _contour.getMat(); int i, total = contour.checkVector(2), counter = 0; - int depth = contour.depth(); + ElemDepth depth = contour.depth(); CV_Assert( total >= 0 && (depth == CV_32S || depth == CV_32F)); bool is_float = depth == CV_32F; diff --git a/modules/imgproc/src/hal_replacement.hpp b/modules/imgproc/src/hal_replacement.hpp index 40f9d302df03..b1d4be29a35a 100644 --- a/modules/imgproc/src/hal_replacement.hpp +++ b/modules/imgproc/src/hal_replacement.hpp @@ -103,7 +103,7 @@ struct cvhalFilter2D {}; @param allowInplace indicates whether the inplace operation will be possible @sa cv::filter2D, cv::hal::Filter2D */ -inline int hal_ni_filterInit(cvhalFilter2D **context, uchar *kernel_data, size_t kernel_step, int kernel_type, int kernel_width, int kernel_height, int max_width, int max_height, int src_type, int dst_type, int borderType, double delta, int anchor_x, int anchor_y, bool allowSubmatrix, bool allowInplace) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_filterInit(cvhalFilter2D **context, uchar *kernel_data, size_t kernel_step, int kernel_type, int kernel_width, int kernel_height, int max_width, int max_height, ElemType src_type, ElemType dst_type, int borderType, double delta, int anchor_x, int anchor_y, bool allowSubmatrix, bool allowInplace) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_filter @param context pointer to user-defined context @@ -149,7 +149,7 @@ inline int hal_ni_filterFree(cvhalFilter2D *context) { return CV_HAL_ERROR_NOT_I @param borderType border processing mode (CV_HAL_BORDER_REFLECT, ...) @sa cv::sepFilter2D, cv::hal::SepFilter2D */ -inline int hal_ni_sepFilterInit(cvhalFilter2D **context, int src_type, int dst_type, int kernel_type, uchar *kernelx_data, int kernelx_length, uchar *kernely_data, int kernely_length, int anchor_x, int anchor_y, double delta, int borderType) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_sepFilterInit(cvhalFilter2D **context, ElemType src_type, ElemType dst_type, int kernel_type, uchar *kernelx_data, int kernelx_length, uchar *kernely_data, int kernely_length, int anchor_x, int anchor_y, double delta, int borderType) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_sepFilter @param context pointer to user-defined context @@ -201,7 +201,7 @@ inline int hal_ni_sepFilterFree(cvhalFilter2D *context) { return CV_HAL_ERROR_NO @param allowInplace indicates whether the inplace operation will be possible @sa cv::erode, cv::dilate, cv::morphologyEx, cv::hal::Morph */ -inline int hal_ni_morphInit(cvhalFilter2D **context, int operation, int src_type, int dst_type, int max_width, int max_height, int kernel_type, uchar *kernel_data, size_t kernel_step, int kernel_width, int kernel_height, int anchor_x, int anchor_y, int borderType, const double borderValue[4], int iterations, bool allowSubmatrix, bool allowInplace) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_morphInit(cvhalFilter2D **context, int operation, ElemType src_type, ElemType dst_type, int max_width, int max_height, int kernel_type, uchar *kernel_data, size_t kernel_step, int kernel_width, int kernel_height, int anchor_x, int anchor_y, int borderType, const double borderValue[4], int iterations, bool allowSubmatrix, bool allowInplace) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_morph @param context pointer to user-defined context @@ -251,7 +251,7 @@ inline int hal_ni_morphFree(cvhalFilter2D *context) { return CV_HAL_ERROR_NOT_IM @param interpolation interpolation mode (CV_HAL_INTER_NEAREST, ...) @sa cv::resize, cv::hal::resize */ -inline int hal_ni_resize(int src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width, int dst_height, double inv_scale_x, double inv_scale_y, int interpolation) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_resize(ElemType src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width, int dst_height, double inv_scale_x, double inv_scale_y, int interpolation) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_warpAffine @param src_type source and destination image type @@ -269,7 +269,7 @@ inline int hal_ni_resize(int src_type, const uchar *src_data, size_t src_step, i @param borderValue values to use for CV_HAL_BORDER_CONSTANT mode @sa cv::warpAffine, cv::hal::warpAffine */ -inline int hal_ni_warpAffine(int src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width, int dst_height, const double M[6], int interpolation, int borderType, const double borderValue[4]) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_warpAffine(ElemType src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width, int dst_height, const double M[6], int interpolation, int borderType, const double borderValue[4]) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_warpPerspective @param src_type source and destination image type @@ -287,7 +287,7 @@ inline int hal_ni_warpAffine(int src_type, const uchar *src_data, size_t src_ste @param borderValue values to use for CV_HAL_BORDER_CONSTANT mode @sa cv::warpPerspective, cv::hal::warpPerspective */ -inline int hal_ni_warpPerspective(int src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width, int dst_height, const double M[9], int interpolation, int borderType, const double borderValue[4]) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_warpPerspective(ElemType src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width, int dst_height, const double M[9], int interpolation, int borderType, const double borderValue[4]) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED #define cv_hal_resize hal_ni_resize @@ -306,7 +306,7 @@ inline int hal_ni_warpPerspective(int src_type, const uchar *src_data, size_t sr @param swapBlue if set to true B and R channels will be swapped (BGR->RGB or RGB->BGR) Convert between BGR, BGRA, RGB and RGBA image formats. */ -inline int hal_ni_cvtBGRtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int scn, int dcn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtBGRtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int scn, int dcn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtBGRtoBGR5x5 @@ -344,7 +344,7 @@ inline int hal_ni_cvtBGR5x5toBGR(const uchar * src_data, size_t src_step, uchar @param swapBlue if set to true B and R source channels will be swapped (treat as RGB) Convert from BGR, BGRA, RGB or RGBA to 1-channel gray. */ -inline int hal_ni_cvtBGRtoGray(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int scn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtBGRtoGray(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int scn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtGraytoBGR @@ -355,7 +355,7 @@ inline int hal_ni_cvtBGRtoGray(const uchar * src_data, size_t src_step, uchar * @param dcn destination image channels (3 or 4) Convert from 1-channel gray to BGR, RGB, RGBA or BGRA. */ -inline int hal_ni_cvtGraytoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int dcn) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtGraytoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int dcn) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtBGR5x5toGray @@ -390,7 +390,7 @@ inline int hal_ni_cvtGraytoBGR5x5(const uchar * src_data, size_t src_step, uchar @param isCbCr if set to true write output in YCbCr format Convert from BGR, RGB, BGRA or RGBA to YUV or YCbCr. */ -inline int hal_ni_cvtBGRtoYUV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int scn, bool swapBlue, bool isCbCr) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtBGRtoYUV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int scn, bool swapBlue, bool isCbCr) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtYUVtoBGR @@ -403,7 +403,7 @@ inline int hal_ni_cvtBGRtoYUV(const uchar * src_data, size_t src_step, uchar * d @param isCbCr if set to true treat source as YCbCr Convert from YUV or YCbCr to BGR, RGB, BGRA or RGBA. */ -inline int hal_ni_cvtYUVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int dcn, bool swapBlue, bool isCbCr) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtYUVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int dcn, bool swapBlue, bool isCbCr) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtBGRtoXYZ @@ -415,7 +415,7 @@ inline int hal_ni_cvtYUVtoBGR(const uchar * src_data, size_t src_step, uchar * d @param swapBlue if set to true B and R source channels will be swapped (treat as RGB) Convert from BGR, RGB, BGRA or RGBA to XYZ. */ -inline int hal_ni_cvtBGRtoXYZ(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int scn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtBGRtoXYZ(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int scn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtXYZtoBGR @@ -427,7 +427,7 @@ inline int hal_ni_cvtBGRtoXYZ(const uchar * src_data, size_t src_step, uchar * d @param swapBlue if set to true B and R destination channels will be swapped (write RGB) Convert from XYZ to BGR, RGB, BGRA or RGBA. */ -inline int hal_ni_cvtXYZtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int dcn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtXYZtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int dcn, bool swapBlue) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtBGRtoHSV @@ -441,7 +441,7 @@ inline int hal_ni_cvtXYZtoBGR(const uchar * src_data, size_t src_step, uchar * d @param isHSV if set to true write HSV otherwise HSL Convert from BGR, RGB, BGRA or RGBA to HSV or HSL. */ -inline int hal_ni_cvtBGRtoHSV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int scn, bool swapBlue, bool isFullRange, bool isHSV) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtBGRtoHSV(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int scn, bool swapBlue, bool isFullRange, bool isHSV) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtHSVtoBGR @@ -455,7 +455,7 @@ inline int hal_ni_cvtBGRtoHSV(const uchar * src_data, size_t src_step, uchar * d @param isHSV if set to true treat source as HSV otherwise HSL Convert from HSV or HSL to BGR, RGB, BGRA or RGBA. */ -inline int hal_ni_cvtHSVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtHSVtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtBGRtoLab @@ -469,7 +469,7 @@ inline int hal_ni_cvtHSVtoBGR(const uchar * src_data, size_t src_step, uchar * d @param srgb if set to true use sRGB gamma correction Convert from BGR, RGB, BGRA or RGBA to Lab or Luv. */ -inline int hal_ni_cvtBGRtoLab(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int scn, bool swapBlue, bool isLab, bool srgb) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtBGRtoLab(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int scn, bool swapBlue, bool isLab, bool srgb) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtLabtoBGR @@ -483,7 +483,7 @@ inline int hal_ni_cvtBGRtoLab(const uchar * src_data, size_t src_step, uchar * d @param srgb if set to true use sRGB gamma correction Convert from Lab or Luv to BGR, RGB, BGRA or RGBA. */ -inline int hal_ni_cvtLabtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, int depth, int dcn, bool swapBlue, bool isLab, bool srgb) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_cvtLabtoBGR(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, ElemDepth depth, int dcn, bool swapBlue, bool isLab, bool srgb) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } /** @brief hal_cvtTwoPlaneYUVtoBGR @@ -609,7 +609,7 @@ inline int hal_ni_cvtMultipliedRGBAtoRGBA(const uchar * src_data, size_t src_ste CV_64F | CV_64F | CV_64F @sa cv::integral */ -inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src_data, size_t src_step, uchar * sum_data, size_t sum_step, uchar * sqsum_data, size_t sqsum_step, uchar * tilted_data, size_t tilted_step, int width, int height, int cn) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_integral(ElemDepth depth, ElemDepth sdepth, int sqdepth, const uchar * src_data, size_t src_step, uchar * sum_data, size_t sum_step, uchar * sqsum_data, size_t sqsum_step, uchar * tilted_data, size_t tilted_step, int width, int height, int cn) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED #define cv_hal_integral hal_ni_integral @@ -624,7 +624,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src @param cn Number of channels @param ksize Size of kernel */ -inline int hal_ni_medianBlur(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int depth, int cn, int ksize) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_medianBlur(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, ElemDepth depth, int cn, int ksize) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED #define cv_hal_medianBlur hal_ni_medianBlur @@ -658,7 +658,7 @@ inline int hal_ni_adaptiveThreshold(const uchar* src_data, size_t src_step, ucha @param maxValue Value assigned to the pixels for which the condition is satisfied @param thresholdType Thresholding type */ -inline int hal_ni_threshold(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int depth, int cn, double thresh, double maxValue, int thresholdType) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_threshold(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, ElemDepth depth, int cn, double thresh, double maxValue, int thresholdType) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED #define cv_hal_threshold hal_ni_threshold @@ -695,7 +695,7 @@ inline int hal_ni_boxFilter(const uchar* src_data, size_t src_step, uchar* dst_d @param sigmaX,sigmaY Gaussian kernel standard deviation. @param border_type Border type */ -inline int hal_ni_gaussianBlur(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int depth, int cn, size_t margin_left, size_t margin_top, size_t margin_right, size_t margin_bottom, size_t ksize_width, size_t ksize_height, double sigmaX, double sigmaY, int border_type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_gaussianBlur(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, ElemDepth depth, int cn, size_t margin_left, size_t margin_top, size_t margin_right, size_t margin_bottom, size_t ksize_width, size_t ksize_height, double sigmaX, double sigmaY, int border_type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED #define cv_hal_gaussianBlur hal_ni_gaussianBlur @@ -750,7 +750,7 @@ inline int hal_ni_scharr(const uchar* src_data, size_t src_step, uchar* dst_data @param cn Number of channels @param border_type Border type */ -inline int hal_ni_pyrdown(const uchar* src_data, size_t src_step, int src_width, int src_height, uchar* dst_data, size_t dst_step, int dst_width, int dst_height, int depth, int cn, int border_type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +inline int hal_ni_pyrdown(const uchar* src_data, size_t src_step, int src_width, int src_height, uchar* dst_data, size_t dst_step, int dst_width, int dst_height, ElemDepth depth, int cn, int border_type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } //! @cond IGNORED #define cv_hal_pyrdown hal_ni_pyrdown diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 59384fce7d9f..a51862191558 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -128,7 +128,8 @@ static void histPrepareImages( const Mat* images, int nimages, const int* channe CV_Assert( channels != 0 || nimages == dims ); imsize = images[0].size(); - int depth = images[0].depth(), esz1 = (int)images[0].elemSize1(); + ElemDepth depth = images[0].depth(); + int esz1 = (int)images[0].elemSize1(); bool isContinuous = true; ptrs.resize(dims + 1); @@ -638,7 +639,7 @@ class ipp_calcHistParallel: public ParallelLoopBody m_uniform = uniform; m_ranges = ranges; m_histSize = histSize; - m_type = ippiGetDataType(src.type()); + m_type = ippiGetDataType(src.depth()); m_levelsNum = histSize+1; ippiHistogram_C1 = getIppiHistogramFunction_C1(src.type()); m_fullRoi = ippiSize(src.size()); @@ -783,9 +784,9 @@ namespace cv ivx::Distribution vxHist = ivx::Distribution::create(ctx, histSize, offset, range); ivx::IVX_CHECK_STATUS(vxuHistogram(ctx, img, vxHist)); - _hist.create(1, &histSize, CV_32F); + _hist.create(1, &histSize, CV_32FC1); Mat hist = _hist.getMat(), ihist = hist; - ihist.flags = (ihist.flags & ~CV_MAT_TYPE_MASK) | CV_32S; + ihist.flags = (ihist.flags & ~CV_MAT_TYPE_MASK) | CV_32SC1; vxHist.copyTo(ihist); ihist.convertTo(hist, CV_32F); @@ -827,7 +828,7 @@ static bool ipp_calchist(const Mat &image, Mat &hist, int histSize, const float* Mat ihist = hist; if(accumulate) - ihist.create(1, &histSize, CV_32S); + ihist.create(1, &histSize, CV_32SC1); bool ok = true; int threads = ippiSuggestThreadsNum(image, (1+((double)ihist.total()/image.total()))*2); @@ -877,7 +878,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels, CV_Assert(dims > 0 && histSize); const uchar* const histdata = _hist.getMat().ptr(); - _hist.create(dims, histSize, CV_32F); + _hist.create(dims, histSize, CV_32FC1); Mat hist = _hist.getMat(); if(histdata != hist.data) @@ -889,7 +890,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels, ipp_calchist(images[0], hist, histSize[0], ranges, uniform, accumulate)); Mat ihist = hist; - ihist.flags = (ihist.flags & ~CV_MAT_TYPE_MASK)|CV_32S; + ihist.flags = static_cast((ihist.flags & ~CV_MAT_TYPE_MASK) | CV_32SC1); if(!accumulate) hist = Scalar(0.); @@ -906,7 +907,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels, uniform, ptrs, deltas, imsize, uniranges ); const double* _uniranges = uniform ? &uniranges[0] : 0; - int depth = images[0].depth(); + ElemDepth depth = images[0].depth(); if( depth == CV_8U ) calcHist_8u(ptrs, deltas, imsize, ihist, dims, ranges, _uniranges, uniform ); @@ -1062,7 +1063,7 @@ static void calcHist( const Mat* images, int nimages, const int* channels, size_t i, N; if( !accumulate ) - hist.create(dims, histSize, CV_32F); + hist.create(dims, histSize, CV_32FC1); else { SparseMatIterator it = hist.begin(); @@ -1084,7 +1085,7 @@ static void calcHist( const Mat* images, int nimages, const int* channels, uniform, ptrs, deltas, imsize, uniranges ); const double* _uniranges = uniform ? &uniranges[0] : 0; - int depth = images[0].depth(); + ElemDepth depth = images[0].depth(); if( depth == CV_8U ) calcSparseHist_8u(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, uniform ); else if( depth == CV_16U ) @@ -1113,7 +1114,7 @@ enum BINS = 256 }; -static bool ocl_calcHist1(InputArray _src, OutputArray _hist, int ddepth = CV_32S) +static bool ocl_calcHist1(InputArray _src, OutputArray _hist, ElemDepth ddepth = CV_32S) { const ocl::Device & dev = ocl::Device::getDefault(); int compunits = dev.maxComputeUnits(); @@ -1130,7 +1131,7 @@ static bool ocl_calcHist1(InputArray _src, OutputArray _hist, int ddepth = CV_32 if (k1.empty()) return false; - _hist.create(BINS, 1, ddepth); + _hist.create(BINS, 1, CV_MAKETYPE(ddepth, 1)); UMat src = _src.getUMat(), ghist(1, BINS * compunits, CV_32SC1), hist = _hist.getUMat(); @@ -1529,13 +1530,13 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels, int dims = hist.dims == 2 && hist.size[1] == 1 ? 1 : hist.dims; CV_Assert( dims > 0 && !hist.empty() ); - _backProject.create( images[0].size(), images[0].depth() ); + _backProject.create(images[0].size(), CV_MAKETYPE(images[0].depth(), 1)); Mat backProject = _backProject.getMat(); histPrepareImages( images, nimages, channels, backProject, dims, hist.size, ranges, uniform, ptrs, deltas, imsize, uniranges ); const double* _uniranges = uniform ? &uniranges[0] : 0; - int depth = images[0].depth(); + ElemDepth depth = images[0].depth(); if( depth == CV_8U ) calcBackProj_8u(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, (float)scale, uniform); else if( depth == CV_16U ) @@ -1697,13 +1698,13 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels, int dims = hist.dims(); CV_Assert( dims > 0 ); - _backProject.create( images[0].size(), images[0].depth() ); + _backProject.create(images[0].size(), CV_MAKETYPE(images[0].depth(), 1)); Mat backProject = _backProject.getMat(); histPrepareImages( images, nimages, channels, backProject, dims, hist.hdr->size, ranges, uniform, ptrs, deltas, imsize, uniranges ); const double* _uniranges = uniform ? &uniranges[0] : 0; - int depth = images[0].depth(); + ElemDepth depth = images[0].depth(); if( depth == CV_8U ) calcSparseBackProj_8u(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, (float)scale, uniform); @@ -1758,7 +1759,7 @@ static bool ocl_calcBackProject( InputArrayOfArrays _images, std::vector ch CV_Assert(nimages > 0); Size size = images[0].size(); - int depth = images[0].depth(); + ElemDepth depth = images[0].depth(); //kernels are valid for this type only if (depth != CV_8U) @@ -1799,7 +1800,7 @@ static bool ocl_calcBackProject( InputArrayOfArrays _images, std::vector ch if (mapk.empty()) return false; - _dst.create(size, depth); + _dst.create(size, CV_MAKETYPE(depth, 1)); UMat dst = _dst.getUMat(); im.offset += cnidx; @@ -1845,7 +1846,7 @@ static bool ocl_calcBackProject( InputArrayOfArrays _images, std::vector ch if (mapk.empty()) return false; - _dst.create(size, depth); + _dst.create(size, CV_MAKETYPE(depth, 1)); UMat dst = _dst.getUMat(); im0.offset += cnidx0; @@ -1890,7 +1891,7 @@ void cv::calcBackProject( InputArrayOfArrays images, const std::vector& cha int hsz[CV_CN_MAX+1]; memcpy(hsz, &H0.size[0], H0.dims*sizeof(hsz[0])); hsz[H0.dims] = hcn; - H = Mat(H0.dims+1, hsz, H0.depth(), H0.ptr()); + H = Mat(H0.dims + 1, hsz, CV_MAKETYPE(H0.depth(), 1), H0.ptr()); } else H = H0; @@ -2136,7 +2137,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method ) double result = 0; int i, dims = H1.dims(); - CV_Assert( dims > 0 && dims == H2.dims() && H1.type() == H2.type() && H1.type() == CV_32F ); + CV_Assert( dims > 0 && dims == H2.dims() && H1.type() == H2.type() && H1.type() == CV_32FC1 ); for( i = 0; i < dims; i++ ) CV_Assert( H1.size(i) == H2.size(i) ); @@ -2253,7 +2254,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method ) } -const int CV_HIST_DEFAULT_TYPE = CV_32F; +const ElemType CV_HIST_DEFAULT_TYPE = CV_32FC1; /* Creates new histogram */ CvHistogram * diff --git a/modules/imgproc/src/hough.cpp b/modules/imgproc/src/hough.cpp index eb4acdad4910..7b4b7a840b4d 100644 --- a/modules/imgproc/src/hough.cpp +++ b/modules/imgproc/src/hough.cpp @@ -105,7 +105,7 @@ array of (rho, theta) pairs. linesMax is the buffer size (number of pairs). Functions return the actual number of found lines. */ static void -HoughLinesStandard( InputArray src, OutputArray lines, int type, +HoughLinesStandard( InputArray src, OutputArray lines, ElemType type, float rho, float theta, int threshold, int linesMax, double min_theta, double max_theta ) @@ -231,7 +231,7 @@ struct hough_index static void -HoughLinesSDiv( InputArray image, OutputArray lines, int type, +HoughLinesSDiv( InputArray image, OutputArray lines, ElemType type, float rho, float theta, int threshold, int srn, int stn, int linesMax, double min_theta, double max_theta ) @@ -897,7 +897,7 @@ void HoughLines( InputArray _image, OutputArray lines, { CV_INSTRUMENT_REGION(); - int type = CV_32FC2; + ElemType type = CV_32FC2; if (lines.fixedType()) { type = lines.type(); @@ -1726,7 +1726,7 @@ static void HoughCircles( InputArray _image, OutputArray _circles, { CV_INSTRUMENT_REGION(); - int type = CV_32FC3; + ElemType type = CV_32FC3; if( _circles.fixedType() ) { type = _circles.type(); diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 601c59a03dc9..890851deb873 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -75,7 +75,7 @@ bool IPPSetSimple(cv::Scalar value, void *dataPointer, int step, IppiSize &size, return func(values, dataPointer, step, size) >= 0; } -static bool IPPSet(const cv::Scalar &value, void *dataPointer, int step, IppiSize &size, int channels, int depth) +static bool IPPSet(const cv::Scalar &value, void *dataPointer, int step, IppiSize &size, int channels, ElemDepth depth) { CV_INSTRUMENT_REGION_IPP(); @@ -1301,8 +1301,10 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input int interpolation, int borderType, const Scalar& borderValue) { const ocl::Device & dev = ocl::Device::getDefault(); - int cn = _src.channels(), type = _src.type(), depth = _src.depth(), - rowsPerWI = dev.isIntel() ? 4 : 1; + int cn = _src.channels(); + ElemType type = _src.type(); + ElemDepth depth = _src.depth(); + int rowsPerWI = dev.isIntel() ? 4 : 1; if (borderType == BORDER_TRANSPARENT || !(interpolation == INTER_LINEAR || interpolation == INTER_NEAREST) || _map1.type() == CV_16SC1 || _map2.type() == CV_16SC1) @@ -1346,7 +1348,7 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input if (interpolation != INTER_NEAREST) { char cvt[3][40]; - int wdepth = std::max(CV_32F, depth); + ElemDepth wdepth = CV_MAX_DEPTH(CV_32F, depth); buildOptions = buildOptions + format(" -D WT=%s -D convertToT=%s -D convertToWT=%s" " -D convertToWT2=%s -D WT2=%s", @@ -1357,7 +1359,7 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input ocl::typeToStr(CV_MAKE_TYPE(wdepth, 2))); } int scalarcn = cn == 3 ? 4 : cn; - int sctype = CV_MAKETYPE(depth, scalarcn); + ElemType sctype = CV_MAKETYPE(depth, scalarcn); buildOptions += format(" -D T=%s -D T1=%s -D cn=%d -D ST=%s -D depth=%d", ocl::typeToStr(type), ocl::typeToStr(depth), cn, ocl::typeToStr(sctype), depth); @@ -1391,11 +1393,11 @@ static bool ocl_linearPolar(InputArray _src, OutputArray _dst, UMat src = _src.getUMat(); _dst.create(src.size(), src.type()); Size dsize = src.size(); - r.create(Size(1, dsize.width), CV_32F); + r.create(Size(1, dsize.width), CV_32FC1); cp_sp.create(Size(1, dsize.height), CV_32FC2); - mapx.create(dsize, CV_32F); - mapy.create(dsize, CV_32F); + mapx.create(dsize, CV_32FC1); + mapy.create(dsize, CV_32FC1); size_t w = dsize.width; size_t h = dsize.height; String buildOptions; @@ -1460,11 +1462,11 @@ static bool ocl_logPolar(InputArray _src, OutputArray _dst, UMat src = _src.getUMat(); _dst.create(src.size(), src.type()); Size dsize = src.size(); - r.create(Size(1, dsize.width), CV_32F); + r.create(Size(1, dsize.width), CV_32FC1); cp_sp.create(Size(1, dsize.height), CV_32FC2); - mapx.create(dsize, CV_32F); - mapy.create(dsize, CV_32F); + mapx.create(dsize, CV_32FC1); + mapy.create(dsize, CV_32FC1); size_t w = dsize.width; size_t h = dsize.height; String buildOptions; @@ -1635,7 +1637,9 @@ class IPPRemapInvoker : IppiRect srcRoiRect = { 0, 0, src.cols, src.rows }; Mat dstRoi = dst.rowRange(range); IppiSize dstRoiSize = ippiSize(dstRoi.size()); - int type = dst.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = dst.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if (borderType == BORDER_CONSTANT && !IPPSet(borderValue, dstRoi.ptr(), (int)dstRoi.step, dstRoiSize, cn, depth)) @@ -1734,7 +1738,8 @@ void cv::remap( InputArray _src, OutputArray _dst, if( interpolation == INTER_AREA ) interpolation = INTER_LINEAR; - int type = src.type(), depth = CV_MAT_DEPTH(type); + ElemType type = src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); #if defined HAVE_IPP && !IPP_DISABLE_REMAP CV_IPP_CHECK() @@ -1830,14 +1835,14 @@ void cv::remap( InputArray _src, OutputArray _dst, void cv::convertMaps( InputArray _map1, InputArray _map2, OutputArray _dstmap1, OutputArray _dstmap2, - int dstm1type, bool nninterpolate ) + ElemType dstm1type, bool nninterpolate ) { CV_INSTRUMENT_REGION(); Mat map1 = _map1.getMat(), map2 = _map2.getMat(), dstmap1, dstmap2; Size size = map1.size(); const Mat *m1 = &map1, *m2 = &map2; - int m1type = m1->type(), m2type = m2->type(); + ElemType m1type = m1->type(), m2type = m2->type(); CV_Assert( (m1type == CV_16SC2 && (nninterpolate || m2type == CV_16UC1 || m2type == CV_16SC1)) || (m2type == CV_16SC2 && (nninterpolate || m1type == CV_16UC1 || m1type == CV_16SC1)) || @@ -1850,7 +1855,7 @@ void cv::convertMaps( InputArray _map1, InputArray _map2, std::swap( m1type, m2type ); } - if( dstm1type <= 0 ) + if (dstm1type <= CV_8UC1) dstm1type = m1type == CV_16SC2 ? CV_32FC2 : CV_16SC2; CV_Assert( dstm1type == CV_16SC2 || dstm1type == CV_32FC1 || dstm1type == CV_32FC2 ); _dstmap1.create( size, dstm1type ); @@ -1868,7 +1873,7 @@ void cv::convertMaps( InputArray _map1, InputArray _map2, ((m1type == CV_16SC2 && dstm1type == CV_32FC2) || (m1type == CV_32FC2 && dstm1type == CV_16SC2))) ) { - m1->convertTo( dstmap1, dstmap1.type() ); + m1->convertTo( dstmap1, dstmap1.depth() ); if( !dstmap2.empty() && dstmap2.type() == m2->type() ) m2->copyTo( dstmap2 ); return; @@ -2296,7 +2301,7 @@ class WarpAffineInvoker : remap( src, dpart, _XY, Mat(), interpolation, borderType, borderValue ); else { - Mat _matA(bh, bw, CV_16U, A); + Mat _matA(bh, bw, CV_16UC1, A); remap( src, dpart, _XY, _matA, interpolation, borderType, borderValue ); } } @@ -2378,7 +2383,10 @@ static bool ocl_warpTransform_cols4(InputArray _src, OutputArray _dst, InputArra { CV_Assert(op_type == OCL_OP_AFFINE || op_type == OCL_OP_PERSPECTIVE); const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), dtype = _dst.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemType dtype = _dst.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int interpolation = flags & INTER_MAX; if( interpolation == INTER_AREA ) @@ -2396,8 +2404,8 @@ static bool ocl_warpTransform_cols4(InputArray _src, OutputArray _dst, InputArra String kernelName = format("warp%s_%s_8u", warp_op[op_type], interpolationMap[interpolation]); bool is32f = (interpolation == INTER_CUBIC || interpolation == INTER_LINEAR) && op_type == OCL_OP_AFFINE; - int wdepth = interpolation == INTER_NEAREST ? depth : std::max(is32f ? CV_32F : CV_32S, depth); - int sctype = CV_MAKETYPE(wdepth, cn); + int wdepth = interpolation == INTER_NEAREST ? depth : CV_MAX_DEPTH(is32f ? CV_32F : CV_32S, depth); + ElemType sctype = CV_MAKETYPE(wdepth, cn); ocl::Kernel k; String opts = format("-D ST=%s", ocl::typeToStr(sctype)); @@ -2415,9 +2423,9 @@ static bool ocl_warpTransform_cols4(InputArray _src, OutputArray _dst, InputArra float M[9] = {0}; int matRows = (op_type == OCL_OP_AFFINE ? 2 : 3); - Mat matM(matRows, 3, CV_32F, M), M1 = _M0.getMat(); - CV_Assert( (M1.type() == CV_32F || M1.type() == CV_64F) && M1.rows == matRows && M1.cols == 3 ); - M1.convertTo(matM, matM.type()); + Mat matM(matRows, 3, CV_32FC1, M), M1 = _M0.getMat(); + CV_Assert( (M1.type() == CV_32FC1 || M1.type() == CV_64FC1) && M1.rows == matRows && M1.cols == 3 ); + M1.convertTo(matM, matM.depth()); if( !(flags & WARP_INVERSE_MAP) ) { @@ -2454,7 +2462,9 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0, CV_Assert(op_type == OCL_OP_AFFINE || op_type == OCL_OP_PERSPECTIVE); const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); const bool doubleSupport = dev.doubleFPConfig() > 0; int interpolation = flags & INTER_MAX; @@ -2476,8 +2486,8 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0, int scalarcn = cn == 3 ? 4 : cn; bool is32f = !dev.isAMD() && (interpolation == INTER_CUBIC || interpolation == INTER_LINEAR) && op_type == OCL_OP_AFFINE; - int wdepth = interpolation == INTER_NEAREST ? depth : std::max(is32f ? CV_32F : CV_32S, depth); - int sctype = CV_MAKETYPE(wdepth, scalarcn); + ElemDepth wdepth = interpolation == INTER_NEAREST ? depth : CV_MAX_DEPTH(is32f ? CV_32F : CV_32S, depth); + ElemType sctype = CV_MAKETYPE(wdepth, scalarcn); ocl::Kernel k; String opts; @@ -2519,10 +2529,10 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0, double M[9] = {0}; int matRows = (op_type == OCL_OP_AFFINE ? 2 : 3); - Mat matM(matRows, 3, CV_64F, M), M1 = _M0.getMat(); - CV_Assert( (M1.type() == CV_32F || M1.type() == CV_64F) && + Mat matM(matRows, 3, CV_64FC1, M), M1 = _M0.getMat(); + CV_Assert( (M1.type() == CV_32FC1 || M1.type() == CV_64FC1) && M1.rows == matRows && M1.cols == 3 ); - M1.convertTo(matM, matM.type()); + M1.convertTo(matM, matM.depth()); if( !(flags & WARP_INVERSE_MAP) ) { @@ -2553,7 +2563,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0, namespace hal { -void warpAffine(int src_type, +void warpAffine(ElemType src_type, const uchar * src_data, size_t src_step, int src_width, int src_height, uchar * dst_data, size_t dst_step, int dst_width, int dst_height, const double M[6], int interpolation, int borderType, const double borderValue[4]) @@ -2613,12 +2623,12 @@ void cv::warpAffine( InputArray _src, OutputArray _dst, src = src.clone(); double M[6] = {0}; - Mat matM(2, 3, CV_64F, M); + Mat matM(2, 3, CV_64FC1, M); if( interpolation == INTER_AREA ) interpolation = INTER_LINEAR; - CV_Assert( (M0.type() == CV_32F || M0.type() == CV_64F) && M0.rows == 2 && M0.cols == 3 ); - M0.convertTo(matM, matM.type()); + CV_Assert( (M0.type() == CV_32FC1 || M0.type() == CV_64FC1) && M0.rows == 2 && M0.cols == 3 ); + M0.convertTo(matM, matM.depth()); if( !(flags & WARP_INVERSE_MAP) ) { @@ -2635,7 +2645,9 @@ void cv::warpAffine( InputArray _src, OutputArray _dst, #if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_WARPAFFINE CV_IPP_CHECK() { - int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if( ( depth == CV_8U || depth == CV_16U || depth == CV_32F ) && ( cn == 1 || cn == 3 || cn == 4 ) && ( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) && @@ -2806,7 +2818,7 @@ class WarpPerspectiveInvoker : remap( src, dpart, _XY, Mat(), interpolation, borderType, borderValue ); else { - Mat _matA(bh, bw, CV_16U, A); + Mat _matA(bh, bw, CV_16UC1, A); remap( src, dpart, _XY, _matA, interpolation, borderType, borderValue ); } } @@ -2878,7 +2890,7 @@ class IPPWarpPerspectiveInvoker : namespace hal { -void warpPerspective(int src_type, +void warpPerspective(ElemType src_type, const uchar * src_data, size_t src_step, int src_width, int src_height, uchar * dst_data, size_t dst_step, int dst_width, int dst_height, const double M[9], int interpolation, int borderType, const double borderValue[4]) @@ -2919,18 +2931,20 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0, src = src.clone(); double M[9]; - Mat matM(3, 3, CV_64F, M); + Mat matM(3, 3, CV_64FC1, M); int interpolation = flags & INTER_MAX; if( interpolation == INTER_AREA ) interpolation = INTER_LINEAR; - CV_Assert( (M0.type() == CV_32F || M0.type() == CV_64F) && M0.rows == 3 && M0.cols == 3 ); - M0.convertTo(matM, matM.type()); + CV_Assert( (M0.type() == CV_32FC1 || M0.type() == CV_64FC1) && M0.rows == 3 && M0.cols == 3 ); + M0.convertTo(matM, matM.depth()); #if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_WARPPERSPECTIVE CV_IPP_CHECK() { - int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if( (depth == CV_8U || depth == CV_16U || depth == CV_32F) && (cn == 1 || cn == 3 || cn == 4) && ( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT ) && @@ -3002,7 +3016,7 @@ cv::Mat cv::getRotationMatrix2D( Point2f center, double angle, double scale ) double alpha = std::cos(angle)*scale; double beta = std::sin(angle)*scale; - Mat M(2, 3, CV_64F); + Mat M(2, 3, CV_64FC1); double* m = M.ptr(); m[0] = alpha; @@ -3043,9 +3057,9 @@ cv::Mat cv::getPerspectiveTransform(const Point2f src[], const Point2f dst[], in { CV_INSTRUMENT_REGION(); - Mat M(3, 3, CV_64F), X(8, 1, CV_64F, M.ptr()); + Mat M(3, 3, CV_64FC1), X(8, 1, CV_64FC1, M.ptr()); double a[8][8], b[8]; - Mat A(8, 8, CV_64F, a), B(8, 1, CV_64F, b); + Mat A(8, 8, CV_64FC1, a), B(8, 1, CV_64FC1, b); for( int i = 0; i < 4; ++i ) { @@ -3089,9 +3103,9 @@ cv::Mat cv::getPerspectiveTransform(const Point2f src[], const Point2f dst[], in cv::Mat cv::getAffineTransform( const Point2f src[], const Point2f dst[] ) { - Mat M(2, 3, CV_64F), X(6, 1, CV_64F, M.ptr()); + Mat M(2, 3, CV_64FC1), X(6, 1, CV_64FC1, M.ptr()); double a[6*6], b[6]; - Mat A(6, 6, CV_64F, a), B(6, 1, CV_64F, b); + Mat A(6, 6, CV_64FC1, a), B(6, 1, CV_64FC1, b); for( int i = 0; i < 3; i++ ) { @@ -3117,7 +3131,7 @@ void cv::invertAffineTransform(InputArray _matM, OutputArray __iM) __iM.create(2, 3, matM.type()); Mat _iM = __iM.getMat(); - if( matM.type() == CV_32F ) + if( matM.type() == CV_32FC1 ) { const softfloat* M = matM.ptr(); softfloat* iM = _iM.ptr(); @@ -3132,7 +3146,7 @@ void cv::invertAffineTransform(InputArray _matM, OutputArray __iM) iM[0] = A11; iM[1] = A12; iM[2] = b1; iM[istep] = A21; iM[istep+1] = A22; iM[istep+2] = b2; } - else if( matM.type() == CV_64F ) + else if( matM.type() == CV_64FC1 ) { const softdouble* M = matM.ptr(); softdouble* iM = _iM.ptr(); @@ -3210,7 +3224,7 @@ cv2DRotationMatrix( CvPoint2D32f center, double angle, { cv::Mat M0 = cv::cvarrToMat(matrix), M = cv::getRotationMatrix2D(center, angle, scale); CV_Assert( M.size() == M0.size() ); - M.convertTo(M0, M0.type()); + M.convertTo(M0, M0.depth()); return matrix; } @@ -3223,7 +3237,7 @@ cvGetPerspectiveTransform( const CvPoint2D32f* src, cv::Mat M0 = cv::cvarrToMat(matrix), M = cv::getPerspectiveTransform((const cv::Point2f*)src, (const cv::Point2f*)dst); CV_Assert( M.size() == M0.size() ); - M.convertTo(M0, M0.type()); + M.convertTo(M0, M0.depth()); return matrix; } @@ -3236,7 +3250,7 @@ cvGetAffineTransform( const CvPoint2D32f* src, cv::Mat M0 = cv::cvarrToMat(matrix), M = cv::getAffineTransform((const cv::Point2f*)src, (const cv::Point2f*)dst); CV_Assert( M.size() == M0.size() ); - M.convertTo(M0, M0.type()); + M.convertTo(M0, M0.depth()); return matrix; } @@ -3278,8 +3292,8 @@ void cv::warpPolar(InputArray _src, OutputArray _dst, Size dsize, } Mat mapx, mapy; - mapx.create(dsize, CV_32F); - mapy.create(dsize, CV_32F); + mapx.create(dsize, CV_32FC1); + mapy.create(dsize, CV_32FC1); bool semiLog = (flags & WARP_POLAR_LOG) != 0; if (!(flags & CV_WARP_INVERSE_MAP)) @@ -3289,7 +3303,7 @@ void cv::warpPolar(InputArray _src, OutputArray _dst, Size dsize, int phi, rho; // precalculate scaled rho - Mat rhos = Mat(1, dsize.width, CV_32F); + Mat rhos = Mat(1, dsize.width, CV_32FC1); float* bufRhos = (float*)(rhos.data); if (semiLog) { @@ -3342,10 +3356,10 @@ void cv::warpPolar(InputArray _src, OutputArray _dst, Size dsize, int x, y; Mat bufx, bufy, bufp, bufa; - bufx = Mat(1, dsize.width, CV_32F); - bufy = Mat(1, dsize.width, CV_32F); - bufp = Mat(1, dsize.width, CV_32F); - bufa = Mat(1, dsize.width, CV_32F); + bufx = Mat(1, dsize.width, CV_32FC1); + bufy = Mat(1, dsize.width, CV_32FC1); + bufp = Mat(1, dsize.width, CV_32FC1); + bufa = Mat(1, dsize.width, CV_32FC1); for (x = 0; x < dsize.width; x++) bufx.at(0, x) = (float)x - center.x; diff --git a/modules/imgproc/src/linefit.cpp b/modules/imgproc/src/linefit.cpp index 1abde1e0d1b8..a56432b7e367 100644 --- a/modules/imgproc/src/linefit.cpp +++ b/modules/imgproc/src/linefit.cpp @@ -184,9 +184,9 @@ static void fitLine3D_wods( const Point3f * points, int count, float *weights, f det[8] = dy2 + dx2; // Searching for a eigenvector of det corresponding to the minimal eigenvalue - Mat _det( 3, 3, CV_32F, det ); - Mat _evc( 3, 3, CV_32F, evc ); - Mat _evl( 3, 1, CV_32F, evl ); + Mat _det( 3, 3, CV_32FC1, det ); + Mat _evc( 3, 3, CV_32FC1, evc ); + Mat _evl( 3, 1, CV_32FC1, evl ); eigen( _det, _evl, _evc ); i = evl[0] < evl[1] ? (evl[0] < evl[2] ? 0 : 2) : (evl[1] < evl[2] ? 1 : 2); @@ -601,8 +601,8 @@ void cv::fitLine( InputArray _points, OutputArray _line, int distType, Mat points = _points.getMat(); float linebuf[6]={0.f}; - int npoints2 = points.checkVector(2, -1, false); - int npoints3 = points.checkVector(3, -1, false); + int npoints2 = points.checkVector(2, CV_DEPTH_AUTO, false); + int npoints3 = points.checkVector(3, CV_DEPTH_AUTO, false); CV_Assert( npoints2 >= 0 || npoints3 >= 0 ); @@ -620,7 +620,7 @@ void cv::fitLine( InputArray _points, OutputArray _line, int distType, fitLine3D( points.ptr(), npoints3, distType, (float)param, (float)reps, (float)aeps, linebuf); - Mat(npoints2 >= 0 ? 4 : 6, 1, CV_32F, linebuf).copyTo(_line); + Mat(npoints2 >= 0 ? 4 : 6, 1, CV_32FC1, linebuf).copyTo(_line); } @@ -632,7 +632,7 @@ cvFitLine( const CvArr* array, int dist, double param, cv::AutoBuffer buf; cv::Mat points = cv::cvarrToMat(array, false, false, 0, &buf); - cv::Mat linemat(points.checkVector(2) >= 0 ? 4 : 6, 1, CV_32F, line); + cv::Mat linemat(points.checkVector(2) >= 0 ? 4 : 6, 1, CV_32FC1, line); cv::fitLine(points, linemat, dist, param, reps, aeps); } diff --git a/modules/imgproc/src/moments.cpp b/modules/imgproc/src/moments.cpp index 6a0a960b193f..95628c873a9d 100644 --- a/modules/imgproc/src/moments.cpp +++ b/modules/imgproc/src/moments.cpp @@ -511,7 +511,7 @@ static bool ocl_moments( InputArray _src, Moments& m, bool binary) return false; UMat src = _src.getUMat(); - UMat umbuf(1, ntiles*K, CV_32S); + UMat umbuf(1, ntiles*K, CV_32SC1); size_t globalsize[] = {(size_t)xtiles, std::max((size_t)TILE_SIZE, (size_t)sz.height)}; size_t localsize[] = {1, TILE_SIZE}; @@ -663,7 +663,9 @@ cv::Moments cv::moments( InputArray _src, bool binary ) MomentsInTileFunc func = 0; uchar nzbuf[TILE_SIZE*TILE_SIZE]; Moments m; - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); Size size = _src.size(); if( size.width <= 0 || size.height <= 0 ) @@ -709,7 +711,7 @@ cv::Moments cv::moments( InputArray _src, bool binary ) if( binary ) { - cv::Mat tmp(tileSize, CV_8U, nzbuf); + cv::Mat tmp(tileSize, CV_8UC1, nzbuf); cv::compare( src, 0, tmp, CV_CMP_NE ); src = tmp; } @@ -798,7 +800,7 @@ void cv::HuMoments( const Moments& m, OutputArray _hu ) { CV_INSTRUMENT_REGION(); - _hu.create(7, 1, CV_64F); + _hu.create(7, 1, CV_64FC1); Mat hu = _hu.getMat(); CV_Assert( hu.isContinuous() ); HuMoments(m, hu.ptr()); diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 66fae07fae77..805916d60774 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -784,7 +784,7 @@ template struct MorphFilter : BaseFilter { anchor = _anchor; ksize = _kernel.size(); - CV_Assert( _kernel.type() == CV_8U ); + CV_Assert( _kernel.type() == CV_8UC1 ); std::vector coeffs; // we do not really the values of non-zero // kernel elements, just their locations @@ -846,7 +846,7 @@ template struct MorphFilter : BaseFilter cv::Ptr cv::getMorphologyRowFilter(int op, int type, int ksize, int anchor) { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); if( anchor < 0 ) anchor = ksize/2; CV_Assert( op == MORPH_ERODE || op == MORPH_DILATE ); @@ -892,7 +892,7 @@ cv::Ptr cv::getMorphologyRowFilter(int op, int type, int ksiz cv::Ptr cv::getMorphologyColumnFilter(int op, int type, int ksize, int anchor) { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); if( anchor < 0 ) anchor = ksize/2; CV_Assert( op == MORPH_ERODE || op == MORPH_DILATE ); @@ -940,7 +940,7 @@ cv::Ptr cv::getMorphologyColumnFilter(int op, int type, in cv::Ptr cv::getMorphologyFilter(int op, int type, InputArray _kernel, Point anchor) { Mat kernel = _kernel.getMat(); - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); anchor = normalizeAnchor(anchor, kernel.size()); CV_Assert( op == MORPH_ERODE || op == MORPH_DILATE ); if( op == MORPH_ERODE ) @@ -974,7 +974,7 @@ cv::Ptr cv::getMorphologyFilter(int op, int type, InputArray _ke } -cv::Ptr cv::createMorphologyFilter( int op, int type, InputArray _kernel, +cv::Ptr cv::createMorphologyFilter(int op, ElemType type, InputArray _kernel, Point anchor, int _rowBorderType, int _columnBorderType, const Scalar& _borderValue ) { @@ -998,7 +998,7 @@ cv::Ptr cv::createMorphologyFilter( int op, int type, InputArr if( (_rowBorderType == BORDER_CONSTANT || _columnBorderType == BORDER_CONSTANT) && borderValue == morphologyDefaultBorderValue() ) { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); CV_Assert( depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F || depth == CV_64F ); if( op == MORPH_ERODE ) @@ -1038,7 +1038,7 @@ cv::Mat cv::getStructuringElement(int shape, Size ksize, Point anchor) inv_r2 = r ? 1./((double)r*r) : 0; } - Mat elem(ksize, CV_8U); + Mat elem(ksize, CV_8UC1); for( i = 0; i < ksize.height; i++ ) { @@ -1076,7 +1076,7 @@ namespace cv // ===== 1. replacement implementation -static bool halMorph(int op, int src_type, int dst_type, +static bool halMorph(int op, ElemType src_type, ElemType dst_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -1124,7 +1124,7 @@ static inline IwiMorphologyType ippiGetMorphologyType(int morphOp) } #endif -static bool ippMorph(int op, int src_type, int dst_type, +static bool ippMorph(int op, ElemType src_type, ElemType dst_type, const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -1320,7 +1320,7 @@ static bool ippMorph(int op, int src_type, int dst_type, // ===== 3. Fallback implementation -static void ocvMorph(int op, int src_type, int dst_type, +static void ocvMorph(int op, ElemType src_type, ElemType dst_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -1330,7 +1330,7 @@ static void ocvMorph(int op, int src_type, int dst_type, int kernel_width, int kernel_height, int anchor_x, int anchor_y, int borderType, const double borderValue[4], int iterations) { - Mat kernel(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step); + Mat kernel(Size(kernel_width, kernel_height), CV_MAKETYPE(kernel_type, 1), kernel_data, kernel_step); Point anchor(anchor_x, anchor_y); Vec borderVal(borderValue); Ptr f = createMorphologyFilter(op, src_type, kernel, anchor, borderType, borderType, borderVal); @@ -1363,7 +1363,7 @@ CV_DEPRECATED Ptr Morph::create(int , int , int , int , int , int , bool , bool ) { return Ptr(); } -void morph(int op, int src_type, int dst_type, +void morph(int op, ElemType src_type, ElemType dst_type, uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, @@ -1409,7 +1409,9 @@ void morph(int op, int src_type, int dst_type, static bool ocl_morph3x3_8UC1( InputArray _src, OutputArray _dst, InputArray _kernel, Point anchor, int op, int actual_op = -1, InputArray _extraMat = noArray()) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); Size ksize = _kernel.size(); Mat kernel8u; @@ -1482,7 +1484,9 @@ static bool ocl_morphSmall( InputArray _src, OutputArray _dst, InputArray _kerne int op, int actual_op = -1, InputArray _extraMat = noArray()) { const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type); bool doubleSupport = dev.doubleFPConfig() > 0; if (cn > 4 || (!doubleSupport && depth == CV_64F) || @@ -1501,7 +1505,8 @@ static bool ocl_morphSmall( InputArray _src, OutputArray _dst, InputArray _kerne Size size = _src.size(), wholeSize; bool isolated = (borderType & BORDER_ISOLATED) != 0; borderType &= ~BORDER_ISOLATED; - int wdepth = depth, wtype = type; + ElemDepth wdepth = depth; + ElemType wtype = type; if (depth == CV_8U) { wdepth = CV_32S; @@ -1639,7 +1644,9 @@ static bool ocl_morphOp(InputArray _src, OutputArray _dst, InputArray _kernel, const Scalar &, int actual_op = -1, InputArray _extraMat = noArray()) { const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); Mat kernel = _kernel.getMat(); Size ksize = !kernel.empty() ? kernel.size() : Size(3, 3), ssize = _src.size(); @@ -1721,7 +1728,8 @@ static bool ocl_morphOp(InputArray _src, OutputArray _dst, InputArray _kernel, static const char * const op2str[] = { "OP_ERODE", "OP_DILATE", NULL, NULL, "OP_GRADIENT", "OP_TOPHAT", "OP_BLACKHAT" }; char cvt[2][50]; - int wdepth = std::max(depth, CV_32F), scalarcn = cn == 3 ? 4 : cn; + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32F); + int scalarcn = cn == 3 ? 4 : cn; if (actual_op < 0) actual_op = op; @@ -2190,7 +2198,7 @@ static void convertConvKernel( const IplConvKernel* src, cv::Mat& dst, cv::Point return; } anchor = cv::Point(src->anchorX, src->anchorY); - dst.create(src->nRows, src->nCols, CV_8U); + dst.create(src->nRows, src->nCols, CV_8UC1); int i, size = src->nRows*src->nCols; for( i = 0; i < size; i++ ) diff --git a/modules/imgproc/src/phasecorr.cpp b/modules/imgproc/src/phasecorr.cpp index a2ba79ee3003..64348b50f452 100644 --- a/modules/imgproc/src/phasecorr.cpp +++ b/modules/imgproc/src/phasecorr.cpp @@ -41,7 +41,8 @@ namespace cv static void magSpectrums( InputArray _src, OutputArray _dst) { Mat src = _src.getMat(); - int depth = src.depth(), cn = src.channels(), type = src.type(); + ElemDepth depth = src.depth(); + int cn = src.channels(), type = src.type(); int rows = src.rows, cols = src.cols; int j, k; @@ -157,7 +158,9 @@ static void magSpectrums( InputArray _src, OutputArray _dst) static void divSpectrums( InputArray _srcA, InputArray _srcB, OutputArray _dst, int flags, bool conjB) { Mat srcA = _srcA.getMat(), srcB = _srcB.getMat(); - int depth = srcA.depth(), cn = srcA.channels(), type = srcA.type(); + ElemDepth depth = srcA.depth(); + int cn = srcA.channels(); + ElemType type = srcA.type(); int rows = srcA.rows, cols = srcA.cols; int j, k; @@ -594,7 +597,7 @@ cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _w } -void cv::createHanningWindow(OutputArray _dst, cv::Size winSize, int type) +void cv::createHanningWindow(OutputArray _dst, cv::Size winSize, ElemType type) { CV_INSTRUMENT_REGION(); diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index 09078965ff84..f6c511c7e993 100644 --- a/modules/imgproc/src/pyramids.cpp +++ b/modules/imgproc/src/pyramids.cpp @@ -1083,7 +1083,9 @@ typedef void (*PyrFunc)(const Mat&, Mat&, int); static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; if (cn > 4 || (depth == CV_64F && !doubleSupport)) @@ -1102,7 +1104,7 @@ static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, in _dst.create( dsize, src.type() ); UMat dst = _dst.getUMat(); - int float_depth = depth == CV_64F ? CV_64F : CV_32F; + ElemDepth float_depth = depth == CV_64F ? CV_64F : CV_32F; const int local_size = 256; int kercn = 1; if (depth == CV_8U && float_depth == CV_32F && cn == 1 && ocl::Device::getDefault().isIntel()) @@ -1132,7 +1134,9 @@ static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, in static bool ocl_pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int channels = CV_MAT_CN(type); if (channels > 4 || borderType != BORDER_DEFAULT) return false; @@ -1150,7 +1154,7 @@ static bool ocl_pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int _dst.create( dsize, src.type() ); UMat dst = _dst.getUMat(); - int float_depth = depth == CV_64F ? CV_64F : CV_32F; + ElemDepth float_depth = depth == CV_64F ? CV_64F : CV_32F; const int local_size = 16; char cvt[2][50]; String buildOptions = format( @@ -1208,7 +1212,7 @@ static bool ipp_pyrdown( InputArray _src, OutputArray _dst, const Size& _dsz, in Mat src = _src.getMat(); _dst.create( dsz, src.type() ); Mat dst = _dst.getMat(); - int depth = src.depth(); + ElemDepth depth = src.depth(); { @@ -1274,7 +1278,7 @@ static bool openvx_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, Size acceptableSize = Size((ssize.width + 1) / 2, (ssize.height + 1) / 2); // OpenVX limitations - if((srcMat.type() != CV_8U) || + if((srcMat.type() != CV_8UC1) || (borderType != BORDER_REPLICATE) || (_dsz != acceptableSize && _dsz.area() != 0)) return false; @@ -1351,7 +1355,7 @@ void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borde Size dsz = _dsz.area() == 0 ? Size((src.cols + 1)/2, (src.rows + 1)/2) : _dsz; _dst.create( dsz, src.type() ); Mat dst = _dst.getMat(); - int depth = src.depth(); + ElemDepth depth = src.depth(); CALL_HAL(pyrDown, cv_hal_pyrdown, src.data, src.step, src.cols, src.rows, dst.data, dst.step, dst.cols, dst.rows, depth, src.channels(), borderType); @@ -1395,7 +1399,7 @@ static bool ipp_pyrup( InputArray _src, OutputArray _dst, const Size& _dsz, int Mat src = _src.getMat(); _dst.create( dsz, src.type() ); Mat dst = _dst.getMat(); - int depth = src.depth(); + ElemDepth depth = src.depth(); { bool isolated = (borderType & BORDER_ISOLATED) != 0; @@ -1456,7 +1460,7 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT Size dsz = _dsz.area() == 0 ? Size(src.cols*2, src.rows*2) : _dsz; _dst.create( dsz, src.type() ); Mat dst = _dst.getMat(); - int depth = src.depth(); + ElemDepth depth = src.depth(); #ifdef HAVE_IPP bool isolated = (borderType & BORDER_ISOLATED) != 0; @@ -1508,7 +1512,7 @@ static bool ipp_buildpyramid( InputArray _src, OutputArrayOfArrays _dst, int max typedef IppStatus (CV_STDCALL * ippiPyramidLayerDownFree)(void* pState); int type = src.type(); - int depth = src.depth(); + ElemDepth depth = src.depth(); ippiPyramidLayerDownInitAlloc pyrInitAllocFunc = 0; ippiPyramidLayerDown pyrDownFunc = 0; ippiPyramidLayerDownFree pyrFreeFunc = 0; @@ -1608,7 +1612,7 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel, if (_src.dims() <= 2 && _dst.isUMatVector()) { UMat src = _src.getUMat(); - _dst.create( maxlevel + 1, 1, 0 ); + _dst.create( maxlevel + 1, 1, static_cast(0) ); _dst.getUMatRef(0) = src; for( int i = 1; i <= maxlevel; i++ ) pyrDown( _dst.getUMatRef(i-1), _dst.getUMatRef(i), Size(), borderType ); @@ -1616,7 +1620,7 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel, } Mat src = _src.getMat(); - _dst.create( maxlevel + 1, 1, 0 ); + _dst.create(maxlevel + 1, 1, static_cast(0)); _dst.getMatRef(0) = src; int i=1; diff --git a/modules/imgproc/src/resize.cpp b/modules/imgproc/src/resize.cpp index 683e4dee5c5d..c1bbd961c233 100644 --- a/modules/imgproc/src/resize.cpp +++ b/modules/imgproc/src/resize.cpp @@ -3437,7 +3437,9 @@ static void ocl_computeResizeAreaTabs(int ssize, int dsize, double scale, int * static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize, double fx, double fy, int interpolation) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); double inv_fx = 1.0 / fx, inv_fy = 1.0 / fy; float inv_fxf = (float)inv_fx, inv_fyf = (float)inv_fy; @@ -3468,12 +3470,12 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize, // See if this could be done with a sampler. We stick with integer // datatypes because the observed error is low. bool useSampler = (interpolation == INTER_LINEAR && ocl::Device::getDefault().imageSupport() && - ocl::Image2D::canCreateAlias(src) && depth <= 4 && + ocl::Image2D::canCreateAlias(src) && depth <= CV_32S && ocl::Image2D::isFormatSupported(depth, cn, true) && src.offset==0); if (useSampler) { - int wdepth = std::max(depth, CV_32S); + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32S); char buf[2][32]; cv::String compileOpts = format("-D USE_SAMPLER -D depth=%d -D T=%s -D T1=%s " "-D convertToDT=%s -D cn=%d", @@ -3535,7 +3537,8 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize, ibeta[dy*2 + 1] = saturate_cast(fyy * INTER_RESIZE_COEF_SCALE); } - int wdepth = std::max(depth, CV_32S), wtype = CV_MAKETYPE(wdepth, cn); + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32S); + ElemType wtype = CV_MAKETYPE(wdepth, cn); UMat coeffs; Mat(1, static_cast(_buffer.size()), CV_8UC1, _buffer.data()).copyTo(coeffs); @@ -3555,7 +3558,8 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize, } else { - int wdepth = std::max(depth, CV_32S), wtype = CV_MAKETYPE(wdepth, cn); + ElemDepth wdepth = CV_MAX_DEPTH(depth, CV_32S); + ElemType wtype = CV_MAKETYPE(wdepth, cn); k.create("resizeLN", ocl::imgproc::resize_oclsrc, format("-D INTER_LINEAR -D depth=%d -D T=%s -D T1=%s " "-D WT=%s -D convertToWT=%s -D convertToDT=%s -D cn=%d " @@ -3584,8 +3588,8 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize, } else if (interpolation == INTER_AREA) { - int wdepth = std::max(depth, is_area_fast ? CV_32S : CV_32F); - int wtype = CV_MAKE_TYPE(wdepth, cn); + ElemDepth wdepth = CV_MAX_DEPTH(depth, is_area_fast ? CV_32S : CV_32F); + ElemType wtype = CV_MAKE_TYPE(wdepth, cn); char cvt[2][40]; String buildOption = format("-D INTER_AREA -D T=%s -D T1=%s -D WTV=%s -D convertToWTV=%s -D cn=%d", @@ -3597,7 +3601,8 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize, if (is_area_fast) { - int wdepth2 = std::max(CV_32F, depth), wtype2 = CV_MAKE_TYPE(wdepth2, cn); + ElemDepth wdepth2 = CV_MAX_DEPTH(CV_32F, depth); + ElemType wtype2 = CV_MAKE_TYPE(wdepth2, cn); buildOption = buildOption + format(" -D convertToT=%s -D WT2V=%s -D convertToWT2V=%s -D INTER_AREA_FAST" " -D XSCALE=%d -D YSCALE=%d -D SCALE=%ff", ocl::convertTypeStr(wdepth2, depth, cn, cvt[0]), @@ -3750,7 +3755,7 @@ class ipp_resizeAffineParallel: public ParallelLoopBody static bool ipp_resize(const uchar * src_data, size_t src_step, int src_width, int src_height, uchar * dst_data, size_t dst_step, int dst_width, int dst_height, double inv_scale_x, double inv_scale_y, - int depth, int channels, int interpolation) + ElemDepth depth, int channels, int interpolation) { #ifdef HAVE_IPP_IW CV_INSTRUMENT_REGION_IPP(); @@ -3845,7 +3850,7 @@ static bool ipp_resize(const uchar * src_data, size_t src_step, int src_width, i namespace hal { -void resize(int src_type, +void resize(ElemType src_type, const uchar * src_data, size_t src_step, int src_width, int src_height, uchar * dst_data, size_t dst_step, int dst_width, int dst_height, double inv_scale_x, double inv_scale_y, int interpolation) @@ -3861,7 +3866,8 @@ void resize(int src_type, CALL_HAL(resize, cv_hal_resize, src_type, src_data, src_step, src_width, src_height, dst_data, dst_step, dst_width, dst_height, inv_scale_x, inv_scale_y, interpolation); - int depth = CV_MAT_DEPTH(src_type), cn = CV_MAT_CN(src_type); + ElemDepth depth = CV_MAT_DEPTH(src_type); + int cn = CV_MAT_CN(src_type); Size dsize = Size(saturate_cast(src_width*inv_scale_x), saturate_cast(src_height*inv_scale_y)); CV_Assert( !dsize.empty() ); diff --git a/modules/imgproc/src/rotcalipers.cpp b/modules/imgproc/src/rotcalipers.cpp index 79a419b661e9..021cdaeedb1b 100644 --- a/modules/imgproc/src/rotcalipers.cpp +++ b/modules/imgproc/src/rotcalipers.cpp @@ -408,7 +408,7 @@ void cv::boxPoints(cv::RotatedRect box, OutputArray _pts) { CV_INSTRUMENT_REGION(); - _pts.create(4, 2, CV_32F); + _pts.create(4, 2, CV_32FC1); Mat pts = _pts.getMat(); box.points(pts.ptr()); } diff --git a/modules/imgproc/src/samplers.cpp b/modules/imgproc/src/samplers.cpp index a0b2aba223ef..cbf8996e6f36 100644 --- a/modules/imgproc/src/samplers.cpp +++ b/modules/imgproc/src/samplers.cpp @@ -368,8 +368,9 @@ void cv::getRectSubPix( InputArray _image, Size patchSize, Point2f center, CV_INSTRUMENT_REGION(); Mat image = _image.getMat(); - int depth = image.depth(), cn = image.channels(); - int ddepth = patchType < 0 ? depth : CV_MAT_DEPTH(patchType); + ElemDepth depth = image.depth(); + int cn = image.channels(); + ElemDepth ddepth = patchType < 0 ? depth : CV_MAT_DEPTH(patchType); CV_Assert( cn == 1 || cn == 3 ); @@ -442,7 +443,7 @@ cvGetQuadrangleSubPix( const void* srcarr, void* dstarr, const CvMat* mat ) cv::Size win_size = dst.size(); double matrix[6] = {0}; - cv::Mat M(2, 3, CV_64F, matrix); + cv::Mat M(2, 3, CV_64FC1, matrix); m.convertTo(M, CV_64F); double dx = (win_size.width - 1)*0.5; double dy = (win_size.height - 1)*0.5; diff --git a/modules/imgproc/src/shapedescr.cpp b/modules/imgproc/src/shapedescr.cpp index d505fde4fcbf..1a7e7d32e079 100644 --- a/modules/imgproc/src/shapedescr.cpp +++ b/modules/imgproc/src/shapedescr.cpp @@ -154,7 +154,7 @@ void cv::minEnclosingCircle( InputArray _points, Point2f& _center, float& _radiu Mat points = _points.getMat(); int count = points.checkVector(2); - int depth = points.depth(); + ElemDepth depth = points.depth(); CV_Assert(count >= 0 && (depth == CV_32F || depth == CV_32S)); _center.x = _center.y = 0.f; @@ -233,7 +233,7 @@ double cv::arcLength( InputArray _curve, bool is_closed ) Mat curve = _curve.getMat(); int count = curve.checkVector(2); - int depth = curve.depth(); + ElemDepth depth = curve.depth(); CV_Assert( count >= 0 && (depth == CV_32F || depth == CV_32S)); double perimeter = 0; @@ -268,7 +268,7 @@ double cv::contourArea( InputArray _contour, bool oriented ) Mat contour = _contour.getMat(); int npoints = contour.checkVector(2); - int depth = contour.depth(); + ElemDepth depth = contour.depth(); CV_Assert(npoints >= 0 && (depth == CV_32F || depth == CV_32S)); if( npoints == 0 ) @@ -301,7 +301,7 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) Mat points = _points.getMat(); int i, n = points.checkVector(2); - int depth = points.depth(); + ElemDepth depth = points.depth(); CV_Assert( n >= 0 && (depth == CV_32F || depth == CV_32S)); RotatedRect box; @@ -321,9 +321,9 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) double *Ad = _Ad.data(), *bd = _bd.data(); // first fit for parameters A - E - Mat A( n, 5, CV_64F, Ad ); - Mat b( n, 1, CV_64F, bd ); - Mat x( 5, 1, CV_64F, gfp ); + Mat A(n, 5, CV_64FC1, Ad); + Mat b(n, 1, CV_64FC1, bd); + Mat x(5, 1, CV_64FC1, gfp); for( i = 0; i < n; i++ ) { @@ -350,9 +350,9 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) // now use general-form parameters A - E to find the ellipse center: // differentiate general form wrt x/y to get two equations for cx and cy - A = Mat( 2, 2, CV_64F, Ad ); - b = Mat( 2, 1, CV_64F, bd ); - x = Mat( 2, 1, CV_64F, rp ); + A = Mat( 2, 2, CV_64FC1, Ad ); + b = Mat( 2, 1, CV_64FC1, bd ); + x = Mat( 2, 1, CV_64FC1, rp ); Ad[0] = 2 * gfp[0]; Ad[1] = Ad[2] = gfp[2]; Ad[3] = 2 * gfp[1]; @@ -361,9 +361,9 @@ cv::RotatedRect cv::fitEllipse( InputArray _points ) solve( A, b, x, DECOMP_SVD ); // re-fit for parameters A - C with those center coordinates - A = Mat( n, 3, CV_64F, Ad ); - b = Mat( n, 1, CV_64F, bd ); - x = Mat( 3, 1, CV_64F, gfp ); + A = Mat( n, 3, CV_64FC1, Ad ); + b = Mat( n, 1, CV_64FC1, bd ); + x = Mat( 3, 1, CV_64FC1, gfp ); for( i = 0; i < n; i++ ) { Point2f p = is_float ? ptsf[i] : Point2f((float)ptsi[i].x, (float)ptsi[i].y); @@ -410,7 +410,7 @@ cv::RotatedRect cv::fitEllipseAMS( InputArray _points ) { Mat points = _points.getMat(); int i, n = points.checkVector(2); - int depth = points.depth(); + ElemDepth depth = points.depth(); CV_Assert( n >= 0 && (depth == CV_32F || depth == CV_32S)); RotatedRect box; @@ -424,7 +424,7 @@ cv::RotatedRect cv::fitEllipseAMS( InputArray _points ) const Point* ptsi = points.ptr(); const Point2f* ptsf = points.ptr(); - Mat A( n, 6, CV_64F); + Mat A(n, 6, CV_64FC1); Matx DM; Matx M; Matx pVec; @@ -452,7 +452,7 @@ cv::RotatedRect cv::fitEllipseAMS( InputArray _points ) A.at(i,4) = (double)p.y; A.at(i,5) = 1.0; } - cv::mulTransposed( A, DM, true, noArray(), 1.0, -1 ); + cv::mulTransposed( A, DM, true, noArray(), 1.0); DM *= (1.0/n); double dnm = ( DM(2,5)*(DM(0,5) + DM(2,5)) - (DM(1,5)*DM(1,5)) ); double ddm = (4.*(DM(0,5) + DM(2,5))*( (DM(0,5)*DM(2,5)) - (DM(1,5)*DM(1,5)))); @@ -586,7 +586,7 @@ cv::RotatedRect cv::fitEllipseDirect( InputArray _points ) { Mat points = _points.getMat(); int i, n = points.checkVector(2); - int depth = points.depth(); + ElemDepth depth = points.depth(); CV_Assert( n >= 0 && (depth == CV_32F || depth == CV_32S)); RotatedRect box; @@ -600,7 +600,7 @@ cv::RotatedRect cv::fitEllipseDirect( InputArray _points ) const Point* ptsi = points.ptr(); const Point2f* ptsf = points.ptr(); - Mat A( n, 6, CV_64F); + Mat A(n, 6, CV_64FC1); Matx DM; Matx33d M, TM, Q; Matx pVec; @@ -627,7 +627,7 @@ cv::RotatedRect cv::fitEllipseDirect( InputArray _points ) A.at(i,4) = (double)p.y; A.at(i,5) = 1.0; } - cv::mulTransposed( A, DM, true, noArray(), 1.0, -1 ); + cv::mulTransposed( A, DM, true, noArray(), 1.0); DM *= (1.0/n); TM(0,0) = DM(0,5)*DM(3,5)*DM(4,4) - DM(0,5)*DM(3,4)*DM(4,5) - DM(0,4)*DM(3,5)*DM(5,4) + \ @@ -737,7 +737,7 @@ namespace cv static Rect pointSetBoundingRect( const Mat& points ) { int npoints = points.checkVector(2); - int depth = points.depth(); + ElemDepth depth = points.depth(); CV_Assert(npoints >= 0 && (depth == CV_32F || depth == CV_32S)); int xmin = 0, ymin = 0, xmax = -1, ymax = -1, i; @@ -1210,7 +1210,7 @@ cvArcLength( const void *array, CvSlice slice, int is_closed ) int i, j = 0, count; const int N = 16; float buf[N]; - CvMat buffer = cvMat( 1, N, CV_32F, buf ); + CvMat buffer = cvMat( 1, N, CV_32FC1, buf ); CvSeqReader reader; CvContour contour_header; CvSeq* contour = 0; diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 5a7635b945ae..fbbe6fbd10a1 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -1062,13 +1062,15 @@ struct ColumnSum : #ifdef HAVE_OPENCL -static bool ocl_boxFilter3x3_8UC1( InputArray _src, OutputArray _dst, int ddepth, +static bool ocl_boxFilter3x3_8UC1(InputArray _src, OutputArray _dst, ElemDepth ddepth, Size ksize, Point anchor, int borderType, bool normalize ) { const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; if (anchor.x < 0) @@ -1120,14 +1122,16 @@ static bool ocl_boxFilter3x3_8UC1( InputArray _src, OutputArray _dst, int ddepth #define DIVUP(total, grain) ((total + grain - 1) / (grain)) #define ROUNDUP(sz, n) ((sz) + (n) - 1 - (((sz) + (n) - 1) % (n))) -static bool ocl_boxFilter( InputArray _src, OutputArray _dst, int ddepth, +static bool ocl_boxFilter(InputArray _src, OutputArray _dst, ElemDepth ddepth, Size ksize, Point anchor, int borderType, bool normalize, bool sqr = false ) { const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type); + ElemType type = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type); bool doubleSupport = dev.doubleFPConfig() > 0; - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; if (cn > 4 || (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F)) || @@ -1144,8 +1148,8 @@ static bool ocl_boxFilter( InputArray _src, OutputArray _dst, int ddepth, Size size = _src.size(), wholeSize; bool isolated = (borderType & BORDER_ISOLATED) != 0; borderType &= ~BORDER_ISOLATED; - int wdepth = std::max(CV_32F, std::max(ddepth, sdepth)), - wtype = CV_MAKE_TYPE(wdepth, cn), dtype = CV_MAKE_TYPE(ddepth, cn); + ElemDepth wdepth = CV_MAX_DEPTH(CV_32F, ddepth, sdepth); + ElemType wtype = CV_MAKE_TYPE(wdepth, cn), dtype = CV_MAKE_TYPE(ddepth, cn); const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", 0, "BORDER_REFLECT_101" }; size_t globalsize[2] = { (size_t)size.width, (size_t)size.height }; @@ -1300,9 +1304,9 @@ static bool ocl_boxFilter( InputArray _src, OutputArray _dst, int ddepth, } -cv::Ptr cv::getRowSumFilter(int srcType, int sumType, int ksize, int anchor) +cv::Ptr cv::getRowSumFilter(ElemType srcType, ElemType sumType, int ksize, int anchor) { - int sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(sumType); + ElemDepth sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(sumType); CV_Assert( CV_MAT_CN(sumType) == CV_MAT_CN(srcType) ); if( anchor < 0 ) @@ -1335,10 +1339,10 @@ cv::Ptr cv::getRowSumFilter(int srcType, int sumType, int ksi } -cv::Ptr cv::getColumnSumFilter(int sumType, int dstType, int ksize, +cv::Ptr cv::getColumnSumFilter(ElemType sumType, ElemType dstType, int ksize, int anchor, double scale) { - int sdepth = CV_MAT_DEPTH(sumType), ddepth = CV_MAT_DEPTH(dstType); + ElemDepth sdepth = CV_MAT_DEPTH(sumType), ddepth = CV_MAT_DEPTH(dstType); CV_Assert( CV_MAT_CN(sumType) == CV_MAT_CN(dstType) ); if( anchor < 0 ) @@ -1375,18 +1379,19 @@ cv::Ptr cv::getColumnSumFilter(int sumType, int dstType, i } -cv::Ptr cv::createBoxFilter( int srcType, int dstType, Size ksize, +cv::Ptr cv::createBoxFilter(ElemType srcType, ElemType dstType, Size ksize, Point anchor, bool normalize, int borderType ) { - int sdepth = CV_MAT_DEPTH(srcType); - int cn = CV_MAT_CN(srcType), sumType = CV_64F; + ElemDepth sdepth = CV_MAT_DEPTH(srcType); + int cn = CV_MAT_CN(srcType); + ElemType sumType = CV_64FC1; if( sdepth == CV_8U && CV_MAT_DEPTH(dstType) == CV_8U && ksize.width*ksize.height <= 256 ) - sumType = CV_16U; + sumType = CV_16UC1; else if( sdepth <= CV_32S && (!normalize || ksize.width*ksize.height <= (sdepth == CV_8U ? (1<<23) : sdepth == CV_16U ? (1 << 15) : (1 << 16))) ) - sumType = CV_32S; + sumType = CV_32SC1; sumType = CV_MAKETYPE( sumType, cn ); Ptr rowFilter = getRowSumFilter(srcType, sumType, ksize.width, anchor.x ); @@ -1403,11 +1408,11 @@ namespace cv namespace ovx { template <> inline bool skipSmallImages(int w, int h) { return w*h < 640 * 480; } } - static bool openvx_boxfilter(InputArray _src, OutputArray _dst, int ddepth, + static bool openvx_boxfilter(InputArray _src, OutputArray _dst, ElemDepth ddepth, Size ksize, Point anchor, bool normalize, int borderType) { - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = CV_8UC1; if (_src.type() != CV_8UC1 || ddepth != CV_8U || !normalize || _src.cols() < 3 || _src.rows() < 3 || @@ -1525,7 +1530,7 @@ static bool ipp_boxfilter(Mat &src, Mat &dst, Size ksize, Point anchor, bool nor #endif -void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, +void cv::boxFilter(InputArray _src, OutputArray _dst, ElemDepth ddepth, Size ksize, Point anchor, bool normalize, int borderType ) { @@ -1539,8 +1544,10 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, CV_OCL_RUN(_dst.isUMat(), ocl_boxFilter(_src, _dst, ddepth, ksize, anchor, borderType, normalize)) Mat src = _src.getMat(); - int stype = src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); - if( ddepth < 0 ) + ElemType stype = src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(stype); + int cn = CV_MAT_CN(stype); + if( ddepth == CV_DEPTH_AUTO ) ddepth = sdepth; _dst.create( src.size(), CV_MAKETYPE(ddepth, cn) ); Mat dst = _dst.getMat(); @@ -1580,7 +1587,7 @@ void cv::blur( InputArray src, OutputArray dst, { CV_INSTRUMENT_REGION(); - boxFilter( src, dst, -1, ksize, anchor, true, borderType ); + boxFilter( src, dst, CV_DEPTH_AUTO, ksize, anchor, true, borderType ); } @@ -1630,7 +1637,7 @@ struct SqrRowSum : static Ptr getSqrRowSumFilter(int srcType, int sumType, int ksize, int anchor) { - int sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(sumType); + ElemDepth sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(sumType); CV_Assert( CV_MAT_CN(sumType) == CV_MAT_CN(srcType) ); if( anchor < 0 ) @@ -1656,16 +1663,18 @@ static Ptr getSqrRowSumFilter(int srcType, int sumType, int ksize } -void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth, +void cv::sqrBoxFilter(InputArray _src, OutputArray _dst, ElemDepth ddepth, Size ksize, Point anchor, bool normalize, int borderType ) { CV_INSTRUMENT_REGION(); - int srcType = _src.type(), sdepth = CV_MAT_DEPTH(srcType), cn = CV_MAT_CN(srcType); + ElemType srcType = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(srcType); + int cn = CV_MAT_CN(srcType); Size size = _src.size(); - if( ddepth < 0 ) + if( ddepth == CV_DEPTH_AUTO ) ddepth = sdepth < CV_32F ? CV_32F : CV_64F; if( borderType != BORDER_CONSTANT && normalize ) @@ -1679,10 +1688,11 @@ void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth, CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2, ocl_boxFilter(_src, _dst, ddepth, ksize, anchor, borderType, normalize, true)) - int sumDepth = CV_64F; + ElemDepth sumDepth = CV_64F; if( sdepth == CV_8U ) sumDepth = CV_32S; - int sumType = CV_MAKETYPE( sumDepth, cn ), dstType = CV_MAKETYPE(ddepth, cn); + ElemType sumType = CV_MAKETYPE(sumDepth, cn); + ElemType dstType = CV_MAKETYPE(ddepth, cn); Mat src = _src.getMat(); _dst.create( size, dstType ); @@ -1707,7 +1717,7 @@ void cv::sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth, Gaussian Blur \****************************************************************************************/ -cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype ) +cv::Mat cv::getGaussianKernel( int n, double sigma, ElemType ktype ) { CV_Assert(n > 0); const int SMALL_GAUSSIAN_SIZE = 7; @@ -1722,7 +1732,7 @@ cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype ) const float* fixed_kernel = n % 2 == 1 && n <= SMALL_GAUSSIAN_SIZE && sigma <= 0 ? small_gaussian_tab[n>>1] : 0; - CV_Assert( ktype == CV_32F || ktype == CV_64F ); + CV_Assert( ktype == CV_32FC1 || ktype == CV_64FC1 ); Mat kernel(n, 1, ktype); float* cf = kernel.ptr(); double* cd = kernel.ptr(); @@ -1736,7 +1746,7 @@ cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype ) { double x = i - (n-1)*0.5; double t = fixed_kernel ? (double)fixed_kernel[i] : std::exp(scale2X*x*x); - if( ktype == CV_32F ) + if( ktype == CV_32FC1 ) { cf[i] = (float)t; sum += cf[i]; @@ -1752,7 +1762,7 @@ cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype ) sum = 1./sum; for( i = 0; i < n; i++ ) { - if( ktype == CV_32F ) + if( ktype == CV_32FC1 ) cf[i] = (float)(cf[i]*sum); else cd[i] *= sum; @@ -3759,14 +3769,14 @@ class fixedSmoothInvoker : public ParallelLoopBody fixedSmoothInvoker& operator=(const fixedSmoothInvoker&); }; -static void getGaussianKernel(int n, double sigma, int ktype, Mat& res) { res = getGaussianKernel(n, sigma, ktype); } -template static void getGaussianKernel(int n, double sigma, int, std::vector& res) { res = getFixedpointGaussianKernel(n, sigma); } +static void getGaussianKernel(int n, double sigma, ElemType ktype, Mat& res) { res = getGaussianKernel(n, sigma, ktype); } +template static void getGaussianKernel(int n, double sigma, ElemType, std::vector& res) { res = getFixedpointGaussianKernel(n, sigma); } template static void createGaussianKernels( T & kx, T & ky, int type, Size &ksize, double sigma1, double sigma2 ) { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); if( sigma2 <= 0 ) sigma2 = sigma1; @@ -3782,16 +3792,16 @@ static void createGaussianKernels( T & kx, T & ky, int type, Size &ksize, sigma1 = std::max( sigma1, 0. ); sigma2 = std::max( sigma2, 0. ); - getGaussianKernel( ksize.width, sigma1, std::max(depth, CV_32F), kx ); + getGaussianKernel(ksize.width, sigma1, CV_MAKETYPE(CV_MAX_DEPTH(depth, CV_32F), 1), kx); if( ksize.height == ksize.width && std::abs(sigma1 - sigma2) < DBL_EPSILON ) ky = kx; else - getGaussianKernel( ksize.height, sigma2, std::max(depth, CV_32F), ky ); + getGaussianKernel(ksize.height, sigma2, CV_MAKETYPE(CV_MAX_DEPTH(depth, CV_32F), 1), ky); } } -cv::Ptr cv::createGaussianFilter( int type, Size ksize, +cv::Ptr cv::createGaussianFilter(ElemType type, Size ksize, double sigma1, double sigma2, int borderType ) { @@ -3805,11 +3815,13 @@ namespace cv { #ifdef HAVE_OPENCL -static bool ocl_GaussianBlur_8UC1(InputArray _src, OutputArray _dst, Size ksize, int ddepth, +static bool ocl_GaussianBlur_8UC1(InputArray _src, OutputArray _dst, Size ksize, ElemDepth ddepth, InputArray _kernelX, InputArray _kernelY, int borderType) { const ocl::Device & dev = ocl::Device::getDefault(); - int type = _src.type(), sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if ( !(dev.isIntel() && (type == CV_8UC1) && (_src.offset() == 0) && (_src.step() % 4 == 0) && @@ -3824,7 +3836,7 @@ static bool ocl_GaussianBlur_8UC1(InputArray _src, OutputArray _dst, Size ksize, if (kernelY.cols % 2 != 1) return false; - if (ddepth < 0) + if (ddepth == CV_DEPTH_AUTO) ddepth = sdepth; Size size = _src.size(); @@ -4079,7 +4091,7 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, { CV_INSTRUMENT_REGION(); - int type = _src.type(); + ElemType type = _src.type(); Size size = _src.size(); _dst.create( size, type ); @@ -4104,7 +4116,8 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, _src.rows() > ksize.height && _src.cols() > ksize.width); CV_UNUSED(useOpenCL); - int sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemDepth sdepth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); Mat kx, ky; createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2); @@ -4912,7 +4925,9 @@ static bool ocl_medianFilter(InputArray _src, OutputArray _dst, int m) { size_t localsize[2] = { 16, 16 }; size_t globalsize[2]; - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); if ( !((depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F) && cn <= 4 && (m == 3 || m == 5)) ) return false; @@ -4969,7 +4984,8 @@ namespace cv } static bool openvx_medianFilter(InputArray _src, OutputArray _dst, int ksize) { - if (_src.type() != CV_8UC1 || _dst.type() != CV_8U + if (_src.type() != CV_8UC1 || _dst.type() != CV_8UC1 + #ifndef VX_VERSION_1_1 || ksize != 3 #endif @@ -5071,7 +5087,7 @@ static bool ipp_medianFilter(Mat &src0, Mat &dst, int ksize) { int bufSize; IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize); - IppDataType ippType = ippiGetDataType(src0.type()); + IppDataType ippType = ippiGetDataType(src0.depth()); int channels = src0.channels(); IppAutoBuffer buffer; @@ -5403,7 +5419,9 @@ static bool ocl_bilateralFilter_8u(InputArray _src, OutputArray _dst, int d, return false; #endif - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int i, j, maxk, radius; if (depth != CV_8U || cn > 4) diff --git a/modules/imgproc/src/sumpixels.cpp b/modules/imgproc/src/sumpixels.cpp index c09e085285e0..07645ff06a42 100755 --- a/modules/imgproc/src/sumpixels.cpp +++ b/modules/imgproc/src/sumpixels.cpp @@ -310,7 +310,7 @@ void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep, #ifdef HAVE_OPENCL -static bool ocl_integral( InputArray _src, OutputArray _sum, int sdepth ) +static bool ocl_integral( InputArray _src, OutputArray _sum, ElemDepth sdepth ) { bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -331,7 +331,7 @@ static bool ocl_integral( InputArray _src, OutputArray _sum, int sdepth ) UMat src = _src.getUMat(); Size src_size = src.size(); Size bufsize(((src_size.height + tileSize - 1) / tileSize) * tileSize, ((src_size.width + tileSize - 1) / tileSize) * tileSize); - UMat buf(bufsize, sdepth); + UMat buf(bufsize, CV_MAKETYPE(sdepth, 1)); kcols.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnlyNoSize(buf)); size_t gt = src.cols, lt = tileSize; if (!kcols.run(1, >, <, false)) @@ -342,7 +342,7 @@ static bool ocl_integral( InputArray _src, OutputArray _sum, int sdepth ) return false; Size sumsize(src_size.width + 1, src_size.height + 1); - _sum.create(sumsize, sdepth); + _sum.create(sumsize, CV_MAKETYPE(sdepth, 1)); UMat sum = _sum.getUMat(); krows.args(ocl::KernelArg::ReadOnlyNoSize(buf), ocl::KernelArg::WriteOnly(sum)); @@ -350,7 +350,7 @@ static bool ocl_integral( InputArray _src, OutputArray _sum, int sdepth ) return krows.run(1, >, <, false); } -static bool ocl_integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, int sdepth, int sqdepth ) +static bool ocl_integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, ElemDepth sdepth, int sqdepth ) { bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -371,8 +371,8 @@ static bool ocl_integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, UMat src = _src.getUMat(); Size src_size = src.size(); Size bufsize(((src_size.height + tileSize - 1) / tileSize) * tileSize, ((src_size.width + tileSize - 1) / tileSize) * tileSize); - UMat buf(bufsize, sdepth); - UMat buf_sq(bufsize, sqdepth); + UMat buf(bufsize, CV_MAKETYPE(sdepth, 1)); + UMat buf_sq(bufsize, CV_MAKETYPE(sqdepth, 1)); kcols.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnlyNoSize(buf), ocl::KernelArg::WriteOnlyNoSize(buf_sq)); size_t gt = src.cols, lt = tileSize; if (!kcols.run(1, >, <, false)) @@ -383,9 +383,9 @@ static bool ocl_integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, return false; Size sumsize(src_size.width + 1, src_size.height + 1); - _sum.create(sumsize, sdepth); + _sum.create(sumsize, CV_MAKETYPE(sdepth, 1)); UMat sum = _sum.getUMat(); - _sqsum.create(sumsize, sqdepth); + _sqsum.create(sumsize, CV_MAKETYPE(sqdepth, 1)); UMat sum_sq = _sqsum.getUMat(); krows.args(ocl::KernelArg::ReadOnlyNoSize(buf), ocl::KernelArg::ReadOnlyNoSize(buf_sq), ocl::KernelArg::WriteOnly(sum), ocl::KernelArg::WriteOnlyNoSize(sum_sq)); @@ -401,7 +401,7 @@ static bool ocl_integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, namespace cv { static bool ipp_integral( - int depth, int sdepth, int sqdepth, + ElemDepth depth, ElemDepth sdepth, int sqdepth, const uchar* src, size_t srcstep, uchar* sum, size_t sumstep, uchar* sqsum, size_t sqsumstep, @@ -424,9 +424,9 @@ static bool ipp_integral( { if(depth == CV_8U && sdepth == CV_32S) return CV_INSTRUMENT_FUN_IPP(ippiIntegral_8u32s_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32s*)sum, (int)sumstep, size, 0) >= 0; - else if(depth == CV_8UC1 && sdepth == CV_32F) + else if(depth == CV_8U && sdepth == CV_32F) return CV_INSTRUMENT_FUN_IPP(ippiIntegral_8u32f_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32f*)sum, (int)sumstep, size, 0) >= 0; - else if(depth == CV_32FC1 && sdepth == CV_32F) + else if(depth == CV_32F && sdepth == CV_32F) return CV_INSTRUMENT_FUN_IPP(ippiIntegral_32f_C1R, (const Ipp32f*)src, (int)srcstep, (Ipp32f*)sum, (int)sumstep, size) >= 0; else return false; @@ -448,7 +448,7 @@ static bool ipp_integral( namespace cv { namespace hal { -void integral(int depth, int sdepth, int sqdepth, +void integral(ElemDepth depth, ElemDepth sdepth, ElemDepth sqdepth, const uchar* src, size_t srcstep, uchar* sum, size_t sumstep, uchar* sqsum, size_t sqsumstep, @@ -492,14 +492,16 @@ void integral(int depth, int sdepth, int sqdepth, }} // cv::hal:: -void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, OutputArray _tilted, int sdepth, int sqdepth ) +void cv::integral(InputArray _src, OutputArray _sum, OutputArray _sqsum, OutputArray _tilted, ElemDepth sdepth, ElemDepth sqdepth) { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - if( sdepth <= 0 ) + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + if (sdepth <= CV_8U) sdepth = depth == CV_8U ? CV_32S : CV_64F; - if ( sqdepth <= 0 ) + if (sqdepth <= CV_8U) sqdepth = CV_64F; sdepth = CV_MAT_DEPTH(sdepth), sqdepth = CV_MAT_DEPTH(sqdepth); @@ -530,14 +532,14 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output src.cols, src.rows, cn); } -void cv::integral( InputArray src, OutputArray sum, int sdepth ) +void cv::integral( InputArray src, OutputArray sum, ElemDepth sdepth ) { CV_INSTRUMENT_REGION(); integral( src, sum, noArray(), noArray(), sdepth ); } -void cv::integral( InputArray src, OutputArray sum, OutputArray sqsum, int sdepth, int sqdepth ) +void cv::integral(InputArray src, OutputArray sum, OutputArray sqsum, ElemDepth sdepth, ElemDepth sqdepth) { CV_INSTRUMENT_REGION(); diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index a2e81b8dcf6f..ec77805c1711 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -58,7 +58,7 @@ enum static bool extractFirstChannel_32F(InputArray _image, OutputArray _result, int cn) { - int depth = _image.depth(); + ElemDepth depth = _image.depth(); ocl::Device dev = ocl::Device::getDefault(); int pxPerWIy = (dev.isIntel() && (dev.type() & ocl::Device::TYPE_GPU)) ? 4 : 1; @@ -78,8 +78,11 @@ static bool extractFirstChannel_32F(InputArray _image, OutputArray _result, int static bool sumTemplate(InputArray _src, UMat & result) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - int wdepth = CV_32F, wtype = CV_MAKE_TYPE(wdepth, cn); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemDepth wdepth = CV_32F; + ElemType wtype = CV_MAKE_TYPE(wdepth, cn); size_t wgs = ocl::Device::getDefault().maxWorkGroupSize(); int wgs2_aligned = 1; @@ -153,9 +156,9 @@ void ConvolveBuf::create(Size image_size, Size templ_size) block_size.height = dft_size.height - templ_size.height + 1; block_size.height = std::min( block_size.height, result_size.height ); - image_block.create(dft_size, CV_32F); - templ_block.create(dft_size, CV_32F); - result_data.create(dft_size, CV_32F); + image_block.create(dft_size, CV_32FC1); + templ_block.create(dft_size, CV_32FC1); + result_data.create(dft_size, CV_32FC1); image_spect.create(dft_size.height, dft_size.width / 2 + 1, CV_32FC2); templ_spect.create(dft_size.height, dft_size.width / 2 + 1, CV_32FC2); @@ -169,11 +172,11 @@ void ConvolveBuf::create(Size image_size, Size templ_size) static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _result) { ConvolveBuf buf; - CV_Assert(_image.type() == CV_32F); - CV_Assert(_templ.type() == CV_32F); + CV_Assert(_image.type() == CV_32FC1); + CV_Assert(_templ.type() == CV_32FC1); buf.create(_image.size(), _templ.size()); - _result.create(buf.result_size, CV_32F); + _result.create(buf.result_size, CV_32FC1); UMat image = _image.getUMat(); UMat templ = _templ.getUMat(); @@ -234,7 +237,7 @@ static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _resu static bool convolve_32F(InputArray _image, InputArray _templ, OutputArray _result) { - _result.create(_image.rows() - _templ.rows() + 1, _image.cols() - _templ.cols() + 1, CV_32F); + _result.create(_image.rows() - _templ.rows() + 1, _image.cols() - _templ.cols() + 1, CV_32FC1); if (_image.channels() == 1) return(convolve_dft(_image, _templ, _result)); @@ -242,7 +245,7 @@ static bool convolve_32F(InputArray _image, InputArray _templ, OutputArray _resu { UMat image = _image.getUMat(); UMat templ = _templ.getUMat(); - UMat result_(image.rows-templ.rows+1,(image.cols-templ.cols+1)*image.channels(), CV_32F); + UMat result_(image.rows-templ.rows+1,(image.cols-templ.cols+1)*image.channels(), CV_32FC1); bool ok = convolve_dft(image.reshape(1), templ.reshape(1), result_); if (ok==false) return false; @@ -253,8 +256,11 @@ static bool convolve_32F(InputArray _image, InputArray _templ, OutputArray _resu static bool matchTemplateNaive_CCORR(InputArray _image, InputArray _templ, OutputArray _result) { - int type = _image.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - int wdepth = CV_32F, wtype = CV_MAKE_TYPE(wdepth, cn); + ElemType type = _image.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemDepth wdepth = CV_32F; + ElemType wtype = CV_MAKE_TYPE(wdepth, cn); ocl::Device dev = ocl::Device::getDefault(); int pxPerWIx = (cn==1 && dev.isIntel() && (dev.type() & ocl::Device::TYPE_GPU)) ? 4 : 1; @@ -317,7 +323,8 @@ static bool matchTemplate_CCORR_NORMED(InputArray _image, InputArray _templ, Out { matchTemplate(_image, _templ, _result, CV_TM_CCORR); - int type = _image.type(), cn = CV_MAT_CN(type); + ElemType type = _image.type(); + int cn = CV_MAT_CN(type); ocl::Kernel k("matchTemplate_CCORR_NORMED", ocl::imgproc::match_template_oclsrc, format("-D CCORR_NORMED -D T=%s -D cn=%d", ocl::typeToStr(type), cn)); @@ -346,8 +353,11 @@ static bool matchTemplate_CCORR_NORMED(InputArray _image, InputArray _templ, Out static bool matchTemplateNaive_SQDIFF(InputArray _image, InputArray _templ, OutputArray _result) { - int type = _image.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - int wdepth = CV_32F, wtype = CV_MAKE_TYPE(wdepth, cn); + ElemType type = _image.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); + ElemDepth wdepth = CV_32F; + ElemType wtype = CV_MAKE_TYPE(wdepth, cn); char cvt[40]; ocl::Kernel k("matchTemplate_Naive_SQDIFF", ocl::imgproc::match_template_oclsrc, @@ -357,7 +367,7 @@ static bool matchTemplateNaive_SQDIFF(InputArray _image, InputArray _templ, Outp return false; UMat image = _image.getUMat(), templ = _templ.getUMat(); - _result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32F); + _result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32FC1); UMat result = _result.getUMat(); k.args(ocl::KernelArg::ReadOnlyNoSize(image), ocl::KernelArg::ReadOnly(templ), @@ -375,7 +385,8 @@ static bool matchTemplate_SQDIFF(InputArray _image, InputArray _templ, OutputArr { matchTemplate(_image, _templ, _result, CV_TM_CCORR); - int type = _image.type(), cn = CV_MAT_CN(type); + ElemType type = _image.type(); + int cn = CV_MAT_CN(type); ocl::Kernel k("matchTemplate_Prepared_SQDIFF", ocl::imgproc::match_template_oclsrc, format("-D SQDIFF_PREPARED -D T=%s -D cn=%d", ocl::typeToStr(type), cn)); @@ -383,7 +394,7 @@ static bool matchTemplate_SQDIFF(InputArray _image, InputArray _templ, OutputArr return false; UMat image = _image.getUMat(), templ = _templ.getUMat(); - _result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32F); + _result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32FC1); UMat result = _result.getUMat(); UMat image_sums, image_sqsums; @@ -406,7 +417,8 @@ static bool matchTemplate_SQDIFF_NORMED(InputArray _image, InputArray _templ, Ou { matchTemplate(_image, _templ, _result, CV_TM_CCORR); - int type = _image.type(), cn = CV_MAT_CN(type); + ElemType type = _image.type(); + int cn = CV_MAT_CN(type); ocl::Kernel k("matchTemplate_SQDIFF_NORMED", ocl::imgproc::match_template_oclsrc, format("-D SQDIFF_NORMED -D T=%s -D cn=%d", ocl::typeToStr(type), cn)); @@ -414,7 +426,7 @@ static bool matchTemplate_SQDIFF_NORMED(InputArray _image, InputArray _templ, Ou return false; UMat image = _image.getUMat(), templ = _templ.getUMat(); - _result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32F); + _result.create(image.rows - templ.rows + 1, image.cols - templ.cols + 1, CV_32FC1); UMat result = _result.getUMat(); UMat image_sums, image_sqsums; @@ -441,7 +453,9 @@ static bool matchTemplate_CCOEFF(InputArray _image, InputArray _templ, OutputArr UMat image_sums, temp; integral(_image, image_sums, CV_32F); - int type = image_sums.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = image_sums.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); ocl::Kernel k("matchTemplate_Prepared_CCOEFF", ocl::imgproc::match_template_oclsrc, format("-D CCOEFF -D T=%s -D T1=%s -D cn=%d", ocl::typeToStr(type), ocl::typeToStr(depth), cn)); @@ -476,7 +490,9 @@ static bool matchTemplate_CCOEFF_NORMED(InputArray _image, InputArray _templ, Ou UMat temp, image_sums, image_sqsums; integral(_image, image_sums, image_sqsums, CV_32F, CV_32F); - int type = image_sums.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = image_sums.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert(cn >= 1 && cn <= 4); ocl::Kernel k("matchTemplate_CCOEFF_NORMED", ocl::imgproc::match_template_oclsrc, @@ -486,7 +502,7 @@ static bool matchTemplate_CCOEFF_NORMED(InputArray _image, InputArray _templ, Ou UMat templ = _templ.getUMat(); Size size = _image.size(), tsize = templ.size(); - _result.create(size.height - templ.rows + 1, size.width - templ.cols + 1, CV_32F); + _result.create(size.height - templ.rows + 1, size.width - templ.cols + 1, CV_32FC1); UMat result = _result.getUMat(); float scale = 1.f / tsize.area(); @@ -564,7 +580,7 @@ static bool ocl_matchTemplate( InputArray _img, InputArray _templ, OutputArray _ #include "opencv2/core/hal/hal.hpp" void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, - Size corrsize, int ctype, + Size corrsize, ElemType ctype, Point anchor, double delta, int borderType ) { const double blockScale = 4.5; @@ -572,15 +588,18 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, std::vector buf; Mat templ = _templ; - int depth = img.depth(), cn = img.channels(); - int tdepth = templ.depth(), tcn = templ.channels(); - int cdepth = CV_MAT_DEPTH(ctype), ccn = CV_MAT_CN(ctype); + ElemDepth depth = img.depth(); + int cn = img.channels(); + ElemDepth tdepth = templ.depth(); + int tcn = templ.channels(); + ElemDepth cdepth = CV_MAT_DEPTH(ctype); + int ccn = CV_MAT_CN(ctype); CV_Assert( img.dims <= 2 && templ.dims <= 2 && corr.dims <= 2 ); - if( depth != tdepth && tdepth != std::max(CV_32F, depth) ) + if (depth != tdepth && static_cast(tdepth) != CV_MAX_DEPTH(CV_32F, depth)) { - _templ.convertTo(templ, std::max(CV_32F, depth)); + _templ.convertTo(templ, CV_MAX_DEPTH(CV_32F, depth)); tdepth = templ.depth(); } @@ -592,7 +611,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, corr.create(corrsize, ctype); - int maxDepth = depth > CV_8S ? CV_64F : std::max(std::max(CV_32F, tdepth), cdepth); + ElemDepth maxDepth = depth > CV_8S ? CV_64F : CV_MAX_DEPTH(CV_32F, tdepth, cdepth); Size blocksize, dftsize; blocksize.width = cvRound(templ.cols*blockScale); @@ -613,8 +632,8 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, blocksize.height = dftsize.height - templ.rows + 1; blocksize.height = MIN( blocksize.height, corr.rows ); - Mat dftTempl( dftsize.height*tcn, dftsize.width, maxDepth ); - Mat dftImg( dftsize, maxDepth ); + Mat dftTempl( dftsize.height*tcn, dftsize.width, CV_MAKETYPE(maxDepth, 1) ); + Mat dftImg( dftsize, CV_MAKETYPE(maxDepth, 1) ); int i, k, bufSize = 0; if( tcn > 1 && tdepth != maxDepth ) @@ -641,7 +660,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, if( tcn > 1 ) { - src = tdepth == maxDepth ? dst1 : Mat(templ.size(), tdepth, &buf[0]); + src = tdepth == maxDepth ? dst1 : Mat(templ.size(), CV_MAKETYPE(tdepth, 1), &buf[0]); int pairs[] = {k, 0}; mixChannels(&templ, 1, &src, 1, pairs, 1); } @@ -704,7 +723,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, if( cn > 1 ) { - src = depth == maxDepth ? dst1 : Mat(y2-y1, x2-x1, depth, &buf[0]); + src = depth == maxDepth ? dst1 : Mat(y2 - y1, x2 - x1, CV_MAKETYPE(depth, 1), &buf[0]); int pairs[] = {k, 0}; mixChannels(&src0, 1, &src, 1, pairs, 1); } @@ -736,7 +755,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, { if( cdepth != maxDepth ) { - Mat plane(bsz, cdepth, &buf[0]); + Mat plane(bsz, CV_MAKETYPE(cdepth, 1), &buf[0]); src.convertTo(plane, cdepth, 1, delta); src = plane; } @@ -751,7 +770,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, { if( maxDepth != cdepth ) { - Mat plane(bsz, cdepth, &buf[0]); + Mat plane(bsz, CV_MAKETYPE(cdepth, 1), &buf[0]); src.convertTo(plane, cdepth); src = plane; } @@ -764,26 +783,32 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _result, int method, InputArray _mask ) { - int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _img.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED ); CV_Assert( (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 ); Mat img = _img.getMat(), templ = _templ.getMat(), mask = _mask.getMat(); - int ttype = templ.type(), tdepth = CV_MAT_DEPTH(ttype), tcn = CV_MAT_CN(ttype); - int mtype = img.type(), mdepth = CV_MAT_DEPTH(type), mcn = CV_MAT_CN(mtype); + ElemType ttype = templ.type(); + ElemDepth tdepth = CV_MAT_DEPTH(ttype); + int tcn = CV_MAT_CN(ttype); + ElemType mtype = img.type(); + ElemDepth mdepth = CV_MAT_DEPTH(type); + int mcn = CV_MAT_CN(mtype); if (depth == CV_8U) { depth = CV_32F; type = CV_MAKETYPE(CV_32F, cn); - img.convertTo(img, type, 1.0 / 255); + img.convertTo(img, CV_MAT_DEPTH(type), 1.0 / 255); } if (tdepth == CV_8U) { tdepth = CV_32F; ttype = CV_MAKETYPE(CV_32F, tcn); - templ.convertTo(templ, ttype, 1.0 / 255); + templ.convertTo(templ, CV_MAT_DEPTH(ttype), 1.0 / 255); } if (mdepth == CV_8U) @@ -791,11 +816,11 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ mdepth = CV_32F; mtype = CV_MAKETYPE(CV_32F, mcn); compare(mask, Scalar::all(0), mask, CMP_NE); - mask.convertTo(mask, mtype, 1.0 / 255); + mask.convertTo(mask, CV_MAT_DEPTH(mtype), 1.0 / 255); } Size corrSize(img.cols - templ.cols + 1, img.rows - templ.rows + 1); - _result.create(corrSize, CV_32F); + _result.create(corrSize, CV_32FC1); Mat result = _result.getMat(); Mat img2 = img.mul(img); @@ -814,7 +839,7 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ { Mat mask2_templ = templ.mul(mask2); - Mat corr(corrSize, CV_32F); + Mat corr(corrSize, CV_32FC1); crossCorr( img, mask2_templ, corr, corr.size(), corr.type(), Point(0,0), 0, 0 ); crossCorr( img2, mask, result, result.size(), result.type(), Point(0,0), 0, 0 ); @@ -829,7 +854,7 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ return; } - Mat corr(corrSize, CV_32F); + Mat corr(corrSize, CV_32FC1); crossCorr( img2, mask2, corr, corr.size(), corr.type(), Point(0,0), 0, 0 ); crossCorr( img, mask_templ, result, result.size(), result.type(), Point(0,0), 0, 0 ); @@ -980,7 +1005,7 @@ static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst, bool normed) IppAutoBuffer buffer; int bufSize=0; - int depth = src.depth(); + ElemDepth depth = src.depth(); ippimatchTemplate ippiCrossCorrNorm = depth==CV_8U ? (ippimatchTemplate)ippiCrossCorrNorm_8u32f_C1R: @@ -1017,7 +1042,7 @@ static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst) IppAutoBuffer buffer; int bufSize=0; - int depth = src.depth(); + ElemDepth depth = src.depth(); ippimatchTemplate ippiSqrDistanceNorm = depth==CV_8U ? (ippimatchTemplate)ippiSqrDistanceNorm_8u32f_C1R: @@ -1097,7 +1122,9 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, return; } - int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _img.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED ); CV_Assert( (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 ); @@ -1115,7 +1142,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, std::swap(img, templ); Size corrSize(img.cols - templ.cols + 1, img.rows - templ.rows + 1); - _result.create(corrSize, CV_32F); + _result.create(corrSize, CV_32FC1); Mat result = _result.getMat(); CV_IPP_RUN_FAST(ipp_matchTemplate(img, templ, result, method)) @@ -1132,7 +1159,7 @@ cvMatchTemplate( const CvArr* _img, const CvArr* _templ, CvArr* _result, int met result = cv::cvarrToMat(_result); CV_Assert( result.size() == cv::Size(std::abs(img.cols - templ.cols) + 1, std::abs(img.rows - templ.rows) + 1) && - result.type() == CV_32F ); + result.type() == CV_32FC1 ); matchTemplate(img, templ, result, method); } diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index c73574a2e036..d06836b5a450 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -1236,7 +1236,9 @@ class ThresholdRunner : public ParallelLoopBody static bool ocl_threshold( InputArray _src, OutputArray _dst, double & thresh, double maxval, int thresh_type ) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type), kercn = ocl::predictOptimalVectorWidth(_src, _dst), ktype = CV_MAKE_TYPE(depth, kercn); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; @@ -1268,9 +1270,9 @@ static bool ocl_threshold( InputArray _src, OutputArray _dst, double & thresh, d double min_val = min_vals[depth]; k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst, cn, kercn), - ocl::KernelArg::Constant(Mat(1, 1, depth, Scalar::all(thresh))), - ocl::KernelArg::Constant(Mat(1, 1, depth, Scalar::all(maxval))), - ocl::KernelArg::Constant(Mat(1, 1, depth, Scalar::all(min_val)))); + ocl::KernelArg::Constant(Mat(1, 1, CV_MAKETYPE(depth, 1), Scalar::all(thresh))), + ocl::KernelArg::Constant(Mat(1, 1, CV_MAKETYPE(depth, 1), Scalar::all(maxval))), + ocl::KernelArg::Constant(Mat(1, 1, CV_MAKETYPE(depth, 1), Scalar::all(min_val)))); size_t globalsize[2] = { (size_t)dst.cols * cn / kercn, (size_t)dst.rows }; globalsize[1] = (globalsize[1] + stride_size - 1) / stride_size; @@ -1526,7 +1528,7 @@ void cv::adaptiveThreshold( InputArray _src, OutputArray _dst, double maxValue, mean = dst; if (method == ADAPTIVE_THRESH_MEAN_C) - boxFilter( src, mean, src.type(), Size(blockSize, blockSize), + boxFilter( src, mean, src.depth(), Size(blockSize, blockSize), Point(-1,-1), true, BORDER_REPLICATE|BORDER_ISOLATED ); else if (method == ADAPTIVE_THRESH_GAUSSIAN_C) { @@ -1534,7 +1536,7 @@ void cv::adaptiveThreshold( InputArray _src, OutputArray _dst, double maxValue, src.convertTo(srcfloat,CV_32F); meanfloat=srcfloat; GaussianBlur(srcfloat, meanfloat, Size(blockSize, blockSize), 0, 0, BORDER_REPLICATE|BORDER_ISOLATED); - meanfloat.convertTo(mean, src.type()); + meanfloat.convertTo(mean, src.depth()); } else CV_Error( CV_StsBadFlag, "Unknown/unsupported adaptive threshold method" ); diff --git a/modules/imgproc/src/undistort.cpp b/modules/imgproc/src/undistort.cpp index 14e5d37d13d4..06365d4a97d9 100644 --- a/modules/imgproc/src/undistort.cpp +++ b/modules/imgproc/src/undistort.cpp @@ -48,7 +48,7 @@ cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize, bool centerPrincipalPoint ) { Mat cameraMatrix = _cameraMatrix.getMat(); - if( !centerPrincipalPoint && cameraMatrix.type() == CV_64F ) + if( !centerPrincipalPoint && cameraMatrix.type() == CV_64FC1 ) return cameraMatrix; Mat newCameraMatrix; @@ -190,12 +190,12 @@ class initUndistortRectifyMapComputer : public cv::ParallelLoopBody void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoeffs, InputArray _matR, InputArray _newCameraMatrix, - Size size, int m1type, OutputArray _map1, OutputArray _map2 ) + Size size, ElemType m1type, OutputArray _map1, OutputArray _map2 ) { Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat(); Mat matR = _matR.getMat(), newCameraMatrix = _newCameraMatrix.getMat(); - if( m1type <= 0 ) + if (m1type <= CV_8UC1) m1type = CV_16SC2; CV_Assert( m1type == CV_16SC2 || m1type == CV_32FC1 || m1type == CV_32FC2 ); _map1.create( size, m1type ); @@ -223,7 +223,7 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef distCoeffs = Mat_(distCoeffs); else { - distCoeffs.create(14, 1, CV_64F); + distCoeffs.create(14, 1, CV_64FC1); distCoeffs = 0.; } @@ -293,7 +293,7 @@ void cv::undistort( InputArray _src, OutputArray _dst, InputArray _cameraMatrix, distCoeffs = Mat_(distCoeffs); else { - distCoeffs.create(5, 1, CV_64F); + distCoeffs.create(5, 1, CV_64FC1); distCoeffs = 0.; } @@ -372,8 +372,8 @@ static void cvUndistortPointsInternal( const CvMat* _src, CvMat* _dst, const CvM { CV_Assert(criteria.isValid()); double A[3][3], RR[3][3], k[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - CvMat matA=cvMat(3, 3, CV_64F, A), _Dk; - CvMat _RR=cvMat(3, 3, CV_64F, RR); + CvMat matA=cvMat(3, 3, CV_64FC1, A), _Dk; + CvMat _RR=cvMat(3, 3, CV_64FC1, RR); cv::Matx33d invMatTilt = cv::Matx33d::eye(); cv::Matx33d matTilt = cv::Matx33d::eye(); @@ -422,7 +422,7 @@ static void cvUndistortPointsInternal( const CvMat* _src, CvMat* _dst, const CvM if( matP ) { double PP[3][3]; - CvMat _P3x3, _PP=cvMat(3, 3, CV_64F, PP); + CvMat _P3x3, _PP=cvMat(3, 3, CV_64FC1, PP); CV_Assert( CV_IS_MAT(matP) && matP->rows == 3 && (matP->cols == 3 || matP->cols == 4)); cvConvert( cvGetCols(matP, &_P3x3, 0, 3), &_PP ); cvMatMul( &_PP, &_RR, &_RR ); @@ -432,8 +432,8 @@ static void cvUndistortPointsInternal( const CvMat* _src, CvMat* _dst, const CvM const CvPoint2D64f* srcd = (const CvPoint2D64f*)_src->data.ptr; CvPoint2D32f* dstf = (CvPoint2D32f*)_dst->data.ptr; CvPoint2D64f* dstd = (CvPoint2D64f*)_dst->data.ptr; - int stype = CV_MAT_TYPE(_src->type); - int dtype = CV_MAT_TYPE(_dst->type); + ElemType stype = CV_MAT_TYPE(_src->type); + ElemType dtype = CV_MAT_TYPE(_dst->type); int sstep = _src->rows == 1 ? 1 : _src->step/CV_ELEM_SIZE(stype); int dstep = _dst->rows == 1 ? 1 : _dst->step/CV_ELEM_SIZE(dtype); @@ -649,19 +649,19 @@ static Point2f invMapPointSpherical(Point2f _p, float alpha, int projType) } float cv::initWideAngleProjMap( InputArray _cameraMatrix0, InputArray _distCoeffs0, - Size imageSize, int destImageWidth, int m1type, + Size imageSize, int destImageWidth, ElemType m1type, OutputArray _map1, OutputArray _map2, int projType, double _alpha ) { Mat cameraMatrix0 = _cameraMatrix0.getMat(), distCoeffs0 = _distCoeffs0.getMat(); double k[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, M[9]={0,0,0,0,0,0,0,0,0}; Mat distCoeffs(distCoeffs0.rows, distCoeffs0.cols, CV_MAKETYPE(CV_64F,distCoeffs0.channels()), k); - Mat cameraMatrix(3,3,CV_64F,M); + Mat cameraMatrix(3,3,CV_64FC1,M); Point2f scenter((float)cameraMatrix.at(0,2), (float)cameraMatrix.at(1,2)); Point2f dcenter((destImageWidth-1)*0.5f, 0.f); float xmin = FLT_MAX, xmax = -FLT_MAX, ymin = FLT_MAX, ymax = -FLT_MAX; int N = 9; std::vector uvec(1), vvec(1); - Mat I = Mat::eye(3,3,CV_64F); + Mat I = Mat::eye(3,3,CV_64FC1); float alpha = (float)_alpha; int ndcoeffs = distCoeffs0.cols*distCoeffs0.rows*distCoeffs0.channels(); diff --git a/modules/imgproc/test/ocl/test_accumulate.cpp b/modules/imgproc/test/ocl/test_accumulate.cpp index 2351d973184b..8cd5e5415bc9 100644 --- a/modules/imgproc/test/ocl/test_accumulate.cpp +++ b/modules/imgproc/test/ocl/test_accumulate.cpp @@ -53,7 +53,8 @@ namespace ocl { PARAM_TEST_CASE(AccumulateBase, std::pair, Channels, bool) { - int sdepth, ddepth, channels; + ElemDepth sdepth, ddepth; + int channels; bool useRoi; double alpha; @@ -72,8 +73,8 @@ PARAM_TEST_CASE(AccumulateBase, std::pair, Channels, bool) void random_roi() { - const int stype = CV_MAKE_TYPE(sdepth, channels), - dtype = CV_MAKE_TYPE(ddepth, channels); + const ElemType stype = CV_MAKE_TYPE(sdepth, channels), + dtype = CV_MAKE_TYPE(ddepth, channels); Size roiSize = randomSize(1, 10); Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0); diff --git a/modules/imgproc/test/ocl/test_blend.cpp b/modules/imgproc/test/ocl/test_blend.cpp index 1bf2758a7f86..4687097086ed 100644 --- a/modules/imgproc/test/ocl/test_blend.cpp +++ b/modules/imgproc/test/ocl/test_blend.cpp @@ -53,7 +53,8 @@ namespace ocl { PARAM_TEST_CASE(BlendLinear, MatDepth, Channels, bool) { - int depth, channels; + ElemDepth depth; + int channels; bool useRoi; TEST_DECLARE_INPUT_PARAMETER(src1); @@ -71,7 +72,7 @@ PARAM_TEST_CASE(BlendLinear, MatDepth, Channels, bool) void random_roi() { - const int type = CV_MAKE_TYPE(depth, channels); + const ElemType type = CV_MAKE_TYPE(depth, channels); const double upValue = 256; Size roiSize = randomSize(1, MAX_VALUE); diff --git a/modules/imgproc/test/ocl/test_boxfilter.cpp b/modules/imgproc/test/ocl/test_boxfilter.cpp index 7f305f03e7f6..bfa667d78844 100644 --- a/modules/imgproc/test/ocl/test_boxfilter.cpp +++ b/modules/imgproc/test/ocl/test_boxfilter.cpp @@ -56,7 +56,8 @@ PARAM_TEST_CASE(BoxFilterBase, MatDepth, Channels, BorderType, bool, bool) static const int kernelMinSize = 2; static const int kernelMaxSize = 10; - int depth, cn, borderType; + ElemDepth depth; + int cn, borderType; Size ksize, dsize; Point anchor; bool normalize, useRoi; @@ -75,7 +76,7 @@ PARAM_TEST_CASE(BoxFilterBase, MatDepth, Channels, BorderType, bool, bool) void random_roi() { - int type = CV_MAKE_TYPE(depth, cn); + ElemType type = CV_MAKE_TYPE(depth, cn); ksize = randomSize(kernelMinSize, kernelMaxSize); Size roiSize = randomSize(ksize.width, MAX_VALUE, ksize.height, MAX_VALUE); @@ -106,8 +107,8 @@ OCL_TEST_P(BoxFilter, Mat) { random_roi(); - OCL_OFF(cv::boxFilter(src_roi, dst_roi, -1, ksize, anchor, normalize, borderType)); - OCL_ON(cv::boxFilter(usrc_roi, udst_roi, -1, ksize, anchor, normalize, borderType)); + OCL_OFF(cv::boxFilter(src_roi, dst_roi, CV_DEPTH_AUTO, ksize, anchor, normalize, borderType)); + OCL_ON(cv::boxFilter(usrc_roi, udst_roi, CV_DEPTH_AUTO, ksize, anchor, normalize, borderType)); Near(depth <= CV_32S ? 1 : 3e-3); } @@ -121,7 +122,7 @@ OCL_TEST_P(SqrBoxFilter, Mat) { random_roi(); - int ddepth = depth == CV_8U ? CV_32S : CV_64F; + ElemDepth ddepth = depth == CV_8U ? CV_32S : CV_64F; OCL_OFF(cv::sqrBoxFilter(src_roi, dst_roi, ddepth, ksize, anchor, normalize, borderType)); OCL_ON(cv::sqrBoxFilter(usrc_roi, udst_roi, ddepth, ksize, anchor, normalize, borderType)); @@ -159,7 +160,8 @@ OCL_INSTANTIATE_TEST_CASE_P(ImageProc, SqrBoxFilter, PARAM_TEST_CASE(BoxFilter3x3_cols16_rows2_Base, MatDepth, Channels, BorderType, bool, bool) { - int depth, cn, borderType; + ElemDepth depth; + int cn, borderType; Size ksize, dsize; Point anchor; bool normalize, useRoi; @@ -178,7 +180,7 @@ PARAM_TEST_CASE(BoxFilter3x3_cols16_rows2_Base, MatDepth, Channels, BorderType, void random_roi() { - int type = CV_MAKE_TYPE(depth, cn); + ElemType type = CV_MAKE_TYPE(depth, cn); ksize = Size(3,3); Size roiSize = randomSize(ksize.width, MAX_VALUE, ksize.height, MAX_VALUE); @@ -211,8 +213,8 @@ OCL_TEST_P(BoxFilter3x3_cols16_rows2, Mat) { random_roi(); - OCL_OFF(cv::boxFilter(src_roi, dst_roi, -1, ksize, anchor, normalize, borderType)); - OCL_ON(cv::boxFilter(usrc_roi, udst_roi, -1, ksize, anchor, normalize, borderType)); + OCL_OFF(cv::boxFilter(src_roi, dst_roi, CV_DEPTH_AUTO, ksize, anchor, normalize, borderType)); + OCL_ON(cv::boxFilter(usrc_roi, udst_roi, CV_DEPTH_AUTO, ksize, anchor, normalize, borderType)); Near(depth <= CV_32S ? 1 : 3e-3); } @@ -220,7 +222,7 @@ OCL_TEST_P(BoxFilter3x3_cols16_rows2, Mat) OCL_INSTANTIATE_TEST_CASE_P(ImageProc, BoxFilter3x3_cols16_rows2, Combine( - Values((MatDepth)CV_8U), + Values(CV_8U), Values((Channels)1), Values((BorderType)BORDER_CONSTANT, (BorderType)BORDER_REPLICATE, diff --git a/modules/imgproc/test/ocl/test_canny.cpp b/modules/imgproc/test/ocl/test_canny.cpp index eee98240f9aa..b65c6c4f4626 100644 --- a/modules/imgproc/test/ocl/test_canny.cpp +++ b/modules/imgproc/test/ocl/test_canny.cpp @@ -80,7 +80,7 @@ PARAM_TEST_CASE(Canny, Channels, ApertureSize, L2gradient, UseRoi) ASSERT_FALSE(img.empty()) << "cann't load shared/fruits.png"; Size roiSize = img.size(); - int type = img.type(); + ElemType type = img.type(); Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); randomSubMat(src, src_roi, roiSize, srcBorder, type, 2, 100); diff --git a/modules/imgproc/test/ocl/test_color.cpp b/modules/imgproc/test/ocl/test_color.cpp index 0d08de07534c..9bedf2942270 100644 --- a/modules/imgproc/test/ocl/test_color.cpp +++ b/modules/imgproc/test/ocl/test_color.cpp @@ -56,7 +56,7 @@ namespace ocl { PARAM_TEST_CASE(CvtColor, MatDepth, bool) { - int depth; + ElemDepth depth; bool use_roi; TEST_DECLARE_INPUT_PARAMETER(src); @@ -70,8 +70,8 @@ PARAM_TEST_CASE(CvtColor, MatDepth, bool) virtual void generateTestData(int channelsIn, int channelsOut) { - const int srcType = CV_MAKE_TYPE(depth, channelsIn); - const int dstType = CV_MAKE_TYPE(depth, channelsOut); + const ElemType srcType = CV_MAKE_TYPE(depth, channelsIn); + const ElemType dstType = CV_MAKE_TYPE(depth, channelsOut); Size roiSize = randomSize(1, MAX_VALUE); Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0); @@ -109,8 +109,8 @@ PARAM_TEST_CASE(CvtColor, MatDepth, bool) ASSERT_EQ(dst_roi.type(), udst_roi.type()); ASSERT_EQ(dst_roi.size(), udst_roi.size()); Mat gold, actual; - dst_roi.convertTo(gold, CV_32FC3); - udst_roi.getMat(ACCESS_READ).convertTo(actual, CV_32FC3); + dst_roi.convertTo(gold, CV_32F); + udst_roi.getMat(ACCESS_READ).convertTo(actual, CV_32F); Mat absdiff1, absdiff2, absdiff3; cv::absdiff(gold, actual, absdiff1); cv::absdiff(gold, actual + h_limit, absdiff2); @@ -352,8 +352,8 @@ struct CvtColor_YUV2RGB_420 : { void generateTestData(int channelsIn, int channelsOut) { - const int srcType = CV_MAKE_TYPE(depth, channelsIn); - const int dstType = CV_MAKE_TYPE(depth, channelsOut); + const ElemType srcType = CV_MAKE_TYPE(depth, channelsIn); + const ElemType dstType = CV_MAKE_TYPE(depth, channelsOut); Size roiSize = randomSize(1, MAX_VALUE); roiSize.width *= 2; @@ -394,8 +394,8 @@ struct CvtColor_RGB2YUV_420 : { void generateTestData(int channelsIn, int channelsOut) { - const int srcType = CV_MAKE_TYPE(depth, channelsIn); - const int dstType = CV_MAKE_TYPE(depth, channelsOut); + const ElemType srcType = CV_MAKE_TYPE(depth, channelsIn); + const ElemType dstType = CV_MAKE_TYPE(depth, channelsOut); Size srcRoiSize = randomSize(1, MAX_VALUE); srcRoiSize.width *= 2; @@ -428,8 +428,8 @@ struct CvtColor_YUV2RGB_422 : { void generateTestData(int channelsIn, int channelsOut) { - const int srcType = CV_MAKE_TYPE(depth, channelsIn); - const int dstType = CV_MAKE_TYPE(depth, channelsOut); + const ElemType srcType = CV_MAKE_TYPE(depth, channelsIn); + const ElemType dstType = CV_MAKE_TYPE(depth, channelsOut); Size roiSize = randomSize(1, MAX_VALUE); roiSize.width *= 2; diff --git a/modules/imgproc/test/ocl/test_filter2d.cpp b/modules/imgproc/test/ocl/test_filter2d.cpp index aaa48cd86561..101dd96c4e90 100644 --- a/modules/imgproc/test/ocl/test_filter2d.cpp +++ b/modules/imgproc/test/ocl/test_filter2d.cpp @@ -56,7 +56,7 @@ PARAM_TEST_CASE(Filter2D, MatDepth, Channels, int, int, BorderType, bool, bool) static const int kernelMinSize = 2; static const int kernelMaxSize = 10; - int type; + ElemType type; Size size; Point anchor; int borderType; @@ -114,8 +114,8 @@ OCL_TEST_P(Filter2D, Mat) { random_roi(); - OCL_OFF(cv::filter2D(src_roi, dst_roi, -1, kernel, anchor, delta, borderType)); - OCL_ON(cv::filter2D(usrc_roi, udst_roi, -1, kernel, anchor, delta, borderType)); + OCL_OFF(cv::filter2D(src_roi, dst_roi, CV_DEPTH_AUTO, kernel, anchor, delta, borderType)); + OCL_ON(cv::filter2D(usrc_roi, udst_roi, CV_DEPTH_AUTO, kernel, anchor, delta, borderType)); Near(1.0); } diff --git a/modules/imgproc/test/ocl/test_filters.cpp b/modules/imgproc/test/ocl/test_filters.cpp index ef52d0a0fe65..ce1fcfb55629 100644 --- a/modules/imgproc/test/ocl/test_filters.cpp +++ b/modules/imgproc/test/ocl/test_filters.cpp @@ -65,7 +65,8 @@ PARAM_TEST_CASE(FilterTestBase, MatType, bool, // roi or not int) // width multiplier { - int type, borderType, ksize; + ElemType type; + int borderType, ksize; Size size; double param; bool useRoi; @@ -106,7 +107,7 @@ PARAM_TEST_CASE(FilterTestBase, MatType, void Near() { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); bool isFP = depth >= CV_32F; if (isFP) @@ -158,8 +159,8 @@ OCL_TEST_P(LaplacianTest, Accuracy) { random_roi(); - OCL_OFF(cv::Laplacian(src_roi, dst_roi, -1, ksize, scale, 10, borderType)); - OCL_ON(cv::Laplacian(usrc_roi, udst_roi, -1, ksize, scale, 10, borderType)); + OCL_OFF(cv::Laplacian(src_roi, dst_roi, CV_DEPTH_AUTO, ksize, scale, 10, borderType)); + OCL_ON(cv::Laplacian(usrc_roi, udst_roi, CV_DEPTH_AUTO, ksize, scale, 10, borderType)); Near(); } @@ -173,7 +174,8 @@ PARAM_TEST_CASE(Deriv3x3_cols16_rows2_Base, MatType, bool, // roi or not int) // width multiplier { - int type, borderType, ksize; + ElemType type; + int borderType, ksize; Size size; double param; bool useRoi; @@ -235,8 +237,8 @@ OCL_TEST_P(Laplacian3_cols16_rows2, Accuracy) { random_roi(); - OCL_OFF(cv::Laplacian(src_roi, dst_roi, -1, ksize, scale, 10, borderType)); - OCL_ON(cv::Laplacian(usrc_roi, udst_roi, -1, ksize, scale, 10, borderType)); + OCL_OFF(cv::Laplacian(src_roi, dst_roi, CV_DEPTH_AUTO, ksize, scale, 10, borderType)); + OCL_ON(cv::Laplacian(usrc_roi, udst_roi, CV_DEPTH_AUTO, ksize, scale, 10, borderType)); Near(); } @@ -257,8 +259,8 @@ OCL_TEST_P(SobelTest, Mat) { random_roi(); - OCL_OFF(cv::Sobel(src_roi, dst_roi, -1, dx, dy, ksize, scale, /* delta */0, borderType)); - OCL_ON(cv::Sobel(usrc_roi, udst_roi, -1, dx, dy, ksize, scale, /* delta */0, borderType)); + OCL_OFF(cv::Sobel(src_roi, dst_roi, CV_DEPTH_AUTO, dx, dy, ksize, scale, /* delta */0, borderType)); + OCL_ON(cv::Sobel(usrc_roi, udst_roi, CV_DEPTH_AUTO, dx, dy, ksize, scale, /* delta */0, borderType)); Near(); } @@ -275,8 +277,8 @@ OCL_TEST_P(Sobel3x3_cols16_rows2, Mat) { random_roi(); - OCL_OFF(cv::Sobel(src_roi, dst_roi, -1, dx, dy, ksize, scale, /* delta */0, borderType)); - OCL_ON(cv::Sobel(usrc_roi, udst_roi, -1, dx, dy, ksize, scale, /* delta */0, borderType)); + OCL_OFF(cv::Sobel(src_roi, dst_roi, CV_DEPTH_AUTO, dx, dy, ksize, scale, /* delta */0, borderType)); + OCL_ON(cv::Sobel(usrc_roi, udst_roi, CV_DEPTH_AUTO, dx, dy, ksize, scale, /* delta */0, borderType)); Near(); } @@ -296,8 +298,8 @@ OCL_TEST_P(ScharrTest, Mat) { random_roi(); - OCL_OFF(cv::Scharr(src_roi, dst_roi, -1, dx, dy, scale, /* delta */ 0, borderType)); - OCL_ON(cv::Scharr(usrc_roi, udst_roi, -1, dx, dy, scale, /* delta */ 0, borderType)); + OCL_OFF(cv::Scharr(src_roi, dst_roi, CV_DEPTH_AUTO, dx, dy, scale, /* delta */ 0, borderType)); + OCL_ON(cv::Scharr(usrc_roi, udst_roi, CV_DEPTH_AUTO, dx, dy, scale, /* delta */ 0, borderType)); Near(); } @@ -314,8 +316,8 @@ OCL_TEST_P(Scharr3x3_cols16_rows2, Mat) { random_roi(); - OCL_OFF(cv::Scharr(src_roi, dst_roi, -1, dx, dy, scale, /* delta */ 0, borderType)); - OCL_ON(cv::Scharr(usrc_roi, udst_roi, -1, dx, dy, scale, /* delta */ 0, borderType)); + OCL_OFF(cv::Scharr(src_roi, dst_roi, CV_DEPTH_AUTO, dx, dy, scale, /* delta */ 0, borderType)); + OCL_ON(cv::Scharr(usrc_roi, udst_roi, CV_DEPTH_AUTO, dx, dy, scale, /* delta */ 0, borderType)); Near(); } @@ -350,7 +352,8 @@ PARAM_TEST_CASE(GaussianBlur_multicols_Base, MatType, bool, // roi or not int) // width multiplier { - int type, borderType, ksize; + ElemType type; + int borderType, ksize; Size size; double param; bool useRoi; @@ -481,7 +484,8 @@ PARAM_TEST_CASE(MorphFilter3x3_cols16_rows2_Base, MatType, bool, // roi or not int) // width multiplier { - int type, borderType, ksize; + ElemType type; + int borderType, ksize; Size size; double param; bool useRoi; @@ -561,7 +565,8 @@ PARAM_TEST_CASE(MorphologyEx, MatType, int, // iterations bool) { - int type, ksize, op, iterations; + ElemType type; + int ksize, op, iterations; bool useRoi; TEST_DECLARE_INPUT_PARAMETER(src); @@ -595,7 +600,7 @@ PARAM_TEST_CASE(MorphologyEx, MatType, void Near() { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); bool isFP = depth >= CV_32F; if (isFP) @@ -664,7 +669,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, LaplacianTest, Combine( Values(1))); // not used OCL_INSTANTIATE_TEST_CASE_P(Filter, Laplacian3_cols16_rows2, Combine( - Values((MatType)CV_8UC1), + Values(CV_8UC1), Values(3), // kernel size Values(Size(0, 0)), // not used FILTER_BORDER_SET_NO_WRAP_NO_ISOLATED, @@ -682,7 +687,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, SobelTest, Combine( Values(1))); // not used OCL_INSTANTIATE_TEST_CASE_P(Filter, Sobel3x3_cols16_rows2, Combine( - Values((MatType)CV_8UC1), + Values(CV_8UC1), Values(3), // kernel size Values(Size(1, 0), Size(1, 1), Size(2, 0), Size(2, 1)), // dx, dy FILTER_BORDER_SET_NO_WRAP_NO_ISOLATED, @@ -718,7 +723,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, GaussianBlurTest, Combine( Values(1))); // not used OCL_INSTANTIATE_TEST_CASE_P(Filter, GaussianBlur_multicols, Combine( - Values((MatType)CV_8UC1), + Values(CV_8UC1), Values(3, 5), // kernel size Values(Size(0, 0)), // not used FILTER_BORDER_SET_NO_WRAP_NO_ISOLATED, @@ -745,7 +750,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine( Values(1))); // not used OCL_INSTANTIATE_TEST_CASE_P(Filter, MorphFilter3x3_cols16_rows2, Combine( - Values((MatType)CV_8UC1), + Values(CV_8UC1), Values(0, 3), // kernel size, 0 means kernel = Mat() Values(Size(0, 0)), // not used Values((BorderType)BORDER_CONSTANT), diff --git a/modules/imgproc/test/ocl/test_histogram.cpp b/modules/imgproc/test/ocl/test_histogram.cpp index 93e58d4d9a0a..f33132d96968 100644 --- a/modules/imgproc/test/ocl/test_histogram.cpp +++ b/modules/imgproc/test/ocl/test_histogram.cpp @@ -64,7 +64,8 @@ namespace ocl { PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool) { - int depth, N; + ElemDepth depth; + int N; bool useRoi; std::vector ranges; @@ -162,7 +163,7 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool) //compute histogram calcHist(&frame1, 1, 0, Mat(), hist1, 1, &histSize, &ranges1, true, false); - normalize(hist1, hist1, 0, 255, NORM_MINMAX, -1, Mat()); + normalize(hist1, hist1, 0, 255, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); Mat dst1; UMat udst1, src, uhist1; @@ -268,7 +269,7 @@ OCL_TEST_P(CalcHist, Mat) ///////////////////////////////////////////////////////////////////////////////////// -OCL_INSTANTIATE_TEST_CASE_P(Imgproc, CalcBackProject, Combine(Values((MatDepth)CV_8U), Values(1, 2), Bool())); +OCL_INSTANTIATE_TEST_CASE_P(Imgproc, CalcBackProject, Combine(Values(CV_8U), Values(1, 2), Bool())); OCL_INSTANTIATE_TEST_CASE_P(Imgproc, CalcHist, Values(true, false)); } } // namespace opencv_test::ocl diff --git a/modules/imgproc/test/ocl/test_imgproc.cpp b/modules/imgproc/test/ocl/test_imgproc.cpp index f5a3fef89cc2..f177c38307ad 100644 --- a/modules/imgproc/test/ocl/test_imgproc.cpp +++ b/modules/imgproc/test/ocl/test_imgproc.cpp @@ -63,10 +63,11 @@ namespace ocl { PARAM_TEST_CASE(ImgprocTestBase, MatType, int, // blockSize - int, // border type + BorderType, // border type bool) // roi or not { - int type, borderType, blockSize; + ElemType type; + int borderType, blockSize; bool useRoi; TEST_DECLARE_INPUT_PARAMETER(src); @@ -110,7 +111,8 @@ PARAM_TEST_CASE(CopyMakeBorder, MatDepth, // depth BorderType, // border type bool) // roi or not { - int type, borderType; + ElemType type; + int borderType; bool useRoi; TestUtils::Border border; @@ -201,7 +203,7 @@ struct CornerTestBase : float val = 255.0f; if (isFP) { - image.convertTo(image, -1, 1.0 / 255); + image.convertTo(image, CV_DEPTH_AUTO, 1.0 / 255); val /= 255.0f; } @@ -280,11 +282,14 @@ OCL_TEST_P(PreCornerDetect, Mat) ////////////////////////////////// integral ///////////////////////////////////////////////// -struct Integral : - public ImgprocTestBase +PARAM_TEST_CASE(Integral, MatType, MatDepth, MatDepth, bool) { - int sdepth, sqdepth; + ElemType type; + ElemDepth sdepth, sqdepth; + bool useRoi; + TEST_DECLARE_INPUT_PARAMETER(src); + TEST_DECLARE_OUTPUT_PARAMETER(dst); TEST_DECLARE_OUTPUT_PARAMETER(dst2); virtual void SetUp() @@ -304,16 +309,24 @@ struct Integral : randomSubMat(src, src_roi, roiSize, srcBorder, type, 5, 256); Border dstBorder = randomBorder(0, useRoi ? 2 : 0); - randomSubMat(dst, dst_roi, isize, dstBorder, sdepth, 5, 16); + randomSubMat(dst, dst_roi, isize, dstBorder, CV_MAKETYPE(sdepth, 1), 5, 16); Border dst2Border = randomBorder(0, useRoi ? 2 : 0); - randomSubMat(dst2, dst2_roi, isize, dst2Border, sqdepth, 5, 16); + randomSubMat(dst2, dst2_roi, isize, dst2Border, CV_MAKETYPE(sqdepth, 1), 5, 16); UMAT_UPLOAD_INPUT_PARAMETER(src); UMAT_UPLOAD_OUTPUT_PARAMETER(dst); UMAT_UPLOAD_OUTPUT_PARAMETER(dst2); } + void Near(double threshold = 0.0, bool relative = false) + { + if (relative) + OCL_EXPECT_MATS_NEAR_RELATIVE(dst, threshold); + else + OCL_EXPECT_MATS_NEAR(dst, threshold); + } + void Near2(double threshold = 0.0, bool relative = false) { if (relative) @@ -436,36 +449,36 @@ OCL_TEST_P(CLAHETest, Accuracy) ///////////////////////////////////////////////////////////////////////////////////// OCL_INSTANTIATE_TEST_CASE_P(Imgproc, EqualizeHist, Combine( - Values((MatType)CV_8UC1), + Values(CV_8UC1), Values(0), // not used Values(0), // not used Bool())); OCL_INSTANTIATE_TEST_CASE_P(Imgproc, CornerMinEigenVal, Combine( - Values((MatType)CV_8UC1, (MatType)CV_32FC1), + Values(CV_8UC1, CV_32FC1), Values(3, 5), Values((BorderType)BORDER_CONSTANT, (BorderType)BORDER_REPLICATE, (BorderType)BORDER_REFLECT, (BorderType)BORDER_REFLECT101), Bool())); OCL_INSTANTIATE_TEST_CASE_P(Imgproc, CornerHarris, Combine( - Values((MatType)CV_8UC1, CV_32FC1), + Values(CV_8UC1, CV_32FC1), Values(3, 5), Values( (BorderType)BORDER_CONSTANT, (BorderType)BORDER_REPLICATE, (BorderType)BORDER_REFLECT, (BorderType)BORDER_REFLECT_101), Bool())); OCL_INSTANTIATE_TEST_CASE_P(Imgproc, PreCornerDetect, Combine( - Values((MatType)CV_8UC1, CV_32FC1), + Values(CV_8UC1, CV_32FC1), Values(3, 5), Values( (BorderType)BORDER_CONSTANT, (BorderType)BORDER_REPLICATE, (BorderType)BORDER_REFLECT, (BorderType)BORDER_REFLECT_101), Bool())); OCL_INSTANTIATE_TEST_CASE_P(Imgproc, Integral, Combine( - Values((MatType)CV_8UC1), // TODO does not work with CV_32F, CV_64F - Values(CV_32SC1, CV_32FC1), // desired sdepth - Values(CV_32FC1, CV_64FC1), // desired sqdepth + Values(CV_8UC1), // TODO does not work with CV_32F, CV_64F + Values(CV_32S, CV_32F), // desired sdepth + Values(CV_32F, CV_64F), // desired sqdepth Bool())); OCL_INSTANTIATE_TEST_CASE_P(Imgproc, Threshold, Combine( @@ -484,7 +497,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Imgproc, CLAHETest, Combine( Bool())); OCL_INSTANTIATE_TEST_CASE_P(ImgprocTestBase, CopyMakeBorder, Combine( - testing::Values((MatDepth)CV_8U, (MatDepth)CV_16S, (MatDepth)CV_32S, (MatDepth)CV_32F), + testing::Values(CV_8U, CV_16S, CV_32S, CV_32F), testing::Values(Channels(1), Channels(3), (Channels)4), Bool(), // border isolated or not Values((BorderType)BORDER_CONSTANT, (BorderType)BORDER_REPLICATE, (BorderType)BORDER_REFLECT, diff --git a/modules/imgproc/test/ocl/test_match_template.cpp b/modules/imgproc/test/ocl/test_match_template.cpp index 3d979e00de9d..c6a31ce46f43 100644 --- a/modules/imgproc/test/ocl/test_match_template.cpp +++ b/modules/imgproc/test/ocl/test_match_template.cpp @@ -55,8 +55,8 @@ CV_ENUM(MatchTemplType, CV_TM_CCORR, CV_TM_CCORR_NORMED, CV_TM_SQDIFF, CV_TM_SQD PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool) { - int type; - int depth; + ElemType type; + ElemDepth depth; int method; bool use_roi; diff --git a/modules/imgproc/test/ocl/test_medianfilter.cpp b/modules/imgproc/test/ocl/test_medianfilter.cpp index e0e114548f7c..f784f9d8248f 100644 --- a/modules/imgproc/test/ocl/test_medianfilter.cpp +++ b/modules/imgproc/test/ocl/test_medianfilter.cpp @@ -53,7 +53,7 @@ namespace ocl { PARAM_TEST_CASE(MedianFilter, MatDepth, Channels, int, bool) { - int type; + ElemType type; int ksize; bool use_roi; diff --git a/modules/imgproc/test/ocl/test_pyramids.cpp b/modules/imgproc/test/ocl/test_pyramids.cpp index d295711fe377..c04c81d259e5 100644 --- a/modules/imgproc/test/ocl/test_pyramids.cpp +++ b/modules/imgproc/test/ocl/test_pyramids.cpp @@ -54,7 +54,8 @@ namespace ocl { PARAM_TEST_CASE(PyrTestBase, MatDepth, Channels, BorderType, bool) { - int depth, channels, borderType; + ElemDepth depth; + int channels, borderType; bool use_roi; TEST_DECLARE_INPUT_PARAMETER(src); @@ -160,7 +161,7 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgprocPyr, PyrUp, Combine( )); OCL_INSTANTIATE_TEST_CASE_P(ImgprocPyr, PyrUp_cols2, Combine( - Values((MatDepth)CV_8U), + Values(CV_8U), Values((Channels)1), Values((BorderType)BORDER_REFLECT_101), Bool() diff --git a/modules/imgproc/test/ocl/test_sepfilter2d.cpp b/modules/imgproc/test/ocl/test_sepfilter2d.cpp index 9b1f1690ae4f..cb8efcc3d216 100644 --- a/modules/imgproc/test/ocl/test_sepfilter2d.cpp +++ b/modules/imgproc/test/ocl/test_sepfilter2d.cpp @@ -56,7 +56,7 @@ PARAM_TEST_CASE(SepFilter2D, MatDepth, Channels, BorderType, bool, bool) static const int kernelMinSize = 2; static const int kernelMaxSize = 10; - int type; + ElemType type; Point anchor; int borderType; bool useRoi; @@ -112,8 +112,8 @@ OCL_TEST_P(SepFilter2D, Mat) { random_roi(); - OCL_OFF(cv::sepFilter2D(src_roi, dst_roi, -1, kernelX, kernelY, anchor, delta, borderType)); - OCL_ON(cv::sepFilter2D(usrc_roi, udst_roi, -1, kernelX, kernelY, anchor, delta, borderType)); + OCL_OFF(cv::sepFilter2D(src_roi, dst_roi, CV_DEPTH_AUTO, kernelX, kernelY, anchor, delta, borderType)); + OCL_ON(cv::sepFilter2D(usrc_roi, udst_roi, CV_DEPTH_AUTO, kernelX, kernelY, anchor, delta, borderType)); Near(1.0); } diff --git a/modules/imgproc/test/ocl/test_warp.cpp b/modules/imgproc/test/ocl/test_warp.cpp index bc828084c91a..07af324d26bc 100644 --- a/modules/imgproc/test/ocl/test_warp.cpp +++ b/modules/imgproc/test/ocl/test_warp.cpp @@ -59,20 +59,16 @@ namespace opencv_test { namespace ocl { -enum -{ - noType = -1 -}; - ///////////////////////////////////////////////////////////////////////////////////////////////// // warpAffine & warpPerspective PARAM_TEST_CASE(WarpTestBase, MatType, Interpolation, bool, bool) { - int type, interpolation; + ElemType type; + int interpolation; Size dsize; bool useRoi, mapInverse; - int depth; + ElemDepth depth; TEST_DECLARE_INPUT_PARAMETER(src); TEST_DECLARE_OUTPUT_PARAMETER(dst); @@ -115,10 +111,11 @@ PARAM_TEST_CASE(WarpTestBase, MatType, Interpolation, bool, bool) PARAM_TEST_CASE(WarpTest_cols4_Base, MatType, Interpolation, bool, bool) { - int type, interpolation; + ElemType type; + int interpolation; Size dsize; bool useRoi, mapInverse; - int depth; + ElemDepth depth; TEST_DECLARE_INPUT_PARAMETER(src); TEST_DECLARE_OUTPUT_PARAMETER(dst); @@ -261,7 +258,8 @@ OCL_TEST_P(WarpPerspective_cols4, Mat) PARAM_TEST_CASE(Resize, MatType, double, double, Interpolation, bool, int) { - int type, interpolation; + ElemType type; + int interpolation; int widthMultiple; double fx, fy; bool useRoi; @@ -315,7 +313,7 @@ OCL_TEST_P(Resize, Mat) { for (int j = 0; j < test_loop_times; j++) { - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); double eps = depth <= CV_32S ? integerEps : 5e-2; random_roi(); @@ -332,7 +330,7 @@ OCL_TEST_P(Resize, Mat) PARAM_TEST_CASE(Remap, MatDepth, Channels, std::pair, BorderType, bool) { - int srcType, map1Type, map2Type; + ElemType srcType, map1Type, map2Type; int borderType; bool useRoi; @@ -369,7 +367,7 @@ PARAM_TEST_CASE(Remap, MatDepth, Channels, std::pair, BorderTy randomSubMat(map1, map1_roi, dstROISize, map1Border, map1Type, -mapMaxValue, mapMaxValue); Border map2Border = randomBorder(0, useRoi ? MAX_VALUE + 1 : 0); - if (map2Type != noType) + if (map2Type != CV_TYPE_AUTO) { int mapMinValue = -mapMaxValue; if (map2Type == CV_16UC1 || map2Type == CV_16SC1) @@ -380,7 +378,7 @@ PARAM_TEST_CASE(Remap, MatDepth, Channels, std::pair, BorderTy UMAT_UPLOAD_INPUT_PARAMETER(src); UMAT_UPLOAD_INPUT_PARAMETER(map1); UMAT_UPLOAD_OUTPUT_PARAMETER(dst); - if (noType != map2Type) + if (map2Type != CV_TYPE_AUTO) UMAT_UPLOAD_INPUT_PARAMETER(map2); } }; @@ -433,7 +431,7 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarp, WarpAffine, Combine( Bool())); OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarp, WarpAffine_cols4, Combine( - Values((MatType)CV_8UC1), + Values(CV_8UC1), Values((Interpolation)INTER_NEAREST, (Interpolation)INTER_LINEAR, (Interpolation)INTER_CUBIC), Bool(), Bool())); @@ -445,7 +443,7 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarp, WarpPerspective, Combine( Bool())); OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarp, WarpPerspective_cols4, Combine( - Values((MatType)CV_8UC1), + Values(CV_8UC1), Values((Interpolation)INTER_NEAREST, (Interpolation)INTER_LINEAR, (Interpolation)INTER_CUBIC), Bool(), Bool())); @@ -467,7 +465,7 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarpLinearExact, Resize, Combine( Values(1, 16))); OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarpResizeArea, Resize, Combine( - Values((MatType)CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), + Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(0.7, 0.4, 0.5), Values(0.3, 0.6, 0.5), Values((Interpolation)INTER_AREA), @@ -477,9 +475,9 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarpResizeArea, Resize, Combine( OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarp, Remap_INTER_LINEAR, Combine( Values(CV_8U, CV_16U, CV_32F), Values(1, 3, 4), - Values(std::pair((MatType)CV_32FC1, (MatType)CV_32FC1), - std::pair((MatType)CV_16SC2, (MatType)CV_16UC1), - std::pair((MatType)CV_32FC2, noType)), + Values(std::pair(CV_32FC1, CV_32FC1), + std::pair(CV_16SC2, CV_16UC1), + std::pair(CV_32FC2, CV_TYPE_AUTO)), Values((BorderType)BORDER_CONSTANT, (BorderType)BORDER_REPLICATE, (BorderType)BORDER_WRAP, @@ -490,10 +488,10 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarp, Remap_INTER_LINEAR, Combine( OCL_INSTANTIATE_TEST_CASE_P(ImgprocWarp, Remap_INTER_NEAREST, Combine( Values(CV_8U, CV_16U, CV_32F), Values(1, 3, 4), - Values(std::pair((MatType)CV_32FC1, (MatType)CV_32FC1), - std::pair((MatType)CV_32FC2, noType), - std::pair((MatType)CV_16SC2, (MatType)CV_16UC1), - std::pair((MatType)CV_16SC2, noType)), + Values(std::pair(CV_32FC1, CV_32FC1), + std::pair(CV_32FC2, CV_TYPE_AUTO), + std::pair(CV_16SC2, CV_16UC1), + std::pair(CV_16SC2, CV_TYPE_AUTO)), Values((BorderType)BORDER_CONSTANT, (BorderType)BORDER_REPLICATE, (BorderType)BORDER_WRAP, diff --git a/modules/imgproc/test/test_bilateral_filter.cpp b/modules/imgproc/test/test_bilateral_filter.cpp index f5e8caab8076..c37bc1249d16 100644 --- a/modules/imgproc/test/test_bilateral_filter.cpp +++ b/modules/imgproc/test/test_bilateral_filter.cpp @@ -232,10 +232,10 @@ namespace opencv_test { namespace { int CV_BilateralFilterTest::prepare_test_case(int /* test_case_index */) { - const static int types[] = { CV_32FC1, CV_32FC3, CV_8UC1, CV_8UC3 }; + const static ElemType types[] = { CV_32FC1, CV_32FC3, CV_8UC1, CV_8UC3 }; RNG& rng = ts->get_rng(); Size size(getRandInt(rng, MIN_WIDTH, MAX_WIDTH), getRandInt(rng, MIN_HEIGHT, MAX_HEIGHT)); - int type = types[rng(sizeof(types) / sizeof(types[0]))]; + ElemType type = types[rng(sizeof(types) / sizeof(types[0]))]; _d = rng.uniform(0., 1.) > 0.5 ? 5 : 3; @@ -260,10 +260,9 @@ namespace opencv_test { namespace { } else { - int type = _src.type(); _src.convertTo(reference_src, CV_32F); reference_bilateral_filter(reference_src, reference_dst, _d, _sigma_color, _sigma_space); - reference_dst.convertTo(reference_dst, type); + reference_dst.convertTo(reference_dst, _src.depth()); e = cvtest::norm(reference_dst, _parallel_dst, NORM_INF); } diff --git a/modules/imgproc/test/test_canny.cpp b/modules/imgproc/test/test_canny.cpp index 161b839f4883..85ab6365c9cf 100644 --- a/modules/imgproc/test/test_canny.cpp +++ b/modules/imgproc/test/test_canny.cpp @@ -49,12 +49,12 @@ class CV_CannyTest : public cvtest::ArrayTest CV_CannyTest(bool custom_deriv = false); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - int prepare_test_case( int test_case_idx ); - void run_func(); - void prepare_to_validation( int ); - int validate_test_results( int /*test_case_idx*/ ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; + int validate_test_results( int /*test_case_idx*/ ) CV_OVERRIDE; int aperture_size; bool use_true_gradient; @@ -86,13 +86,13 @@ CV_CannyTest::CV_CannyTest(bool custom_deriv) void CV_CannyTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); double thresh_range; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_8U; + types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_8UC1; aperture_size = cvtest::randInt(rng) % 2 ? 5 : 3; thresh_range = aperture_size == 3 ? 300 : 1000; @@ -209,7 +209,7 @@ test_Canny( const Mat& src, Mat& dst, Mat dxkernel = cvtest::calcSobelKernel2D( 1, 0, m, 0 ); Mat dykernel = cvtest::calcSobelKernel2D( 0, 1, m, 0 ); - Mat dx, dy, mag(height, width, CV_32F); + Mat dx, dy, mag(height, width, CV_32FC1); cvtest::filter2D(src, dx, CV_32S, dxkernel, anchor, 0, BORDER_REPLICATE); cvtest::filter2D(src, dy, CV_32S, dykernel, anchor, 0, BORDER_REPLICATE); @@ -385,7 +385,7 @@ TEST_P(CannyVX, Accuracy) // 'smart' diff check (excluding isolated pixels) Mat diff, diff1; absdiff(canny, cannyVX, diff); - boxFilter(diff, diff1, -1, Size(3,3)); + boxFilter(diff, diff1, CV_DEPTH_AUTO, Size(3,3)); const int minPixelsAroud = 3; // empirical number diff1 = diff1 > 255/9 * minPixelsAroud; erode(diff1, diff1, Mat()); diff --git a/modules/imgproc/test/test_color.cpp b/modules/imgproc/test/test_color.cpp index 5f5de472a287..6826376efc78 100644 --- a/modules/imgproc/test/test_color.cpp +++ b/modules/imgproc/test/test_color.cpp @@ -51,10 +51,10 @@ class CV_ColorCvtBaseTest : public cvtest::ArrayTest CV_ColorCvtBaseTest( bool custom_inv_transform, bool allow_32f, bool allow_16u ); protected: - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; // input --- fwd_transform -> ref_output[0] virtual void convert_forward( const Mat& src, Mat& dst ); @@ -70,7 +70,7 @@ class CV_ColorCvtBaseTest : public cvtest::ArrayTest const char* fwd_code_str; const char* inv_code_str; - void run_func(); + void run_func() CV_OVERRIDE; bool allow_16u, allow_32f; int blue_idx; bool inplace; @@ -105,12 +105,11 @@ CV_ColorCvtBaseTest::CV_ColorCvtBaseTest( bool _custom_inv_transform, bool _allo } -void CV_ColorCvtBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_ColorCvtBaseTest::get_minmax_bounds( int i, int j, ElemDepth depth, Scalar& low, Scalar& high ) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); + cvtest::ArrayTest::get_minmax_bounds(i, j, depth, low, high); if( i == INPUT ) { - int depth = CV_MAT_DEPTH(type); low = Scalar::all(0.); high = Scalar::all( depth == CV_8U ? 256 : depth == CV_16U ? 65536 : 1. ); } @@ -118,21 +117,22 @@ void CV_ColorCvtBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low void CV_ColorCvtBaseTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); - int depth, cn; + ElemDepth depth; + int cn; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); if( allow_16u && allow_32f ) { - depth = cvtest::randInt(rng) % 3; - depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : CV_32F; + int _depth = cvtest::randInt(rng) % 3; + depth = _depth == 0 ? CV_8U : _depth == 1 ? CV_16U : CV_32F; } else if( allow_16u || allow_32f ) { - depth = cvtest::randInt(rng) % 2; - depth = depth == 0 ? CV_8U : allow_16u ? CV_16U : CV_32F; + int _depth = cvtest::randInt(rng) % 2; + depth = _depth == 0 ? CV_8U : allow_16u ? CV_16U : CV_32F; } else depth = CV_8U; @@ -186,7 +186,7 @@ void CV_ColorCvtBaseTest::prepare_to_validation( int /*test_case_idx*/ ) convert_forward( test_mat[INPUT][0], test_mat[REF_OUTPUT][0] ); convert_backward( test_mat[INPUT][0], test_mat[REF_OUTPUT][0], test_mat[REF_OUTPUT][1] ); - int depth = test_mat[REF_OUTPUT][0].depth(); + ElemDepth depth = test_mat[REF_OUTPUT][0].depth(); if( depth == CV_8U && hue_range ) { for( int y = 0; y < test_mat[REF_OUTPUT][0].rows; y++ ) @@ -208,7 +208,7 @@ void CV_ColorCvtBaseTest::convert_forward( const Mat& src, Mat& dst ) { const float c8u = 0.0039215686274509803f; // 1./255 const float c16u = 1.5259021896696422e-005f; // 1./65535 - int depth = src.depth(); + ElemDepth depth = src.depth(); int cn = src.channels(), dst_cn = dst.channels(); int cols = src.cols, dst_cols_n = dst.cols*dst_cn; vector _src_buf(src.cols*3); @@ -303,7 +303,7 @@ void CV_ColorCvtBaseTest::convert_backward( const Mat& src, const Mat& dst, Mat& { if( custom_inv_transform ) { - int depth = src.depth(); + ElemDepth depth = src.depth(); int src_cn = dst.channels(), cn = dst2.channels(); int cols_n = src.cols*src_cn, dst_cols = dst.cols; vector _src_buf(src.cols*3); @@ -424,10 +424,10 @@ class CV_ColorGrayTest : public CV_ColorCvtBaseTest public: CV_ColorGrayTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; void convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ); void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); - double get_success_error_level( int test_case_idx, int i, int j ); + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; }; @@ -437,11 +437,11 @@ CV_ColorGrayTest::CV_ColorGrayTest() : CV_ColorCvtBaseTest( true, true, true ) } -void CV_ColorGrayTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorGrayTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); int cn = CV_MAT_CN(types[INPUT][0]); - types[OUTPUT][0] = types[REF_OUTPUT][0] = types[INPUT][0] & CV_MAT_DEPTH_MASK; + types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(CV_MAT_DEPTH(types[INPUT][0]), 1); inplace = false; if( cn == 3 ) @@ -463,14 +463,14 @@ void CV_ColorGrayTest::get_test_array_types_and_sizes( int test_case_idx, vector double CV_ColorGrayTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); return depth == CV_8U ? 2 : depth == CV_16U ? 16 : 1e-5; } void CV_ColorGrayTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); double scale = depth == CV_8U ? 255 : depth == CV_16U ? 65535 : 1; double cr = 0.299*scale; double cg = 0.587*scale; @@ -497,8 +497,8 @@ class CV_ColorYCrCbTest : public CV_ColorCvtBaseTest public: CV_ColorYCrCbTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ); void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); }; @@ -510,7 +510,7 @@ CV_ColorYCrCbTest::CV_ColorYCrCbTest() : CV_ColorCvtBaseTest( true, true, true ) } -void CV_ColorYCrCbTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorYCrCbTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -523,14 +523,14 @@ void CV_ColorYCrCbTest::get_test_array_types_and_sizes( int test_case_idx, vecto double CV_ColorYCrCbTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); return depth == CV_8U ? 2 : depth == CV_16U ? 32 : 1e-3; } void CV_ColorYCrCbTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); double scale = depth == CV_8U ? 255 : depth == CV_16U ? 65535 : 1; double bias = depth == CV_8U ? 128 : depth == CV_16U ? 32768 : 0.5; @@ -558,7 +558,7 @@ void CV_ColorYCrCbTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* void CV_ColorYCrCbTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); double bias = depth == CV_8U ? 128 : depth == CV_16U ? 32768 : 0.5; double scale = depth == CV_8U ? 1./255 : depth == CV_16U ? 1./65535 : 1; double M[] = { 1, 1.40252, 0, @@ -589,8 +589,8 @@ class CV_ColorHSVTest : public CV_ColorCvtBaseTest public: CV_ColorHSVTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ); void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); }; @@ -603,7 +603,7 @@ CV_ColorHSVTest::CV_ColorHSVTest() : CV_ColorCvtBaseTest( true, true, false ) } -void CV_ColorHSVTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorHSVTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); RNG& rng = ts->get_rng(); @@ -630,14 +630,14 @@ void CV_ColorHSVTest::get_test_array_types_and_sizes( int test_case_idx, vector< double CV_ColorHSVTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); return depth == CV_8U ? (j == 0 ? 4 : 16) : depth == CV_16U ? 32 : 1e-3; } void CV_ColorHSVTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float h_scale = depth == CV_8U ? hue_range*30.f/180 : 60.f; float scale = depth == CV_8U ? 255.f : depth == CV_16U ? 65535.f : 1.f; int j; @@ -676,7 +676,7 @@ void CV_ColorHSVTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* d // taken from http://www.cs.rit.edu/~ncs/color/t_convert.html void CV_ColorHSVTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float h_scale = depth == CV_8U ? 180/(hue_range*30.f) : 1.f/60; float scale = depth == CV_8U ? 1.f/255 : depth == CV_16U ? 1.f/65535 : 1; int j; @@ -728,8 +728,8 @@ class CV_ColorHLSTest : public CV_ColorCvtBaseTest public: CV_ColorHLSTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ); void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); }; @@ -742,7 +742,7 @@ CV_ColorHLSTest::CV_ColorHLSTest() : CV_ColorCvtBaseTest( true, true, false ) } -void CV_ColorHLSTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorHLSTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -755,14 +755,14 @@ void CV_ColorHLSTest::get_test_array_types_and_sizes( int test_case_idx, vector< double CV_ColorHLSTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); return depth == CV_8U ? (j == 0 ? 4 : 16) : depth == CV_16U ? 32 : 1e-4; } void CV_ColorHLSTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float h_scale = depth == CV_8U ? 30.f : 60.f; float scale = depth == CV_8U ? 255.f : depth == CV_16U ? 65535.f : 1.f; int j; @@ -803,7 +803,7 @@ void CV_ColorHLSTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* d void CV_ColorHLSTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float h_scale = depth == CV_8U ? 1.f/30 : 1.f/60; float scale = depth == CV_8U ? 1.f/255 : depth == CV_16U ? 1.f/65535 : 1; int j; @@ -912,8 +912,8 @@ class CV_ColorXYZTest : public CV_ColorCvtBaseTest public: CV_ColorXYZTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ); void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); }; @@ -925,7 +925,7 @@ CV_ColorXYZTest::CV_ColorXYZTest() : CV_ColorCvtBaseTest( true, true, true ) } -void CV_ColorXYZTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorXYZTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -938,14 +938,14 @@ void CV_ColorXYZTest::get_test_array_types_and_sizes( int test_case_idx, vector< double CV_ColorXYZTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); return depth == CV_8U ? (j == 0 ? 2 : 8) : depth == CV_16U ? (j == 0 ? 64 : 128) : 1e-1; } void CV_ColorXYZTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); softdouble scale(depth == CV_8U ? 255 : depth == CV_16U ? 65535 : 1); @@ -971,7 +971,7 @@ void CV_ColorXYZTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* d void CV_ColorXYZTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); softdouble scale(depth == CV_8U ? 1./255 : depth == CV_16U ? 1./65535 : 1); @@ -1039,8 +1039,8 @@ class CV_ColorLabTest : public CV_ColorCvtBaseTest public: CV_ColorLabTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ); void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); }; @@ -1052,7 +1052,7 @@ CV_ColorLabTest::CV_ColorLabTest() : CV_ColorCvtBaseTest( true, true, false ) } -void CV_ColorLabTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorLabTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -1075,7 +1075,7 @@ void CV_ColorLabTest::get_test_array_types_and_sizes( int test_case_idx, vector< double CV_ColorLabTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); // j == 0 is for forward code, j == 1 is for inverse code return (depth == CV_8U) ? (srgb ? 32 : 8) : //(depth == CV_16U) ? 32 : // 16u is disabled @@ -1085,7 +1085,7 @@ double CV_ColorLabTest::get_success_error_level( int /*test_case_idx*/, int i, i void CV_ColorLabTest::convert_row_bgr2abc_32f_c3(const float* src_row, float* dst_row, int n) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float Lscale = depth == CV_8U ? 255.f/100.f : depth == CV_16U ? 65535.f/100.f : 1.f; float ab_bias = depth == CV_8U ? 128.f : depth == CV_16U ? 32768.f : 0.f; float M[9]; @@ -1140,7 +1140,7 @@ void CV_ColorLabTest::convert_row_bgr2abc_32f_c3(const float* src_row, float* ds void CV_ColorLabTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float Lscale = depth == CV_8U ? 100.f/255.f : depth == CV_16U ? 100.f/65535.f : 1.f; float ab_bias = depth == CV_8U ? 128.f : depth == CV_16U ? 32768.f : 0.f; float M[9]; @@ -1218,8 +1218,8 @@ class CV_ColorLuvTest : public CV_ColorCvtBaseTest public: CV_ColorLuvTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ); void convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ); }; @@ -1231,7 +1231,7 @@ CV_ColorLuvTest::CV_ColorLuvTest() : CV_ColorCvtBaseTest( true, true, false ) } -void CV_ColorLuvTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorLuvTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -1254,7 +1254,7 @@ void CV_ColorLuvTest::get_test_array_types_and_sizes( int test_case_idx, vector< double CV_ColorLuvTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); // j == 0 is for forward code, j == 1 is for inverse code return (depth == CV_8U) ? (srgb ? 36 : 8) : //(depth == CV_16U) ? 32 : // 16u is disabled @@ -1264,7 +1264,7 @@ double CV_ColorLuvTest::get_success_error_level( int /*test_case_idx*/, int i, i void CV_ColorLuvTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float Lscale = depth == CV_8U ? 255.f/100.f : depth == CV_16U ? 65535.f/100.f : 1.f; static const float uLow = -134.f, uHigh = 220.f, uRange = uHigh - uLow; static const float vLow = -140.f, vHigh = 122.f, vRange = vHigh - vLow; @@ -1341,7 +1341,7 @@ void CV_ColorLuvTest::convert_row_bgr2abc_32f_c3( const float* src_row, float* d void CV_ColorLuvTest::convert_row_abc2bgr_32f_c3( const float* src_row, float* dst_row, int n ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); float Lscale = depth == CV_8U ? 100.f/255.f : depth == CV_16U ? 100.f/65535.f : 1.f; static const float uLow = -134.f, uHigh = 220.f, uRange = uHigh - uLow; static const float vLow = -140.f, vHigh = 122.f, vRange = vHigh - vLow; @@ -1424,8 +1424,8 @@ class CV_ColorRGBTest : public CV_ColorCvtBaseTest public: CV_ColorRGBTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; void convert_forward( const Mat& src, Mat& dst ); void convert_backward( const Mat& src, const Mat& dst, Mat& dst2 ); int dst_bits; @@ -1438,7 +1438,7 @@ CV_ColorRGBTest::CV_ColorRGBTest() : CV_ColorCvtBaseTest( true, true, true ) } -void CV_ColorRGBTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorRGBTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -1493,7 +1493,8 @@ double CV_ColorRGBTest::get_success_error_level( int /*test_case_idx*/, int /*i* void CV_ColorRGBTest::convert_forward( const Mat& src, Mat& dst ) { - int depth = src.depth(), cn = src.channels(); + ElemDepth depth = src.depth(); + int cn = src.channels(); /*#if defined _DEBUG || defined DEBUG int dst_cn = CV_MAT_CN(dst->type); #endif*/ @@ -1579,7 +1580,8 @@ void CV_ColorRGBTest::convert_forward( const Mat& src, Mat& dst ) void CV_ColorRGBTest::convert_backward( const Mat& /*src*/, const Mat& src, Mat& dst ) { - int depth = src.depth(), cn = dst.channels(); + ElemDepth depth = src.depth(); + int cn = dst.channels(); /*#if defined _DEBUG || defined DEBUG int src_cn = CV_MAT_CN(src->type); #endif*/ @@ -1690,10 +1692,10 @@ class CV_ColorBayerTest : public CV_ColorCvtBaseTest public: CV_ColorBayerTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int test_case_idx ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; }; @@ -1709,12 +1711,12 @@ CV_ColorBayerTest::CV_ColorBayerTest() : CV_ColorCvtBaseTest( false, false, true } -void CV_ColorBayerTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ColorBayerTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_ColorCvtBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - types[INPUT][0] = CV_MAT_DEPTH(types[INPUT][0]); + types[INPUT][0] = CV_MAKETYPE(CV_MAT_DEPTH(types[INPUT][0]), 1); types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(CV_MAT_DEPTH(types[INPUT][0]), 3); inplace = false; @@ -1818,7 +1820,7 @@ void CV_ColorBayerTest::prepare_to_validation( int /*test_case_idx*/ ) { const Mat& src = test_mat[INPUT][0]; Mat& dst = test_mat[REF_OUTPUT][0]; - int depth = src.depth(); + ElemDepth depth = src.depth(); if( depth == CV_8U ) bayer2BGR_(src, dst, fwd_code); else if( depth == CV_16U ) @@ -1891,7 +1893,7 @@ TEST(Imgproc_ColorBayerVNG, regression) } // creating Bayer pattern -template +template static void calculateBayerPattern(const Mat& src, Mat& bayer, const char* pattern) { Size ssize = src.size(); diff --git a/modules/imgproc/test/test_contours.cpp b/modules/imgproc/test/test_contours.cpp index a5c924829de7..82db78c4c2db 100644 --- a/modules/imgproc/test/test_contours.cpp +++ b/modules/imgproc/test/test_contours.cpp @@ -246,7 +246,7 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx ) storage = cvCreateMemStorage( 1 << 10 ); for( i = 0; i < NUM_IMG; i++ ) - img[i] = cvCreateImage( cvSize(img_size), 8, 1 ); + img[i] = cvCreateImage(cvSize(img_size), IPL_DEPTH_8U, 1); cvTsGenerateBlobImage( img[0], min_blob_size, max_blob_size, blob_count, min_brightness, max_brightness, rng ); @@ -445,7 +445,7 @@ TEST(Imgproc_FindContours, hilbert) { int n = 64, n2 = n*n, scale = 10, w = (n + 2)*scale; Point ofs(scale, scale); - Mat img(w, w, CV_8U); + Mat img(w, w, CV_8UC1); img.setTo(Scalar::all(0)); Point p(0,0); @@ -471,12 +471,12 @@ TEST(Imgproc_FindContours, hilbert) TEST(Imgproc_FindContours, border) { Mat img; - cv::copyMakeBorder(Mat::zeros(8, 10, CV_8U), img, 1, 1, 1, 1, BORDER_CONSTANT, Scalar(1)); + cv::copyMakeBorder(Mat::zeros(8, 10, CV_8UC1), img, 1, 1, 1, 1, BORDER_CONSTANT, Scalar(1)); std::vector > contours; findContours(img, contours, RETR_LIST, CHAIN_APPROX_NONE); - Mat img_draw_contours = Mat::zeros(img.size(), CV_8U); + Mat img_draw_contours = Mat::zeros(img.size(), CV_8UC1); for (size_t cpt = 0; cpt < contours.size(); cpt++) { drawContours(img_draw_contours, contours, static_cast(cpt), cv::Scalar(1)); diff --git a/modules/imgproc/test/test_distancetransform.cpp b/modules/imgproc/test/test_distancetransform.cpp index 652b5bfd24f9..3ffe0e84c293 100644 --- a/modules/imgproc/test/test_distancetransform.cpp +++ b/modules/imgproc/test/test_distancetransform.cpp @@ -49,13 +49,13 @@ class CV_DisTransTest : public cvtest::ArrayTest CV_DisTransTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - int prepare_test_case( int test_case_idx ); + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; int mask_size; int dist_type; @@ -77,7 +77,7 @@ CV_DisTransTest::CV_DisTransTest() void CV_DisTransTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -113,10 +113,10 @@ double CV_DisTransTest::get_success_error_level( int /*test_case_idx*/, int /*i* } -void CV_DisTransTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_DisTransTest::get_minmax_bounds( int i, int j, ElemDepth depth, Scalar& low, Scalar& high ) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); - if( i == INPUT && CV_MAT_DEPTH(type) == CV_8U ) + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); + if( i == INPUT && depth == CV_8U ) { low = Scalar::all(0); high = Scalar::all(10); @@ -188,7 +188,7 @@ cvTsDistTransform( const CvMat* _src, CvMat* _dst, int dist_type, mask[2] = 2.1969f; } - temp = cvCreateMat( height + mask_size-1, width + mask_size-1, CV_32F ); + temp = cvCreateMat( height + mask_size-1, width + mask_size-1, CV_32FC1); tstep = temp->step / sizeof(float); if( mask_size == 3 ) @@ -296,7 +296,7 @@ BIGDATA_TEST(Imgproc_DistanceTransform, large_image_12218) distanceTransform(src, dst, labels, cv::DIST_L2, cv::DIST_MASK_3, DIST_LABEL_PIXEL); double scale = (double)lls_mincnt / (double)lls_maxcnt; - labels.convertTo(labels, CV_32SC1, scale); + labels.convertTo(labels, CV_32S, scale); Size size = labels.size(); nz = cv::countNonZero(labels); EXPECT_EQ(nz, (size.height*size.width / 2)); diff --git a/modules/imgproc/test/test_drawing.cpp b/modules/imgproc/test/test_drawing.cpp index c42d7aa572ba..a5710814b7b7 100644 --- a/modules/imgproc/test/test_drawing.cpp +++ b/modules/imgproc/test/test_drawing.cpp @@ -573,7 +573,7 @@ class CV_FillConvexPolyTest : public cvtest::BaseTest line2.push_back(Point(10, 16)); line2.push_back(Point(2, 16)); - Mat gray0(10,10,CV_8U, Scalar(0)); + Mat gray0(10,10,CV_8UC1, Scalar(0)); fillConvexPoly(gray0, line1, Scalar(255), 8, 0); int nz1 = countNonZero(gray0); diff --git a/modules/imgproc/test/test_emd.cpp b/modules/imgproc/test/test_emd.cpp index 51f05f374e97..14ebd63cb94d 100644 --- a/modules/imgproc/test/test_emd.cpp +++ b/modules/imgproc/test/test_emd.cpp @@ -71,9 +71,9 @@ void CV_EMDTest::run( int ) }; static float w1[] = { 50, 60, 50, 50 }, w2[] = { 30, 20, 70, 30, 60 }; - Mat _w1(4, 1, CV_32F, w1); - Mat _w2(5, 1, CV_32F, w2); - Mat _cost(_w1.rows, _w2.rows, CV_32F, cost); + Mat _w1(4, 1, CV_32FC1, w1); + Mat _w2(5, 1, CV_32FC1, w2); + Mat _cost(_w1.rows, _w2.rows, CV_32FC1, cost); float emd = EMD( _w1, _w2, -1, _cost ); if( fabs( emd - emd0 ) > success_error_level*emd0 ) diff --git a/modules/imgproc/test/test_filter.cpp b/modules/imgproc/test/test_filter.cpp index b34599440515..fe02dd29979b 100644 --- a/modules/imgproc/test/test_filter.cpp +++ b/modules/imgproc/test/test_filter.cpp @@ -49,10 +49,10 @@ class CV_FilterBaseTest : public cvtest::ArrayTest CV_FilterBaseTest( bool _fp_kernel ); protected: - int prepare_test_case( int test_case_idx ); - int read_params( CvFileStorage* fs ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + int read_params(CvFileStorage* fs) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; Size aperture_size; Point anchor; int max_aperture_size; @@ -89,9 +89,9 @@ int CV_FilterBaseTest::read_params( CvFileStorage* fs ) } -void CV_FilterBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_FilterBaseTest::get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); if( i == INPUT ) { if( j == 1 ) @@ -109,12 +109,12 @@ void CV_FilterBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, high = Scalar::all(2); } } - else if( CV_MAT_DEPTH(type) == CV_16U ) + else if (depth == CV_16U) { low = Scalar::all(0.); high = Scalar::all(40000.); } - else if( CV_MAT_DEPTH(type) == CV_32F ) + else if(depth == CV_32F) { low = Scalar::all(-10.); high = Scalar::all(10.); @@ -125,13 +125,13 @@ void CV_FilterBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, void CV_FilterBaseTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % CV_32F; + ElemDepth depth = static_cast(cvtest::randInt(rng) % static_cast(CV_32F)); int cn = cvtest::randInt(rng) % 3 + 1; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - depth += depth == CV_8S; + if (depth == CV_8S) depth = CV_16U; cn += cn == 2; types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth, cn); @@ -171,10 +171,10 @@ class CV_MorphologyBaseTest : public CV_FilterBaseTest CV_MorphologyBaseTest(); protected: - void prepare_to_validation( int test_case_idx ); - int prepare_test_case( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; int optype, optype_min, optype_max; int shape; IplConvKernel* element; @@ -190,11 +190,11 @@ CV_MorphologyBaseTest::CV_MorphologyBaseTest() : CV_FilterBaseTest( false ) void CV_MorphologyBaseTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_FilterBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = cvtest::randInt(rng) % 4; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 4); depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : depth == 2 ? CV_16S : CV_32F; int cn = CV_MAT_CN(types[INPUT][0]); @@ -254,7 +254,7 @@ int CV_MorphologyBaseTest::prepare_test_case( int test_case_idx ) void CV_MorphologyBaseTest::prepare_to_validation( int /*test_case_idx*/ ) { Mat& src = test_mat[INPUT][0], &dst = test_mat[REF_OUTPUT][0]; - Mat _ielement(element->nRows, element->nCols, CV_32S, element->values); + Mat _ielement(element->nRows, element->nCols, CV_32SC1, element->values); Mat _element; _ielement.convertTo(_element, CV_8U); Point _anchor(element->anchorX, element->anchorY); @@ -285,19 +285,19 @@ void CV_MorphologyBaseTest::prepare_to_validation( int /*test_case_idx*/ ) { cvtest::erode( src, temp, _element, _anchor, _border ); cvtest::dilate( src, dst, _element, _anchor, _border ); - cvtest::add( dst, 1, temp, -1, Scalar::all(0), dst, dst.type() ); + cvtest::add(dst, 1, temp, -1, Scalar::all(0), dst, dst.depth()); } else if( optype == CV_MOP_TOPHAT ) { cvtest::erode( src, temp, _element, _anchor, _border ); cvtest::dilate( temp, dst, _element, _anchor, _border ); - cvtest::add( src, 1, dst, -1, Scalar::all(0), dst, dst.type() ); + cvtest::add(src, 1, dst, -1, Scalar::all(0), dst, dst.depth()); } else if( optype == CV_MOP_BLACKHAT ) { cvtest::dilate( src, temp, _element, _anchor, _border ); cvtest::erode( temp, dst, _element, _anchor, _border ); - cvtest::add( dst, 1, src, -1, Scalar::all(0), dst, dst.type() ); + cvtest::add(dst, 1, src, -1, Scalar::all(0), dst, dst.depth()); } else CV_Error( CV_StsBadArg, "Unknown operation" ); @@ -314,7 +314,7 @@ class CV_ErodeTest : public CV_MorphologyBaseTest public: CV_ErodeTest(); protected: - void run_func(); + void run_func() CV_OVERRIDE; }; @@ -338,7 +338,7 @@ class CV_DilateTest : public CV_MorphologyBaseTest public: CV_DilateTest(); protected: - void run_func(); + void run_func() CV_OVERRIDE; }; @@ -361,7 +361,7 @@ class CV_MorphExTest : public CV_MorphologyBaseTest public: CV_MorphExTest(); protected: - void run_func(); + void run_func() CV_OVERRIDE; }; @@ -386,10 +386,10 @@ class CV_FilterTest : public CV_FilterBaseTest CV_FilterTest(); protected: - void prepare_to_validation( int test_case_idx ); - void run_func(); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; }; @@ -399,11 +399,11 @@ CV_FilterTest::CV_FilterTest() : CV_FilterBaseTest( true ) void CV_FilterTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { CV_FilterBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng)%3; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 3); int cn = CV_MAT_CN(types[INPUT][0]); depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : CV_32F; types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth, cn); @@ -412,7 +412,7 @@ void CV_FilterTest::get_test_array_types_and_sizes( int test_case_idx, double CV_FilterTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth <= CV_8S ? 2 : depth <= CV_32S ? 32 : depth == CV_32F ? 1e-4 : 1e-10; } @@ -428,7 +428,7 @@ void CV_FilterTest::run_func() void CV_FilterTest::prepare_to_validation( int /*test_case_idx*/ ) { - cvtest::filter2D( test_mat[INPUT][0], test_mat[REF_OUTPUT][0], test_mat[REF_OUTPUT][0].type(), + cvtest::filter2D( test_mat[INPUT][0], test_mat[REF_OUTPUT][0], test_mat[REF_OUTPUT][0].depth(), test_mat[INPUT][1], anchor, 0, BORDER_REPLICATE ); } @@ -440,8 +440,8 @@ class CV_DerivBaseTest : public CV_FilterBaseTest public: CV_DerivBaseTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; int _aperture_size; }; @@ -453,11 +453,11 @@ CV_DerivBaseTest::CV_DerivBaseTest() : CV_FilterBaseTest( true ) void CV_DerivBaseTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_FilterBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = cvtest::randInt(rng) % 2; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2); depth = depth == 0 ? CV_8U : CV_32F; types[INPUT][0] = CV_MAKETYPE(depth,1); types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth==CV_8U?CV_16S:CV_32F,1); @@ -468,7 +468,7 @@ void CV_DerivBaseTest::get_test_array_types_and_sizes( int test_case_idx, double CV_DerivBaseTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth <= CV_8S ? 2 : 5e-4; } @@ -481,10 +481,10 @@ class CV_SobelTest : public CV_DerivBaseTest CV_SobelTest(); protected: - void prepare_to_validation( int test_case_idx ); - void run_func(); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; void get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ); + vector >& sizes, vector >& types ) CV_OVERRIDE; int dx, dy, origin; }; @@ -494,7 +494,7 @@ CV_SobelTest::CV_SobelTest() {} void CV_SobelTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); CV_DerivBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -559,10 +559,10 @@ class CV_SpatialGradientTest : public CV_DerivBaseTest CV_SpatialGradientTest(); protected: - void prepare_to_validation( int test_case_idx ); - void run_func(); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; void get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ); + vector >& sizes, vector >& types ) CV_OVERRIDE; int ksize; }; @@ -575,7 +575,7 @@ CV_SpatialGradientTest::CV_SpatialGradientTest() { void CV_SpatialGradientTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { CV_DerivBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -604,11 +604,11 @@ void CV_SpatialGradientTest::prepare_to_validation( int /*test_case_idx*/ ) int dx, dy; dx = 1; dy = 0; - Sobel( test_mat[INPUT][0], test_mat[REF_OUTPUT][0], CV_16SC1, dx, dy, ksize, + Sobel( test_mat[INPUT][0], test_mat[REF_OUTPUT][0], CV_16S, dx, dy, ksize, 1, 0, border ); dx = 0; dy = 1; - Sobel( test_mat[INPUT][0], test_mat[REF_OUTPUT][1], CV_16SC1, dx, dy, ksize, + Sobel( test_mat[INPUT][0], test_mat[REF_OUTPUT][1], CV_16S, dx, dy, ksize, 1, 0, border ); } @@ -621,10 +621,10 @@ class CV_LaplaceTest : public CV_DerivBaseTest CV_LaplaceTest(); protected: - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int test_case_idx ); - void run_func(); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; }; @@ -634,7 +634,7 @@ CV_LaplaceTest::CV_LaplaceTest() void CV_LaplaceTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { CV_DerivBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); if( _aperture_size <= 1 ) @@ -682,8 +682,8 @@ class CV_SmoothBaseTest : public CV_FilterBaseTest CV_SmoothBaseTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; const char* smooth_type; }; @@ -695,11 +695,11 @@ CV_SmoothBaseTest::CV_SmoothBaseTest() : CV_FilterBaseTest( true ) void CV_SmoothBaseTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_FilterBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = cvtest::randInt(rng) % 2; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2); int cn = CV_MAT_CN(types[INPUT][0]); depth = depth == 0 ? CV_8U : CV_32F; types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth,cn); @@ -713,7 +713,7 @@ void CV_SmoothBaseTest::get_test_array_types_and_sizes( int test_case_idx, double CV_SmoothBaseTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth < CV_32F ? 1 : 1e-5; } @@ -726,10 +726,10 @@ class CV_BlurTest : public CV_SmoothBaseTest CV_BlurTest(); protected: - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int test_case_idx ); - void run_func(); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; bool normalize; }; @@ -740,11 +740,11 @@ CV_BlurTest::CV_BlurTest() void CV_BlurTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_SmoothBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = cvtest::randInt(rng) % 4; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 4); int cn = (cvtest::randInt(rng) % 4) + 1; depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : depth == 2 ? CV_16S : CV_32F; types[OUTPUT][0] = types[REF_OUTPUT][0] = types[INPUT][0] = CV_MAKETYPE(depth, cn); @@ -774,7 +774,7 @@ int CV_BlurTest::prepare_test_case( int test_case_idx ) void CV_BlurTest::prepare_to_validation( int /*test_case_idx*/ ) { - Mat kernel(aperture_size, CV_64F); + Mat kernel(aperture_size, CV_64FC1); kernel.setTo(Scalar::all(normalize ? 1./(aperture_size.width*aperture_size.height) : 1.)); cvtest::filter2D( test_mat[INPUT][0], test_mat[REF_OUTPUT][0], test_mat[REF_OUTPUT][0].depth(), kernel, anchor, 0, BORDER_REPLICATE ); @@ -789,10 +789,10 @@ class CV_GaussianBlurTest : public CV_SmoothBaseTest CV_GaussianBlurTest(); protected: - void prepare_to_validation( int test_case_idx ); - void run_func(); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) CV_OVERRIDE; double sigma; int param1, param2; }; @@ -807,13 +807,13 @@ CV_GaussianBlurTest::CV_GaussianBlurTest() : CV_SmoothBaseTest() double CV_GaussianBlurTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth <= CV_8S ? 8 : 1e-5; } void CV_GaussianBlurTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int kernel_case = cvtest::randInt(rng) % 2; @@ -880,7 +880,7 @@ calcGaussianKernel( int n, double sigma, vector& kernel ) static Mat calcGaussianKernel2D( Size ksize, double sigma ) { vector kx, ky; - Mat kernel(ksize, CV_32F); + Mat kernel(ksize, CV_32FC1); calcGaussianKernel( kernel.cols, sigma, kx ); calcGaussianKernel( kernel.rows, sigma, ky ); @@ -908,10 +908,10 @@ class CV_MedianBlurTest : public CV_SmoothBaseTest CV_MedianBlurTest(); protected: - void prepare_to_validation( int test_case_idx ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); + void prepare_to_validation( int test_case_idx ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; }; @@ -922,10 +922,10 @@ CV_MedianBlurTest::CV_MedianBlurTest() void CV_MedianBlurTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { CV_SmoothBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = CV_8U; + ElemDepth depth = CV_8U; int cn = CV_MAT_CN(types[INPUT][0]); types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_MAKETYPE(depth,cn); types[INPUT][1] = CV_MAKETYPE(depth,1); @@ -1057,12 +1057,12 @@ void CV_MedianBlurTest::prepare_to_validation( int /*test_case_idx*/ ) Mat& dst0 = test_mat[REF_OUTPUT][0]; int i, cn = src0.channels(); int m = aperture_size.width; - Mat src(src0.rows + m - 1, src0.cols + m - 1, src0.depth()); + Mat src(src0.rows + m - 1, src0.cols + m - 1, CV_MAKETYPE(src0.depth(), 1)); Mat dst; if( cn == 1 ) dst = dst0; else - dst.create(src0.size(), src0.depth()); + dst.create(src0.size(), CV_MAKETYPE(src0.depth(), 1)); for( i = 0; i < cn; i++ ) { @@ -1088,8 +1088,8 @@ class CV_PyramidBaseTest : public CV_FilterBaseTest CV_PyramidBaseTest( bool downsample ); protected: - double get_success_error_level( int test_case_idx, int i, int j ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; bool downsample; Mat kernel; }; @@ -1099,30 +1099,30 @@ CV_PyramidBaseTest::CV_PyramidBaseTest( bool _downsample ) : CV_FilterBaseTest(t { static float kdata[] = { 1.f, 4.f, 6.f, 4.f, 1.f }; downsample = _downsample; - Mat kernel1d(1, 5, CV_32F, kdata); + Mat kernel1d(1, 5, CV_32FC1, kdata); kernel = (kernel1d.t()*kernel1d)*((downsample ? 1 : 4)/256.); } double CV_PyramidBaseTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth < CV_32F ? 1 : 1e-5; } void CV_PyramidBaseTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { const int channels[] = {1, 3, 4}; - const int depthes[] = {CV_8U, CV_16S, CV_16U, CV_32F}; + const ElemDepth depthes[] = {CV_8U, CV_16S, CV_16U, CV_32F}; RNG& rng = ts->get_rng(); CvSize sz = {0, 0}; CV_FilterBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = depthes[cvtest::randInt(rng) % (sizeof(depthes)/sizeof(depthes[0]))]; + ElemDepth depth = depthes[cvtest::randInt(rng) % (sizeof(depthes)/sizeof(depthes[0]))]; int cn = channels[cvtest::randInt(rng) % (sizeof(channels)/sizeof(channels[0]))]; aperture_size = cvSize(5,5); @@ -1161,8 +1161,8 @@ class CV_PyramidDownTest : public CV_PyramidBaseTest CV_PyramidDownTest(); protected: - void run_func(); - void prepare_to_validation( int ); + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -1210,8 +1210,8 @@ class CV_PyramidUpTest : public CV_PyramidBaseTest CV_PyramidUpTest(); protected: - void run_func(); - void prepare_to_validation( int ); + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -1265,10 +1265,10 @@ class CV_FeatureSelBaseTest : public cvtest::ArrayTest CV_FeatureSelBaseTest( int width_factor ); protected: - int read_params( CvFileStorage* fs ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - double get_success_error_level( int test_case_idx, int i, int j ); + int read_params(CvFileStorage* fs) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; int aperture_size, block_size; int max_aperture_size; int max_block_size; @@ -1306,15 +1306,15 @@ int CV_FeatureSelBaseTest::read_params( CvFileStorage* fs ) double CV_FeatureSelBaseTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth <= CV_8S ? 3e-2 : depth == CV_32F ? 1e-3 : 1e-10; } -void CV_FeatureSelBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_FeatureSelBaseTest::get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); - if( i == INPUT && CV_MAT_DEPTH(type) == CV_32F ) + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); + if( i == INPUT && depth == CV_32F ) { low = Scalar::all(-10.); high = Scalar::all(10.); @@ -1323,14 +1323,15 @@ void CV_FeatureSelBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& l void CV_FeatureSelBaseTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = cvtest::randInt(rng) % 2, asz; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2); + int asz; depth = depth == 0 ? CV_8U : CV_32F; - types[INPUT][0] = depth; + types[INPUT][0] = CV_MAKETYPE(depth, 1); types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_32FC1; aperture_size = (cvtest::randInt(rng) % (max_aperture_size+2) - 1) | 1; @@ -1364,16 +1365,16 @@ test_cornerEigenValsVecs( const Mat& src, Mat& eigenv, Mat& ocv_eigenv, ((mode > 0 && src.cols == eigenv.cols) || (mode == 0 && src.cols*6 == eigenv.cols)) ); - int type = src.type(); - int ftype = CV_32FC1; - double kernel_scale = type != ftype ? 1./255 : 1; + ElemDepth depth = src.depth(); + ElemDepth fdepth = CV_32F; + double kernel_scale = depth != fdepth ? 1. / 255 : 1; - Mat dx2, dy2, dxdy(src.size(), CV_32F), kernel; + Mat dx2, dy2, dxdy(src.size(), CV_32FC1), kernel; kernel = cvtest::calcSobelKernel2D( 1, 0, _aperture_size ); - cvtest::filter2D( src, dx2, ftype, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE ); + cvtest::filter2D(src, dx2, fdepth, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); kernel = cvtest::calcSobelKernel2D( 0, 1, _aperture_size ); - cvtest::filter2D( src, dy2, ftype, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE ); + cvtest::filter2D(src, dy2, fdepth, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); double denom = (1 << (aperture_size-1))*block_size; denom = denom * denom; @@ -1396,12 +1397,12 @@ test_cornerEigenValsVecs( const Mat& src, Mat& eigenv, Mat& ocv_eigenv, } } - kernel = Mat::ones(block_size, block_size, CV_32F); + kernel = Mat::ones(block_size, block_size, CV_32FC1); anchor = Point(block_size/2, block_size/2); - cvtest::filter2D( dx2, dx2, ftype, kernel, anchor, 0, BORDER_REPLICATE ); - cvtest::filter2D( dy2, dy2, ftype, kernel, anchor, 0, BORDER_REPLICATE ); - cvtest::filter2D( dxdy, dxdy, ftype, kernel, anchor, 0, BORDER_REPLICATE ); + cvtest::filter2D(dx2, dx2, fdepth, kernel, anchor, 0, BORDER_REPLICATE); + cvtest::filter2D(dy2, dy2, fdepth, kernel, anchor, 0, BORDER_REPLICATE); + cvtest::filter2D(dxdy, dxdy, fdepth, kernel, anchor, 0, BORDER_REPLICATE); if( mode == 0 ) { @@ -1481,8 +1482,8 @@ class CV_MinEigenValTest : public CV_FeatureSelBaseTest CV_MinEigenValTest(); protected: - void run_func(); - void prepare_to_validation( int ); + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -1512,8 +1513,8 @@ class CV_EigenValVecTest : public CV_FeatureSelBaseTest CV_EigenValVecTest(); protected: - void run_func(); - void prepare_to_validation( int ); + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -1543,9 +1544,9 @@ class CV_PreCornerDetectTest : public CV_FeatureSelBaseTest CV_PreCornerDetectTest(); protected: - void run_func(); - void prepare_to_validation( int ); - int prepare_test_case( int ); + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; + int prepare_test_case( int ) CV_OVERRIDE; }; @@ -1576,23 +1577,23 @@ void CV_PreCornerDetectTest::prepare_to_validation( int /*test_case_idx*/ ) const Mat& src = test_mat[INPUT][0]; Mat& dst = test_mat[REF_OUTPUT][0]; - int type = src.type(), ftype = CV_32FC1; + ElemDepth depth = src.depth(), fdepth = CV_32F; Point anchor(aperture_size/2, aperture_size/2); - double kernel_scale = type != ftype ? 1./255 : 1.; + double kernel_scale = depth != fdepth ? 1. / 255 : 1.; Mat dx, dy, d2x, d2y, dxy, kernel; kernel = cvtest::calcSobelKernel2D(1, 0, aperture_size); - cvtest::filter2D(src, dx, ftype, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); + cvtest::filter2D(src, dx, fdepth, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); kernel = cvtest::calcSobelKernel2D(2, 0, aperture_size); - cvtest::filter2D(src, d2x, ftype, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); + cvtest::filter2D(src, d2x, fdepth, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); kernel = cvtest::calcSobelKernel2D(0, 1, aperture_size); - cvtest::filter2D(src, dy, ftype, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); + cvtest::filter2D(src, dy, fdepth, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); kernel = cvtest::calcSobelKernel2D(0, 2, aperture_size); - cvtest::filter2D(src, d2y, ftype, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); + cvtest::filter2D(src, d2y, fdepth, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); kernel = cvtest::calcSobelKernel2D(1, 1, aperture_size); - cvtest::filter2D(src, dxy, ftype, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); + cvtest::filter2D(src, dxy, fdepth, kernel*kernel_scale, anchor, 0, BORDER_REPLICATE); double denom = 1 << (aperture_size-1); denom = denom * denom * denom; @@ -1626,13 +1627,13 @@ class CV_IntegralTest : public cvtest::ArrayTest CV_IntegralTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; - int prepare_test_case( int test_case_idx ); + int prepare_test_case(int test_case_idx) CV_OVERRIDE; }; @@ -1649,10 +1650,9 @@ CV_IntegralTest::CV_IntegralTest() } -void CV_IntegralTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_IntegralTest::get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); - int depth = CV_MAT_DEPTH(type); + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); if( depth == CV_32F ) { low = Scalar::all(-10.); @@ -1662,10 +1662,10 @@ void CV_IntegralTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Sc void CV_IntegralTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % 2, sum_depth; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2), sum_depth; int cn = cvtest::randInt(rng) % 3 + 1; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); Size sum_size; @@ -1698,7 +1698,7 @@ void CV_IntegralTest::get_test_array_types_and_sizes( int test_case_idx, double CV_IntegralTest::get_success_error_level( int, int i, int j ) { - int depth = test_mat[i][j].depth(); + ElemDepth depth = test_mat[i][j].depth(); return depth == CV_32S ? 0 : depth == CV_64F ? FLT_EPSILON : 5e-3; } @@ -1722,11 +1722,11 @@ static void test_integral( const Mat& img, Mat* sum, Mat* sqsum, Mat* tilted ) { CV_Assert( img.depth() == CV_32F ); - sum->create(img.rows+1, img.cols+1, CV_64F); + sum->create(img.rows+1, img.cols+1, CV_64FC1); if( sqsum ) - sqsum->create(img.rows+1, img.cols+1, CV_64F); + sqsum->create(img.rows+1, img.cols+1, CV_64FC1); if( tilted ) - tilted->create(img.rows+1, img.cols+1, CV_64F); + tilted->create(img.rows+1, img.cols+1, CV_64FC1); const float* data = img.ptr(); double* sdata = sum->ptr(); @@ -1856,7 +1856,7 @@ class CV_FilterSupportedFormatsTest : public cvtest::BaseTest protected: void run(int) { - const int depths[][2] = + const ElemDepth depths[][2] = { {CV_8U, CV_8U}, {CV_8U, CV_16U}, @@ -1871,7 +1871,7 @@ class CV_FilterSupportedFormatsTest : public cvtest::BaseTest {CV_16S, CV_64F}, {CV_32F, CV_32F}, {CV_64F, CV_64F}, - {-1, -1} + {CV_DEPTH_AUTO, CV_DEPTH_AUTO} }; int i = 0; @@ -1881,9 +1881,9 @@ class CV_FilterSupportedFormatsTest : public cvtest::BaseTest // 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); + Mat small_kernel(5, 5, CV_32FC1), big_kernel(21, 21, CV_32FC1); + Mat kernelX(11, 1, CV_32FC1), kernelY(7, 1, CV_32FC1); + Mat symkernelX(11, 1, CV_32FC1), symkernelY(7, 1, CV_32FC1); randu(small_kernel, -10, 10); randu(big_kernel, -1, 1); randu(kernelX, -1, 1); @@ -1896,10 +1896,10 @@ class CV_FilterSupportedFormatsTest : public cvtest::BaseTest 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++ ) + for (i = 0; depths[i][0] >= CV_8U; i++) { - int sdepth = depths[i][0]; - int ddepth = depths[i][1]; + ElemDepth sdepth = depths[i][0]; + ElemDepth ddepth = depths[i][1]; Mat src(sz, CV_MAKETYPE(sdepth, 5)), dst; randu(src, 0, 100); // non-separable filtering with a small kernel @@ -2098,7 +2098,7 @@ TEST(Imgproc_MorphEx, hitmiss_regression_8957) Mat dst; cv::morphologyEx(src, dst, MORPH_HITMISS, kernel); - Mat ref = Mat::zeros(3, 3, CV_8U); + Mat ref = Mat::zeros(3, 3, CV_8UC1); ref.at(1, 1) = 255; ASSERT_DOUBLE_EQ(cvtest::norm(dst, ref, NORM_INF), 0.); @@ -2157,7 +2157,7 @@ TEST(Imgproc_Filter2D, dftFilter2d_regression_10683) Mat dst = Mat::zeros(src.size(), src.type()); int sz = 12, size2 = sz * sz; - Mat kernel = Mat::ones(sz, sz, CV_32F) / size2; + Mat kernel = Mat::ones(sz, sz, CV_32FC1) / size2; uchar expected_[24*24] = { 83, 83, 77, 80, 76, 76, 76, 75, 71, 67, 72, 71, 73, 70, 80, 83, 86, 84, 89, 88, 88, 96, 99, 98, @@ -2194,7 +2194,7 @@ TEST(Imgproc_Filter2D, dftFilter2d_regression_10683) cv::Rect region(c * 3, r * 3, 3, 3); Mat roi_i(src, region); Mat roi_o(dst, region); - cv::filter2D(roi_i, roi_o, -1, kernel); + cv::filter2D(roi_i, roi_o, CV_DEPTH_AUTO, kernel); } } diff --git a/modules/imgproc/test/test_floodfill.cpp b/modules/imgproc/test/test_floodfill.cpp index b880c4ee3746..658a873da362 100644 --- a/modules/imgproc/test/test_floodfill.cpp +++ b/modules/imgproc/test/test_floodfill.cpp @@ -49,15 +49,15 @@ class CV_FloodFillTest : public cvtest::ArrayTest CV_FloodFillTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; - void fill_array( int test_case_idx, int i, int j, Mat& arr ); + void fill_array( int test_case_idx, int i, int j, Mat& arr ) CV_OVERRIDE; /*int write_default_params(CvFileStorage* fs); - void get_timing_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types + void get_timing_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types CvSize** whole_sizes, bool *are_images ); void print_timing_params( int test_case_idx, char* ptr, int params_left );*/ Point seed_pt; @@ -88,15 +88,16 @@ CV_FloodFillTest::CV_FloodFillTest() void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, - vector >& types ) + vector >& types ) { RNG& rng = ts->get_rng(); - int depth, cn; + ElemDepth depth; + int cn; int i; double buff[8]; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - depth = cvtest::randInt(rng) % 3; + depth = static_cast(cvtest::randInt(rng) % 3); depth = depth == 0 ? CV_8U : depth == 1 ? CV_32S : CV_32F; cn = cvtest::randInt(rng) & 1 ? 3 : 1; @@ -126,7 +127,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx, l_diff = u_diff = Scalar::all(0.); else { - Mat m( 1, 8, CV_16S, buff ); + Mat m( 1, 8, CV_16SC1, buff ); rng.fill( m, RNG::NORMAL, Scalar::all(0), Scalar::all(32) ); for( i = 0; i < 4; i++ ) { @@ -165,7 +166,7 @@ void CV_FloodFillTest::fill_array( int test_case_idx, int i, int j, Mat& arr ) Scalar m = Scalar::all(128); Scalar s = Scalar::all(10); - if( arr.depth() == CV_32FC1 ) + if( arr.depth() == CV_32F ) tmp.create(arr.size(), CV_MAKETYPE(CV_8U, arr.channels())); if( range_type == 0 ) @@ -173,7 +174,7 @@ void CV_FloodFillTest::fill_array( int test_case_idx, int i, int j, Mat& arr ) rng.fill(tmp, RNG::NORMAL, m, s ); if( arr.data != tmp.data ) - cvtest::convert(tmp, arr, arr.type()); + cvtest::convert(tmp, arr, arr.depth()); } else { @@ -258,13 +259,13 @@ cvTsFloodFill( CvMat* _img, CvPoint seed_pt, CvScalar new_val, if( CV_MAT_DEPTH(_img->type) == CV_8U || CV_MAT_DEPTH(_img->type) == CV_32S ) { tmp = cvCreateMat( rows, cols, CV_MAKETYPE(CV_32F,CV_MAT_CN(_img->type)) ); - cvtest::convert(cvarrToMat(_img), cvarrToMat(tmp), -1); + cvtest::convert(cvarrToMat(_img), cvarrToMat(tmp), CV_DEPTH_AUTO); } mask = cvCreateMat( rows + 2, cols + 2, CV_16UC1 ); if( _mask ) - cvtest::convert(cvarrToMat(_mask), cvarrToMat(mask), -1); + cvtest::convert(cvarrToMat(_mask), cvarrToMat(mask), CV_DEPTH_AUTO); else { Mat m_mask = cvarrToMat(mask); @@ -481,7 +482,7 @@ cvTsFloodFill( CvMat* _img, CvPoint seed_pt, CvScalar new_val, if( tmp != _img ) { if( !mask_only ) - cvtest::convert(cvarrToMat(tmp), cvarrToMat(_img), -1); + cvtest::convert(cvarrToMat(tmp), cvarrToMat(_img), CV_DEPTH_AUTO); cvReleaseMat( &tmp ); } @@ -530,8 +531,8 @@ TEST(Imgproc_FloodFill, accuracy) { CV_FloodFillTest test; test.safe_run(); } TEST(Imgproc_FloodFill, maskValue) { const int n = 50; - Mat img = Mat::zeros(n, n, CV_8U); - Mat mask = Mat::zeros(n + 2, n + 2, CV_8U); + Mat img = Mat::zeros(n, n, CV_8UC1); + Mat mask = Mat::zeros(n + 2, n + 2, CV_8UC1); circle(img, Point(n/2, n/2), 20, Scalar(100), 4); diff --git a/modules/imgproc/test/test_goodfeaturetotrack.cpp b/modules/imgproc/test/test_goodfeaturetotrack.cpp index 1a339bea55eb..47f3882138fc 100644 --- a/modules/imgproc/test/test_goodfeaturetotrack.cpp +++ b/modules/imgproc/test/test_goodfeaturetotrack.cpp @@ -76,23 +76,23 @@ test_cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size, CV_Assert( ( src.rows == eigenv.rows ) && (((mode == MINEIGENVAL)||(mode == HARRIS)) && (src.cols == eigenv.cols)) ); - int type = src.type(); - int ftype = CV_32FC1; + ElemDepth depth = src.depth(); + ElemDepth fdepth = CV_32F; double kernel_scale = 1; - Mat dx2, dy2, dxdy(src.size(), CV_32F), kernel; + Mat dx2, dy2, dxdy(src.size(), CV_32FC1), kernel; kernel = cvtest::calcSobelKernel2D( 1, 0, _aperture_size ); - cvtest::filter2D( src, dx2, ftype, kernel*kernel_scale, anchor, 0, borderType, borderValue ); + cvtest::filter2D(src, dx2, fdepth, kernel*kernel_scale, anchor, 0, borderType, borderValue); kernel = cvtest::calcSobelKernel2D( 0, 1, _aperture_size ); - cvtest::filter2D( src, dy2, ftype, kernel*kernel_scale, anchor, 0, borderType,borderValue ); + cvtest::filter2D(src, dy2, fdepth, kernel*kernel_scale, anchor, 0, borderType, borderValue); double denom = (1 << (aperture_size-1))*block_size; denom = denom * denom; if( _aperture_size < 0 ) denom *= 4; - if(type != ftype ) + if (depth != fdepth) denom *= 255.; denom = 1./denom; @@ -112,12 +112,12 @@ test_cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size, } } - kernel = Mat::ones(block_size, block_size, CV_32F); + kernel = Mat::ones(block_size, block_size, CV_32FC1); anchor = Point(block_size/2, block_size/2); - cvtest::filter2D( dx2, dx2, ftype, kernel, anchor, 0, borderType, borderValue ); - cvtest::filter2D( dy2, dy2, ftype, kernel, anchor, 0, borderType, borderValue ); - cvtest::filter2D( dxdy, dxdy, ftype, kernel, anchor, 0, borderType, borderValue ); + cvtest::filter2D(dx2, dx2, fdepth, kernel, anchor, 0, borderType, borderValue); + cvtest::filter2D(dy2, dy2, fdepth, kernel, anchor, 0, borderType, borderValue); + cvtest::filter2D(dxdy, dxdy, fdepth, kernel, anchor, 0, borderType, borderValue); if( mode == MINEIGENVAL ) { @@ -173,7 +173,7 @@ test_goodFeaturesToTrack( InputArray _image, OutputArray _corners, Mat eig, tmp, tt; - eig.create( image.size(), CV_32F ); + eig.create( image.size(), CV_32FC1 ); if( useHarrisDetector ) test_cornerEigenValsVecs( image, eig, blockSize, aperture_size, harrisK, HARRIS, borderType, 0 ); @@ -300,7 +300,7 @@ test_goodFeaturesToTrack( InputArray _image, OutputArray _corners, } } - Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F); + Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.depth() : CV_32F); } @@ -371,7 +371,7 @@ void CV_GoodFeatureToTTest::run_func() int cn = src_gray.channels(); CV_Assert( cn == 1 ); - CV_Assert( ( CV_MAT_DEPTH(SrcType) == CV_32FC1 ) || ( CV_MAT_DEPTH(SrcType) == CV_8UC1 )); + CV_Assert( ( CV_MAT_DEPTH(SrcType) == CV_32F ) || ( CV_MAT_DEPTH(SrcType) == CV_8U )); TEST_MESSAGEL (" maxCorners = ", maxCorners) if (useHarrisDetector) @@ -383,9 +383,9 @@ void CV_GoodFeatureToTTest::run_func() TEST_MESSAGE (" useHarrisDetector = false\n"); } - if( CV_MAT_DEPTH(SrcType) == CV_32FC1) + if( CV_MAT_DEPTH(SrcType) == CV_32F) { - if (src_gray.depth() != CV_32FC1 ) src_gray.convertTo(src_gray32f, CV_32FC1); + if (src_gray.depth() != CV_32F ) src_gray.convertTo(src_gray32f, CV_32F); else src_gray32f = src_gray.clone(); TEST_MESSAGE ("goodFeaturesToTrack 32f\n") @@ -403,7 +403,7 @@ void CV_GoodFeatureToTTest::run_func() } else { - if (src_gray.depth() != CV_8UC1 ) src_gray.convertTo(src_gray8U, CV_8UC1); + if (src_gray.depth() != CV_8U ) src_gray.convertTo(src_gray8U, CV_8U); else src_gray8U = src_gray.clone(); TEST_MESSAGE ("goodFeaturesToTrack 8U\n") @@ -426,9 +426,9 @@ int CV_GoodFeatureToTTest::validate_test_results( int test_case_idx ) { static const double eps = 2e-6; - if( CV_MAT_DEPTH(SrcType) == CV_32FC1 ) + if( CV_MAT_DEPTH(SrcType) == CV_32F ) { - if (src_gray.depth() != CV_32FC1 ) src_gray.convertTo(src_gray32f, CV_32FC1); + if (src_gray.depth() != CV_32F ) src_gray.convertTo(src_gray32f, CV_32F); else src_gray32f = src_gray.clone(); TEST_MESSAGE ("test_goodFeaturesToTrack 32f\n") @@ -446,7 +446,7 @@ int CV_GoodFeatureToTTest::validate_test_results( int test_case_idx ) } else { - if (src_gray.depth() != CV_8UC1 ) src_gray.convertTo(src_gray8U, CV_8UC1); + if (src_gray.depth() != CV_8U ) src_gray.convertTo(src_gray8U, CV_8U); else src_gray8U = src_gray.clone(); TEST_MESSAGE ("test_goodFeaturesToTrack 8U\n") diff --git a/modules/imgproc/test/test_histograms.cpp b/modules/imgproc/test/test_histograms.cpp index 4214892739dc..6ce3b7dbb3a4 100644 --- a/modules/imgproc/test/test_histograms.cpp +++ b/modules/imgproc/test/test_histograms.cpp @@ -74,7 +74,7 @@ class CV_BaseHistTest : public cvtest::BaseTest double gen_hist_max_val, gen_hist_sparse_nz_ratio; int init_ranges; - int img_type; + ElemDepth img_depth; int img_max_log_size; double low, high, range_delta; Size img_size; @@ -155,14 +155,14 @@ void CV_BaseHistTest::get_hist_params( int /*test_case_idx*/ ) total_size *= dims[i]; } - img_type = cvtest::randInt(rng) % 2 ? CV_32F : CV_8U; + img_depth = cvtest::randInt(rng) % 2 ? CV_32F : CV_8U; img_size.width = cvRound( exp(cvtest::randReal(rng) * img_max_log_size * CV_LOG2) ); img_size.height = cvRound( exp(cvtest::randReal(rng) * img_max_log_size * CV_LOG2) ); - if( img_type < CV_32F ) + if (img_depth < CV_32F) { - low = cvtest::getMinVal(img_type); - high = cvtest::getMaxVal(img_type); + low = cvtest::getMinVal(img_depth); + high = cvtest::getMaxVal(img_depth); } else { @@ -368,14 +368,14 @@ int CV_QueryHistTest::prepare_test_case( int test_case_idx ) iters = (cvtest::randInt(rng) % MAX(total_size/10,100)) + 1; iters = MIN( iters, total_size*9/10 + 1 ); - indices = Mat(1, iters*cdims, CV_32S); - values = Mat(1, iters, CV_32F ); - values0 = Mat( 1, iters, CV_32F ); + indices = Mat(1, iters*cdims, CV_32SC1); + values = Mat(1, iters, CV_32FC1); + values0 = Mat( 1, iters, CV_32FC1); idx = indices.ptr(); //printf( "total_size = %d, cdims = %d, iters = %d\n", total_size, cdims, iters ); - Mat bit_mask(1, (total_size + 7)/8, CV_8U, Scalar(0)); + Mat bit_mask(1, (total_size + 7)/8, CV_8UC1, Scalar(0)); #define GET_BIT(n) (bit_mask.data[(n)/8] & (1 << ((n)&7))) #define SET_BIT(n) bit_mask.data[(n)/8] |= (1 << ((n)&7)) @@ -826,7 +826,7 @@ int CV_ThreshHistTest::prepare_test_case( int test_case_idx ) { orig_nz_count = total_size; - values = Mat( 1, total_size, CV_32F ); + values = Mat( 1, total_size, CV_32FC1); indices = Mat(); memcpy( values.ptr(), cvPtr1D( hist[0]->bins, 0 ), total_size*sizeof(float) ); } @@ -839,8 +839,8 @@ int CV_ThreshHistTest::prepare_test_case( int test_case_idx ) orig_nz_count = sparse->heap->active_count; - values = Mat( 1, orig_nz_count+1, CV_32F ); - indices = Mat( 1, (orig_nz_count+1)*cdims, CV_32S ); + values = Mat( 1, orig_nz_count+1, CV_32FC1); + indices = Mat( 1, (orig_nz_count+1)*cdims, CV_32SC1 ); for( node = cvInitSparseMatIterator( sparse, &iterator ), i = 0; node != 0; node = cvGetNextSparseNode( &iterator ), i++ ) @@ -1153,7 +1153,7 @@ int CV_CalcHistTest::prepare_test_case( int test_case_idx ) if( i < cdims ) { int nch = 1; //cvtest::randInt(rng) % 3 + 1; - images[i] = Mat(img_size, CV_MAKETYPE(img_type, nch)); + images[i] = Mat(img_size, CV_MAKETYPE(img_depth, nch)); channels[i] = cvtest::randInt(rng) % nch; cvtest::randUni( rng, images[i], Scalar::all(low), Scalar::all(high) ); } @@ -1162,7 +1162,7 @@ int CV_CalcHistTest::prepare_test_case( int test_case_idx ) if( cvtest::randInt(rng) % 2 ) { // create mask - images[i] = Mat(img_size, CV_8U); + images[i] = Mat(img_size, CV_8UC1); // make ~25% pixels in the mask non-zero cvtest::randUni( rng, images[i], Scalar::all(-2), Scalar::all(2) ); @@ -1414,7 +1414,7 @@ int CV_CalcBackProjectTest::prepare_test_case( int test_case_idx ) if( i < cdims ) { int nch = 1; //cvtest::randInt(rng) % 3 + 1; - images[i] = Mat(img_size, CV_MAKETYPE(img_type, nch)); + images[i] = Mat(img_size, CV_MAKETYPE(img_depth, nch)); channels[i] = cvtest::randInt(rng) % nch; cvtest::randUni( rng, images[i], Scalar::all(low), Scalar::all(high) ); @@ -1424,7 +1424,7 @@ int CV_CalcBackProjectTest::prepare_test_case( int test_case_idx ) if(cvtest::randInt(rng) % 2 ) { // create mask - images[i] = Mat(img_size, CV_8U); + images[i] = Mat(img_size, CV_8UC1); // make ~25% pixels in the mask non-zero cvtest::randUni( rng, images[i], Scalar::all(-2), Scalar::all(2) ); } @@ -1451,7 +1451,7 @@ int CV_CalcBackProjectTest::prepare_test_case( int test_case_idx ) int idx = cvtest::randInt(rng) % img_len; double val = cvtest::randReal(rng)*(high - low) + low; - if( img_type == CV_8U ) + if (img_depth == CV_8U) ((uchar*)data)[idx] = (uchar)cvRound(val); else ((float*)data)[idx] = (float)val; @@ -1692,13 +1692,13 @@ int CV_CalcBackProjectPatchTest::prepare_test_case( int test_case_idx ) if( i < cdims ) { int nch = 1; //cvtest::randInt(rng) % 3 + 1; - images[i] = Mat(img_size, CV_MAKETYPE(img_type, nch)); + images[i] = Mat(img_size, CV_MAKETYPE(img_depth, nch)); channels[i] = cvtest::randInt(rng) % nch; cvtest::randUni( rng, images[i], Scalar::all(low), Scalar::all(high) ); } else if( i >= CV_MAX_DIM ) { - images[i] = Mat(img_size - patch_size + Size(1, 1), CV_32F); + images[i] = Mat(img_size - patch_size + Size(1, 1), CV_32FC1); } } @@ -1715,7 +1715,7 @@ int CV_CalcBackProjectPatchTest::prepare_test_case( int test_case_idx ) int idx = cvtest::randInt(rng) % img_len; double val = cvtest::randReal(rng)*(high - low) + low; - if( img_type == CV_8U ) + if (img_depth == CV_8U) ((uchar*)data)[idx] = (uchar)cvRound(val); else ((float*)data)[idx] = (float)val; diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 400426af15a6..e3b1e5e8d267 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -49,11 +49,11 @@ class CV_ImgWarpBaseTest : public cvtest::ArrayTest CV_ImgWarpBaseTest( bool warp_matrix ); protected: - int read_params( CvFileStorage* fs ); - int prepare_test_case( int test_case_idx ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); + int read_params(CvFileStorage* fs) CV_OVERRIDE; + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; + void fill_array(int test_case_idx, int i, int j, Mat& arr) CV_OVERRIDE; int interpolation; int max_interpolation; @@ -83,10 +83,10 @@ int CV_ImgWarpBaseTest::read_params( CvFileStorage* fs ) } -void CV_ImgWarpBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_ImgWarpBaseTest::get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); - if( CV_MAT_DEPTH(type) == CV_32F ) + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); + if( depth == CV_32F ) { low = Scalar::all(-10.); high = Scalar::all(10); @@ -95,10 +95,10 @@ void CV_ImgWarpBaseTest::get_minmax_bounds( int i, int j, int type, Scalar& low, void CV_ImgWarpBaseTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % 3; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 3); int cn = cvtest::randInt(rng) % 3 + 1; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : CV_32F; @@ -123,7 +123,9 @@ int CV_ImgWarpBaseTest::prepare_test_case( int test_case_idx ) int code = cvtest::ArrayTest::prepare_test_case( test_case_idx ); Mat& img = test_mat[INPUT][0]; int i, j, cols = img.cols; - int type = img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = img.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); double scale = depth == CV_16U ? 1000. : 255.*0.5; double space_scale = spatial_scale_decimate; vector buffer(img.cols*cn); @@ -189,9 +191,9 @@ int CV_ImgWarpBaseTest::prepare_test_case( int test_case_idx ) default: assert(0); }*/ - cv::Mat src(1, cols*cn, CV_32F, &buffer[0]); - cv::Mat dst(1, cols*cn, depth, ptr); - src.convertTo(dst, dst.type()); + cv::Mat src(1, cols*cn, CV_32FC1, &buffer[0]); + cv::Mat dst(1, cols*cn, CV_MAKETYPE(depth, 1), ptr); + src.convertTo(dst, dst.depth()); } return code; @@ -206,10 +208,10 @@ class CV_ResizeTest : public CV_ImgWarpBaseTest CV_ResizeTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; }; @@ -218,7 +220,7 @@ CV_ResizeTest::CV_ResizeTest() : CV_ImgWarpBaseTest( false ) } -void CV_ResizeTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_ResizeTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); @@ -265,7 +267,7 @@ void CV_ResizeTest::run_func() double CV_ResizeTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth == CV_8U ? 16 : depth == CV_16U ? 1024 : 1e-1; } @@ -340,7 +342,7 @@ class CV_ResizeExactTest : public CV_ResizeTest CV_ResizeExactTest(); protected: - void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; }; @@ -350,7 +352,7 @@ CV_ResizeExactTest::CV_ResizeExactTest() : CV_ResizeTest() } -void CV_ResizeExactTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) +void CV_ResizeExactTest::get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) { CV_ResizeTest::get_test_array_types_and_sizes(test_case_idx, sizes, types); interpolation = INTER_LINEAR_EXACT; @@ -368,7 +370,8 @@ static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& ma int drows = dst.rows, dcols = dst.cols; int srows = src.rows, scols = src.cols; const uchar* sptr0 = src.ptr(); - int depth = src.depth(), cn = src.channels(); + ElemDepth depth = src.depth(); + int cn = src.channels(); int elem_size = (int)src.elemSize(); int step = (int)(src.step / CV_ELEM_SIZE(depth)); int delta; @@ -486,11 +489,11 @@ class CV_WarpAffineTest : public CV_ImgWarpBaseTest CV_WarpAffineTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; }; @@ -501,7 +504,7 @@ CV_WarpAffineTest::CV_WarpAffineTest() : CV_ImgWarpBaseTest( true ) } -void CV_WarpAffineTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_WarpAffineTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); Size sz = sizes[INPUT][0]; @@ -521,7 +524,7 @@ void CV_WarpAffineTest::run_func() double CV_WarpAffineTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth == CV_8U ? 16 : depth == CV_16U ? 1024 : 5e-2; } @@ -561,7 +564,7 @@ void CV_WarpAffineTest::prepare_to_validation( int /*test_case_idx*/ ) const Mat& src = test_mat[INPUT][0]; Mat& dst = test_mat[REF_INPUT_OUTPUT][0]; Mat& dst0 = test_mat[INPUT_OUTPUT][0]; - Mat mapx(dst.size(), CV_32F), mapy(dst.size(), CV_32F); + Mat mapx(dst.size(), CV_32FC1), mapy(dst.size(), CV_32FC1); double m[6]; Mat srcAb, dstAb( 2, 3, CV_64FC1, m ); @@ -582,7 +585,7 @@ void CV_WarpAffineTest::prepare_to_validation( int /*test_case_idx*/ ) mapy.at(y, x) = (float)(x*m[3] + y*m[4] + m[5]); } - Mat mask( dst.size(), CV_8U ); + Mat mask( dst.size(), CV_8UC1 ); test_remap( src, dst, mapx, mapy, &mask ); dst.setTo(Scalar::all(0), mask); dst0.setTo(Scalar::all(0), mask); @@ -597,11 +600,11 @@ class CV_WarpPerspectiveTest : public CV_ImgWarpBaseTest CV_WarpPerspectiveTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; }; @@ -612,7 +615,7 @@ CV_WarpPerspectiveTest::CV_WarpPerspectiveTest() : CV_ImgWarpBaseTest( true ) } -void CV_WarpPerspectiveTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_WarpPerspectiveTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); Size sz = sizes[INPUT][0]; @@ -632,7 +635,7 @@ void CV_WarpPerspectiveTest::run_func() double CV_WarpPerspectiveTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth == CV_8U ? 16 : depth == CV_16U ? 1024 : 5e-2; } @@ -682,9 +685,9 @@ void CV_WarpPerspectiveTest::prepare_to_validation( int /*test_case_idx*/ ) Mat& src = test_mat[INPUT][0]; Mat& dst = test_mat[REF_INPUT_OUTPUT][0]; Mat& dst0 = test_mat[INPUT_OUTPUT][0]; - Mat mapx(dst.size(), CV_32F), mapy(dst.size(), CV_32F); + Mat mapx(dst.size(), CV_32FC1), mapy(dst.size(), CV_32FC1); double m[9]; - Mat srcM, dstM(3, 3, CV_64F, m); + Mat srcM, dstM(3, 3, CV_64FC1, m); //cvInvert( &tM, &M, CV_LU ); // [R|t] -> [R^-1 | -(R^-1)*t] @@ -708,7 +711,7 @@ void CV_WarpPerspectiveTest::prepare_to_validation( int /*test_case_idx*/ ) } } - Mat mask( dst.size(), CV_8U ); + Mat mask( dst.size(), CV_8UC1 ); test_remap( src, dst, mapx, mapy, &mask ); dst.setTo(Scalar::all(0), mask); dst0.setTo(Scalar::all(0), mask); @@ -723,12 +726,12 @@ class CV_RemapTest : public CV_ImgWarpBaseTest CV_RemapTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void fill_array( int test_case_idx, int i, int j, Mat& arr ) CV_OVERRIDE; }; @@ -742,7 +745,7 @@ CV_RemapTest::CV_RemapTest() : CV_ImgWarpBaseTest( false ) } -void CV_RemapTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_RemapTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); types[INPUT][1] = types[INPUT][2] = CV_32FC1; @@ -766,7 +769,7 @@ void CV_RemapTest::run_func() double CV_RemapTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth == CV_8U ? 16 : depth == CV_16U ? 1024 : 5e-2; } @@ -777,8 +780,8 @@ int CV_RemapTest::prepare_test_case( int test_case_idx ) int code = CV_ImgWarpBaseTest::prepare_test_case( test_case_idx ); const Mat& src = test_mat[INPUT][0]; double a[9] = {0,0,0,0,0,0,0,0,1}, k[4]; - Mat _a( 3, 3, CV_64F, a ); - Mat _k( 4, 1, CV_64F, k ); + Mat _a( 3, 3, CV_64FC1, a ); + Mat _k( 4, 1, CV_64FC1, k ); double sz = MAX(src.rows, src.cols); if( code <= 0 ) @@ -805,7 +808,7 @@ void CV_RemapTest::prepare_to_validation( int /*test_case_idx*/ ) { Mat& dst = test_mat[REF_INPUT_OUTPUT][0]; Mat& dst0 = test_mat[INPUT_OUTPUT][0]; - Mat mask( dst.size(), CV_8U ); + Mat mask( dst.size(), CV_8UC1 ); test_remap(test_mat[INPUT][0], dst, test_mat[INPUT][1], test_mat[INPUT][2], &mask, interpolation ); dst.setTo(Scalar::all(0), mask); @@ -821,12 +824,12 @@ class CV_UndistortTest : public CV_ImgWarpBaseTest CV_UndistortTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void fill_array( int test_case_idx, int i, int j, Mat& arr ) CV_OVERRIDE; private: bool useCPlus; @@ -852,15 +855,15 @@ CV_UndistortTest::CV_UndistortTest() : CV_ImgWarpBaseTest( false ) } -void CV_UndistortTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_UndistortTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int type = types[INPUT][0]; + ElemType type = types[INPUT][0]; type = CV_MAKETYPE( CV_8U, CV_MAT_CN(type) ); types[INPUT][0] = types[INPUT_OUTPUT][0] = types[REF_INPUT_OUTPUT][0] = type; - types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; - types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; + types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64FC1 : CV_32FC1; + types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64FC1 : CV_32FC1; sizes[INPUT][1] = cvSize(3,3); sizes[INPUT][2] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4); types[INPUT][3] = types[INPUT][1]; @@ -899,7 +902,7 @@ void CV_UndistortTest::run_func() double CV_UndistortTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth == CV_8U ? 16 : depth == CV_16U ? 1024 : 5e-2; } @@ -915,9 +918,9 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx ) double sz = MAX(src.rows, src.cols); Mat& _new_cam0 = test_mat[INPUT][3]; - Mat _new_cam(test_mat[INPUT][3].rows,test_mat[INPUT][3].cols,CV_64F,new_cam); + Mat _new_cam(test_mat[INPUT][3].rows,test_mat[INPUT][3].cols,CV_64FC1,new_cam); Mat& _a0 = test_mat[INPUT][1]; - Mat _a(3,3,CV_64F,a); + Mat _a(3,3,CV_64FC1,a); Mat& _k0 = test_mat[INPUT][2]; Mat _k(_k0.rows,_k0.cols, CV_MAKETYPE(CV_64F,_k0.channels()),k); @@ -973,14 +976,14 @@ void CV_UndistortTest::prepare_to_validation( int /*test_case_idx*/ ) if (useCPlus) { Mat& output = test_mat[INPUT_OUTPUT][0]; - input_output.convertTo(output, output.type()); + input_output.convertTo(output, output.depth()); } Mat& src = test_mat[INPUT][0]; Mat& dst = test_mat[REF_INPUT_OUTPUT][0]; Mat& dst0 = test_mat[INPUT_OUTPUT][0]; Mat mapx, mapy; cvtest::initUndistortMap( test_mat[INPUT][1], test_mat[INPUT][2], dst.size(), mapx, mapy ); - Mat mask( dst.size(), CV_8U ); + Mat mask( dst.size(), CV_8UC1 ); test_remap( src, dst, mapx, mapy, &mask, interpolation ); dst.setTo(Scalar::all(0), mask); dst0.setTo(Scalar::all(0), mask); @@ -993,12 +996,12 @@ class CV_UndistortMapTest : public cvtest::ArrayTest CV_UndistortMapTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void fill_array( int test_case_idx, int i, int j, Mat& arr ) CV_OVERRIDE; private: bool dualChannel; @@ -1018,17 +1021,17 @@ CV_UndistortMapTest::CV_UndistortMapTest() } -void CV_UndistortMapTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_UndistortMapTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; + ElemDepth depth = cvtest::randInt(rng)%2 ? CV_64F : CV_32F; Size sz = sizes[OUTPUT][0]; - types[INPUT][0] = types[INPUT][1] = depth; + types[INPUT][0] = types[INPUT][1] = CV_MAKETYPE(depth, 1); dualChannel = cvtest::randInt(rng)%2 == 0; types[OUTPUT][0] = types[OUTPUT][1] = - types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = dualChannel ? CV_32FC2 : CV_32F; + types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = dualChannel ? CV_32FC2 : CV_32FC1; sizes[INPUT][0] = cvSize(3,3); sizes[INPUT][1] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4); @@ -1071,7 +1074,7 @@ int CV_UndistortMapTest::prepare_test_case( int test_case_idx ) double k[4], a[9] = {0,0,0,0,0,0,0,0,1}; double sz = MAX(mapx.rows, mapx.cols); Mat& _a0 = test_mat[INPUT][0], &_k0 = test_mat[INPUT][1]; - Mat _a(3,3,CV_64F,a); + Mat _a(3,3,CV_64FC1,a); Mat _k(_k0.rows,_k0.cols, CV_MAKETYPE(CV_64F,_k0.channels()),k); if( code <= 0 ) @@ -1163,12 +1166,12 @@ class CV_GetRectSubPixTest : public CV_ImgWarpBaseTest CV_GetRectSubPixTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); - void fill_array( int test_case_idx, int i, int j, Mat& arr ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void fill_array( int test_case_idx, int i, int j, Mat& arr ) CV_OVERRIDE; CvPoint2D32f center; bool test_cpp; @@ -1183,11 +1186,11 @@ CV_GetRectSubPixTest::CV_GetRectSubPixTest() : CV_ImgWarpBaseTest( false ) } -void CV_GetRectSubPixTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_GetRectSubPixTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int src_depth = cvtest::randInt(rng) % 2, dst_depth; + ElemDepth src_depth = static_cast(cvtest::randInt(rng) % 2), dst_depth; int cn = cvtest::randInt(rng) % 2 ? 3 : 1; Size src_size, dst_size; @@ -1234,8 +1237,8 @@ void CV_GetRectSubPixTest::run_func() double CV_GetRectSubPixTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int in_depth = test_mat[INPUT][0].depth(); - int out_depth = test_mat[INPUT_OUTPUT][0].depth(); + ElemDepth in_depth = test_mat[INPUT][0].depth(); + ElemDepth out_depth = test_mat[INPUT_OUTPUT][0].depth(); return in_depth >= CV_32F ? 1e-3 : out_depth >= CV_32F ? 1e-2 : 1; } @@ -1252,7 +1255,7 @@ void CV_GetRectSubPixTest::prepare_to_validation( int /*test_case_idx*/ ) Mat& src0 = test_mat[INPUT][0]; Mat& dst0 = test_mat[REF_INPUT_OUTPUT][0]; Mat src = src0, dst = dst0; - int ftype = CV_MAKETYPE(CV_32F,src0.channels()); + ElemType ftype = CV_MAKETYPE(CV_32F,src0.channels()); double a[] = { 1, 0, center.x - dst.cols*0.5 + 0.5, 0, 1, center.y - dst.rows*0.5 + 0.5 }; if( src.depth() != CV_32F ) @@ -1274,11 +1277,11 @@ class CV_GetQuadSubPixTest : public CV_ImgWarpBaseTest CV_GetQuadSubPixTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void run_func(); - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + int prepare_test_case( int test_case_idx ) CV_OVERRIDE; + void prepare_to_validation( int /*test_case_idx*/ ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; }; @@ -1289,13 +1292,14 @@ CV_GetQuadSubPixTest::CV_GetQuadSubPixTest() : CV_ImgWarpBaseTest( true ) } -void CV_GetQuadSubPixTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) +void CV_GetQuadSubPixTest::get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) { int min_size = 4; CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); Size sz = sizes[INPUT][0], dsz; RNG& rng = ts->get_rng(); - int msz, src_depth = cvtest::randInt(rng) % 2, dst_depth; + int msz; + ElemDepth src_depth = static_cast(cvtest::randInt(rng) % 2), dst_depth; int cn = cvtest::randInt(rng) % 2 ? 3 : 1; dst_depth = src_depth = src_depth == 0 ? CV_8U : CV_32F; @@ -1330,8 +1334,8 @@ void CV_GetQuadSubPixTest::run_func() double CV_GetQuadSubPixTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int in_depth = test_mat[INPUT][0].depth(); - //int out_depth = test_mat[INPUT_OUTPUT][0].depth(); + ElemDepth in_depth = test_mat[INPUT][0].depth(); + //ElemDepth out_depth = test_mat[INPUT_OUTPUT][0].depth(); return in_depth >= CV_32F ? 1e-2 : 4; } @@ -1376,9 +1380,9 @@ void CV_GetQuadSubPixTest::prepare_to_validation( int /*test_case_idx*/ ) Mat& src0 = test_mat[INPUT][0]; Mat& dst0 = test_mat[REF_INPUT_OUTPUT][0]; Mat src = src0, dst = dst0; - int ftype = CV_MAKETYPE(CV_32F,src0.channels()); + ElemType ftype = CV_MAKETYPE(CV_32F, src0.channels()); double a[6], dx = (dst0.cols - 1)*0.5, dy = (dst0.rows - 1)*0.5; - Mat A( 2, 3, CV_64F, a ); + Mat A( 2, 3, CV_64FC1, a ); if( src.depth() != CV_32F ) src0.convertTo(src, CV_32F); @@ -1446,7 +1450,7 @@ TEST(Imgproc_cvWarpAffine, regression) cvZero(src); float m[6]; - CvMat M = cvMat( 2, 3, CV_32F, m ); + CvMat M = cvMat( 2, 3, CV_32FC1, m ); int w = src->width; int h = src->height; cv2DRotationMatrix(cvPoint2D32f(w*0.5f, h*0.5f), 45.0, 1.0, &M); @@ -1671,19 +1675,21 @@ void resizeArea(const cv::Mat & src, cv::Mat & dst) TEST(Resize, Area_half) { const int size = 1000; - int types[] = { CV_8UC1, CV_8UC4, - CV_16UC1, CV_16UC4, - CV_16SC1, CV_16SC3, CV_16SC4, - CV_32FC1, CV_32FC4 }; + ElemType types[] = { CV_8UC1, CV_8UC4, + CV_16UC1, CV_16UC4, + CV_16SC1, CV_16SC3, CV_16SC4, + CV_32FC1, CV_32FC4 }; cv::RNG rng(17); for (int i = 0, _size = sizeof(types) / sizeof(types[0]); i < _size; ++i) { - int type = types[i], depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = types[i]; + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); const float eps = depth <= CV_32S ? 0 : 7e-5f; - SCOPED_TRACE(depth); + SCOPED_TRACE(static_cast(depth)); SCOPED_TRACE(cn); cv::Mat src(size, size, type), dst_actual(size >> 1, size >> 1, type), @@ -1761,7 +1767,7 @@ TEST(Imgproc_Remap, DISABLED_memleak) { Mat src; const int N = 400; - src.create(N, N, CV_8U); + src.create(N, N, CV_8UC1); randu(src, 0, 256); Mat map_x, map_y, dst; dst.create( src.size(), src.type() ); diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp index 31869f1d752f..a02ed9e426a0 100644 --- a/modules/imgproc/test/test_imgwarp_strict.cpp +++ b/modules/imgproc/test/test_imgwarp_strict.cpp @@ -146,9 +146,9 @@ void CV_ImageWarpBaseTest::generate_test_data() // generating the src matrix structure Size ssize = randSize(rng), dsize; - int depth = rng.uniform(0, CV_64F); + ElemDepth depth = static_cast(rng.uniform(0, CV_64F)); while (depth == CV_8S || depth == CV_32S) - depth = rng.uniform(0, CV_64F); + depth = static_cast(rng.uniform(0, CV_64F)); int cn = rng.uniform(1, 4); while (cn == 2) @@ -425,9 +425,9 @@ void CV_Resize_Test::generate_test_data() // generating the src matrix structure Size ssize = randSize(rng), dsize; - int depth = rng.uniform(0, CV_64F); + ElemDepth depth = static_cast(rng.uniform(0, CV_64F)); while (depth == CV_8S || depth == CV_32S) - depth = rng.uniform(0, CV_64F); + depth = static_cast(rng.uniform(0, CV_64F)); int cn = rng.uniform(1, 4); while (cn == 2) @@ -742,7 +742,7 @@ void CV_Remap_Test::generate_test_data() borderValue = Scalar::all(rng.uniform(0, 255)); // generating the mapx, mapy matrices - static const int mapx_types[] = { CV_16SC2, CV_32FC1, CV_32FC2 }; + static const ElemType mapx_types[] = { CV_16SC2, CV_32FC1, CV_32FC2 }; mapx.create(dst.size(), mapx_types[rng.uniform(0, sizeof(mapx_types) / sizeof(int))]); mapy.release(); @@ -762,26 +762,34 @@ void CV_Remap_Test::generate_test_data() if (interpolation != INTER_NEAREST) { - static const int mapy_types[] = { CV_16UC1, CV_16SC1 }; + static const ElemType mapy_types[] = { CV_16UC1, CV_16SC1 }; mapy.create(dst.size(), mapy_types[rng.uniform(0, sizeof(mapy_types) / sizeof(int))]); - switch (mapy.type()) + CV_Assert(mapy.channels() == 1); + switch (mapy.depth()) { - case CV_16UC1: + case CV_16U: { MatIterator_ begin_y = mapy.begin(), end_y = mapy.end(); for ( ; begin_y != end_y; ++begin_y) *begin_y = static_cast(rng.uniform(0, 1024)); + break; } - break; - case CV_16SC1: + case CV_16S: { MatIterator_ begin_y = mapy.begin(), end_y = mapy.end(); for ( ; begin_y != end_y; ++begin_y) *begin_y = static_cast(rng.uniform(0, 1024)); + break; } - break; + case CV_8U: + case CV_8S: + case CV_32S: + case CV_32F: + case CV_64F: + case CV_16F: + break; //unhandled } } } @@ -838,7 +846,7 @@ void CV_Remap_Test::convert_maps() convertMaps(mapx.clone(), mapy.clone(), mapx, mapy, CV_16SC2, interpolation == INTER_NEAREST); else if (interpolation != INTER_NEAREST) if (mapy.type() != CV_16UC1) - mapy.clone().convertTo(mapy, CV_16UC1); + mapy.clone().convertTo(mapy, CV_16U); if (interpolation == INTER_NEAREST) mapy = Mat(); @@ -1067,12 +1075,12 @@ void CV_WarpAffine_Test::generate_test_data() RNG& rng = ts->get_rng(); // generating the M 2x3 matrix - static const int depths[] = { CV_32FC1, CV_64FC1 }; + static const ElemDepth depths[] = { CV_32F, CV_64F }; // generating 2d matrix M = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), rng.uniform(-180.f, 180.f), rng.uniform(0.4f, 2.0f)); - int depth = depths[rng.uniform(0, sizeof(depths) / sizeof(depths[0]))]; + ElemDepth depth = depths[rng.uniform(0, sizeof(depths) / sizeof(depths[0]))]; if (M.depth() != depth) { Mat tmp; @@ -1202,8 +1210,8 @@ void CV_WarpPerspective_Test::generate_test_data() Point2f(rng.uniform(0.0f, cols), rng.uniform(0.0f, rows)) }; M = getPerspectiveTransform(sp, dp); - static const int depths[] = { CV_32F, CV_64F }; - int depth = depths[rng.uniform(0, 2)]; + static const ElemDepth depths[] = { CV_32F, CV_64F }; + ElemDepth depth = depths[rng.uniform(0, 2)]; M.clone().convertTo(M, depth); } diff --git a/modules/imgproc/test/test_moments.cpp b/modules/imgproc/test/test_moments.cpp index faaf4cd10876..228169f373bb 100644 --- a/modules/imgproc/test/test_moments.cpp +++ b/modules/imgproc/test/test_moments.cpp @@ -59,12 +59,12 @@ class CV_MomentsTest : public cvtest::ArrayTest protected: enum { MOMENT_COUNT = 25 }; - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void prepare_to_validation(int /*test_case_idx*/) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; bool is_binary; bool try_umat_; }; @@ -82,10 +82,9 @@ CV_MomentsTest::CV_MomentsTest(bool try_umat) : } -void CV_MomentsTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_MomentsTest::get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); - int depth = CV_MAT_DEPTH(type); + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); if( depth == CV_16U ) { @@ -105,11 +104,11 @@ void CV_MomentsTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Sca } void CV_MomentsTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - int depth = cvtest::randInt(rng) % 4; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 4); depth = depth == 0 ? CV_8U : depth == 1 ? CV_16U : depth == 2 ? CV_16S : CV_32F; is_binary = cvtest::randInt(rng) % 2 != 0; @@ -132,7 +131,7 @@ void CV_MomentsTest::get_test_array_types_and_sizes( int test_case_idx, double CV_MomentsTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { - int depth = test_mat[INPUT][0].depth(); + ElemDepth depth = test_mat[INPUT][0].depth(); return depth != CV_32F ? FLT_EPSILON*10 : FLT_EPSILON*100; } @@ -181,7 +180,7 @@ void CV_MomentsTest::prepare_to_validation( int /*test_case_idx*/ ) Mat& src = test_mat[INPUT][0]; CvMoments m = cvMoments(); double* mdata = test_mat[REF_OUTPUT][0].ptr(); - int depth = src.depth(); + ElemDepth depth = src.depth(); int cn = src.channels(); int i, y, x, cols = src.cols; double xc = 0., yc = 0.; @@ -311,12 +310,12 @@ class CV_HuMomentsTest : public cvtest::ArrayTest enum { MOMENT_COUNT = 18, HU_MOMENT_COUNT = 7 }; - int prepare_test_case( int test_case_idx ); - void prepare_to_validation( int /*test_case_idx*/ ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); + int prepare_test_case(int test_case_idx) CV_OVERRIDE; + void prepare_to_validation(int /*test_case_idx*/) CV_OVERRIDE; + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; }; @@ -328,16 +327,16 @@ CV_HuMomentsTest::CV_HuMomentsTest() } -void CV_HuMomentsTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_HuMomentsTest::get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); low = Scalar::all(-10000); high = Scalar::all(10000); } void CV_HuMomentsTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); types[INPUT][0] = types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_64FC1; diff --git a/modules/imgproc/test/test_pc.cpp b/modules/imgproc/test/test_pc.cpp index 22c4bb5d7686..fd56e716e98e 100644 --- a/modules/imgproc/test/test_pc.cpp +++ b/modules/imgproc/test/test_pc.cpp @@ -59,8 +59,8 @@ void CV_PhaseCorrelatorTest::run( int ) { ts->set_failed_test_info(cvtest::TS::OK); - Mat r1 = Mat::ones(Size(129, 128), CV_64F); - Mat r2 = Mat::ones(Size(129, 128), CV_64F); + Mat r1 = Mat::ones(Size(129, 128), CV_64FC1); + Mat r2 = Mat::ones(Size(129, 128), CV_64FC1); double expectedShiftX = -10.0; double expectedShiftY = -20.0; @@ -70,7 +70,7 @@ void CV_PhaseCorrelatorTest::run( int ) cv::rectangle(r2, Point(90, 80), Point(100, 90), Scalar(0, 0, 0), CV_FILLED); Mat hann; - createHanningWindow(hann, r1.size(), CV_64F); + createHanningWindow(hann, r1.size(), CV_64FC1); Point2d phaseShift = phaseCorrelate(r1, r2, hann); // test accuracy should be less than 1 pixel... @@ -85,7 +85,7 @@ TEST(Imgproc_PhaseCorrelatorTest, accuracy) { CV_PhaseCorrelatorTest test; test. TEST(Imgproc_PhaseCorrelatorTest, accuracy_real_img) { Mat img = imread(cvtest::TS::ptr()->get_data_path() + "shared/airplane.png", IMREAD_GRAYSCALE); - img.convertTo(img, CV_64FC1); + img.convertTo(img, CV_64F); const int xLen = 129; const int yLen = 129; @@ -96,7 +96,7 @@ TEST(Imgproc_PhaseCorrelatorTest, accuracy_real_img) Mat roi2 = img(Rect(0, 0, xLen, yLen)); Mat hann; - createHanningWindow(hann, roi1.size(), CV_64F); + createHanningWindow(hann, roi1.size(), CV_64FC1); Point2d phaseShift = phaseCorrelate(roi1, roi2, hann); ASSERT_NEAR(phaseShift.x, (double)xShift, 1.); @@ -104,8 +104,8 @@ TEST(Imgproc_PhaseCorrelatorTest, accuracy_real_img) } TEST(Imgproc_PhaseCorrelatorTest, accuracy_1d_odd_fft) { - Mat r1 = Mat::ones(Size(129, 1), CV_64F)*255; // 129 will be completed to 135 before FFT - Mat r2 = Mat::ones(Size(129, 1), CV_64F)*255; + Mat r1 = Mat::ones(Size(129, 1), CV_64FC1)*255; // 129 will be completed to 135 before FFT + Mat r2 = Mat::ones(Size(129, 1), CV_64FC1)*255; const int xShift = 10; diff --git a/modules/imgproc/test/test_resize_bitexact.cpp b/modules/imgproc/test/test_resize_bitexact.cpp index 2dafd502165a..70bf5eba1bd6 100644 --- a/modules/imgproc/test/test_resize_bitexact.cpp +++ b/modules/imgproc/test/test_resize_bitexact.cpp @@ -24,7 +24,7 @@ TEST(Resize_Bitexact, Linear8U) struct testmode { - int type; + ElemType type; Size sz; } modes[] = { { CV_8UC1, Size( 512, 768) }, // 1/2 1 @@ -73,7 +73,9 @@ TEST(Resize_Bitexact, Linear8U) for (int modeind = 0, _modecnt = sizeof(modes) / sizeof(modes[0]); modeind < _modecnt; ++modeind) { - int type = modes[modeind].type, depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = modes[modeind].type; + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int dcols = modes[modeind].sz.width, drows = modes[modeind].sz.height; int cols = 1024, rows = 768; diff --git a/modules/imgproc/test/test_smooth_bitexact.cpp b/modules/imgproc/test/test_smooth_bitexact.cpp index 20328c34168c..ddda921cc088 100644 --- a/modules/imgproc/test/test_smooth_bitexact.cpp +++ b/modules/imgproc/test/test_smooth_bitexact.cpp @@ -40,7 +40,7 @@ TEST(GaussianBlur_Bitexact, Linear8U) { struct testmode { - int type; + ElemType type; Size sz; Size kernel; double sigma_x; @@ -90,7 +90,9 @@ TEST(GaussianBlur_Bitexact, Linear8U) for (int modeind = 0, _modecnt = sizeof(modes) / sizeof(modes[0]); modeind < _modecnt; ++modeind) { - int type = modes[modeind].type, depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = modes[modeind].type; + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int dcols = modes[modeind].sz.width, drows = modes[modeind].sz.height; Size kernel = modes[modeind].kernel; diff --git a/modules/imgproc/test/test_templmatch.cpp b/modules/imgproc/test/test_templmatch.cpp index d1389f4c7933..88ec4a925791 100644 --- a/modules/imgproc/test/test_templmatch.cpp +++ b/modules/imgproc/test/test_templmatch.cpp @@ -49,12 +49,12 @@ class CV_TemplMatchTest : public cvtest::ArrayTest CV_TemplMatchTest(); protected: - int read_params( CvFileStorage* fs ); - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + int read_params(CvFileStorage* fs) CV_OVERRIDE; + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) CV_OVERRIDE; + double get_success_error_level(int test_case_idx, int i, int j) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation(int) CV_OVERRIDE; int max_template_size; int method; @@ -88,10 +88,9 @@ int CV_TemplMatchTest::read_params( CvFileStorage* fs ) } -void CV_TemplMatchTest::get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) +void CV_TemplMatchTest::get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high) { - cvtest::ArrayTest::get_minmax_bounds( i, j, type, low, high ); - int depth = CV_MAT_DEPTH(type); + cvtest::ArrayTest::get_minmax_bounds( i, j, depth, low, high ); if( depth == CV_32F ) { low = Scalar::all(-10.); @@ -101,10 +100,11 @@ void CV_TemplMatchTest::get_minmax_bounds( int i, int j, int type, Scalar& low, void CV_TemplMatchTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % 2, cn = cvtest::randInt(rng) & 1 ? 3 : 1; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 2); + int cn = cvtest::randInt(rng) & 1 ? 3 : 1; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); depth = depth == 0 ? CV_8U : CV_32F; @@ -147,7 +147,8 @@ void CV_TemplMatchTest::run_func() static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* result, int method ) { int i, j, k, l; - int depth = CV_MAT_DEPTH(img->type), cn = CV_MAT_CN(img->type); + ElemDepth depth = CV_MAT_DEPTH(img->type); + int cn = CV_MAT_CN(img->type); int width_n = templ->cols*cn, height = templ->rows; int a_step = img->step / CV_ELEM_SIZE(img->type & CV_MAT_DEPTH_MASK); int b_step = templ->step / CV_ELEM_SIZE(templ->type & CV_MAT_DEPTH_MASK); diff --git a/modules/imgproc/test/test_thresh.cpp b/modules/imgproc/test/test_thresh.cpp index e9bed8c72e71..271751dc9a9e 100644 --- a/modules/imgproc/test/test_thresh.cpp +++ b/modules/imgproc/test/test_thresh.cpp @@ -49,10 +49,10 @@ class CV_ThreshTest : public cvtest::ArrayTest CV_ThreshTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); - void run_func(); - void prepare_to_validation( int ); + void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; + void run_func() CV_OVERRIDE; + void prepare_to_validation( int ) CV_OVERRIDE; int thresh_type; double thresh_val; @@ -71,10 +71,11 @@ CV_ThreshTest::CV_ThreshTest() void CV_ThreshTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); - int depth = cvtest::randInt(rng) % 5, cn = cvtest::randInt(rng) % 4 + 1; + ElemDepth depth = static_cast(cvtest::randInt(rng) % 5); + int cn = cvtest::randInt(rng) % 4 + 1; cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); depth = depth == 0 ? CV_8U : depth == 1 ? CV_16S : depth == 2 ? CV_16U : depth == 3 ? CV_32F : CV_64F; @@ -131,7 +132,8 @@ static void test_threshold( const Mat& _src, Mat& _dst, double thresh, double maxval, int thresh_type ) { int i, j; - int depth = _src.depth(), cn = _src.channels(); + ElemDepth depth = _src.depth(); + int cn = _src.channels(); int width_n = _src.cols*cn, height = _src.rows; int ithresh = cvFloor(thresh); int imaxval, ithresh2; @@ -422,7 +424,7 @@ TEST(Imgproc_Threshold, accuracy) { CV_ThreshTest test; test.safe_run(); } BIGDATA_TEST(Imgproc_Threshold, huge) { - Mat m(65000, 40000, CV_8U); + Mat m(65000, 40000, CV_8UC1); ASSERT_FALSE(m.isContinuous()); uint64 i, n = (uint64)m.rows*m.cols; diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index c2f6e8514c5b..afbba2093a6d 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -64,7 +64,9 @@ def checkFileRemap(path): "size_t" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "__int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, - "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" } + "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" }, + "ElemType": { "j_type" : "int", "jn_type" : "int", "jni_type" : "jint", "suffix" : "I", "cast_from" : "int", "cast_to" : "ElemType" }, + "ElemDepth": { "j_type" : "int", "jn_type" : "int", "jni_type" : "jint", "suffix" : "I", "cast_from" : "int", "cast_to" : "ElemDepth" }, } # Defines a rule to add extra prefixes for names from specific namespaces. @@ -562,7 +564,7 @@ def gen_func(self, ci, fi, prop_name=''): cpp_code = ci.cpp_code # c_decl - # e.g: void add(Mat src1, Mat src2, Mat dst, Mat mask = Mat(), int dtype = -1) + # e.g: void add(Mat src1, Mat src2, Mat dst, Mat mask = Mat(), ElemDepth ddepth = CV_DEPTH_AUTO) if prop_name: c_decl = "%s %s::%s" % (fi.ctype, fi.classname, prop_name) else: @@ -720,7 +722,7 @@ def gen_func(self, ci, fi, prop_name=''): # java part: # private java NATIVE method decl # e.g. - # private static native void add_0(long src1, long src2, long dst, long mask, int dtype); + # private static native void add_0(long src1, long src2, long dst, long mask, ElemDepth ddepth); jn_code.write( Template(\ " private static native $type $name($args);\n").substitute(\ type = type_dict[fi.ctype].get("jn_type", "double[]"), \ @@ -746,8 +748,8 @@ def gen_func(self, ci, fi, prop_name=''): # public java wrapper method impl (calling native one above) # e.g. - # public static void add( Mat src1, Mat src2, Mat dst, Mat mask, int dtype ) - # { add_0( src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, dtype ); } + # public static void add( Mat src1, Mat src2, Mat dst, Mat mask, ElemDepth ddepth ) + # { add_0( src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, ddepth ); } ret_type = fi.ctype if fi.ctype.endswith('*'): ret_type = ret_type[:-1] diff --git a/modules/java/generator/src/cpp/Mat.cpp b/modules/java/generator/src/cpp/Mat.cpp index db9f1936da4b..b2e4192631a6 100644 --- a/modules/java/generator/src/cpp/Mat.cpp +++ b/modules/java/generator/src/cpp/Mat.cpp @@ -65,7 +65,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIILjava_nio_ByteBuffer static const char method_name[] = "Mat::n_1Mat__IIILByteBuffer()"; try { LOGD("%s", method_name); - return (jlong) new Mat( rows, cols, type, (void*)env->GetDirectBufferAddress(data) ); + return (jlong) new Mat( rows, cols, static_cast(type), (void*)env->GetDirectBufferAddress(data) ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -90,7 +90,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III static const char method_name[] = "Mat::n_1Mat__III()"; try { LOGD("%s", method_name); - return (jlong) new Mat( rows, cols, type ); + return (jlong) new Mat(rows, cols, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -116,7 +116,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - return (jlong) new Mat( size, type ); + return (jlong) new Mat(size, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -143,7 +143,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD try { LOGD("%s", method_name); Scalar s(s_val0, s_val1, s_val2, s_val3); - return (jlong) new Mat( rows, cols, type, s ); + return (jlong) new Mat(rows, cols, static_cast(type), s); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -170,7 +170,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD LOGD("%s", method_name); Size size((int)size_width, (int)size_height); Scalar s(s_val0, s_val1, s_val2, s_val3); - return (jlong) new Mat( size, type, s ); + return (jlong) new Mat( size, static_cast(type), s ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -258,20 +258,20 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI // -// void Mat::assignTo(Mat m, int type = -1) +// void Mat::assignTo(Mat m, ElemDepth depth = CV_DEPTH_AUTO) // JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint type); JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI - (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint type) + (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint depth) { static const char method_name[] = "Mat::n_1assignTo__JJI()"; try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - me->assignTo( (*(Mat*)m_nativeObj), type ); + me->assignTo((*(Mat*)m_nativeObj), static_cast(depth)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -327,7 +327,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels // -// int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true) +// int Mat::checkVector(int elemChannels, ElemDepth depth = -1, bool requireContinuous = true) // JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ @@ -340,7 +340,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - return me->checkVector( elemChannels, depth, requireContinuous ); + return me->checkVector(elemChannels, static_cast(depth), requireContinuous); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -362,7 +362,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - return me->checkVector( elemChannels, depth ); + return me->checkVector(elemChannels, static_cast(depth)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -531,21 +531,21 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols // -// void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0) +// void Mat::convertTo(Mat& m, ElemDepth ddepth, double alpha = 1, double beta = 0) // JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta); JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD - (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta) + (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint depth, jdouble alpha, jdouble beta) { static const char method_name[] = "Mat::n_1convertTo__JJIDD()"; try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo( m, rtype, alpha, beta ); + me->convertTo(m, static_cast(depth), alpha, beta); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -558,14 +558,14 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha); JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID - (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha) + (JNIEnv* env, jclass, jlong self, jlong m_nativeObj, jint rdepth, jdouble alpha) { static const char method_name[] = "Mat::n_1convertTo__JJID()"; try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo( m, rtype, alpha ); + me->convertTo(m, static_cast(rdepth), alpha); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -585,7 +585,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Mat& m = *((Mat*)m_nativeObj); - me->convertTo( m, rtype ); + me->convertTo( m, static_cast(rtype) ); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -660,7 +660,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII try { LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL - me->create( rows, cols, type ); + me->create(rows, cols, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -685,7 +685,7 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI LOGD("%s", method_name); Mat* me = (Mat*) self; //TODO: check for NULL Size size((int)size_width, (int)size_height); - me->create( size, type ); + me->create(size, static_cast(type)); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { @@ -938,7 +938,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III static const char method_name[] = "Mat::n_1eye__III()"; try { LOGD("%s", method_name); - Mat _retval_ = Mat::eye( rows, cols, type ); + Mat _retval_ = Mat::eye(rows, cols, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -965,7 +965,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - Mat _retval_ = Mat::eye( size, type ); + Mat _retval_ = Mat::eye(size, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1171,7 +1171,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III static const char method_name[] = "Mat::n_1ones__III()"; try { LOGD("%s", method_name); - Mat _retval_ = Mat::ones( rows, cols, type ); + Mat _retval_ = Mat::ones(rows, cols, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1198,7 +1198,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - Mat _retval_ = Mat::ones( size, type ); + Mat _retval_ = Mat::ones(size, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1724,7 +1724,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III static const char method_name[] = "Mat::n_1zeros__III()"; try { LOGD("%s", method_name); - Mat _retval_ = Mat::zeros( rows, cols, type ); + Mat _retval_ = Mat::zeros(rows, cols, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1751,7 +1751,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI try { LOGD("%s", method_name); Size size((int)size_width, (int)size_height); - Mat _retval_ = Mat::zeros( size, type ); + Mat _retval_ = Mat::zeros(size, static_cast(type)); return (jlong) new Mat(_retval_); } catch(const std::exception &e) { throwJavaException(env, &e, method_name); @@ -1795,7 +1795,7 @@ namespace { const char JavaOpenCVTrait::get[] = "Mat::nGet" s "()"; \ const char JavaOpenCVTrait::put[] = "Mat::nPut" s "()" - JOCvT(jbyte, "B", CV_8U, CV_8S); + JOCvT(jbyte, "B", CV_8UC1, CV_8S); JOCvT(jshort, "S", CV_16U, CV_16S); JOCvT(jint, "I", CV_32S, CV_32S); JOCvT(jfloat, "F", CV_32F, CV_32F); @@ -1840,7 +1840,7 @@ template static jint java_mat_put(JNIEnv* env, jlong self, jint row LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind - if(me->depth() != JavaOpenCVTrait::cvtype_1 && me->depth() != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type + if(static_cast(me->depth()) != JavaOpenCVTrait::cvtype_1 && static_cast(me->depth()) != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type if(me->rows<=row || me->cols<=col) return 0; // indexes out of range char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0); @@ -1935,6 +1935,8 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD case CV_32S: PUT_ITEM(int, row, c); break; case CV_32F: PUT_ITEM(float, row, c); break; case CV_64F: PUT_ITEM(double, row, c); break; + case CV_16F: + break; //unhandled } } @@ -1949,6 +1951,8 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD case CV_32S: PUT_ITEM(int, r, c); break; case CV_32F: PUT_ITEM(float, r, c); break; case CV_64F: PUT_ITEM(double, r, c); break; + case CV_16F: + break; //unhandled } } @@ -2001,7 +2005,7 @@ template static jint java_mat_get(JNIEnv* env, jlong self, jint row LOGD("%s", method_name); cv::Mat* me = (cv::Mat*) self; if(! self) return 0; // no native object behind - if(me->depth() != JavaOpenCVTrait::cvtype_1 && me->depth() != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type + if(static_cast(me->depth()) != JavaOpenCVTrait::cvtype_1 && static_cast(me->depth()) != JavaOpenCVTrait::cvtype_2) return 0; // incompatible type if(me->rows<=row || me->cols<=col) return 0; // indexes out of range char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0); @@ -2089,6 +2093,8 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet case CV_32S: for(i=0; ichannels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break; case CV_32F: for(i=0; ichannels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break; case CV_64F: for(i=0; ichannels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break; + case CV_16F: + break; //unhandled } env->SetDoubleArrayRegion(res, 0, me->channels(), buff); } diff --git a/modules/js/src/core_bindings.cpp b/modules/js/src/core_bindings.cpp index e8f0ee7f856a..f16e159201a1 100644 --- a/modules/js/src/core_bindings.cpp +++ b/modules/js/src/core_bindings.cpp @@ -97,7 +97,7 @@ namespace binding_utils return emscripten::val(emscripten::memory_view(mat.step1(1), mat.ptr(i,j))); } - cv::Mat* createMat(int rows, int cols, int type, intptr_t data, size_t step) + cv::Mat* createMat(int rows, int cols, ElemType type, intptr_t data, size_t step) { return new cv::Mat(rows, cols, type, reinterpret_cast(data), step); } @@ -120,29 +120,29 @@ namespace binding_utils return step; } - static Mat matEye(int rows, int cols, int type) + static Mat matEye(int rows, int cols, ElemType type) { return Mat(cv::Mat::eye(rows, cols, type)); } - static Mat matEye(Size size, int type) + static Mat matEye(Size size, ElemType type) { return Mat(cv::Mat::eye(size, type)); } - void convertTo(const Mat& obj, Mat& m, int rtype, double alpha, double beta) + void convertTo(const Mat& obj, Mat& m, ElemDepth ddepth, double alpha, double beta) { - obj.convertTo(m, rtype, alpha, beta); + obj.convertTo(m, ddepth, alpha, beta); } - void convertTo(const Mat& obj, Mat& m, int rtype) + void convertTo(const Mat& obj, Mat& m, ElemDepth ddepth) { - obj.convertTo(m, rtype); + obj.convertTo(m, ddepth); } - void convertTo(const Mat& obj, Mat& m, int rtype, double alpha) + void convertTo(const Mat& obj, Mat& m, ElemDepth ddepth, double alpha) { - obj.convertTo(m, rtype, alpha); + obj.convertTo(m, ddepth, alpha); } Size matSize(const cv::Mat& mat) @@ -150,24 +150,24 @@ namespace binding_utils return mat.size(); } - cv::Mat matZeros(int arg0, int arg1, int arg2) + cv::Mat matZeros(int cols, int rows, ElemType type) { - return cv::Mat::zeros(arg0, arg1, arg2); + return cv::Mat::zeros(cols, rows, type); } - cv::Mat matZeros(cv::Size arg0, int arg1) + cv::Mat matZeros(cv::Size size, ElemType type) { - return cv::Mat::zeros(arg0,arg1); + return cv::Mat::zeros(size, type); } - cv::Mat matOnes(int arg0, int arg1, int arg2) + cv::Mat matOnes(int cols, int rows, ElemType type) { - return cv::Mat::ones(arg0, arg1, arg2); + return cv::Mat::ones(cols, rows, type); } - cv::Mat matOnes(cv::Size arg0, int arg1) + cv::Mat matOnes(cv::Size size, ElemType type) { - return cv::Mat::ones(arg0, arg1); + return cv::Mat::ones(size, type); } double matDot(const cv::Mat& obj, const Mat& mat) @@ -185,9 +185,9 @@ namespace binding_utils return Mat(obj.t()); } - Mat matInv(const cv::Mat& obj, int type) + Mat matInv(const cv::Mat& obj, int method) { - return Mat(obj.inv(type)); + return Mat(obj.inv(method)); } void matCopyTo(const cv::Mat& obj, cv::Mat& mat) @@ -331,17 +331,17 @@ EMSCRIPTEN_BINDINGS(binding_utils) emscripten::class_("Mat") .constructor<>() .constructor() - .constructor() - .constructor() - .constructor() + .constructor() + .constructor() + .constructor() .constructor(&binding_utils::createMat, allow_raw_pointers()) - .class_function("eye", select_overload(&binding_utils::matEye)) - .class_function("eye", select_overload(&binding_utils::matEye)) - .class_function("ones", select_overload(&binding_utils::matOnes)) - .class_function("ones", select_overload(&binding_utils::matOnes)) - .class_function("zeros", select_overload(&binding_utils::matZeros)) - .class_function("zeros", select_overload(&binding_utils::matZeros)) + .class_function("eye", select_overload(&binding_utils::matEye)) + .class_function("eye", select_overload(&binding_utils::matEye)) + .class_function("ones", select_overload(&binding_utils::matOnes)) + .class_function("ones", select_overload(&binding_utils::matOnes)) + .class_function("zeros", select_overload(&binding_utils::matZeros)) + .class_function("zeros", select_overload(&binding_utils::matZeros)) .property("rows", &cv::Mat::rows) .property("cols", &cv::Mat::cols) @@ -358,24 +358,24 @@ EMSCRIPTEN_BINDINGS(binding_utils) .function("elemSize", select_overload(&cv::Mat::elemSize)) .function("elemSize1", select_overload(&cv::Mat::elemSize1)) .function("channels", select_overload(&cv::Mat::channels)) - .function("convertTo", select_overload(&binding_utils::convertTo)) - .function("convertTo", select_overload(&binding_utils::convertTo)) - .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) + .function("convertTo", select_overload(&binding_utils::convertTo)) .function("total", select_overload(&cv::Mat::total)) .function("row", select_overload(&cv::Mat::row)) - .function("create", select_overload(&cv::Mat::create)) - .function("create", select_overload(&cv::Mat::create)) + .function("create", select_overload(&cv::Mat::create)) + .function("create", select_overload(&cv::Mat::create)) .function("rowRange", select_overload(&cv::Mat::rowRange)) .function("rowRange", select_overload(&cv::Mat::rowRange)) .function("copyTo", select_overload(&binding_utils::matCopyTo)) .function("copyTo", select_overload(&binding_utils::matCopyTo)) - .function("type", select_overload(&cv::Mat::type)) + .function("type", select_overload(&cv::Mat::type)) .function("empty", select_overload(&cv::Mat::empty)) .function("colRange", select_overload(&cv::Mat::colRange)) .function("colRange", select_overload(&cv::Mat::colRange)) .function("step1", select_overload(&cv::Mat::step1)) .function("clone", select_overload(&cv::Mat::clone)) - .function("depth", select_overload(&cv::Mat::depth)) + .function("depth", select_overload(&cv::Mat::depth)) .function("col", select_overload(&cv::Mat::col)) .function("dot", select_overload(&binding_utils::matDot)) .function("mul", select_overload(&binding_utils::matMul)) @@ -536,49 +536,49 @@ EMSCRIPTEN_BINDINGS(binding_utils) function("getBuildInformation", &binding_utils::getBuildInformation); - constant("CV_8UC1", CV_8UC1); - constant("CV_8UC2", CV_8UC2); - constant("CV_8UC3", CV_8UC3); - constant("CV_8UC4", CV_8UC4); - - constant("CV_8SC1", CV_8SC1); - constant("CV_8SC2", CV_8SC2); - constant("CV_8SC3", CV_8SC3); - constant("CV_8SC4", CV_8SC4); - - constant("CV_16UC1", CV_16UC1); - constant("CV_16UC2", CV_16UC2); - constant("CV_16UC3", CV_16UC3); - constant("CV_16UC4", CV_16UC4); - - constant("CV_16SC1", CV_16SC1); - constant("CV_16SC2", CV_16SC2); - constant("CV_16SC3", CV_16SC3); - constant("CV_16SC4", CV_16SC4); - - constant("CV_32SC1", CV_32SC1); - constant("CV_32SC2", CV_32SC2); - constant("CV_32SC3", CV_32SC3); - constant("CV_32SC4", CV_32SC4); - - constant("CV_32FC1", CV_32FC1); - constant("CV_32FC2", CV_32FC2); - constant("CV_32FC3", CV_32FC3); - constant("CV_32FC4", CV_32FC4); - - constant("CV_64FC1", CV_64FC1); - constant("CV_64FC2", CV_64FC2); - constant("CV_64FC3", CV_64FC3); - constant("CV_64FC4", CV_64FC4); - - constant("CV_8U", CV_8U); - constant("CV_8S", CV_8S); - constant("CV_16U", CV_16U); - constant("CV_16S", CV_16S); - constant("CV_32S", CV_32S); - constant("CV_32F", CV_32F); - constant("CV_64F", CV_64F); - - constant("INT_MIN", INT_MIN); - constant("INT_MAX", INT_MAX); + constant("CV_8UC1", static_cast(CV_8UC1)); + constant("CV_8UC2", static_cast(CV_8UC2)); + constant("CV_8UC3", static_cast(CV_8UC3)); + constant("CV_8UC4", static_cast(CV_8UC4)); + + constant("CV_8SC1", static_cast(CV_8SC1)); + constant("CV_8SC2", static_cast(CV_8SC2)); + constant("CV_8SC3", static_cast(CV_8SC3)); + constant("CV_8SC4", static_cast(CV_8SC4)); + + constant("CV_16UC1", static_cast(CV_16UC1)); + constant("CV_16UC2", static_cast(CV_16UC2)); + constant("CV_16UC3", static_cast(CV_16UC3)); + constant("CV_16UC4", static_cast(CV_16UC4)); + + constant("CV_16SC1", static_cast(CV_16SC1)); + constant("CV_16SC2", static_cast(CV_16SC2)); + constant("CV_16SC3", static_cast(CV_16SC3)); + constant("CV_16SC4", static_cast(CV_16SC4)); + + constant("CV_32SC1", static_cast(CV_32SC1)); + constant("CV_32SC2", static_cast(CV_32SC2)); + constant("CV_32SC3", static_cast(CV_32SC3)); + constant("CV_32SC4", static_cast(CV_32SC4)); + + constant("CV_32FC1", static_cast(CV_32FC1)); + constant("CV_32FC2", static_cast(CV_32FC2)); + constant("CV_32FC3", static_cast(CV_32FC3)); + constant("CV_32FC4", static_cast(CV_32FC4)); + + constant("CV_64FC1", static_cast(CV_64FC1)); + constant("CV_64FC2", static_cast(CV_64FC2)); + constant("CV_64FC3", static_cast(CV_64FC3)); + constant("CV_64FC4", static_cast(CV_64FC4)); + + constant("CV_8U", static_cast(CV_8U)); + constant("CV_8S", static_cast(CV_8S)); + constant("CV_16U", static_cast(CV_16U)); + constant("CV_16S", static_cast(CV_16S)); + constant("CV_32S", static_cast(CV_32S)); + constant("CV_32F", static_cast(CV_32F)); + constant("CV_64F", static_cast(CV_64F)); + + constant("INT_MIN", static_cast(INT_MIN)); + constant("INT_MAX", static_cast(INT_MAX)); } diff --git a/modules/js/src/embindgen.py b/modules/js/src/embindgen.py index 9fb508212d32..9f736b90d1bf 100644 --- a/modules/js/src/embindgen.py +++ b/modules/js/src/embindgen.py @@ -381,8 +381,8 @@ def add_enum(self, decl): if candidate_name not in ns.enums: name = candidate_name break; - val = '_'.join(classes + [name]) cname = name.replace('.', '::') + type_dict[normalize_class_name(name)] = cname if name in ns.enums: print("Generator warning: enum %s (cname=%s) already exists" \ % (name, cname)) @@ -826,7 +826,8 @@ def gen(self, dst_file, src_files, core_bindings): for variant in method.variants: args = [] for arg in variant.args: - args.append(arg.tp) + arg_type = type_dict[arg.tp] if arg.tp in type_dict else arg.tp + args.append(arg_type) # print('Constructor: ', class_info.name, len(variant.args)) args_num = len(variant.args) if args_num in class_info.constructor_arg_num: diff --git a/modules/js/src/templates.py b/modules/js/src/templates.py index 05dc9bbc37ee..be9d61ef14ba 100644 --- a/modules/js/src/templates.py +++ b/modules/js/src/templates.py @@ -176,7 +176,7 @@ """) const_template = Template(""" - constant("$js_name", +$value); + constant("$js_name", static_cast($value)); """) vector_template = Template(""" diff --git a/modules/ml/src/ann_mlp.cpp b/modules/ml/src/ann_mlp.cpp index 569aefa43a18..d88f841a23fe 100644 --- a/modules/ml/src/ann_mlp.cpp +++ b/modules/ml/src/ann_mlp.cpp @@ -327,14 +327,14 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP "and every hidden layer must have more than 1 neuron" ); max_lsize = std::max( max_lsize, n ); if( i > 0 ) - weights[i].create(layer_sizes[i-1]+1, n, CV_64F); + weights[i].create(layer_sizes[i-1]+1, n, CV_64FC1); } int ninputs = layer_sizes.front(); int noutputs = layer_sizes.back(); - weights[0].create(1, ninputs*2, CV_64F); - weights[l_count].create(1, noutputs*2, CV_64F); - weights[l_count+1].create(1, noutputs*2, CV_64F); + weights[0].create(1, ninputs*2, CV_64FC1); + weights[l_count].create(1, noutputs*2, CV_64FC1); + weights[l_count+1].create(1, noutputs*2, CV_64FC1); } } @@ -344,10 +344,11 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP CV_Error( CV_StsError, "The network has not been trained or loaded" ); Mat inputs = _inputs.getMat(); - int type = inputs.type(), l_count = layer_count(); + ElemType type = inputs.type(); + int l_count = layer_count(); int n = inputs.rows, dn0 = n; - CV_Assert( (type == CV_32F || type == CV_64F) && inputs.cols == layer_sizes[0] ); + CV_Assert((type == CV_32FC1 || type == CV_64FC1) && inputs.cols == layer_sizes[0]); int noutputs = layer_sizes[l_count-1]; Mat outputs; @@ -381,7 +382,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP dn = std::min( dn0, n - i ); Mat layer_in = inputs.rowRange(i, i + dn); - Mat layer_out( dn, layer_in.cols, CV_64F, buf); + Mat layer_out( dn, layer_in.cols, CV_64FC1, buf); scale_input( layer_in, layer_out ); layer_in = layer_out; @@ -391,7 +392,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP double* data = buf + ((j&1) ? max_lsize*dn0 : 0); int cols = layer_sizes[j]; - layer_out = Mat(dn, cols, CV_64F, data); + layer_out = Mat(dn, cols, CV_64FC1, data); Mat w = weights[j].rowRange(0, layer_in.cols); gemm(layer_in, w, 1, noArray(), 0, layer_out); calc_activ_func( layer_out, weights[j] ); @@ -418,7 +419,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP int cols = _src.cols; const double* w = weights[0].ptr(); - if( _src.type() == CV_32F ) + if( _src.type() == CV_32FC1 ) { for( int i = 0; i < _src.rows; i++ ) { @@ -445,7 +446,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP int cols = _src.cols; const double* w = weights[layer_count()].ptr(); - if( _dst.type() == CV_32F ) + if( _dst.type() == CV_32FC1 ) { for( int i = 0; i < _src.rows; i++ ) { @@ -820,14 +821,14 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP CV_Error( CV_StsError, "The network has not been created. Use method create or the appropriate constructor" ); - if( (inputs.type() != CV_32F && inputs.type() != CV_64F) || + if( (inputs.type() != CV_32FC1 && inputs.type() != CV_64FC1) || inputs.cols != layer_sizes[0] ) CV_Error( CV_StsBadArg, "input training data should be a floating-point matrix with " "the number of rows equal to the number of training samples and " "the number of columns equal to the size of 0-th (input) layer" ); - if( (outputs.type() != CV_32F && outputs.type() != CV_64F) || + if( (outputs.type() != CV_32FC1 && outputs.type() != CV_64FC1) || outputs.cols != layer_sizes.back() ) CV_Error( CV_StsBadArg, "output training data should be a floating-point matrix with " @@ -915,10 +916,10 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP int n = layer_sizes[i]; x[i].resize(n+1); df[i].resize(n); - dw[i] = Mat::zeros(weights[i].size(), CV_64F); + dw[i] = Mat::zeros(weights[i].size(), CV_64FC1); } - Mat _idx_m(1, count, CV_32S); + Mat _idx_m(1, count, CV_32SC1); int* _idx = _idx_m.ptr(); for( i = 0; i < count; i++ ) _idx[i] = i; @@ -970,21 +971,21 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP for( j = 0; j < ivcount; j++ ) x[0][j] = (itype == CV_32F ? (double)x0data_f[j] : x0data_d[j])*w[j*2] + w[j*2 + 1]; - Mat x1( 1, ivcount, CV_64F, &x[0][0] ); + Mat x1( 1, ivcount, CV_64FC1, &x[0][0] ); // forward pass, compute y[i]=w*x[i-1], x[i]=f(y[i]), df[i]=f'(y[i]) for( i = 1; i < l_count; i++ ) { int n = layer_sizes[i]; - Mat x2(1, n, CV_64F, &x[i][0] ); + Mat x2(1, n, CV_64FC1, &x[i][0] ); Mat _w = weights[i].rowRange(0, x1.cols); gemm(x1, _w, 1, noArray(), 0, x2); - Mat _df(1, n, CV_64F, &df[i][0] ); + Mat _df(1, n, CV_64FC1, &df[i][0] ); calc_activ_func_deriv( x2, _df, weights[i] ); x1 = x2; } - Mat grad1( 1, ovcount, CV_64F, buf[l_count&1] ); + Mat grad1( 1, ovcount, CV_64FC1, buf[l_count&1] ); w = weights[l_count+1].ptr(); // calculate error @@ -1005,15 +1006,15 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP for( i = l_count-1; i > 0; i-- ) { int n1 = layer_sizes[i-1], n2 = layer_sizes[i]; - Mat _df(1, n2, CV_64F, &df[i][0]); + Mat _df(1, n2, CV_64FC1, &df[i][0]); multiply( grad1, _df, grad1 ); - Mat _x(n1+1, 1, CV_64F, &x[i-1][0]); + Mat _x(n1+1, 1, CV_64FC1, &x[i-1][0]); x[i-1][n1] = 1.; gemm( _x, grad1, params.bpDWScale, dw[i], params.bpMomentScale, dw[i] ); add( weights[i], dw[i], weights[i] ); if( i > 1 ) { - Mat grad2(1, n1, CV_64F, buf[i&1]); + Mat grad2(1, n1, CV_64FC1, buf[i&1]); Mat _w = weights[i].rowRange(0, n1); gemm( grad1, _w, 1, noArray(), 0, grad2, GEMM_2_T ); grad1 = grad2; @@ -1084,20 +1085,20 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP for( j = 0; j < ivcount; j++ ) xdata[j] = (itype == CV_32F ? (double)x0data_f[j] : x0data_d[j])*w[j*2] + w[j*2+1]; } - Mat x1(dcount, ivcount, CV_64F, &x[0][0]); + Mat x1(dcount, ivcount, CV_64FC1, &x[0][0]); // forward pass, compute y[i]=w*x[i-1], x[i]=f(y[i]), df[i]=f'(y[i]) for( i = 1; i < l_count; i++ ) { - Mat x2( dcount, ann->layer_sizes[i], CV_64F, &x[i][0] ); + Mat x2(dcount, ann->layer_sizes[i], CV_64FC1, &x[i][0]); Mat _w = ann->weights[i].rowRange(0, x1.cols); gemm( x1, _w, 1, noArray(), 0, x2 ); - Mat _df( x2.size(), CV_64F, &df[i][0] ); + Mat _df(x2.size(), CV_64FC1, &df[i][0]); ann->calc_activ_func_deriv( x2, _df, ann->weights[i] ); x1 = x2; } - Mat grad1(dcount, ovcount, CV_64F, buf[l_count & 1]); + Mat grad1(dcount, ovcount, CV_64FC1, buf[l_count & 1]); w = ann->weights[l_count+1].ptr(); @@ -1124,13 +1125,13 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP for( i = l_count-1; i > 0; i-- ) { int n1 = ann->layer_sizes[i-1], n2 = ann->layer_sizes[i]; - Mat _df(dcount, n2, CV_64F, &df[i][0]); + Mat _df(dcount, n2, CV_64FC1, &df[i][0]); multiply(grad1, _df, grad1); { AutoLock lock(ann->mtx); Mat _dEdw = dEdw->at(i).rowRange(0, n1); - x1 = Mat(dcount, n1, CV_64F, &x[i-1][0]); + x1 = Mat(dcount, n1, CV_64FC1, &x[i-1][0]); gemm(x1, grad1, 1, _dEdw, 1, _dEdw, GEMM_1_T); // update bias part of dEdw @@ -1143,7 +1144,7 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP } } - Mat grad2( dcount, n1, CV_64F, buf[i&1] ); + Mat grad2( dcount, n1, CV_64FC1, buf[i&1] ); if( i > 1 ) { Mat _w = ann->weights[i].rowRange(0, n1); @@ -1182,10 +1183,10 @@ class ANN_MLPImpl CV_FINAL : public ANN_MLP for( i = 0; i < l_count; i++ ) { total += layer_sizes[i]; - dw[i].create(weights[i].size(), CV_64F); + dw[i].create(weights[i].size(), CV_64FC1); dw[i].setTo(Scalar::all(params.rpDW0)); - prev_dEdw_sign[i] = Mat::zeros(weights[i].size(), CV_8S); - dEdw[i] = Mat::zeros(weights[i].size(), CV_64F); + prev_dEdw_sign[i] = Mat::zeros(weights[i].size(), CV_8SC1); + dEdw[i] = Mat::zeros(weights[i].size(), CV_64FC1); } CV_Assert(total > 0); int dcount0 = max_buf_size/(2*total); diff --git a/modules/ml/src/boost.cpp b/modules/ml/src/boost.cpp index b3e8c2724a60..1899bcac7c45 100644 --- a/modules/ml/src/boost.cpp +++ b/modules/ml/src/boost.cpp @@ -207,7 +207,7 @@ class DTreesImplForBoost CV_FINAL : public DTreesImpl cv::AutoBuffer buf(n + nvars); double* result = buf.data(); float* sbuf = (float*)(result + n); - Mat sample(1, nvars, CV_32F, sbuf); + Mat sample(1, nvars, CV_32FC1, sbuf); int predictFlags = bparams.boostType == Boost::DISCRETE ? (PREDICT_MAX_VOTE | RAW_OUTPUT) : PREDICT_SUM; predictFlags |= COMPRESSED_INPUT; diff --git a/modules/ml/src/data.cpp b/modules/ml/src/data.cpp index daf39b9a330f..d0b17062ec99 100644 --- a/modules/ml/src/data.cpp +++ b/modules/ml/src/data.cpp @@ -101,11 +101,11 @@ Mat TrainData::getSubMatrix(const Mat& m, const Mat& idx, int layout) { if (idx.empty()) return m; - int type = m.type(); - CV_CheckType(type, type == CV_32S || type == CV_32F || type == CV_64F, ""); - if (type == CV_32S || type == CV_32F) // 32-bit + ElemType type = m.type(); + CV_CheckType(type, type == CV_32SC1 || type == CV_32FC1 || type == CV_64FC1, ""); + if (type == CV_32SC1 || type == CV_32FC1) // 32-bit return getSubMatrixImpl(m, idx, layout); - if (type == CV_64F) // 64-bit + if (type == CV_64FC1) // 64-bit return getSubMatrixImpl(m, idx, layout); CV_Error(Error::StsInternal, ""); } @@ -254,14 +254,14 @@ class TrainDataImpl CV_FINAL : public TrainData int ninputvars = layout == ROW_SAMPLE ? samples.cols : samples.rows; int i, noutputvars = 0; - CV_Assert( samples.type() == CV_32F || samples.type() == CV_32S ); + CV_Assert( samples.type() == CV_32FC1 || samples.type() == CV_32SC1 ); if( !sampleIdx.empty() ) { CV_Assert( (sampleIdx.checkVector(1, CV_32S, true) > 0 && checkRange(sampleIdx, true, 0, 0, nsamples)) || - sampleIdx.checkVector(1, CV_8U, true) == nsamples ); - if( sampleIdx.type() == CV_8U ) + sampleIdx.checkVector(1, CV_8U, true) == nsamples); + if( sampleIdx.type() == CV_8UC1 ) sampleIdx = convertMaskToIdx(sampleIdx); } @@ -271,7 +271,7 @@ class TrainDataImpl CV_FINAL : public TrainData } else { - sampleWeights = Mat::ones(nsamples, 1, CV_32F); + sampleWeights = Mat::ones(nsamples, 1, CV_32FC1); } if( !varIdx.empty() ) @@ -279,7 +279,7 @@ class TrainDataImpl CV_FINAL : public TrainData CV_Assert( (varIdx.checkVector(1, CV_32S, true) > 0 && checkRange(varIdx, true, 0, 0, ninputvars)) || varIdx.checkVector(1, CV_8U, true) == ninputvars ); - if( varIdx.type() == CV_8U ) + if( varIdx.type() == CV_8UC1 ) varIdx = convertMaskToIdx(varIdx); varIdx = varIdx.clone(); std::sort(varIdx.ptr(), varIdx.ptr() + varIdx.total()); @@ -287,7 +287,7 @@ class TrainDataImpl CV_FINAL : public TrainData if( !responses.empty() ) { - CV_Assert( responses.type() == CV_32F || responses.type() == CV_32S ); + CV_Assert( responses.type() == CV_32FC1 || responses.type() == CV_32SC1 ); if( (responses.cols == 1 || responses.rows == 1) && (int)responses.total() == nsamples ) noutputvars = 1; else @@ -313,10 +313,10 @@ class TrainDataImpl CV_FINAL : public TrainData } else { - varType.create(1, nvars, CV_8U); + varType.create(1, nvars, CV_8UC1); varType = Scalar::all(VAR_ORDERED); if( noutputvars == 1 ) - varType.at(ninputvars) = (uchar)(responses.type() < CV_32F ? VAR_CATEGORICAL : VAR_ORDERED); + varType.at(ninputvars) = (uchar)(responses.type() < CV_32FC1 ? VAR_CATEGORICAL : VAR_ORDERED); } if( noutputvars > 1 ) @@ -326,18 +326,18 @@ class TrainDataImpl CV_FINAL : public TrainData } catOfs = Mat::zeros(1, nvars, CV_32SC2); - missingSubst = Mat::zeros(1, nvars, CV_32F); + missingSubst = Mat::zeros(1, nvars, CV_32FC1); vector labels, counters, sortbuf, tempCatMap; vector tempCatOfs; CatMapHash ofshash; AutoBuffer buf(nsamples); - Mat non_missing(layout == ROW_SAMPLE ? Size(1, nsamples) : Size(nsamples, 1), CV_8U, buf.data()); + Mat non_missing(layout == ROW_SAMPLE ? Size(1, nsamples) : Size(nsamples, 1), CV_8UC1, buf.data()); bool haveMissing = !missing.empty(); if( haveMissing ) { - CV_Assert( missing.size() == samples.size() && missing.type() == CV_8U ); + CV_Assert( missing.size() == samples.size() && missing.type() == CV_8UC1 ); } // we iterate through all the variables. For each categorical variable we build a map @@ -412,7 +412,7 @@ class TrainDataImpl CV_FINAL : public TrainData Mat convertMaskToIdx(const Mat& mask) { int i, j, nz = countNonZero(mask), n = mask.cols + mask.rows - 1; - Mat idx(1, nz, CV_32S); + Mat idx(1, nz, CV_32SC1); for( i = j = 0; i < n; i++ ) if( mask.at(i) ) idx.at(j++) = i; @@ -430,13 +430,13 @@ class TrainDataImpl CV_FINAL : public TrainData void preprocessCategorical(const Mat& data, Mat* normdata, vector& labels, vector* counters, vector& sortbuf) { - CV_Assert((data.cols == 1 || data.rows == 1) && (data.type() == CV_32S || data.type() == CV_32F)); + CV_Assert((data.cols == 1 || data.rows == 1) && (data.type() == CV_32SC1 || data.type() == CV_32FC1)); int* odata = 0; int ostep = 0; if(normdata) { - normdata->create(data.size(), CV_32S); + normdata->create(data.size(), CV_32SC1); odata = normdata->ptr(); ostep = normdata->isContinuous() ? 1 : (int)normdata->step1(); } @@ -447,7 +447,7 @@ class TrainDataImpl CV_FINAL : public TrainData int* idata = (int*)data.ptr(); int istep = data.isContinuous() ? 1 : (int)data.step1(); - if( data.type() == CV_32F ) + if( data.type() == CV_32FC1 ) { idata = idx + n; const float* fdata = data.ptr(); @@ -616,7 +616,7 @@ class TrainDataImpl CV_FINAL : public TrainData allresponses.push_back(rowvals[i]); rowvals.pop_back(); } - Mat rmat(1, ninputvars, CV_32F, &rowvals[0]); + Mat rmat(1, ninputvars, CV_32FC1, &rowvals[0]); tempSamples.push_back(rmat); } @@ -653,12 +653,12 @@ class TrainDataImpl CV_FINAL : public TrainData //If there are responses in the csv file, save them. If not, responses matrix will contain just zeros if (noutputvars != 0){ - Mat(nsamples, noutputvars, CV_32F, &allresponses[0]).copyTo(tempResponses); + Mat(nsamples, noutputvars, CV_32FC1, &allresponses[0]).copyTo(tempResponses); setData(tempSamples, ROW_SAMPLE, tempResponses, noArray(), noArray(), noArray(), Mat(vtypes).clone(), tempMissing); } else{ - Mat zero_mat(nsamples, 1, CV_32F, Scalar(0)); + Mat zero_mat(nsamples, 1, CV_32FC1, Scalar(0)); zero_mat.copyTo(tempResponses); setData(tempSamples, ROW_SAMPLE, tempResponses, noArray(), noArray(), noArray(), noArray(), tempMissing); @@ -785,12 +785,12 @@ class TrainDataImpl CV_FINAL : public TrainData testSampleIdx = sampleIdx; else { - Mat mask(1, nsamples, CV_8U); + Mat mask(1, nsamples, CV_8UC1); uchar* mptr = mask.ptr(); for( i = 0; i < nsamples; i++ ) mptr[i] = (uchar)(i < count); - trainSampleIdx.create(1, count, CV_32S); - testSampleIdx.create(1, nsamples - count, CV_32S); + trainSampleIdx.create(1, count, CV_32SC1); + testSampleIdx.create(1, nsamples - count, CV_32SC1); int j0 = 0, j1 = 0; const int* sptr = !sampleIdx.empty() ? sampleIdx.ptr() : 0; int* trainptr = trainSampleIdx.ptr(); @@ -868,7 +868,7 @@ class TrainDataImpl CV_FINAL : public TrainData std::swap(sstep, vstep); } - Mat dsamples(drows, dcols, CV_32F); + Mat dsamples(drows, dcols, CV_32FC1); for( int i = 0; i < drows; i++ ) { diff --git a/modules/ml/src/em.cpp b/modules/ml/src/em.cpp index c2dfc9c5235e..d56ad0c6c34f 100644 --- a/modules/ml/src/em.cpp +++ b/modules/ml/src/em.cpp @@ -162,7 +162,7 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM { bool needprobs = _outputs.needed(); Mat samples = _inputs.getMat(), probs, probsrow; - int ptype = CV_64F; + ElemType ptype = CV_64FC1; float firstres = 0.f; int i, nsamples = samples.rows; @@ -189,7 +189,7 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM Vec2d predict2(InputArray _sample, OutputArray _probs) const CV_OVERRIDE { - int ptype = CV_64F; + ElemType ptype = CV_64FC1; Mat sample = _sample.getMat(); CV_Assert(isTrained()); @@ -197,7 +197,7 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM if(sample.type() != CV_64FC1) { Mat tmp; - sample.convertTo(tmp, CV_64FC1); + sample.convertTo(tmp, CV_64F); sample = tmp; } sample = sample.reshape(1, 1); @@ -293,12 +293,12 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM } } - static void preprocessSampleData(const Mat& src, Mat& dst, int dstType, bool isAlwaysClone) + static void preprocessSampleData(const Mat& src, Mat& dst, ElemType dstType, bool isAlwaysClone) { if(src.type() == dstType && !isAlwaysClone) dst = src; else - src.convertTo(dst, dstType); + src.convertTo(dst, CV_MAT_DEPTH(dstType)); } static void preprocessProbability(Mat& probs) @@ -343,21 +343,21 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM // set weights if(weights0 && (startStep == START_E_STEP && covs0)) { - weights0->convertTo(weights, CV_64FC1); + weights0->convertTo(weights, CV_64F); weights = weights.reshape(1,1); preprocessProbability(weights); } // set means if(means0 && (startStep == START_E_STEP/* || startStep == START_AUTO_STEP*/)) - means0->convertTo(means, isKMeansInit ? CV_32FC1 : CV_64FC1); + means0->convertTo(means, isKMeansInit ? CV_32F : CV_64F); // set covs if(covs0 && (startStep == START_E_STEP && weights0)) { covs.resize(nclusters); for(size_t i = 0; i < covs0->size(); i++) - (*covs0)[i].convertTo(covs[i], CV_64FC1); + (*covs0)[i].convertTo(covs[i], CV_64F); } } @@ -402,13 +402,13 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM // Convert samples and means to 32F, because kmeans requires this type. Mat trainSamplesFlt, meansFlt; if(trainSamples.type() != CV_32FC1) - trainSamples.convertTo(trainSamplesFlt, CV_32FC1); + trainSamples.convertTo(trainSamplesFlt, CV_32F); else trainSamplesFlt = trainSamples; if(!means.empty()) { if(means.type() != CV_32FC1) - means.convertTo(meansFlt, CV_32FC1); + means.convertTo(meansFlt, CV_32F); else meansFlt = means; } @@ -423,10 +423,10 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM if(trainSamples.type() != CV_64FC1) { Mat trainSamplesBuffer; - trainSamplesFlt.convertTo(trainSamplesBuffer, CV_64FC1); + trainSamplesFlt.convertTo(trainSamplesBuffer, CV_64F); trainSamples = trainSamplesBuffer; } - meansFlt.convertTo(means, CV_64FC1); + meansFlt.convertTo(means, CV_64F); // Compute weights and covs weights = Mat(1, nclusters, CV_64FC1, Scalar(0)); @@ -445,7 +445,7 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM CV_Assert(!clusterSamples.empty()); calcCovarMatrix(clusterSamples, covs[clusterIndex], means.row(clusterIndex), - CV_COVAR_NORMAL + CV_COVAR_ROWS + CV_COVAR_USE_AVG + CV_COVAR_SCALE, CV_64FC1); + CV_COVAR_NORMAL + CV_COVAR_ROWS + CV_COVAR_USE_AVG + CV_COVAR_SCALE, CV_64F); weights.at(clusterIndex) = static_cast(clusterSamples.rows)/static_cast(nsamples); } @@ -556,7 +556,7 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM return true; } - Vec2d computeProbabilities(const Mat& sample, Mat* probs, int ptype) const + Vec2d computeProbabilities(const Mat& sample, Mat* probs, ElemType ptype) const { // L_ik = log(weight_k) - 0.5 * log(|det(cov_k)|) - 0.5 *(x_i - mean_k)' cov_k^(-1) (x_i - mean_k)] // q = arg(max_k(L_ik)) @@ -564,20 +564,20 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM // see Alex Smola's blog http://blog.smola.org/page/2 for // details on the log-sum-exp trick - int stype = sample.type(); + ElemType stype = sample.type(); CV_Assert(!means.empty()); - CV_Assert((stype == CV_32F || stype == CV_64F) && (ptype == CV_32F || ptype == CV_64F)); + CV_Assert((stype == CV_32FC1 || stype == CV_64FC1) && (ptype == CV_32FC1 || ptype == CV_64FC1)); CV_Assert(sample.size() == Size(means.cols, 1)); int dim = sample.cols; - Mat L(1, nclusters, CV_64FC1), centeredSample(1, dim, CV_64F); + Mat L(1, nclusters, CV_64FC1), centeredSample(1, dim, CV_64FC1); int i, label = 0; for(int clusterIndex = 0; clusterIndex < nclusters; clusterIndex++) { const double* mptr = means.ptr(clusterIndex); double* dptr = centeredSample.ptr(); - if( stype == CV_32F ) + if (stype == CV_32FC1) { const float* sptr = sample.ptr(); for( i = 0; i < dim; i++ ) @@ -618,7 +618,7 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM CV_Assert(expDiffSum > 0); if(probs) - L.convertTo(*probs, ptype, 1./expDiffSum); + L.convertTo(*probs, CV_MAT_DEPTH(ptype), 1./expDiffSum); Vec2d res; res[0] = std::log(expDiffSum) + maxLVal - 0.5 * dim * CV_LOG2PI; @@ -642,7 +642,7 @@ class CV_EXPORTS EMImpl CV_FINAL : public EM for(int sampleIndex = 0; sampleIndex < trainSamples.rows; sampleIndex++) { Mat sampleProbs = trainProbs.row(sampleIndex); - Vec2d res = computeProbabilities(trainSamples.row(sampleIndex), &sampleProbs, CV_64F); + Vec2d res = computeProbabilities(trainSamples.row(sampleIndex), &sampleProbs, CV_64FC1); trainLogLikelihoods.at(sampleIndex) = res[0]; trainLabels.at(sampleIndex) = static_cast(res[1]); } diff --git a/modules/ml/src/gbt.cpp b/modules/ml/src/gbt.cpp index 57f2eb176b9f..f2f77557b8fe 100644 --- a/modules/ml/src/gbt.cpp +++ b/modules/ml/src/gbt.cpp @@ -191,7 +191,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag, CV_SWAP(n,m,tmp); } - CvMat* new_responses = cvCreateMat( n, 1, CV_32F); + CvMat* new_responses = cvCreateMat( n, 1, CV_32FC1); cvZero(new_responses); data = new CvDTreeTrainData( _train_data, _tflag, new_responses, _var_idx, @@ -203,7 +203,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag, cvCopy( _missing_mask, missing); } - orig_response = cvCreateMat( 1, n, CV_32F ); + orig_response = cvCreateMat( 1, n, CV_32FC1 ); int step = (_responses->cols > _responses->rows) ? 1 : _responses->step / CV_ELEM_SIZE(_responses->type); switch (CV_MAT_TYPE(_responses->type)) { @@ -237,7 +237,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag, } delete[] mask; - class_labels = cvCreateMat(1, class_count, CV_32S); + class_labels = cvCreateMat(1, class_count, CV_32SC1); class_labels->data.i[0] = int(orig_response->data.fl[0]); int j = 1; for (int i=1; idata.i[i] = _sample_idx->data.i[i]; std::sort(sample_idx->data.i, sample_idx->data.i + sample_idx_len); @@ -276,7 +276,7 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag, int active_samples_count = 0; for (int i=0; idata.ptr[i] ); - sample_idx = cvCreateMat( 1, active_samples_count, CV_32S ); + sample_idx = cvCreateMat( 1, active_samples_count, CV_32SC1 ); active_samples_count = 0; for (int i=0; idata.ptr[i] )) @@ -288,13 +288,13 @@ CvGBTrees::train( const CvMat* _train_data, int _tflag, } else { - sample_idx = cvCreateMat( 1, n, CV_32S ); + sample_idx = cvCreateMat( 1, n, CV_32SC1 ); for (int i=0; idata.i[i] = i; } - sum_response = cvCreateMat(class_count, n, CV_32F); - sum_response_tmp = cvCreateMat(class_count, n, CV_32F); + sum_response = cvCreateMat(class_count, n, CV_32FC1); + sum_response_tmp = cvCreateMat(class_count, n, CV_32FC1); cvZero(sum_response); delta = 0.0f; @@ -574,7 +574,7 @@ void CvGBTrees::change_values(CvDTree* tree, const int _k) continue; } - CvMat* leaf_idx = cvCreateMat(1, samples_in_leaf, CV_32S); + CvMat* leaf_idx = cvCreateMat(1, samples_in_leaf, CV_32SC1); int* leaf_idx_data = leaf_idx->data.i; for (int j=0; jget_sample_indices(leaves[i], leaf_idx_data); //CvMat* leaf_idx = new CvMat(); - //cvInitMatHeader(leaf_idx, n, 1, CV_32S, leaf_idx_data); + //cvInitMatHeader(leaf_idx, n, 1, CV_32SC1, leaf_idx_data); leaf_idx.cols = n; leaf_idx.data.i = leaf_idx_data; @@ -793,7 +793,7 @@ void CvGBTrees::do_subsample() /* int n = get_len(sample_idx); if (subsample_train == 0) - subsample_train = cvCreateMat(1, n, CV_32S); + subsample_train = cvCreateMat(1, n, CV_32SC1); int* subsample_data = subsample_train->data.i; for (int i=0; i& data, bool testerr, OutputArray Mat resp; if (_resp.needed()) - resp.create(n, 1, CV_32F); + resp.create(n, 1, CV_32FC1); double err = 0; vector errStrip(n,0.0); @@ -174,7 +174,7 @@ float StatModel::calcError(const Ptr& data, bool testerr, OutputArray static void Cholesky( const Mat& A, Mat& S ) { CV_TRACE_FUNCTION(); - CV_Assert(A.type() == CV_32F); + CV_Assert(A.type() == CV_32FC1); S = A.clone(); cv::Cholesky ((float*)S.ptr(),S.step, S.rows,NULL, 0, 0); @@ -197,7 +197,7 @@ void randMVNormal( InputArray _mean, InputArray _cov, int nsamples, OutputArray mean = mean.reshape(1,1); // ensure a row vector // generate n-samples of the same dimension, from ~N(0,1) - _samples.create(nsamples, dim, CV_32F); + _samples.create(nsamples, dim, CV_32FC1); Mat samples = _samples.getMat(); randn(samples, Scalar::all(0), Scalar::all(1)); diff --git a/modules/ml/src/kdtree.cpp b/modules/ml/src/kdtree.cpp index 1ab840093697..9d737650f1c6 100644 --- a/modules/ml/src/kdtree.cpp +++ b/modules/ml/src/kdtree.cpp @@ -164,7 +164,7 @@ void KDTree::build(InputArray _points, bool _copyData) void KDTree::build(InputArray __points, InputArray __labels, bool _copyData) { Mat _points = __points.getMat(), _labels = __labels.getMat(); - CV_Assert(_points.type() == CV_32F && !_points.empty()); + CV_Assert(_points.type() == CV_32FC1 && !_points.empty()); std::vector().swap(nodes); if( !_copyData ) @@ -191,7 +191,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData) _labels_data = _labels.ptr(); } - Mat sumstack(MAX_TREE_DEPTH*2, ptdims*2, CV_64F); + Mat sumstack(MAX_TREE_DEPTH*2, ptdims*2, CV_64FC1); SubTree stack[MAX_TREE_DEPTH*2]; std::vector _ptofs(n); @@ -277,7 +277,7 @@ int KDTree::findNearest(InputArray _vec, int K, int emax, { Mat vecmat = _vec.getMat(); - CV_Assert( vecmat.isContinuous() && vecmat.type() == CV_32F && vecmat.total() == (size_t)points.cols ); + CV_Assert( vecmat.isContinuous() && vecmat.type() == CV_32FC1 && vecmat.total() == (size_t)points.cols ); const float* vec = vecmat.ptr(); K = std::min(K, points.rows); int ptdims = points.cols; @@ -401,15 +401,15 @@ int KDTree::findNearest(InputArray _vec, int K, int emax, K = std::min(K, ncount); if( _neighborsIdx.needed() ) { - _neighborsIdx.create(K, 1, CV_32S, -1, true); + _neighborsIdx.create(K, 1, CV_32SC1, -1, true); Mat nidx = _neighborsIdx.getMat(); - Mat(nidx.size(), CV_32S, &idx[0]).copyTo(nidx); + Mat(nidx.size(), CV_32SC1, &idx[0]).copyTo(nidx); } if( _dist.needed() ) - sqrt(Mat(K, 1, CV_32F, dist), _dist); + sqrt(Mat(K, 1, CV_32FC1, dist), _dist); if( _neighbors.needed() || _labels.needed() ) - getPoints(Mat(K, 1, CV_32S, idx), _neighbors, _labels); + getPoints(Mat(K, 1, CV_32SC1, idx), _neighbors, _labels); return K; } @@ -426,7 +426,7 @@ void KDTree::findOrthoRange(InputArray _lowerBound, lowerBound.isContinuous() && upperBound.isContinuous() && lowerBound.type() == upperBound.type() && - lowerBound.type() == CV_32F && + lowerBound.type() == CV_32FC1 && lowerBound.total() == (size_t)ptdims ); const float* L = lowerBound.ptr(); const float* R = upperBound.ptr(); @@ -463,9 +463,9 @@ void KDTree::findOrthoRange(InputArray _lowerBound, if( _neighborsIdx.needed() ) { - _neighborsIdx.create((int)idx.size(), 1, CV_32S, -1, true); + _neighborsIdx.create((int)idx.size(), 1, CV_32SC1, -1, true); Mat nidx = _neighborsIdx.getMat(); - Mat(nidx.size(), CV_32S, &idx[0]).copyTo(nidx); + Mat(nidx.size(), CV_32SC1, &idx[0]).copyTo(nidx); } getPoints( idx, _neighbors, _labels ); } @@ -474,7 +474,7 @@ void KDTree::findOrthoRange(InputArray _lowerBound, void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) const { Mat idxmat = _idx.getMat(), pts, labelsmat; - CV_Assert( idxmat.isContinuous() && idxmat.type() == CV_32S && + CV_Assert( idxmat.isContinuous() && idxmat.type() == CV_32SC1 && (idxmat.cols == 1 || idxmat.rows == 1) ); const int* idx = idxmat.ptr(); int* dstlabels = 0; @@ -496,7 +496,7 @@ void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) c if(_labels.needed()) { - _labels.create(nidx, 1, CV_32S, -1, true); + _labels.create(nidx, 1, CV_32SC1, -1, true); labelsmat = _labels.getMat(); CV_Assert( labelsmat.isContinuous() ); dstlabels = labelsmat.ptr(); diff --git a/modules/ml/src/knearest.cpp b/modules/ml/src/knearest.cpp index cee7bdfdb005..178ad930f088 100644 --- a/modules/ml/src/knearest.cpp +++ b/modules/ml/src/knearest.cpp @@ -78,7 +78,7 @@ class Impl data->getTrainResponses().convertTo(new_responses, CV_32F); bool update = (flags & ml::KNearest::UPDATE_MODEL) != 0 && !samples.empty(); - CV_Assert( new_samples.type() == CV_32F ); + CV_Assert( new_samples.type() == CV_32FC1 ); if( !update ) { @@ -309,7 +309,7 @@ class BruteForceImpl CV_FINAL : public Impl k = std::min(k, samples.rows); Mat test_samples = _samples.getMat(); - CV_Assert( test_samples.type() == CV_32F && test_samples.cols == samples.cols ); + CV_Assert( test_samples.type() == CV_32FC1 && test_samples.cols == samples.cols ); int testcount = test_samples.rows; if( testcount == 0 ) @@ -323,17 +323,17 @@ class BruteForceImpl CV_FINAL : public Impl Mat res, nr, d, *pres = 0, *pnr = 0, *pd = 0; if( _results.needed() ) { - _results.create(testcount, 1, CV_32F); + _results.create(testcount, 1, CV_32FC1); pres = &(res = _results.getMat()); } if( _neighborResponses.needed() ) { - _neighborResponses.create(testcount, k, CV_32F); + _neighborResponses.create(testcount, k, CV_32FC1); pnr = &(nr = _neighborResponses.getMat()); } if( _dists.needed() ) { - _dists.create(testcount, k, CV_32F); + _dists.create(testcount, k, CV_32FC1); pd = &(d = _dists.getMat()); } @@ -366,7 +366,7 @@ class KDTreeImpl CV_FINAL : public Impl k = std::min(k, samples.rows); Mat test_samples = _samples.getMat(); - CV_Assert( test_samples.type() == CV_32F && test_samples.cols == samples.cols ); + CV_Assert( test_samples.type() == CV_32FC1 && test_samples.cols == samples.cols ); int testcount = test_samples.rows; if( testcount == 0 ) @@ -380,17 +380,17 @@ class KDTreeImpl CV_FINAL : public Impl Mat res, nr, d; if( _results.needed() ) { - _results.create(testcount, 1, CV_32F); + _results.create(testcount, 1, CV_32FC1); res = _results.getMat(); } if( _neighborResponses.needed() ) { - _neighborResponses.create(testcount, k, CV_32F); + _neighborResponses.create(testcount, k, CV_32FC1); nr = _neighborResponses.getMat(); } if( _dists.needed() ) { - _dists.create(testcount, k, CV_32F); + _dists.create(testcount, k, CV_32FC1); d = _dists.getMat(); } diff --git a/modules/ml/src/lr.cpp b/modules/ml/src/lr.cpp index 166b6a39d802..b8783d8ed0c1 100644 --- a/modules/ml/src/lr.cpp +++ b/modules/ml/src/lr.cpp @@ -178,11 +178,11 @@ bool LogisticRegressionImpl::train(const Ptr& trainData, int) // add a column of ones to the data (bias/intercept term) Mat data_t; - hconcat( cv::Mat::ones( _data_i.rows, 1, CV_32F ), _data_i, data_t ); + hconcat( cv::Mat::ones( _data_i.rows, 1, CV_32FC1 ), _data_i, data_t ); // coefficient matrix (zero-initialized) Mat thetas; - Mat init_theta = Mat::zeros(data_t.cols, 1, CV_32F); + Mat init_theta = Mat::zeros(data_t.cols, 1, CV_32FC1); // fit the model (handles binary and multiclass cases) Mat new_theta; @@ -200,7 +200,7 @@ bool LogisticRegressionImpl::train(const Ptr& trainData, int) { /* take each class and rename classes you will get a theta per class as in multi class class scenario, we will have n thetas for n classes */ - thetas.create(num_classes, data_t.cols, CV_32F); + thetas.create(num_classes, data_t.cols, CV_32FC1); Mat labels_binary; int ii = 0; for(map::iterator it = this->forward_mapper.begin(); it != this->forward_mapper.end(); ++it) @@ -239,7 +239,7 @@ float LogisticRegressionImpl::predict(InputArray samples, OutputArray results, i // coefficient matrix Mat thetas; - if ( learnt_thetas.type() == CV_32F ) + if ( learnt_thetas.type() == CV_32FC1 ) { thetas = learnt_thetas; } @@ -251,14 +251,14 @@ float LogisticRegressionImpl::predict(InputArray samples, OutputArray results, i // data samples Mat data = samples.getMat(); - if(data.type() != CV_32F) + if(data.depth() != CV_32F) { CV_Error( CV_StsBadArg, "data must be of floating type" ); } // add a column of ones to the data (bias/intercept term) Mat data_t; - hconcat( cv::Mat::ones( data.rows, 1, CV_32F ), data, data_t ); + hconcat( cv::Mat::ones( data.rows, 1, CV_32FC1 ), data, data_t ); CV_Assert(data_t.cols == thetas.cols); // predict class labels for samples (handles binary and multiclass cases) @@ -542,8 +542,8 @@ bool LogisticRegressionImpl::set_label_map(const Mat &_labels_i) int ii = 0; Mat labels; - this->labels_o = Mat(0,1, CV_8U); - this->labels_n = Mat(0,1, CV_8U); + this->labels_o = Mat(0,1, CV_8UC1); + this->labels_n = Mat(0,1, CV_8UC1); _labels_i.convertTo(labels, CV_32S); diff --git a/modules/ml/src/nbayes.cpp b/modules/ml/src/nbayes.cpp index baa46d8f0a48..0584920d61a7 100644 --- a/modules/ml/src/nbayes.cpp +++ b/modules/ml/src/nbayes.cpp @@ -310,7 +310,7 @@ class NormalBayesClassifierImpl : public NormalBayesClassifier int nsamples = samples.rows, nclasses = (int)cls_labels.total(); bool rawOutput = (flags & RAW_OUTPUT) != 0; - if( samples.type() != CV_32F || samples.cols != nallvars ) + if( samples.type() != CV_32FC1 || samples.cols != nallvars ) CV_Error( CV_StsBadArg, "The input samples must be 32f matrix with the number of columns = nallvars" ); @@ -320,15 +320,15 @@ class NormalBayesClassifierImpl : public NormalBayesClassifier if( _results.needed() ) { - _results.create(nsamples, 1, CV_32S); + _results.create(nsamples, 1, CV_32SC1); results = _results.getMat(); } else - results = Mat(1, 1, CV_32S, &value); + results = Mat(1, 1, CV_32SC1, &value); if( _resultsProb.needed() ) { - _resultsProb.create(nsamples, nclasses, CV_32F); + _resultsProb.create(nsamples, nclasses, CV_32FC1); resultsProb = _resultsProb.getMat(); } diff --git a/modules/ml/src/precomp.hpp b/modules/ml/src/precomp.hpp index 6d50357b7a45..f5a4b9f44a40 100644 --- a/modules/ml/src/precomp.hpp +++ b/modules/ml/src/precomp.hpp @@ -221,7 +221,8 @@ namespace ml { WNode() { - class_idx = sample_count = depth = complexity = 0; + class_idx = sample_count = complexity = 0; + depth = CV_8U; parent = left = right = split = defaultDir = -1; Tn = INT_MAX; value = maxlr = alpha = node_risk = tree_risk = tree_error = 0.; diff --git a/modules/ml/src/rtrees.cpp b/modules/ml/src/rtrees.cpp index b7e32b92b005..8b4d8440e52e 100644 --- a/modules/ml/src/rtrees.cpp +++ b/modules/ml/src/rtrees.cpp @@ -154,7 +154,7 @@ class DTreesImplForRTrees CV_FINAL : public DTreesImpl Mat samples = w->data->getSamples(); float* psamples = samples.ptr(); size_t sstep0 = samples.step1(), sstep1 = 1; - Mat sample0, sample(nallvars, 1, CV_32F, &samplebuf[0]); + Mat sample0, sample(nallvars, 1, CV_32FC1, &samplebuf[0]); int predictFlags = _isClassifier ? (PREDICT_MAX_VOTE + RAW_OUTPUT) : PREDICT_SUM; bool calcOOBError = eps > 0 || rparams.calcVarImportance; @@ -210,7 +210,7 @@ class DTreesImplForRTrees CV_FINAL : public DTreesImpl for( i = 0; i < n_oob; i++ ) { j = oobidx[i]; - sample = Mat( nallvars, 1, CV_32F, psamples + sstep0*w->sidx[j], sstep1*sizeof(psamples[0]) ); + sample = Mat( nallvars, 1, CV_32FC1, psamples + sstep0*w->sidx[j], sstep1*sizeof(psamples[0]) ); double val = predictTrees(Range(treeidx, treeidx+1), sample, predictFlags); if( !_isClassifier ) @@ -261,7 +261,7 @@ class DTreesImplForRTrees CV_FINAL : public DTreesImpl { j = oobidx[i]; int vj = oobperm[i]; - sample0 = Mat( nallvars, 1, CV_32F, psamples + sstep0*w->sidx[j], sstep1*sizeof(psamples[0]) ); + sample0 = Mat( nallvars, 1, CV_32FC1, psamples + sstep0*w->sidx[j], sstep1*sizeof(psamples[0]) ); sample0.copyTo(sample_clone); //create a copy so we don't mess up the original data sample_clone.at(vi) = psamples[sstep0*w->sidx[vj] + sstep1*vi]; @@ -380,7 +380,7 @@ class DTreesImplForRTrees CV_FINAL : public DTreesImpl if( predictType == PREDICT_SUM ) { - output.create(nsamples, ntrees, CV_32F); + output.create(nsamples, ntrees, CV_32FC1); results = output.getMat(); for( i = 0; i < nsamples; i++ ) { @@ -393,7 +393,7 @@ class DTreesImplForRTrees CV_FINAL : public DTreesImpl } else { vector votes; - output.create(nsamples+1, nclasses, CV_32S); + output.create(nsamples+1, nclasses, CV_32SC1); results = output.getMat(); for ( j = 0; j < nclasses; j++) diff --git a/modules/ml/src/svm.cpp b/modules/ml/src/svm.cpp index 02043ac9298b..1bd6cbd0ace2 100644 --- a/modules/ml/src/svm.cpp +++ b/modules/ml/src/svm.cpp @@ -89,7 +89,7 @@ namespace cv { namespace ml { typedef float Qfloat; -const int QFLOAT_TYPE = DataDepth::value; +const ElemType QFLOAT_TYPE = CV_MAKETYPE(DataDepth::value, 1); // Param Grid static void checkParamGrid(const ParamGrid& pg) @@ -1378,7 +1378,7 @@ class SVMImpl CV_FINAL : public SVM vector _alpha; Solver::SolutionInfo sinfo; - CV_Assert( _samples.type() == CV_32F ); + CV_Assert( _samples.type() == CV_32FC1 ); var_count = _samples.cols; if( svmType == ONE_CLASS || svmType == EPS_SVR || svmType == NU_SVR ) @@ -1403,7 +1403,7 @@ class SVMImpl CV_FINAL : public SVM CV_Assert(sv_count != 0); - sv.create(sv_count, _samples.cols, CV_32F); + sv.create(sv_count, _samples.cols, CV_32FC1); df_alpha.resize(sv_count); df_index.resize(sv_count); @@ -1436,7 +1436,7 @@ class SVMImpl CV_FINAL : public SVM if( (cw.cols != 1 && cw.rows != 1) || (int)cw.total() != class_count || - (cw.type() != CV_32F && cw.type() != CV_64F) ) + (cw.type() != CV_32FC1 && cw.type() != CV_64FC1) ) CV_Error( CV_StsBadArg, "params.class_weights must be 1d floating-point vector " "containing as many elements as the number of classes" ); @@ -1580,7 +1580,7 @@ class SVMImpl CV_FINAL : public SVM AutoBuffer vbuf(var_count); double* v = vbuf.data(); - Mat new_sv(df_count, var_count, CV_32F); + Mat new_sv(df_count, var_count, CV_32FC1); vector new_df; @@ -1669,10 +1669,10 @@ class SVMImpl CV_FINAL : public SVM cv::Ptr svm = makePtr(); svm->class_labels = labels; - int rtype = responses.type(); + ElemType rtype = responses.type(); - Mat temp_train_samples(train_sample_count, var_count_, CV_32F); - Mat temp_test_samples(test_sample_count, var_count_, CV_32F); + Mat temp_train_samples(train_sample_count, var_count_, CV_32FC1); + Mat temp_test_samples(test_sample_count, var_count_, CV_32FC1); Mat temp_train_responses(train_sample_count, 1, rtype); Mat temp_test_responses; @@ -1807,7 +1807,7 @@ class SVMImpl CV_FINAL : public SVM else responses = data->getTrainResponses(); - CV_Assert(samples.type() == CV_32F); + CV_Assert(samples.type() == CV_32FC1); int sample_count = samples.rows; var_count = samples.cols; @@ -2007,7 +2007,7 @@ class SVMImpl CV_FINAL : public SVM int nsamples = samples.rows; bool returnDFVal = (flags & RAW_OUTPUT) != 0; - CV_Assert( samples.cols == var_count && samples.type() == CV_32F ); + CV_Assert( samples.cols == var_count && samples.type() == CV_32FC1 ); if( _results.needed() ) { @@ -2017,7 +2017,7 @@ class SVMImpl CV_FINAL : public SVM else { CV_Assert( nsamples == 1 ); - results = Mat(1, 1, CV_32F, &result); + results = Mat(1, 1, CV_32FC1, &result); } PredictBody invoker(this, samples, results, returnDFVal); @@ -2033,8 +2033,8 @@ class SVMImpl CV_FINAL : public SVM CV_Assert( 0 <= i && i < (int)decision_func.size()); const DecisionFunc& df = decision_func[i]; int count = getSVCount(i); - Mat(1, count, CV_64F, (double*)&df_alpha[df.ofs]).copyTo(_alpha); - Mat(1, count, CV_32S, (int*)&df_index[df.ofs]).copyTo(_svidx); + Mat(1, count, CV_64FC1, (double*)&df_alpha[df.ofs]).copyTo(_alpha); + Mat(1, count, CV_32SC1, (int*)&df_index[df.ofs]).copyTo(_svidx); return df.rho; } @@ -2273,7 +2273,7 @@ class SVMImpl CV_FINAL : public SVM CV_Assert((int)sv_node.size() == sv_total); - sv.create(sv_total, var_count, CV_32F); + sv.create(sv_total, var_count, CV_32FC1); FileNodeIterator sv_it = sv_node.begin(); for( i = 0; i < sv_total; i++, ++sv_it ) { @@ -2288,7 +2288,7 @@ class SVMImpl CV_FINAL : public SVM FileNode uncompressed_sv_node = fn["uncompressed_support_vectors"]; CV_Assert((int)uncompressed_sv_node.size() == uncompressed_sv_total); - uncompressed_sv.create(uncompressed_sv_total, var_count, CV_32F); + uncompressed_sv.create(uncompressed_sv_total, var_count, CV_32FC1); FileNodeIterator uncompressed_sv_it = uncompressed_sv_node.begin(); for( i = 0; i < uncompressed_sv_total; i++, ++uncompressed_sv_it ) diff --git a/modules/ml/src/svmsgd.cpp b/modules/ml/src/svmsgd.cpp index ac778f4da85d..5f60fb74fff3 100644 --- a/modules/ml/src/svmsgd.cpp +++ b/modules/ml/src/svmsgd.cpp @@ -177,7 +177,7 @@ void SVMSGDImpl::makeExtendedTrainSamples(const Mat &trainSamples, Mat &extended normalizeSamples(normalizedTrainSamples, average, multiplier); - Mat onesCol = Mat::ones(samplesCount, 1, CV_32F); + Mat onesCol = Mat::ones(samplesCount, 1, CV_32FC1); cv::hconcat(normalizedTrainSamples, onesCol, extendedTrainSamples); } @@ -250,7 +250,7 @@ bool SVMSGDImpl::train(const Ptr& data, int) if ( positiveCount <= 0 || negativeCount <= 0 ) { - weights_ = Mat::zeros(1, featureCount, CV_32F); + weights_ = Mat::zeros(1, featureCount, CV_32FC1); shift_ = (positiveCount > 0) ? 1.f : -1.f; return true; } @@ -263,12 +263,12 @@ bool SVMSGDImpl::train(const Ptr& data, int) int extendedTrainSamplesCount = extendedTrainSamples.rows; int extendedFeatureCount = extendedTrainSamples.cols; - Mat extendedWeights = Mat::zeros(1, extendedFeatureCount, CV_32F); - Mat previousWeights = Mat::zeros(1, extendedFeatureCount, CV_32F); + Mat extendedWeights = Mat::zeros(1, extendedFeatureCount, CV_32FC1); + Mat previousWeights = Mat::zeros(1, extendedFeatureCount, CV_32FC1); Mat averageExtendedWeights; if (params.svmsgdType == ASGD) { - averageExtendedWeights = Mat::zeros(1, extendedFeatureCount, CV_32F); + averageExtendedWeights = Mat::zeros(1, extendedFeatureCount, CV_32FC1); } RNG rng(0); diff --git a/modules/ml/src/testset.cpp b/modules/ml/src/testset.cpp index 48cd1341543d..1e4e939500ff 100644 --- a/modules/ml/src/testset.cpp +++ b/modules/ml/src/testset.cpp @@ -70,13 +70,13 @@ void createConcentricSpheresTestSet( int num_samples, int num_features, int num_ int i, cur_class; - _samples.create( num_samples, num_features, CV_32F ); - _responses.create( 1, num_samples, CV_32S ); + _samples.create(num_samples, num_features, CV_32FC1); + _responses.create(1, num_samples, CV_32SC1); Mat responses = _responses.getMat(); - Mat mean = Mat::zeros(1, num_features, CV_32F); - Mat cov = Mat::eye(num_features, num_features, CV_32F); + Mat mean = Mat::zeros(1, num_features, CV_32FC1); + Mat cov = Mat::eye(num_features, num_features, CV_32FC1); // fill the feature values matrix with random numbers drawn from standard normal distribution randMVNormal( mean, cov, num_samples, _samples ); diff --git a/modules/ml/src/tree.cpp b/modules/ml/src/tree.cpp index 2f9dc049e14c..792c16fe2dfc 100644 --- a/modules/ml/src/tree.cpp +++ b/modules/ml/src/tree.cpp @@ -177,7 +177,7 @@ void DTreesImpl::startTraining( const Ptr& data, int ) Mat class_weights = params.priors; if( !class_weights.empty() ) { - if( class_weights.type() != CV_64F || !class_weights.isContinuous() ) + if( class_weights.type() != CV_64FC1 || !class_weights.isContinuous() ) { Mat temp; class_weights.convertTo(temp, CV_64F); @@ -1224,7 +1224,7 @@ int DTreesImpl::pruneCV( int root ) ab[ti] = std::sqrt(ab[ti]*ab[ti+1]); ab[tree_count-1] = DBL_MAX*0.5; - Mat err_jk(cv_n, tree_count, CV_64F); + Mat err_jk(cv_n, tree_count, CV_64FC1); for( j = 0; j < cv_n; j++ ) { @@ -1363,7 +1363,7 @@ bool DTreesImpl::cutTree( int root, double T, int fold, double min_alpha ) float DTreesImpl::predictTrees( const Range& range, const Mat& sample, int flags ) const { - CV_Assert( sample.type() == CV_32F ); + CV_Assert( sample.type() == CV_32FC1 ); int predictType = flags & PREDICT_MASK; int nvars = (int)varIdx.size(); @@ -1498,14 +1498,14 @@ float DTreesImpl::predict( InputArray _samples, OutputArray _results, int flags CV_Assert( !roots.empty() ); Mat samples = _samples.getMat(), results; int i, nsamples = samples.rows; - int rtype = CV_32F; + ElemType rtype = CV_32FC1; bool needresults = _results.needed(); float retval = 0.f; bool iscls = isClassifier(); float scale = !iscls ? 1.f/(int)roots.size() : 1.f; if( iscls && (flags & PREDICT_MASK) == PREDICT_MAX_VOTE ) - rtype = CV_32S; + rtype = CV_32SC1; if( needresults ) { @@ -1520,7 +1520,7 @@ float DTreesImpl::predict( InputArray _samples, OutputArray _results, int flags float val = predictTrees( Range(0, (int)roots.size()), samples.row(i), flags )*scale; if( needresults ) { - if( rtype == CV_32F ) + if (rtype == CV_32FC1) results.at(i) = val; else results.at(i) = cvRound(val); diff --git a/modules/ml/test/test_emknearestkmeans.cpp b/modules/ml/test/test_emknearestkmeans.cpp index 691815c52a0a..04f56d73c755 100644 --- a/modules/ml/test/test_emknearestkmeans.cpp +++ b/modules/ml/test/test_emknearestkmeans.cpp @@ -47,7 +47,7 @@ using cv::ml::TrainData; using cv::ml::EM; using cv::ml::KNearest; -void defaultDistribs( Mat& means, vector& covs, int type=CV_32FC1 ) +void defaultDistribs( Mat& means, vector& covs, ElemType type=CV_32FC1 ) { CV_TRACE_FUNCTION(); float mp0[] = {0.0f, 0.0f}, cp0[] = {0.67f, 0.0f, 0.0f, 0.67f}; @@ -60,20 +60,21 @@ void defaultDistribs( Mat& means, vector& covs, int type=CV_32FC1 ) means.resize(3), covs.resize(3); Mat mr0 = means.row(0); - m0.convertTo(mr0, type); - c0.convertTo(covs[0], type); + ElemDepth depth = CV_MAT_DEPTH(type); + m0.convertTo(mr0, depth); + c0.convertTo(covs[0], depth); Mat mr1 = means.row(1); - m1.convertTo(mr1, type); - c1.convertTo(covs[1], type); + m1.convertTo(mr1, depth); + c1.convertTo(covs[1], depth); Mat mr2 = means.row(2); - m2.convertTo(mr2, type); - c2.convertTo(covs[2], type); + m2.convertTo(mr2, depth); + c2.convertTo(covs[2], depth); } // generate points sets by normal distributions -void generateData( Mat& data, Mat& labels, const vector& sizes, const Mat& _means, const vector& covs, int dataType, int labelType ) +void generateData( Mat& data, Mat& labels, const vector& sizes, const Mat& _means, const vector& covs, int dataType, ElemType labelType ) { CV_TRACE_FUNCTION(); vector::const_iterator sit = sizes.begin(); diff --git a/modules/ml/test/test_mltests.cpp b/modules/ml/test/test_mltests.cpp index db82a44e28b5..8e3b4c9690b2 100644 --- a/modules/ml/test/test_mltests.cpp +++ b/modules/ml/test/test_mltests.cpp @@ -165,8 +165,8 @@ TEST(ML_NBAYES, regression_5911) EXPECT_EQ(sum(P1 == P2)[0], 255 * P2.total()); // bulk prediction, with non-continuous memory storage - Mat R3_(N, 1+1, CV_32S), - P3_(N, 3+1, CV_32F); + Mat R3_(N, 1+1, CV_32SC1), + P3_(N, 3+1, CV_32FC1); nb->predictProb(X, R3_.col(0), P3_.colRange(0,3)); Mat R3 = R3_.col(0).clone(), P3 = P3_.colRange(0,3).clone(); @@ -187,7 +187,7 @@ TEST(ML_RTrees, getVotes) Ptr rt = cv::ml::RTrees::create(); //data - Mat data(n, 4, CV_32F); + Mat data(n, 4, CV_32FC1); randu(data, 0, 10); //labels @@ -196,7 +196,7 @@ TEST(ML_RTrees, getVotes) rt->train(data, ml::ROW_SAMPLE, labels); //run function - Mat test(1, 4, CV_32F); + Mat test(1, 4, CV_32FC1); Mat result; randu(test, 0, 10); rt->getVotes(test, result, 0); diff --git a/modules/ml/test/test_mltests2.cpp b/modules/ml/test/test_mltests2.cpp index 44d5aeb99280..37e11e5aa484 100644 --- a/modules/ml/test/test_mltests2.cpp +++ b/modules/ml/test/test_mltests2.cpp @@ -136,7 +136,7 @@ Mat ann_get_new_responses( Ptr _data, map& cls_map ) if( it == cls_map.end() ) cls_map[r] = cls_count++; } - Mat new_responses = Mat::zeros( nresponses, cls_count, CV_32F ); + Mat new_responses = Mat::zeros( nresponses, cls_count, CV_32FC1); for( si = 0; si < n; si++ ) { int sidx = train_sidx_ptr ? train_sidx_ptr[si] : si; @@ -560,7 +560,7 @@ int CV_MLBaseTest::train( int testCaseIdx ) data = TrainData::create(data->getSamples(), data->getLayout(), new_responses, data->getVarIdx(), data->getTrainSampleIdx()); int layer_sz[] = { data->getNAllVars(), 100, 100, (int)cls_map.size() }; - Mat layer_sizes( 1, (int)(sizeof(layer_sz)/sizeof(layer_sz[0])), CV_32S, layer_sz ); + Mat layer_sizes( 1, (int)(sizeof(layer_sz)/sizeof(layer_sz[0])), CV_32SC1, layer_sz ); Ptr m = ANN_MLP::create(); m->setLayerSizes(layer_sizes); m->setActivationFunction(ANN_MLP::SIGMOID_SYM, 0, 0); diff --git a/modules/ml/test/test_save_load.cpp b/modules/ml/test/test_save_load.cpp index 5be010d65719..0af9188d28bd 100644 --- a/modules/ml/test/test_save_load.cpp +++ b/modules/ml/test/test_save_load.cpp @@ -208,7 +208,7 @@ class CV_LegacyTest : public cvtest::BaseTest } else { - Mat input = Mat(isTree ? 10 : 1, model->getVarCount(), CV_32F); + Mat input = Mat(isTree ? 10 : 1, model->getVarCount(), CV_32FC1); ts->get_rng().fill(input, RNG::UNIFORM, 0, 40); if (isTree) @@ -285,7 +285,7 @@ TEST(DISABLED_ML_SVM, linear_save_load) ASSERT_EQ(svm1->getVarCount(), svm3->getVarCount()); int m = 10000, n = svm1->getVarCount(); - Mat samples(m, n, CV_32F), r1, r2, r3; + Mat samples(m, n, CV_32FC1), r1, r2, r3; randu(samples, 0., 1.); svm1->predict(samples, r1); diff --git a/modules/ml/test/test_svmtrainauto.cpp b/modules/ml/test/test_svmtrainauto.cpp index 6d7a73eaefff..fcab5e2e0963 100644 --- a/modules/ml/test/test_svmtrainauto.cpp +++ b/modules/ml/test/test_svmtrainauto.cpp @@ -58,7 +58,7 @@ void CV_SVMTrainAutoTest::run( int /*start_from*/ ) { int datasize = 100; cv::Mat samples = cv::Mat::zeros( datasize, 2, CV_32FC1 ); - cv::Mat responses = cv::Mat::zeros( datasize, 1, CV_32S ); + cv::Mat responses = cv::Mat::zeros( datasize, 1, CV_32SC1); RNG rng(0); for (int i = 0; i < datasize; ++i) @@ -93,7 +93,7 @@ TEST(ML_SVM, trainAuto_regression_5369) { int datasize = 100; cv::Mat samples = cv::Mat::zeros( datasize, 2, CV_32FC1 ); - cv::Mat responses = cv::Mat::zeros( datasize, 1, CV_32S ); + cv::Mat responses = cv::Mat::zeros( datasize, 1, CV_32SC1); RNG rng(0); // fixed! for (int i = 0; i < datasize; ++i) diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 213cfe9f3733..124bfdce3236 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -644,7 +644,7 @@ void HaarEvaluator::computeChannels(int scaleIdx, InputArray img) int sqy = sy + (sqofs / sbufSize.width); UMat sum(usbuf, Rect(sx, sy, s.szi.width, s.szi.height)); UMat sqsum(usbuf, Rect(sx, sqy, s.szi.width, s.szi.height)); - sqsum.flags = (sqsum.flags & ~UMat::DEPTH_MASK) | CV_32S; + sqsum.flags = (sqsum.flags & static_cast(~UMat::DEPTH_MASK)) | CV_32SC1; if (hasTiltedFeatures) { diff --git a/modules/objdetect/test/opencl/test_hogdetector.cpp b/modules/objdetect/test/opencl/test_hogdetector.cpp index 009274096f6f..240c01892186 100644 --- a/modules/objdetect/test/opencl/test_hogdetector.cpp +++ b/modules/objdetect/test/opencl/test_hogdetector.cpp @@ -115,7 +115,7 @@ OCL_TEST_P(HOG, Detect) INSTANTIATE_TEST_CASE_P(OCL_ObjDetect, HOG, testing::Combine( testing::Values(Size(64, 128), Size(48, 96)), - testing::Values( MatType(CV_8UC1) ) ) ); + testing::Values( CV_8UC1 ) ) ); }} // namespace #endif diff --git a/modules/objdetect/test/test_cascadeandhog.cpp b/modules/objdetect/test/test_cascadeandhog.cpp index 106f3341b23d..78eb7b9b49eb 100644 --- a/modules/objdetect/test/test_cascadeandhog.cpp +++ b/modules/objdetect/test/test_cascadeandhog.cpp @@ -1169,7 +1169,7 @@ void HOGDescriptorTester::compute(InputArray _img, vector& descriptors, void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle, Size paddingTL, Size paddingBR) const { - CV_Assert( img.type() == CV_8U || img.type() == CV_8UC3 ); + CV_Assert( img.type() == CV_8UC1 || img.type() == CV_8UC3 ); Size gradsize(img.cols + paddingTL.width + paddingBR.width, img.rows + paddingTL.height + paddingBR.height); @@ -1209,10 +1209,10 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle int width = gradsize.width; AutoBuffer _dbuf(width*4); float* dbuf = _dbuf.data(); - Mat Dx(1, width, CV_32F, dbuf); - Mat Dy(1, width, CV_32F, dbuf + width); - Mat Mag(1, width, CV_32F, dbuf + width*2); - Mat Angle(1, width, CV_32F, dbuf + width*3); + Mat Dx(1, width, CV_32FC1, dbuf); + Mat Dy(1, width, CV_32FC1, dbuf + width); + Mat Mag(1, width, CV_32FC1, dbuf + width*2); + Mat Angle(1, width, CV_32FC1, dbuf + width*3); int _nbins = nbins; float angleScale = (float)(_nbins/CV_PI); @@ -1330,7 +1330,7 @@ TEST(Objdetect_HOGDetector_Strict, accuracy) // creating a matrix Size ssize(rng.uniform(1, 10) * actual_hog.winSize.width, rng.uniform(1, 10) * actual_hog.winSize.height); - int type = rng.uniform(0, 1) > 0 ? CV_8UC1 : CV_8UC3; + ElemType type = rng.uniform(0, 1) > 0 ? CV_8UC1 : CV_8UC3; Mat image(ssize, type); rng.fill(image, RNG::UNIFORM, 0, 256, true); @@ -1366,7 +1366,7 @@ TEST(Objdetect_CascadeDetector, small_img) { int width = rng.uniform(1, 100); int height = rng.uniform(1, 100); - Mat img(height, width, CV_8U); + Mat img(height, width, CV_8UC1); randu(img, 0, 256); cascade.detectMultiScale(img, objects); } diff --git a/modules/photo/perf/perf_cuda.cpp b/modules/photo/perf/perf_cuda.cpp index b179129962fc..cf3e69d78bba 100644 --- a/modules/photo/perf/perf_cuda.cpp +++ b/modules/photo/perf/perf_cuda.cpp @@ -69,7 +69,7 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, CUDA_NonLocalMeans, declare.time(600.0); const cv::Size size = GET_PARAM(0); - const int depth = GET_PARAM(1); + const ElemDepth depth = GET_PARAM(1); const int channels = GET_PARAM(2); const int search_widow_size = GET_PARAM(3); const int block_size = GET_PARAM(4); @@ -77,7 +77,7 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, CUDA_NonLocalMeans, const float h = 10; const int borderMode = cv::BORDER_REFLECT101; - const int type = CV_MAKE_TYPE(depth, channels); + const ElemType type = CV_MAKE_TYPE(depth, channels); cv::Mat src(size, type); declare.in(src, WARMUP_RNG); @@ -113,12 +113,12 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, CUDA_FastNonLocalMeans, declare.time(60.0); const cv::Size size = GET_PARAM(0); - const int depth = GET_PARAM(1); + const ElemDepth depth = GET_PARAM(1); const int search_widow_size = GET_PARAM(2); const int block_size = GET_PARAM(3); const float h = 10; - const int type = CV_MAKE_TYPE(depth, 1); + const ElemType type = CV_MAKE_TYPE(depth, 1); cv::Mat src(size, type); declare.in(src, WARMUP_RNG); @@ -156,12 +156,12 @@ PERF_TEST_P(Sz_Depth_WinSz_BlockSz, CUDA_FastNonLocalMeansColored, declare.time(60.0); const cv::Size size = GET_PARAM(0); - const int depth = GET_PARAM(1); + const ElemDepth depth = GET_PARAM(1); const int search_widow_size = GET_PARAM(2); const int block_size = GET_PARAM(3); const float h = 10; - const int type = CV_MAKE_TYPE(depth, 3); + const ElemType type = CV_MAKE_TYPE(depth, 3); cv::Mat src(size, type); declare.in(src, WARMUP_RNG); diff --git a/modules/photo/src/align.cpp b/modules/photo/src/align.cpp index 6a3972045ee9..b027e1feb78c 100644 --- a/modules/photo/src/align.cpp +++ b/modules/photo/src/align.cpp @@ -214,8 +214,8 @@ class AlignMTBImpl CV_FINAL : public AlignMTB CV_INSTRUMENT_REGION(); Mat img = _img.getMat(); - _tb.create(img.size(), CV_8U); - _eb.create(img.size(), CV_8U); + _tb.create(img.size(), CV_8UC1); + _eb.create(img.size(), CV_8UC1); Mat tb = _tb.getMat(), eb = _eb.getMat(); int median = getMedian(img); compare(img, median, tb, CMP_GT); diff --git a/modules/photo/src/calibrate.cpp b/modules/photo/src/calibrate.cpp index 9614a1c9ae04..30a962881dbc 100644 --- a/modules/photo/src/calibrate.cpp +++ b/modules/photo/src/calibrate.cpp @@ -76,7 +76,7 @@ class CalibrateDebevecImpl CV_FINAL : public CalibrateDebevec // create output int channels = images[0].channels(); - int CV_32FCC = CV_MAKETYPE(CV_32F, channels); + ElemType CV_32FCC = CV_MAKETYPE(CV_32F, channels); int rows = images[0].rows; int cols = images[0].cols; @@ -117,8 +117,8 @@ class CalibrateDebevecImpl CV_FINAL : public CalibrateDebevec for(int ch = 0; ch < channels; ch++) { // initialize system of linear equations Mat A = Mat::zeros((int)points.size() * (int)images.size() + LDR_SIZE + 1, - LDR_SIZE + (int)points.size(), CV_32F); - Mat B = Mat::zeros(A.rows, 1, CV_32F); + LDR_SIZE + (int)points.size(), CV_32FC1); + Mat B = Mat::zeros(A.rows, 1, CV_32FC1); // include the data-fitting equations int k = 0; @@ -223,7 +223,7 @@ class CalibrateRobertsonImpl CV_FINAL : public CalibrateRobertson CV_Assert(images[0].depth() == CV_8U); int channels = images[0].channels(); - int CV_32FCC = CV_MAKETYPE(CV_32F, channels); + ElemType CV_32FCC = CV_MAKETYPE(CV_32F, channels); CV_Assert(channels >= 1 && channels <= 3); dst.create(LDR_SIZE, 1, CV_32FCC); diff --git a/modules/photo/src/contrast_preserve.cpp b/modules/photo/src/contrast_preserve.cpp index d9b183964ed5..b06264c4568a 100644 --- a/modules/photo/src/contrast_preserve.cpp +++ b/modules/photo/src/contrast_preserve.cpp @@ -71,7 +71,7 @@ void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost) double pre_E = std::numeric_limits::infinity(); Mat img; - I.convertTo(img, CV_32FC3, 1.0/255.0); + I.convertTo(img, CV_32F, 1.0/255.0); // Initialization Decolor obj; @@ -156,7 +156,7 @@ void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost) Mat Gray = Mat::zeros(img.size(),CV_32FC1); obj.grayImContruct(wei, img, Gray); - Gray.convertTo(dst,CV_8UC1,255); + Gray.convertTo(dst,CV_8U,255); /////////////////////////////////// Contrast Boosting ///////////////////////////////// diff --git a/modules/photo/src/contrast_preserve.hpp b/modules/photo/src/contrast_preserve.hpp index 1afd4bc3e382..4f2a9b68a74e 100644 --- a/modules/photo/src/contrast_preserve.hpp +++ b/modules/photo/src/contrast_preserve.hpp @@ -130,7 +130,7 @@ void Decolor::singleChannelGradx(const Mat &img, Mat& dest) const { const int w = img.size().width; const Point anchor(kernelx.cols - kernelx.cols/2 - 1, kernelx.rows - kernelx.rows/2 - 1); - filter2D(img, dest, -1, kernelx, anchor, 0.0, BORDER_CONSTANT); + filter2D(img, dest, CV_DEPTH_AUTO, kernelx, anchor, 0.0, BORDER_CONSTANT); dest.col(w - 1) = 0.0; } @@ -138,7 +138,7 @@ void Decolor::singleChannelGrady(const Mat &img, Mat& dest) const { const int h = img.size().height; const Point anchor(kernely.cols - kernely.cols/2 - 1, kernely.rows - kernely.rows/2 - 1); - filter2D(img, dest, -1, kernely, anchor, 0.0, BORDER_CONSTANT); + filter2D(img, dest, CV_DEPTH_AUTO, kernely, anchor, 0.0, BORDER_CONSTANT); dest.row(h - 1) = 0.0; } diff --git a/modules/photo/src/denoise_tvl1.cpp b/modules/photo/src/denoise_tvl1.cpp index df756c4c85b9..793a8724a206 100644 --- a/modules/photo/src/denoise_tvl1.cpp +++ b/modules/photo/src/denoise_tvl1.cpp @@ -65,7 +65,7 @@ namespace cv{ const double L2 = 8.0, tau = 0.02, sigma = 1./(L2*tau), theta = 1.0; double clambda = (double)lambda; double s=0; - const int workdepth = CV_64F; + const ElemDepth workdepth = CV_64F; int i, x, y, rows=observations[0].rows, cols=observations[0].cols,count; for(i=1;i<(int)observations.size();i++){ @@ -76,7 +76,7 @@ namespace cv{ observations[0].convertTo(X, workdepth, 1./255); std::vector< Mat_ > Rs(observations.size()); for(count=0;count<(int)Rs.size();count++){ - Rs[count]=Mat::zeros(rows,cols,workdepth); + Rs[count]=Mat::zeros(rows,cols,CV_MAKETYPE(workdepth, 1)); } for( i = 0; i < niters; i++ ) @@ -147,7 +147,7 @@ namespace cv{ } } - result.create(X.rows,X.cols,CV_8U); + result.create(X.rows,X.cols,CV_8UC1); X.convertTo(result, CV_8U, 255); } } diff --git a/modules/photo/src/denoising.cpp b/modules/photo/src/denoising.cpp index d81795e42be3..0bbeeca26b26 100644 --- a/modules/photo/src/denoising.cpp +++ b/modules/photo/src/denoising.cpp @@ -115,7 +115,9 @@ void cv::fastNlMeansDenoising( InputArray _src, OutputArray _dst, const std::vec { CV_INSTRUMENT_REGION(); - int hn = (int)h.size(), type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + int hn = (int)h.size(), type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert(!_src.empty()); CV_Assert(hn == 1 || hn == cn); @@ -171,7 +173,9 @@ void cv::fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst, { CV_INSTRUMENT_REGION(); - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); Size src_size = _src.size(); if (type != CV_8UC3 && type != CV_8UC4) { @@ -302,7 +306,7 @@ static void fastNlMeansDenoisingMulti_( const std::vector& srcImgs, Mat& ds break; default: CV_Error(Error::StsBadArg, - "Unsupported image format! Only CV_8U, CV_8UC2, CV_8UC3 and CV_8UC4 are supported"); + "Unsupported image format! Only CV_8UC1, CV_8UC2, CV_8UC3 and CV_8UC4 are supported"); } } @@ -331,7 +335,9 @@ void cv::fastNlMeansDenoisingMulti( InputArrayOfArrays _srcImgs, OutputArray _ds temporalWindowSize, templateWindowSize, searchWindowSize); int hn = (int)h.size(); - int type = srcImgs[0].type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + int type = srcImgs[0].type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); CV_Assert(hn == 1 || hn == cn); _dst.create(srcImgs[0].size(), srcImgs[0].type()); @@ -396,7 +402,8 @@ void cv::fastNlMeansDenoisingColoredMulti( InputArrayOfArrays _srcImgs, OutputAr _dst.create(srcImgs[0].size(), srcImgs[0].type()); Mat dst = _dst.getMat(); - int type = srcImgs[0].type(), depth = CV_MAT_DEPTH(type); + ElemType type = srcImgs[0].type(); + ElemDepth depth = CV_MAT_DEPTH(type); int src_imgs_size = static_cast(srcImgs.size()); if (type != CV_8UC3) diff --git a/modules/photo/src/denoising.cuda.cpp b/modules/photo/src/denoising.cuda.cpp index 7ea37f6951be..06267222b682 100644 --- a/modules/photo/src/denoising.cuda.cpp +++ b/modules/photo/src/denoising.cuda.cpp @@ -87,7 +87,7 @@ void cv::cuda::nonLocalMeans(InputArray _src, OutputArray _dst, float h, int sea const GpuMat src = _src.getGpuMat(); - CV_Assert(src.type() == CV_8U || src.type() == CV_8UC2 || src.type() == CV_8UC3); + CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC2 || src.type() == CV_8UC3); const func_t func = funcs[src.channels() - 1]; CV_Assert(func != 0); @@ -133,7 +133,7 @@ void cv::cuda::fastNlMeansDenoising(InputArray _src, OutputArray _dst, float h, int bcols, brows; device::imgproc::nln_fast_get_buffer_size(src_hdr, search_window, block_window, bcols, brows); - GpuMat buffer = pool.getBuffer(brows, bcols, CV_32S); + GpuMat buffer = pool.getBuffer(brows, bcols, CV_32SC1); using namespace cv::cuda::device::imgproc; typedef void (*nlm_fast_t)(const PtrStepSzb&, PtrStepSzb, PtrStepi, int, int, float, cudaStream_t); @@ -156,7 +156,7 @@ void cv::cuda::fastNlMeansDenoisingColored(InputArray _src, OutputArray _dst, fl GpuMat lab = pool.getBuffer(src.size(), src.type()); cv::cuda::cvtColor(src, lab, cv::COLOR_BGR2Lab, 0, stream); - GpuMat l = pool.getBuffer(src.size(), CV_8U); + GpuMat l = pool.getBuffer(src.size(), CV_8UC1); GpuMat ab = pool.getBuffer(src.size(), CV_8UC2); device::imgproc::fnlm_split_channels(lab, l, ab, StreamAccessor::getStream(stream)); diff --git a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp index b19adbda96d4..eb02ad930e94 100644 --- a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp @@ -33,7 +33,7 @@ static bool ocl_calcAlmostDist2Weight(UMat & almostDist2Weight, std::numeric_limits::max(); int fixedPointMult = (int)std::min(std::numeric_limits::max() / maxEstimateSumValue, std::numeric_limits::max()); - int depth = DataType::depth; + ElemDepth depth = DataType::depth; bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0; if (depth == CV_64F && !doubleSupport) @@ -79,7 +79,9 @@ static bool ocl_calcAlmostDist2Weight(UMat & almostDist2Weight, static bool ocl_fastNlMeansDenoising(InputArray _src, OutputArray _dst, const float *h, int hn, int templateWindowSize, int searchWindowSize, int normType) { - int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); int ctaSize = ocl::Device::getDefault().isIntel() ? CTA_SIZE_INTEL : CTA_SIZE_DEFAULT; Size size = _src.size(); @@ -189,12 +191,12 @@ static bool ocl_fastNlMeansDenoisingColored( InputArray _src, OutputArray _dst, UMat src_lab; cvtColor(src, src_lab, COLOR_LBGR2Lab); - UMat l(src.size(), CV_8U); + UMat l(src.size(), CV_8UC1); UMat ab(src.size(), CV_8UC2); std::vector l_ab(2), l_ab_denoised(2); l_ab[0] = l; l_ab[1] = ab; - l_ab_denoised[0].create(src.size(), CV_8U); + l_ab_denoised[0].create(src.size(), CV_8UC1); l_ab_denoised[1].create(src.size(), CV_8UC2); int from_to[] = { 0,0, 1,1, 2,2 }; diff --git a/modules/photo/src/hdr_common.cpp b/modules/photo/src/hdr_common.cpp index 983efe3792a8..774896fe1859 100644 --- a/modules/photo/src/hdr_common.cpp +++ b/modules/photo/src/hdr_common.cpp @@ -62,7 +62,7 @@ void checkImageDimensions(const std::vector& images) Mat triangleWeights() { // hat function - Mat w(LDR_SIZE, 1, CV_32F); + Mat w(LDR_SIZE, 1, CV_32FC1); int half = LDR_SIZE / 2; for(int i = 0; i < LDR_SIZE; i++) { w.at(i) = i < half ? i + 1.0f : LDR_SIZE - i; diff --git a/modules/photo/src/inpaint.cpp b/modules/photo/src/inpaint.cpp index 03011e0c1370..9b96e0e0f64a 100644 --- a/modules/photo/src/inpaint.cpp +++ b/modules/photo/src/inpaint.cpp @@ -747,9 +747,9 @@ cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_i if( !CV_ARE_SIZES_EQ(input_img,output_img) || !CV_ARE_SIZES_EQ(input_img,inpaint_mask)) CV_Error( CV_StsUnmatchedSizes, "All the input and output images must have the same size" ); - if( (CV_MAT_TYPE(input_img->type) != CV_8U && - CV_MAT_TYPE(input_img->type) != CV_16U && - CV_MAT_TYPE(input_img->type) != CV_32F && + if( (CV_MAT_TYPE(input_img->type) != CV_8UC1 && + CV_MAT_TYPE(input_img->type) != CV_16UC1 && + CV_MAT_TYPE(input_img->type) != CV_32FC1 && CV_MAT_TYPE(input_img->type) != CV_8UC3) || !CV_ARE_TYPES_EQ(input_img,output_img) ) CV_Error( CV_StsUnsupportedFormat, diff --git a/modules/photo/src/merge.cpp b/modules/photo/src/merge.cpp index fbeb4639b43a..521e0a8a670a 100644 --- a/modules/photo/src/merge.cpp +++ b/modules/photo/src/merge.cpp @@ -70,7 +70,7 @@ class MergeDebevecImpl CV_FINAL : public MergeDebevec int channels = images[0].channels(); Size size = images[0].size(); - int CV_32FCC = CV_MAKETYPE(CV_32F, channels); + ElemType CV_32FCC = CV_MAKETYPE(CV_32F, channels); dst.create(images[0].size(), CV_32FCC); Mat result = dst.getMat(); @@ -93,13 +93,13 @@ class MergeDebevecImpl CV_FINAL : public MergeDebevec result = Mat::zeros(size, CV_32FCC); std::vector result_split; split(result, result_split); - Mat weight_sum = Mat::zeros(size, CV_32F); + Mat weight_sum = Mat::zeros(size, CV_32FC1); for(size_t i = 0; i < images.size(); i++) { std::vector splitted; split(images[i], splitted); - Mat w = Mat::zeros(size, CV_32F); + Mat w = Mat::zeros(size, CV_32FC1); for(int c = 0; c < channels; c++) { LUT(splitted[c], weights, splitted[c]); w += splitted[c]; @@ -168,10 +168,10 @@ class MergeMertensImpl CV_FINAL : public MergeMertens int channels = images[0].channels(); CV_Assert(channels == 1 || channels == 3); Size size = images[0].size(); - int CV_32FCC = CV_MAKETYPE(CV_32F, channels); + ElemType CV_32FCC = CV_MAKETYPE(CV_32F, channels); std::vector weights(images.size()); - Mat weight_sum = Mat::zeros(size, CV_32F); + Mat weight_sum = Mat::zeros(size, CV_32FC1); for(size_t i = 0; i < images.size(); i++) { Mat img, gray, contrast, saturation, wellexp; @@ -188,13 +188,13 @@ class MergeMertensImpl CV_FINAL : public MergeMertens Laplacian(gray, contrast, CV_32F); contrast = abs(contrast); - Mat mean = Mat::zeros(size, CV_32F); + Mat mean = Mat::zeros(size, CV_32FC1); for(int c = 0; c < channels; c++) { mean += splitted[c]; } mean /= channels; - saturation = Mat::zeros(size, CV_32F); + saturation = Mat::zeros(size, CV_32FC1); for(int c = 0; c < channels; c++) { Mat deviation = splitted[c] - mean; pow(deviation, 2.0f, deviation); @@ -202,7 +202,7 @@ class MergeMertensImpl CV_FINAL : public MergeMertens } sqrt(saturation, saturation); - wellexp = Mat::ones(size, CV_32F); + wellexp = Mat::ones(size, CV_32FC1); for(int c = 0; c < channels; c++) { Mat expo = splitted[c] - 0.5f; pow(expo, 2.0f, expo); @@ -321,7 +321,7 @@ class MergeRobertsonImpl CV_FINAL : public MergeRobertson CV_Assert(images[0].depth() == CV_8U); int channels = images[0].channels(); - int CV_32FCC = CV_MAKETYPE(CV_32F, channels); + ElemType CV_32FCC = CV_MAKETYPE(CV_32F, channels); dst.create(images[0].size(), CV_32FCC); Mat result = dst.getMat(); diff --git a/modules/photo/src/npr.cpp b/modules/photo/src/npr.cpp index 804a2aaf9090..0ebf7e16d514 100644 --- a/modules/photo/src/npr.cpp +++ b/modules/photo/src/npr.cpp @@ -58,7 +58,7 @@ void cv::edgePreservingFilter(InputArray _src, OutputArray dst, int flags, float Domain_Filter obj; Mat img; - I.convertTo(img,CV_32FC3,1.0/255.0); + I.convertTo(img,CV_32F,1.0/255.0); Mat res; obj.filter(img, res, sigma_s, sigma_r, flags); @@ -75,7 +75,7 @@ void cv::detailEnhance(InputArray _src, OutputArray dst, float sigma_s, float si float factor = 3.0f; Mat img; - I.convertTo(img,CV_32FC3,1.0/255.0); + I.convertTo(img,CV_32F,1.0/255.0); Mat lab; vector lab_channel; @@ -83,7 +83,7 @@ void cv::detailEnhance(InputArray _src, OutputArray dst, float sigma_s, float si split(lab,lab_channel); Mat L; - lab_channel[0].convertTo(L,CV_32FC1,1.0/255.0); + lab_channel[0].convertTo(L,CV_32F,1.0/255.0); Domain_Filter obj; @@ -94,12 +94,12 @@ void cv::detailEnhance(InputArray _src, OutputArray dst, float sigma_s, float si multiply(detail,factor,detail); L = res + detail; - L.convertTo(lab_channel[0],CV_32FC1,255); + L.convertTo(lab_channel[0],CV_32F,255); merge(lab_channel,lab); cvtColor(lab,res,COLOR_Lab2BGR); - res.convertTo(dst,CV_8UC3,255); + res.convertTo(dst,CV_8U,255); } void cv::pencilSketch(InputArray _src, OutputArray _dst1, OutputArray _dst2, float sigma_s, float sigma_r, float shade_factor) @@ -114,7 +114,7 @@ void cv::pencilSketch(InputArray _src, OutputArray _dst1, OutputArray _dst2, flo Mat dst2 = _dst2.getMat(); Mat img = Mat(I.size(),CV_32FC3); - I.convertTo(img,CV_32FC3,1.0/255.0); + I.convertTo(img,CV_32F,1.0/255.0); Domain_Filter obj; @@ -123,8 +123,8 @@ void cv::pencilSketch(InputArray _src, OutputArray _dst1, OutputArray _dst2, flo obj.pencil_sketch(img, sketch, color_sketch, sigma_s, sigma_r, shade_factor); - sketch.convertTo(dst1,CV_8UC1,255); - color_sketch.convertTo(dst2,CV_8UC3,255); + sketch.convertTo(dst1,CV_8U,255); + color_sketch.convertTo(dst2,CV_8U,255); } @@ -137,7 +137,7 @@ void cv::stylization(InputArray _src, OutputArray _dst, float sigma_s, float sig Mat dst = _dst.getMat(); Mat img; - I.convertTo(img,CV_32FC3,1.0/255.0); + I.convertTo(img,CV_32F,1.0/255.0); int h = img.size().height; int w = img.size().width; @@ -159,5 +159,5 @@ void cv::stylization(InputArray _src, OutputArray _dst, float sigma_s, float sig multiply(temp[2],magnitude,temp[2]); merge(temp,stylized); - stylized.convertTo(dst,CV_8UC3,255); + stylized.convertTo(dst,CV_8U,255); } diff --git a/modules/photo/src/npr.hpp b/modules/photo/src/npr.hpp index 2ff1985aca6b..ce831fc223de 100644 --- a/modules/photo/src/npr.hpp +++ b/modules/photo/src/npr.hpp @@ -148,14 +148,14 @@ void Domain_Filter::find_magnitude(Mat &img, Mat &mag) Mat magXB = Mat(h, w, CV_32FC1); Mat magYB = Mat(h, w, CV_32FC1); - Sobel(planes[0], magXR, CV_32FC1, 1, 0, 3); - Sobel(planes[0], magYR, CV_32FC1, 0, 1, 3); + Sobel(planes[0], magXR, CV_32F, 1, 0, 3); + Sobel(planes[0], magYR, CV_32F, 0, 1, 3); - Sobel(planes[1], magXG, CV_32FC1, 1, 0, 3); - Sobel(planes[1], magYG, CV_32FC1, 0, 1, 3); + Sobel(planes[1], magXG, CV_32F, 1, 0, 3); + Sobel(planes[1], magYG, CV_32F, 0, 1, 3); - Sobel(planes[2], magXB, CV_32FC1, 1, 0, 3); - Sobel(planes[2], magYB, CV_32FC1, 0, 1, 3); + Sobel(planes[2], magXB, CV_32F, 1, 0, 3); + Sobel(planes[2], magYB, CV_32F, 0, 1, 3); Mat mag1 = Mat(h,w,CV_32FC1); Mat mag2 = Mat(h,w,CV_32FC1); diff --git a/modules/photo/src/seamless_cloning_impl.cpp b/modules/photo/src/seamless_cloning_impl.cpp index 1b87e86b209c..75273bdecb1c 100644 --- a/modules/photo/src/seamless_cloning_impl.cpp +++ b/modules/photo/src/seamless_cloning_impl.cpp @@ -47,7 +47,7 @@ using namespace std; void Cloning::computeGradientX( const Mat &img, Mat &gx) { - Mat kernel = Mat::zeros(1, 3, CV_8S); + Mat kernel = Mat::zeros(1, 3, CV_8SC1); kernel.at(0,2) = 1; kernel.at(0,1) = -1; @@ -68,7 +68,7 @@ void Cloning::computeGradientX( const Mat &img, Mat &gx) void Cloning::computeGradientY( const Mat &img, Mat &gy) { - Mat kernel = Mat::zeros(3, 1, CV_8S); + Mat kernel = Mat::zeros(3, 1, CV_8SC1); kernel.at(2,0) = 1; kernel.at(1,0) = -1; @@ -89,7 +89,7 @@ void Cloning::computeGradientY( const Mat &img, Mat &gy) void Cloning::computeLaplacianX( const Mat &img, Mat &laplacianX) { - Mat kernel = Mat::zeros(1, 3, CV_8S); + Mat kernel = Mat::zeros(1, 3, CV_8SC1); kernel.at(0,0) = -1; kernel.at(0,1) = 1; filter2D(img, laplacianX, CV_32F, kernel); @@ -97,7 +97,7 @@ void Cloning::computeLaplacianX( const Mat &img, Mat &laplacianX) void Cloning::computeLaplacianY( const Mat &img, Mat &laplacianY) { - Mat kernel = Mat::zeros(3, 1, CV_8S); + Mat kernel = Mat::zeros(3, 1, CV_8SC1); kernel.at(0,0) = -1; kernel.at(1,0) = 1; filter2D(img, laplacianY, CV_32F, kernel); @@ -105,7 +105,7 @@ void Cloning::computeLaplacianY( const Mat &img, Mat &laplacianY) void Cloning::dst(const Mat& src, Mat& dest, bool invert) { - Mat temp = Mat::zeros(src.rows, 2 * src.cols + 2, CV_32F); + Mat temp = Mat::zeros(src.rows, 2 * src.cols + 2, CV_32FC1); int flag = invert ? DFT_ROWS + DFT_SCALE + DFT_INVERSE: DFT_ROWS; @@ -121,13 +121,13 @@ void Cloning::dst(const Mat& src, Mat& dest, bool invert) } } - Mat planes[] = {temp, Mat::zeros(temp.size(), CV_32F)}; + Mat planes[] = {temp, Mat::zeros(temp.size(), CV_32FC1)}; Mat complex; merge(planes, 2, complex); dft(complex, complex, flag); split(complex, planes); - temp = Mat::zeros(src.cols, 2 * src.rows + 2, CV_32F); + temp = Mat::zeros(src.cols, 2 * src.rows + 2, CV_32FC1); for(int j = 0 ; j < src.cols ; ++j) { @@ -140,7 +140,7 @@ void Cloning::dst(const Mat& src, Mat& dest, bool invert) } } - Mat planes2[] = {temp, Mat::zeros(temp.size(), CV_32F)}; + Mat planes2[] = {temp, Mat::zeros(temp.size(), CV_32FC1)}; merge(planes2, 2, complex); dft(complex, complex, flag); @@ -268,7 +268,7 @@ void Cloning::computeDerivatives(const Mat& destination, const Mat &patch, const Kernel.setTo(Scalar(1)); erode(binaryMask, binaryMask, Kernel, Point(-1,-1), 3); - binaryMask.convertTo(binaryMaskFloat, CV_32FC1, 1.0/255.0); + binaryMask.convertTo(binaryMaskFloat, CV_32F, 1.0/255.0); } void Cloning::scalarProduct(Mat mat, float r, float g, float b) @@ -318,7 +318,7 @@ void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned) { bitwise_not(wmask,wmask); - wmask.convertTo(binaryMaskFloatInverted,CV_32FC1,1.0/255.0); + wmask.convertTo(binaryMaskFloatInverted,CV_32F,1.0/255.0); arrayProduct(destinationGradientX, binaryMaskFloatInverted, destinationGradientX); arrayProduct(destinationGradientY, binaryMaskFloatInverted, destinationGradientY); diff --git a/modules/photo/src/tonemap.cpp b/modules/photo/src/tonemap.cpp index fd73865d6b3e..5ea47122be58 100644 --- a/modules/photo/src/tonemap.cpp +++ b/modules/photo/src/tonemap.cpp @@ -414,7 +414,7 @@ class TonemapMantiukImpl CV_FINAL : public TonemapMantiuk mapContrast(y_contrast[i]); } - Mat right(src.size(), CV_32F); + Mat right(src.size(), CV_32FC1); calculateSum(x_contrast, y_contrast, right); Mat p, r, product, x = log_img; @@ -503,7 +503,7 @@ class TonemapMantiukImpl CV_FINAL : public TonemapMantiuk void getGradient(Mat src, Mat& dst, int pos) { - dst = Mat::zeros(src.size(), CV_32F); + dst = Mat::zeros(src.size(), CV_32FC1); Mat a, b; Mat grad = src.colRange(1, src.cols) - src.colRange(0, src.cols - 1); grad.copyTo(dst.colRange(pos, src.cols + pos - 1)); @@ -532,7 +532,7 @@ class TonemapMantiukImpl CV_FINAL : public TonemapMantiuk if (x_contrast.empty()) return; const int last = (int)x_contrast.size() - 1; - sum = Mat::zeros(x_contrast[last].size(), CV_32F); + sum = Mat::zeros(x_contrast[last].size(), CV_32FC1); for(int i = last; i >= 0; i--) { Mat grad_x, grad_y; diff --git a/modules/photo/test/ocl/test_denoising.cpp b/modules/photo/test/ocl/test_denoising.cpp index 974a8f81a8c5..302c08a52eff 100644 --- a/modules/photo/test/ocl/test_denoising.cpp +++ b/modules/photo/test/ocl/test_denoising.cpp @@ -39,7 +39,7 @@ PARAM_TEST_CASE(FastNlMeansDenoisingTestBase, Channels, int, bool, bool) void generateTestData() { - const int type = CV_8UC(cn); + const ElemType type = CV_8UC(cn); Mat image; if (use_image) { diff --git a/modules/photo/test/test_denoise_tvl1.cpp b/modules/photo/test/test_denoise_tvl1.cpp index 2117d6ee146b..aac2723c8ef1 100644 --- a/modules/photo/test/test_denoise_tvl1.cpp +++ b/modules/photo/test/test_denoise_tvl1.cpp @@ -45,7 +45,7 @@ namespace opencv_test { namespace { void make_noisy(const cv::Mat& img, cv::Mat& noisy, double sigma, double pepper_salt_ratio,cv::RNG& rng) { noisy.create(img.size(), img.type()); - cv::Mat noise(img.size(), img.type()), mask(img.size(), CV_8U); + cv::Mat noise(img.size(), img.type()), mask(img.size(), CV_8UC1); rng.fill(noise,cv::RNG::NORMAL,128.0,sigma); cv::addWeighted(img, 1, noise, 1, -128, noisy); cv::randn(noise, cv::Scalar::all(0), cv::Scalar::all(2)); diff --git a/modules/photo/test/test_hdr.cpp b/modules/photo/test/test_hdr.cpp index fd4797fac73c..135581cf4e08 100644 --- a/modules/photo/test/test_hdr.cpp +++ b/modules/photo/test/test_hdr.cpp @@ -96,31 +96,31 @@ TEST(Photo_Tonemap, regression) Ptr linear = createTonemap(gamma); linear->process(img, result); loadImage(test_path + "linear.png", expected); - result.convertTo(result, CV_8UC3, 255); + result.convertTo(result, CV_8U, 255); checkEqual(result, expected, 3, "Simple"); Ptr drago = createTonemapDrago(gamma); drago->process(img, result); loadImage(test_path + "drago.png", expected); - result.convertTo(result, CV_8UC3, 255); + result.convertTo(result, CV_8U, 255); checkEqual(result, expected, 3, "Drago"); Ptr durand = createTonemapDurand(gamma); durand->process(img, result); loadImage(test_path + "durand.png", expected); - result.convertTo(result, CV_8UC3, 255); + result.convertTo(result, CV_8U, 255); checkEqual(result, expected, 3, "Durand"); Ptr reinhard = createTonemapReinhard(gamma); reinhard->process(img, result); loadImage(test_path + "reinhard.png", expected); - result.convertTo(result, CV_8UC3, 255); + result.convertTo(result, CV_8U, 255); checkEqual(result, expected, 3, "Reinhard"); Ptr mantiuk = createTonemapMantiuk(gamma); mantiuk->process(img, result); loadImage(test_path + "mantiuk.png", expected); - result.convertTo(result, CV_8UC3, 255); + result.convertTo(result, CV_8U, 255); checkEqual(result, expected, 3, "Mantiuk"); } @@ -164,7 +164,7 @@ TEST(Photo_MergeMertens, regression) Mat result, expected; loadImage(test_path + "merge/mertens.png", expected); merge->process(images, result); - result.convertTo(result, CV_8UC3, 255); + result.convertTo(result, CV_8U, 255); checkEqual(expected, result, 3, "Mertens"); Mat uniform(100, 100, CV_8UC3); @@ -174,7 +174,7 @@ TEST(Photo_MergeMertens, regression) images.push_back(uniform); merge->process(images, result); - result.convertTo(result, CV_8UC3, 255); + result.convertTo(result, CV_8U, 255); checkEqual(uniform, result, 1e-2f, "Mertens"); } diff --git a/modules/photo/test/test_inpaint.cpp b/modules/photo/test/test_inpaint.cpp index 7288501a8a5e..f78bde1c3c1d 100644 --- a/modules/photo/test/test_inpaint.cpp +++ b/modules/photo/test/test_inpaint.cpp @@ -73,7 +73,7 @@ void CV_InpaintTest::run( int ) } Mat inv_mask; - mask.convertTo(inv_mask, CV_8UC3, -1.0, 255.0); + mask.convertTo(inv_mask, CV_8U, -1.0, 255.0); Mat mask1ch; cv::cvtColor(mask, mask1ch, COLOR_BGR2GRAY); @@ -116,15 +116,15 @@ void CV_InpaintTest::run( int ) TEST(Photo_Inpaint, regression) { CV_InpaintTest test; test.safe_run(); } -typedef testing::TestWithParam > formats; +typedef testing::TestWithParam > formats; TEST_P(formats, 1c) { - const int type = get<0>(GetParam()); + const ElemType type = get<0>(GetParam()); Mat src(100, 100, type); src.setTo(Scalar::all(128)); Mat ref = src.clone(); - Mat dst, mask = Mat::zeros(src.size(), CV_8U); + Mat dst, mask = Mat::zeros(src.size(), CV_8UC1); circle(src, Point(50, 50), 5, Scalar(200), 6); circle(mask, Point(50, 50), 5, Scalar(200), 6); diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 5ae963a94fca..a0032b7e1a31 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -239,7 +239,7 @@ class NumpyAllocator : public MatAllocator NumpyAllocator() { stdAllocator = Mat::getStdAllocator(); } ~NumpyAllocator() {} - UMatData* allocate(PyObject* o, int dims, const int* sizes, int type, size_t* step) const + UMatData* allocate(PyObject* o, int dims, const int* sizes, ElemType type, size_t* step) const { UMatData* u = new UMatData(this); u->data = u->origdata = (uchar*)PyArray_DATA((PyArrayObject*) o); @@ -252,7 +252,7 @@ class NumpyAllocator : public MatAllocator return u; } - UMatData* allocate(int dims0, const int* sizes, int type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE + UMatData* allocate(int dims0, const int* sizes, ElemType type, void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const CV_OVERRIDE { if( data != 0 ) { @@ -262,7 +262,7 @@ class NumpyAllocator : public MatAllocator } PyEnsureGIL gil; - int depth = CV_MAT_DEPTH(type); + ElemDepth depth = CV_MAT_DEPTH(type); int cn = CV_MAT_CN(type); const int f = (int)(sizeof(size_t)/8); int typenum = depth == CV_8U ? NPY_UBYTE : depth == CV_8S ? NPY_BYTE : @@ -323,19 +323,19 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info) if( PyInt_Check(o) ) { double v[] = {static_cast(PyInt_AsLong((PyObject*)o)), 0., 0., 0.}; - m = Mat(4, 1, CV_64F, v).clone(); + m = Mat(4, 1, CV_64FC1, v).clone(); return true; } if( PyFloat_Check(o) ) { double v[] = {PyFloat_AsDouble((PyObject*)o), 0., 0., 0.}; - m = Mat(4, 1, CV_64F, v).clone(); + m = Mat(4, 1, CV_64FC1, v).clone(); return true; } if( PyTuple_Check(o) ) { int i, sz = (int)PyTuple_Size((PyObject*)o); - m = Mat(sz, 1, CV_64F); + m = Mat(sz, 1, CV_64FC1); for( i = 0; i < sz; i++ ) { PyObject* oi = PyTuple_GET_ITEM(o, i); @@ -363,22 +363,22 @@ static bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo info) bool needcopy = false, needcast = false; int typenum = PyArray_TYPE(oarr), new_typenum = typenum; - int type = typenum == NPY_UBYTE ? CV_8U : - typenum == NPY_BYTE ? CV_8S : - typenum == NPY_USHORT ? CV_16U : - typenum == NPY_SHORT ? CV_16S : - typenum == NPY_INT ? CV_32S : - typenum == NPY_INT32 ? CV_32S : - typenum == NPY_FLOAT ? CV_32F : - typenum == NPY_DOUBLE ? CV_64F : -1; - - if( type < 0 ) + ElemType type = typenum == NPY_UBYTE ? CV_8UC1 : + typenum == NPY_BYTE ? CV_8SC1 : + typenum == NPY_USHORT ? CV_16UC1 : + typenum == NPY_SHORT ? CV_16SC1 : + typenum == NPY_INT ? CV_32SC1 : + typenum == NPY_INT32 ? CV_32SC1 : + typenum == NPY_FLOAT ? CV_32FC1 : + typenum == NPY_DOUBLE ? CV_64FC1 : CV_TYPE_AUTO; + + if (type == CV_TYPE_AUTO) { if( typenum == NPY_INT64 || typenum == NPY_UINT64 || typenum == NPY_LONG ) { needcopy = needcast = true; new_typenum = NPY_INT; - type = CV_32S; + type = CV_32SC1; } else { @@ -1148,8 +1148,9 @@ template struct pyopencvVecConverter int i, j, n = (int)PySequence_Fast_GET_SIZE(seq); value.resize(n); - int type = traits::Type<_Tp>::value; - int depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type); + ElemType type = traits::Type<_Tp>::value; + ElemDepth depth = CV_MAT_DEPTH(type); + int channels = CV_MAT_CN(type); PyObject** items = PySequence_Fast_ITEMS(seq); for( i = 0; i < n; i++ ) @@ -1176,8 +1177,8 @@ template struct pyopencvVecConverter ((src.cols != 1 || src.rows != channels) && (src.cols != channels || src.rows != 1))) break; - Mat dst(src.rows, src.cols, depth, data); - src.convertTo(dst, type); + Mat dst(src.rows, src.cols, CV_MAKETYPE(depth, 1), data); + src.convertTo(dst, depth); if( dst.data != (uchar*)data ) break; continue; @@ -1232,8 +1233,9 @@ template struct pyopencvVecConverter if(value.empty()) return PyTuple_New(0); int type = traits::Type<_Tp>::value; - int depth = CV_MAT_DEPTH(type), channels = CV_MAT_CN(type); - Mat src((int)value.size(), channels, depth, (uchar*)&value[0]); + ElemDepth depth = CV_MAT_DEPTH(type); + int channels = CV_MAT_CN(type); + Mat src((int)value.size(), channels, CV_MAKETYPE(depth, 1), (uchar*)&value[0]); return pyopencv_from(src); } }; diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 9830d9637ce0..ddc2d4f6b50e 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -863,7 +863,7 @@ def clear(self): self.classes = {} self.namespaces = {} self.consts = {} - self.enumTypes = [] + self.enumTypes = ["ElemType", "ElemDepth", ] self.code_include = StringIO() self.code_types = StringIO() self.code_funcs = StringIO() diff --git a/modules/python/test/tst_scene_render.py b/modules/python/test/tst_scene_render.py index 2dd6309ce1a3..4610b417818d 100644 --- a/modules/python/test/tst_scene_render.py +++ b/modules/python/test/tst_scene_render.py @@ -95,7 +95,7 @@ def getNextFrame(self): if self.noise: noise = np.zeros(self.sceneBg.shape, np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) - img = cv.add(img, noise, dtype=cv.CV_8UC3) + img = cv.add(img, noise, ddepth=cv.CV_8U) return img def resetTime(self): diff --git a/modules/shape/src/aff_trans.cpp b/modules/shape/src/aff_trans.cpp index 75daf2b17363..6631470d06f3 100644 --- a/modules/shape/src/aff_trans.cpp +++ b/modules/shape/src/aff_trans.cpp @@ -114,17 +114,17 @@ void AffineTransformerImpl::warpImage(InputArray transformingImage, OutputArray static Mat _localAffineEstimate(const std::vector& shape1, const std::vector& shape2, bool fullAfine) { - Mat out(2,3,CV_32F); + Mat out(2,3,CV_32FC1); int siz=2*(int)shape1.size(); if (fullAfine) { - Mat matM(siz, 6, CV_32F); - Mat matP(siz,1,CV_32F); + Mat matM(siz, 6, CV_32FC1); + Mat matP(siz,1,CV_32FC1); int contPt=0; for (int ii=0; ii(0,0)=shape1[contPt].x; @@ -149,12 +149,12 @@ static Mat _localAffineEstimate(const std::vector& shape1, const std::v } else { - Mat matM(siz, 4, CV_32F); - Mat matP(siz,1,CV_32F); + Mat matM(siz, 4, CV_32FC1); + Mat matP(siz,1,CV_32FC1); int contPt=0; for (int ii=0; ii(0,0)=shape1[contPt].x; @@ -194,9 +194,9 @@ void AffineTransformerImpl::estimateTransformation(InputArray _pts1, InputArray CV_Assert((pts1.channels()==2) && (pts1.cols>0) && (pts2.channels()==2) && (pts2.cols>0)); CV_Assert(_matches.size()>1); - if (pts1.type() != CV_32F) + if (pts1.type() != CV_32FC1) pts1.convertTo(pts1, CV_32F); - if (pts2.type() != CV_32F) + if (pts2.type() != CV_32FC1) pts2.convertTo(pts2, CV_32F); // Use only valid matchings // @@ -259,7 +259,7 @@ float AffineTransformerImpl::applyTransformation(InputArray inPts, OutputArray o } // Updating Transform Cost // - Mat Af(2, 2, CV_32F); + Mat Af(2, 2, CV_32FC1); Af.at(0,0)=affineMat.at(0,0); Af.at(0,1)=affineMat.at(1,0); Af.at(1,0)=affineMat.at(0,1); diff --git a/modules/shape/src/haus_dis.cpp b/modules/shape/src/haus_dis.cpp index a544edcaa5e5..d1e544b1918e 100644 --- a/modules/shape/src/haus_dis.cpp +++ b/modules/shape/src/haus_dis.cpp @@ -102,7 +102,7 @@ class HausdorffDistanceExtractorImpl CV_FINAL : public HausdorffDistanceExtracto static float _apply(const Mat &set1, const Mat &set2, int distType, double propRank) { // Building distance matrix // - Mat disMat(set1.cols, set2.cols, CV_32F); + Mat disMat(set1.cols, set2.cols, CV_32FC1); int K = int(propRank*(disMat.rows-1)); for (int r=0; r0)); CV_Assert((set2.channels()==2) && (set2.cols>0)); diff --git a/modules/shape/src/hist_cost.cpp b/modules/shape/src/hist_cost.cpp index f255d6069483..ec4565f2b2cc 100644 --- a/modules/shape/src/hist_cost.cpp +++ b/modules/shape/src/hist_cost.cpp @@ -131,7 +131,7 @@ void NormHistogramCostExtractorImpl::buildCostMatrix(InputArray _descriptors1, I Mat descriptors1=_descriptors1.getMat(); Mat descriptors2=_descriptors2.getMat(); int costrows = std::max(descriptors1.rows, descriptors2.rows)+nDummies; - _costMatrix.create(costrows, costrows, CV_32F); + _costMatrix.create(costrows, costrows, CV_32FC1); Mat costMatrix=_costMatrix.getMat(); @@ -259,7 +259,7 @@ void EMDHistogramCostExtractorImpl::buildCostMatrix(InputArray _descriptors1, In Mat descriptors1=_descriptors1.getMat(); Mat descriptors2=_descriptors2.getMat(); int costrows = std::max(descriptors1.rows, descriptors2.rows)+nDummies; - _costMatrix.create(costrows, costrows, CV_32F); + _costMatrix.create(costrows, costrows, CV_32FC1); Mat costMatrix=_costMatrix.getMat(); // Obtain copies of the descriptors // @@ -285,7 +285,7 @@ void EMDHistogramCostExtractorImpl::buildCostMatrix(InputArray _descriptors1, In { if (i(i,j) = cv::EMDL1(sig1, sig2); diff --git a/modules/shape/src/sc_dis.cpp b/modules/shape/src/sc_dis.cpp index 23c77f071734..c974fecbdbce 100644 --- a/modules/shape/src/sc_dis.cpp +++ b/modules/shape/src/sc_dis.cpp @@ -191,12 +191,12 @@ float ShapeContextDistanceExtractorImpl::computeDistance(InputArray contour1, In // Checking // Mat sset1=contour1.getMat(), sset2=contour2.getMat(), set1, set2; - if (set1.type() != CV_32F) + if (set1.type() != CV_32FC1) sset1.convertTo(set1, CV_32F); else sset1.copyTo(set1); - if (set2.type() != CV_32F) + if (set2.type() != CV_32FC1) sset2.convertTo(set2, CV_32F); else sset2.copyTo(set2); @@ -291,7 +291,7 @@ float ShapeContextDistanceExtractorImpl::computeDistance(InputArray contour1, In Mat temp=(warpedImage-image2); multiply(temp, temp, diffIm); } - gaussWindow = Mat::zeros(warpedImage.rows, warpedImage.cols, CV_32F); + gaussWindow = Mat::zeros(warpedImage.rows, warpedImage.cols, CV_32FC1); for (pt=0; pt(0,pt); @@ -305,7 +305,7 @@ float ShapeContextDistanceExtractorImpl::computeDistance(InputArray contour1, In } } - Mat appIm(diffIm.rows, diffIm.cols, CV_32F); + Mat appIm(diffIm.rows, diffIm.cols, CV_32FC1); for (ii=0; ii createShapeContextDistanceExtractor(int nAng void SCD::extractSCD(cv::Mat &contour, cv::Mat &descriptors, const std::vector &queryInliers, const float _meanDistance) { cv::Mat contourMat = contour; - cv::Mat disMatrix = cv::Mat::zeros(contourMat.cols, contourMat.cols, CV_32F); - cv::Mat angleMatrix = cv::Mat::zeros(contourMat.cols, contourMat.cols, CV_32F); + cv::Mat disMatrix = cv::Mat::zeros(contourMat.cols, contourMat.cols, CV_32FC1); + cv::Mat angleMatrix = cv::Mat::zeros(contourMat.cols, contourMat.cols, CV_32FC1); std::vector logspaces, angspaces; logarithmicSpaces(logspaces); @@ -343,7 +343,7 @@ void SCD::extractSCD(cv::Mat &contour, cv::Mat &descriptors, const std::vector &vecSpaces) const void SCD::buildNormalizedDistanceMatrix(cv::Mat &contour, cv::Mat &disMatrix, const std::vector &queryInliers, const float _meanDistance) { cv::Mat contourMat = contour; - cv::Mat mask(disMatrix.rows, disMatrix.cols, CV_8U); + cv::Mat mask(disMatrix.rows, disMatrix.cols, CV_8UC1); for (int i=0; i0) && (pts2.channels()==2) && (pts2.cols>0)); CV_Assert(_matches.size()>1); - if (pts1.type() != CV_32F) + if (pts1.depth() != CV_32F) pts1.convertTo(pts1, CV_32F); - if (pts2.type() != CV_32F) + if (pts2.depth() != CV_32F) pts2.convertTo(pts2, CV_32F); // Use only valid matchings // @@ -219,8 +219,8 @@ void ThinPlateSplineShapeTransformerImpl::estimateTransformation(InputArray _pts } // Organizing the correspondent points in matrix style // - Mat shape1((int)matches.size(),2,CV_32F); // transforming shape - Mat shape2((int)matches.size(),2,CV_32F); // target shape + Mat shape1((int)matches.size(), 2, CV_32FC1); // transforming shape + Mat shape2((int)matches.size(), 2, CV_32FC1); // target shape for (int i=0, end = (int)matches.size(); i(0,matches[i].queryIdx); @@ -236,8 +236,8 @@ void ThinPlateSplineShapeTransformerImpl::estimateTransformation(InputArray _pts // Building the matrices for solving the L*(w|a)=(v|0) problem with L={[K|P];[P'|0]} //Building K and P (Needed to build L) - Mat matK((int)matches.size(),(int)matches.size(),CV_32F); - Mat matP((int)matches.size(),3,CV_32F); + Mat matK((int)matches.size(), (int)matches.size(), CV_32FC1); + Mat matP((int)matches.size(), 3, CV_32FC1); for (int i=0, end=(int)matches.size(); i(i,0) = shape2.at(i,0); //x's diff --git a/modules/shape/test/test_shape.cpp b/modules/shape/test/test_shape.cpp index cf3d3f8f7be6..5962f9092567 100644 --- a/modules/shape/test/test_shape.cpp +++ b/modules/shape/test/test_shape.cpp @@ -70,7 +70,7 @@ class ShapeBaseTest : public cvtest::BaseTest } // distance matrix const int totalCount = (int)filenames.size(); - distanceMat = Mat::zeros(totalCount, totalCount, CV_32F); + distanceMat = Mat::zeros(totalCount, totalCount, CV_32FC1); } protected: diff --git a/modules/stitching/include/opencv2/stitching.hpp b/modules/stitching/include/opencv2/stitching.hpp index 07e1b5f73a42..b1055ff0d34f 100644 --- a/modules/stitching/include/opencv2/stitching.hpp +++ b/modules/stitching/include/opencv2/stitching.hpp @@ -205,7 +205,7 @@ class CV_EXPORTS_W Stitcher const cv::UMat& matchingMask() const { return matching_mask_; } void setMatchingMask(const cv::UMat &mask) { - CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows); + CV_Assert(mask.type() == CV_8UC1 && mask.cols == mask.rows); matching_mask_ = mask.clone(); } diff --git a/modules/stitching/include/opencv2/stitching/detail/blenders.hpp b/modules/stitching/include/opencv2/stitching/detail/blenders.hpp index 542f1e42fb69..f631f1830c3c 100644 --- a/modules/stitching/include/opencv2/stitching/detail/blenders.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/blenders.hpp @@ -127,7 +127,7 @@ inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpnes class CV_EXPORTS MultiBandBlender : public Blender { public: - MultiBandBlender(int try_gpu = false, int num_bands = 5, int weight_type = CV_32F); + MultiBandBlender(int try_gpu = false, int num_bands = 5, ElemDepth weight_type = CV_32F); int numBands() const { return actual_num_bands_; } void setNumBands(int val) { actual_num_bands_ = val; } @@ -142,7 +142,7 @@ class CV_EXPORTS MultiBandBlender : public Blender std::vector dst_band_weights_; Rect dst_roi_final_; bool can_use_gpu_; - int weight_type_; //CV_32F or CV_16S + ElemDepth weight_type_; //CV_32F or CV_16S #if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING) std::vector gpu_dst_pyr_laplace_; std::vector gpu_dst_band_weights_; diff --git a/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp b/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp index 40f12c32fc86..2954fc883422 100644 --- a/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp @@ -132,7 +132,7 @@ class CV_EXPORTS BundleAdjusterBase : public Estimator const Mat refinementMask() const { return refinement_mask_.clone(); } void setRefinementMask(const Mat &mask) { - CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3)); + CV_Assert(mask.type() == CV_8UC1 && mask.size() == Size(3, 3)); refinement_mask_ = mask.clone(); } @@ -154,7 +154,7 @@ class CV_EXPORTS BundleAdjusterBase : public Estimator num_errs_per_measurement_(num_errs_per_measurement), features_(0), pairwise_matches_(0), conf_thresh_(0) { - setRefinementMask(Mat::ones(3, 3, CV_8U)); + setRefinementMask(Mat::ones(3, 3, CV_8UC1)); setConfThresh(1.); setTermCriteria(TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 1000, DBL_EPSILON)); } diff --git a/modules/stitching/include/opencv2/stitching/detail/warpers.hpp b/modules/stitching/include/opencv2/stitching/detail/warpers.hpp index 1b05651f9adc..96b40123a7cf 100644 --- a/modules/stitching/include/opencv2/stitching/detail/warpers.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/warpers.hpp @@ -123,9 +123,9 @@ class CV_EXPORTS RotationWarper */ struct CV_EXPORTS ProjectorBase { - void setCameraParams(InputArray K = Mat::eye(3, 3, CV_32F), - InputArray R = Mat::eye(3, 3, CV_32F), - InputArray T = Mat::zeros(3, 1, CV_32F)); + void setCameraParams(InputArray K = Mat::eye(3, 3, CV_32FC1), + InputArray R = Mat::eye(3, 3, CV_32FC1), + InputArray T = Mat::zeros(3, 1, CV_32FC1)); float scale; float k[9]; diff --git a/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp b/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp index f4a19d9c24ff..f0a247a8569b 100644 --- a/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/warpers_inl.hpp @@ -70,8 +70,8 @@ Rect RotationWarperBase

::buildMaps(Size src_size, InputArray K, InputArray R, Point dst_tl, dst_br; detectResultRoi(src_size, dst_tl, dst_br); - _xmap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); - _ymap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); + _xmap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32FC1); + _ymap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32FC1); Mat xmap = _xmap.getMat(), ymap = _ymap.getMat(); @@ -116,8 +116,8 @@ void RotationWarperBase

::warpBackward(InputArray src, InputArray K, InputArra Size size = src.size(); CV_Assert(src_br.x - src_tl.x + 1 == size.width && src_br.y - src_tl.y + 1 == size.height); - Mat xmap(dst_size, CV_32F); - Mat ymap(dst_size, CV_32F); + Mat xmap(dst_size, CV_32FC1); + Mat ymap(dst_size, CV_32FC1); float u, v; for (int y = 0; y < dst_size.height; ++y) diff --git a/modules/stitching/perf/perf_estimators.cpp b/modules/stitching/perf/perf_estimators.cpp index 7b2b53392705..840b4e00d09b 100644 --- a/modules/stitching/perf/perf_estimators.cpp +++ b/modules/stitching/perf/perf_estimators.cpp @@ -91,7 +91,7 @@ PERF_TEST_P(bundleAdjuster, affine, testing::Combine(TEST_DETECTORS, AFFINE_FUNC SANITY_CHECK(R_second, .01, ERROR_ABSOLUTE); // rotations must be more precise // last row should be precisely (0, 0, 1) as it is just added for representation in homogeneous // coordinates - EXPECT_TRUE(h.type() == CV_32F); + EXPECT_TRUE(h.type() == CV_32FC1); EXPECT_FLOAT_EQ(h.at(0), 0.f); EXPECT_FLOAT_EQ(h.at(1), 0.f); EXPECT_FLOAT_EQ(h.at(2), 1.f); diff --git a/modules/stitching/src/autocalib.cpp b/modules/stitching/src/autocalib.cpp index 18b6e048d00e..907e7343acda 100644 --- a/modules/stitching/src/autocalib.cpp +++ b/modules/stitching/src/autocalib.cpp @@ -62,7 +62,7 @@ namespace detail { void focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, bool &f1_ok) { - CV_Assert(H.type() == CV_64F && H.size() == Size(3, 3)); + CV_Assert(H.type() == CV_64FC1 && H.size() == Size(3, 3)); const double* h = H.ptr(); @@ -147,7 +147,7 @@ bool calibrateRotatingCamera(const std::vector &Hs, Mat &K) std::vector Hs_(m); for (int i = 0; i < m; ++i) { - CV_Assert(Hs[i].size() == Size(3, 3) && Hs[i].type() == CV_64F); + CV_Assert(Hs[i].size() == Size(3, 3) && Hs[i].type() == CV_64FC1); Hs_[i] = Hs[i] / std::pow(determinant(Hs[i]), 1./3.); } diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index 3e21a8fdb43f..40e4ddc57a2e 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -87,7 +87,7 @@ void Blender::prepare(Rect dst_roi) { dst_.create(dst_roi.size(), CV_16SC3); dst_.setTo(Scalar::all(0)); - dst_mask_.create(dst_roi.size(), CV_8U); + dst_mask_.create(dst_roi.size(), CV_8UC1); dst_mask_.setTo(Scalar::all(0)); dst_roi_ = dst_roi; } @@ -101,7 +101,7 @@ void Blender::feed(InputArray _img, InputArray _mask, Point tl) Mat dst_mask = dst_mask_.getMat(ACCESS_RW); CV_Assert(img.type() == CV_16SC3); - CV_Assert(mask.type() == CV_8U); + CV_Assert(mask.type() == CV_8UC1); int dx = tl.x - dst_roi_.x; int dy = tl.y - dst_roi_.y; @@ -137,7 +137,7 @@ void Blender::blend(InputOutputArray dst, InputOutputArray dst_mask) void FeatherBlender::prepare(Rect dst_roi) { Blender::prepare(dst_roi); - dst_weight_map_.create(dst_roi.size(), CV_32F); + dst_weight_map_.create(dst_roi.size(), CV_32FC1); dst_weight_map_.setTo(0); } @@ -148,7 +148,7 @@ void FeatherBlender::feed(InputArray _img, InputArray mask, Point tl) Mat dst = dst_.getMat(ACCESS_RW); CV_Assert(img.type() == CV_16SC3); - CV_Assert(mask.type() == CV_8U); + CV_Assert(mask.type() == CV_8UC1); createWeightMap(mask, sharpness_, weight_map_); Mat weight_map = weight_map_.getMat(ACCESS_READ); @@ -191,7 +191,7 @@ Rect FeatherBlender::createWeightMaps(const std::vector &masks, const std: createWeightMap(masks[i], sharpness_, weight_maps[i]); Rect dst_roi = resultRoi(corners, masks); - Mat weights_sum(dst_roi.size(), CV_32F); + Mat weights_sum(dst_roi.size(), CV_32FC1); weights_sum.setTo(0); for (size_t i = 0; i < weight_maps.size(); ++i) @@ -214,7 +214,7 @@ Rect FeatherBlender::createWeightMaps(const std::vector &masks, const std: } -MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, int weight_type) +MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, ElemDepth weight_type) { num_bands_ = 0; setNumBands(num_bands); @@ -263,7 +263,7 @@ void MultiBandBlender::prepare(Rect dst_roi) gpu_dst_pyr_laplace_[0].setTo(Scalar::all(0)); gpu_dst_band_weights_.resize(num_bands_ + 1); - gpu_dst_band_weights_[0].create(dst_roi.size(), weight_type_); + gpu_dst_band_weights_[0].create(dst_roi.size(), CV_MAKETYPE(weight_type_, 1)); gpu_dst_band_weights_[0].setTo(0); for (int i = 1; i <= num_bands_; ++i) @@ -271,7 +271,7 @@ void MultiBandBlender::prepare(Rect dst_roi) gpu_dst_pyr_laplace_[i].create((gpu_dst_pyr_laplace_[i - 1].rows + 1) / 2, (gpu_dst_pyr_laplace_[i - 1].cols + 1) / 2, CV_16SC3); gpu_dst_band_weights_[i].create((gpu_dst_band_weights_[i - 1].rows + 1) / 2, - (gpu_dst_band_weights_[i - 1].cols + 1) / 2, weight_type_); + (gpu_dst_band_weights_[i - 1].cols + 1) / 2, CV_MAKETYPE(weight_type_, 1)); gpu_dst_pyr_laplace_[i].setTo(Scalar::all(0)); gpu_dst_band_weights_[i].setTo(0); } @@ -283,7 +283,7 @@ void MultiBandBlender::prepare(Rect dst_roi) dst_pyr_laplace_[0] = dst_; dst_band_weights_.resize(num_bands_ + 1); - dst_band_weights_[0].create(dst_roi.size(), weight_type_); + dst_band_weights_[0].create(dst_roi.size(), CV_MAKETYPE(weight_type_, 1)); dst_band_weights_[0].setTo(0); for (int i = 1; i <= num_bands_; ++i) @@ -291,7 +291,7 @@ void MultiBandBlender::prepare(Rect dst_roi) dst_pyr_laplace_[i].create((dst_pyr_laplace_[i - 1].rows + 1) / 2, (dst_pyr_laplace_[i - 1].cols + 1) / 2, CV_16SC3); dst_band_weights_[i].create((dst_band_weights_[i - 1].rows + 1) / 2, - (dst_band_weights_[i - 1].cols + 1) / 2, weight_type_); + (dst_band_weights_[i - 1].cols + 1) / 2, CV_MAKETYPE(weight_type_, 1)); dst_pyr_laplace_[i].setTo(Scalar::all(0)); dst_band_weights_[i].setTo(0); } @@ -362,7 +362,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl) #endif CV_Assert(img.type() == CV_16SC3 || img.type() == CV_8UC3); - CV_Assert(mask.type() == CV_8U); + CV_Assert(mask.type() == CV_8UC1); // Keep source image in memory with small border int gap = 3 * (1 << num_bands_); @@ -776,7 +776,7 @@ void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src) void createWeightMap(InputArray mask, float sharpness, InputOutputArray weight) { - CV_Assert(mask.type() == CV_8U); + CV_Assert(mask.type() == CV_8UC1); distanceTransform(mask, weight, DIST_L1, 3); UMat tmp; multiply(weight, sharpness, tmp); diff --git a/modules/stitching/src/camera.cpp b/modules/stitching/src/camera.cpp index 0b1ae36a94dc..f14793c69e94 100644 --- a/modules/stitching/src/camera.cpp +++ b/modules/stitching/src/camera.cpp @@ -46,7 +46,7 @@ namespace cv { namespace detail { CameraParams::CameraParams() : focal(1), aspect(1), ppx(0), ppy(0), - R(Mat::eye(3, 3, CV_64F)), t(Mat::zeros(3, 1, CV_64F)) {} + R(Mat::eye(3, 3, CV_64FC1)), t(Mat::zeros(3, 1, CV_64FC1)) {} CameraParams::CameraParams(const CameraParams &other) { *this = other; } @@ -63,7 +63,7 @@ CameraParams& CameraParams::operator =(const CameraParams &other) Mat CameraParams::K() const { - Mat_ k = Mat::eye(3, 3, CV_64F); + Mat_ k = Mat::eye(3, 3, CV_64FC1); k(0,0) = focal; k(0,2) = ppx; k(1,1) = focal * aspect; k(1,2) = ppy; return k; diff --git a/modules/stitching/src/exposure_compensate.cpp b/modules/stitching/src/exposure_compensate.cpp index 7b72efbd16a6..ec91f41f437b 100644 --- a/modules/stitching/src/exposure_compensate.cpp +++ b/modules/stitching/src/exposure_compensate.cpp @@ -209,7 +209,7 @@ void BlocksGainCompensator::feed(const std::vector &corners, const std::v for (int img_idx = 0; img_idx < num_images; ++img_idx) { Size bl_per_img = bl_per_imgs[img_idx]; - gain_maps_[img_idx].create(bl_per_img, CV_32F); + gain_maps_[img_idx].create(bl_per_img, CV_32FC1); { Mat_ gain_map = gain_maps_[img_idx].getMat(ACCESS_WRITE); diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index 6d583c8a6aa8..76d0496583ba 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -58,6 +58,11 @@ using xfeatures2d::SIFT; # include "opencv2/cudaimgproc.hpp" #endif +#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER +// Tell MS VC++ to suppress exception specification warnings +#pragma warning(disable:4290) +#endif + namespace { struct DistIdxPair @@ -674,10 +679,10 @@ void FeaturesMatcher::operator ()(const std::vector &features, st { const int num_images = static_cast(features.size()); - CV_Assert(mask.empty() || (mask.type() == CV_8U && mask.cols == num_images && mask.rows)); + CV_Assert(mask.empty() || (mask.type() == CV_8UC1 && mask.cols == num_images && mask.rows)); Mat_ mask_(mask.getMat(ACCESS_READ)); if (mask_.empty()) - mask_ = Mat::ones(num_images, num_images, CV_8U); + mask_ = Mat::ones(num_images, num_images, CV_8UC1); std::vector > near_pairs; for (int i = 0; i < num_images - 1; ++i) @@ -816,10 +821,10 @@ void BestOf2NearestRangeMatcher::operator ()(const std::vector &f { const int num_images = static_cast(features.size()); - CV_Assert(mask.empty() || (mask.type() == CV_8U && mask.cols == num_images && mask.rows)); + CV_Assert(mask.empty() || (mask.type() == CV_8UC1 && mask.cols == num_images && mask.rows)); Mat_ mask_(mask.getMat(ACCESS_READ)); if (mask_.empty()) - mask_ = Mat::ones(num_images, num_images, CV_8U); + mask_ = Mat::ones(num_images, num_images, CV_8UC1); std::vector > near_pairs; for (int i = 0; i < num_images - 1; ++i) @@ -885,7 +890,7 @@ void AffineBestOf2NearestMatcher::match(const ImageFeatures &features1, const Im // matches_info.confidence = matches_info.confidence > 3. ? 0. : matches_info.confidence; // extend H to represent linear transformation in homogeneous coordinates - matches_info.H.push_back(Mat::zeros(1, 3, CV_64F)); + matches_info.H.push_back(Mat::zeros(1, 3, CV_64FC1)); matches_info.H.at(2, 2) = 1; } diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp index 6a07842444e6..84b52c000fae 100644 --- a/modules/stitching/src/motion_estimators.cpp +++ b/modules/stitching/src/motion_estimators.cpp @@ -66,13 +66,13 @@ struct CalcRotation { int pair_idx = edge.from * num_images + edge.to; - Mat_ K_from = Mat::eye(3, 3, CV_64F); + Mat_ K_from = Mat::eye(3, 3, CV_64FC1); K_from(0,0) = cameras[edge.from].focal; K_from(1,1) = cameras[edge.from].focal * cameras[edge.from].aspect; K_from(0,2) = cameras[edge.from].ppx; K_from(1,2) = cameras[edge.from].ppy; - Mat_ K_to = Mat::eye(3, 3, CV_64F); + Mat_ K_to = Mat::eye(3, 3, CV_64FC1); K_to(0,0) = cameras[edge.to].focal; K_to(1,1) = cameras[edge.to].focal * cameras[edge.to].aspect; K_to(0,2) = cameras[edge.to].ppx; @@ -328,7 +328,7 @@ bool BundleAdjusterBase::estimate(const std::vector &features, void BundleAdjusterReproj::setUpInitialCameraParams(const std::vector &cameras) { - cam_params_.create(num_images_ * 7, 1, CV_64F); + cam_params_.create(num_images_ * 7, 1, CV_64FC1); SVD svd; for (int i = 0; i < num_images_; ++i) { @@ -344,7 +344,7 @@ void BundleAdjusterReproj::setUpInitialCameraParams(const std::vector(i * 7 + 4, 0) = rvec.at(0, 0); cam_params_.at(i * 7 + 5, 0) = rvec.at(1, 0); cam_params_.at(i * 7 + 6, 0) = rvec.at(2, 0); @@ -361,7 +361,7 @@ void BundleAdjusterReproj::obtainRefinedCameraParams(std::vector & cameras[i].ppy = cam_params_.at(i * 7 + 2, 0); cameras[i].aspect = cam_params_.at(i * 7 + 3, 0); - Mat rvec(3, 1, CV_64F); + Mat rvec(3, 1, CV_64FC1); rvec.at(0, 0) = cam_params_.at(i * 7 + 4, 0); rvec.at(1, 0) = cam_params_.at(i * 7 + 5, 0); rvec.at(2, 0) = cam_params_.at(i * 7 + 6, 0); @@ -376,7 +376,7 @@ void BundleAdjusterReproj::obtainRefinedCameraParams(std::vector & void BundleAdjusterReproj::calcError(Mat &err) { - err.create(total_num_matches_ * 2, 1, CV_64F); + err.create(total_num_matches_ * 2, 1, CV_64FC1); int match_idx = 0; for (size_t edge_idx = 0; edge_idx < edges_.size(); ++edge_idx) @@ -393,15 +393,15 @@ void BundleAdjusterReproj::calcError(Mat &err) double a2 = cam_params_.at(j * 7 + 3, 0); double R1[9]; - Mat R1_(3, 3, CV_64F, R1); - Mat rvec(3, 1, CV_64F); + Mat R1_(3, 3, CV_64FC1, R1); + Mat rvec(3, 1, CV_64FC1); rvec.at(0, 0) = cam_params_.at(i * 7 + 4, 0); rvec.at(1, 0) = cam_params_.at(i * 7 + 5, 0); rvec.at(2, 0) = cam_params_.at(i * 7 + 6, 0); Rodrigues(rvec, R1_); double R2[9]; - Mat R2_(3, 3, CV_64F, R2); + Mat R2_(3, 3, CV_64FC1, R2); rvec.at(0, 0) = cam_params_.at(j * 7 + 4, 0); rvec.at(1, 0) = cam_params_.at(j * 7 + 5, 0); rvec.at(2, 0) = cam_params_.at(j * 7 + 6, 0); @@ -411,11 +411,11 @@ void BundleAdjusterReproj::calcError(Mat &err) const ImageFeatures& features2 = features_[j]; const MatchesInfo& matches_info = pairwise_matches_[i * num_images_ + j]; - Mat_ K1 = Mat::eye(3, 3, CV_64F); + Mat_ K1 = Mat::eye(3, 3, CV_64FC1); K1(0,0) = f1; K1(0,2) = ppx1; K1(1,1) = f1*a1; K1(1,2) = ppy1; - Mat_ K2 = Mat::eye(3, 3, CV_64F); + Mat_ K2 = Mat::eye(3, 3, CV_64FC1); K2(0,0) = f2; K2(0,2) = ppx2; K2(1,1) = f2*a2; K2(1,2) = ppy2; @@ -443,7 +443,7 @@ void BundleAdjusterReproj::calcError(Mat &err) void BundleAdjusterReproj::calcJacobian(Mat &jac) { - jac.create(total_num_matches_ * 2, num_images_ * 7, CV_64F); + jac.create(total_num_matches_ * 2, num_images_ * 7, CV_64FC1); jac.setTo(0); double val; @@ -509,7 +509,7 @@ void BundleAdjusterReproj::calcJacobian(Mat &jac) void BundleAdjusterRay::setUpInitialCameraParams(const std::vector &cameras) { - cam_params_.create(num_images_ * 4, 1, CV_64F); + cam_params_.create(num_images_ * 4, 1, CV_64FC1); SVD svd; for (int i = 0; i < num_images_; ++i) { @@ -522,7 +522,7 @@ void BundleAdjusterRay::setUpInitialCameraParams(const std::vector Mat rvec; Rodrigues(R, rvec); - CV_Assert(rvec.type() == CV_32F); + CV_Assert(rvec.type() == CV_32FC1); cam_params_.at(i * 4 + 1, 0) = rvec.at(0, 0); cam_params_.at(i * 4 + 2, 0) = rvec.at(1, 0); cam_params_.at(i * 4 + 3, 0) = rvec.at(2, 0); @@ -536,7 +536,7 @@ void BundleAdjusterRay::obtainRefinedCameraParams(std::vector &cam { cameras[i].focal = cam_params_.at(i * 4, 0); - Mat rvec(3, 1, CV_64F); + Mat rvec(3, 1, CV_64FC1); rvec.at(0, 0) = cam_params_.at(i * 4 + 1, 0); rvec.at(1, 0) = cam_params_.at(i * 4 + 2, 0); rvec.at(2, 0) = cam_params_.at(i * 4 + 3, 0); @@ -551,7 +551,7 @@ void BundleAdjusterRay::obtainRefinedCameraParams(std::vector &cam void BundleAdjusterRay::calcError(Mat &err) { - err.create(total_num_matches_ * 3, 1, CV_64F); + err.create(total_num_matches_ * 3, 1, CV_64FC1); int match_idx = 0; for (size_t edge_idx = 0; edge_idx < edges_.size(); ++edge_idx) @@ -562,15 +562,15 @@ void BundleAdjusterRay::calcError(Mat &err) double f2 = cam_params_.at(j * 4, 0); double R1[9]; - Mat R1_(3, 3, CV_64F, R1); - Mat rvec(3, 1, CV_64F); + Mat R1_(3, 3, CV_64FC1, R1); + Mat rvec(3, 1, CV_64FC1); rvec.at(0, 0) = cam_params_.at(i * 4 + 1, 0); rvec.at(1, 0) = cam_params_.at(i * 4 + 2, 0); rvec.at(2, 0) = cam_params_.at(i * 4 + 3, 0); Rodrigues(rvec, R1_); double R2[9]; - Mat R2_(3, 3, CV_64F, R2); + Mat R2_(3, 3, CV_64FC1, R2); rvec.at(0, 0) = cam_params_.at(j * 4 + 1, 0); rvec.at(1, 0) = cam_params_.at(j * 4 + 2, 0); rvec.at(2, 0) = cam_params_.at(j * 4 + 3, 0); @@ -580,11 +580,11 @@ void BundleAdjusterRay::calcError(Mat &err) const ImageFeatures& features2 = features_[j]; const MatchesInfo& matches_info = pairwise_matches_[i * num_images_ + j]; - Mat_ K1 = Mat::eye(3, 3, CV_64F); + Mat_ K1 = Mat::eye(3, 3, CV_64FC1); K1(0,0) = f1; K1(0,2) = features1.img_size.width * 0.5; K1(1,1) = f1; K1(1,2) = features1.img_size.height * 0.5; - Mat_ K2 = Mat::eye(3, 3, CV_64F); + Mat_ K2 = Mat::eye(3, 3, CV_64FC1); K2(0,0) = f2; K2(0,2) = features2.img_size.width * 0.5; K2(1,1) = f2; K2(1,2) = features2.img_size.height * 0.5; @@ -625,7 +625,7 @@ void BundleAdjusterRay::calcError(Mat &err) void BundleAdjusterRay::calcJacobian(Mat &jac) { - jac.create(total_num_matches_ * 3, num_images_ * 4, CV_64F); + jac.create(total_num_matches_ * 3, num_images_ * 4, CV_64FC1); double val; const double step = 1e-3; @@ -649,17 +649,17 @@ void BundleAdjusterRay::calcJacobian(Mat &jac) void BundleAdjusterAffine::setUpInitialCameraParams(const std::vector &cameras) { - cam_params_.create(num_images_ * 6, 1, CV_64F); + cam_params_.create(num_images_ * 6, 1, CV_64FC1); for (size_t i = 0; i < static_cast(num_images_); ++i) { - CV_Assert(cameras[i].R.type() == CV_32F); + CV_Assert(cameras[i].R.type() == CV_32FC1); // cameras[i].R is // a b tx // c d ty // 0 0 1. (optional) // cam_params_ model for LevMarq is // (a, b, tx, c, d, ty) - Mat params (2, 3, CV_64F, cam_params_.ptr() + i * 6); + Mat params (2, 3, CV_64FC1, cam_params_.ptr() + i * 6); cameras[i].R.rowRange(0, 2).convertTo(params, CV_64F); } } @@ -673,7 +673,7 @@ void BundleAdjusterAffine::obtainRefinedCameraParams(std::vector & // a b tx // c d ty // 0 0 1 - cameras[i].R = Mat::eye(3, 3, CV_32F); + cameras[i].R = Mat::eye(3, 3, CV_32FC1); Mat params = cam_params_.rowRange(i * 6, i * 6 + 6).reshape(1, 2); params.convertTo(cameras[i].R.rowRange(0, 2), CV_32F); } @@ -682,7 +682,7 @@ void BundleAdjusterAffine::obtainRefinedCameraParams(std::vector & void BundleAdjusterAffine::calcError(Mat &err) { - err.create(total_num_matches_ * 2, 1, CV_64F); + err.create(total_num_matches_ * 2, 1, CV_64FC1); int match_idx = 0; for (size_t edge_idx = 0; edge_idx < edges_.size(); ++edge_idx) @@ -694,15 +694,15 @@ void BundleAdjusterAffine::calcError(Mat &err) const ImageFeatures& features2 = features_[j]; const MatchesInfo& matches_info = pairwise_matches_[i * num_images_ + j]; - Mat H1 (2, 3, CV_64F, cam_params_.ptr() + i * 6); - Mat H2 (2, 3, CV_64F, cam_params_.ptr() + j * 6); + Mat H1 (2, 3, CV_64FC1, cam_params_.ptr() + i * 6); + Mat H2 (2, 3, CV_64FC1, cam_params_.ptr() + j * 6); // invert H1 Mat H1_inv; invertAffineTransform(H1, H1_inv); // convert to representation in homogeneous coordinates - Mat last_row = Mat::zeros(1, 3, CV_64F); + Mat last_row = Mat::zeros(1, 3, CV_64FC1); last_row.at(2) = 1.; H1_inv.push_back(last_row); H2.push_back(last_row); @@ -732,7 +732,7 @@ void BundleAdjusterAffine::calcError(Mat &err) void BundleAdjusterAffine::calcJacobian(Mat &jac) { - jac.create(total_num_matches_ * 2, num_images_ * 6, CV_64F); + jac.create(total_num_matches_ * 2, num_images_ * 6, CV_64FC1); double val; const double step = 1e-4; @@ -757,10 +757,10 @@ void BundleAdjusterAffine::calcJacobian(Mat &jac) void BundleAdjusterAffinePartial::setUpInitialCameraParams(const std::vector &cameras) { - cam_params_.create(num_images_ * 4, 1, CV_64F); + cam_params_.create(num_images_ * 4, 1, CV_64FC1); for (size_t i = 0; i < static_cast(num_images_); ++i) { - CV_Assert(cameras[i].R.type() == CV_32F); + CV_Assert(cameras[i].R.type() == CV_32FC1); // cameras[i].R is // a -b tx // b a ty @@ -793,7 +793,7 @@ void BundleAdjusterAffinePartial::obtainRefinedCameraParams(std::vector() + j * 4; double H2_buf[9] = { @@ -828,12 +828,12 @@ void BundleAdjusterAffinePartial::calcError(Mat &err) H2_ptr[1], H2_ptr[0], H2_ptr[3], 0., 0., 1. }; - Mat H2 (3, 3, CV_64F, H2_buf); + Mat H2 (3, 3, CV_64FC1, H2_buf); // invert H1 Mat H1_aff (H1, Range(0, 2)); double H1_inv_buf[6]; - Mat H1_inv (2, 3, CV_64F, H1_inv_buf); + Mat H1_inv (2, 3, CV_64FC1, H1_inv_buf); invertAffineTransform(H1_aff, H1_inv); H1_inv.copyTo(H1_aff); @@ -862,7 +862,7 @@ void BundleAdjusterAffinePartial::calcError(Mat &err) void BundleAdjusterAffinePartial::calcJacobian(Mat &jac) { - jac.create(total_num_matches_ * 2, num_images_ * 4, CV_64F); + jac.create(total_num_matches_ * 2, num_images_ * 4, CV_64FC1); double val; const double step = 1e-4; @@ -897,7 +897,7 @@ void waveCorrect(std::vector &rmats, WaveCorrectKind kind) return; } - Mat moment = Mat::zeros(3, 3, CV_32F); + Mat moment = Mat::zeros(3, 3, CV_32FC1); for (size_t i = 0; i < rmats.size(); ++i) { Mat col = rmats[i].col(0); @@ -914,7 +914,7 @@ void waveCorrect(std::vector &rmats, WaveCorrectKind kind) else CV_Error(CV_StsBadArg, "unsupported kind of wave correction"); - Mat img_k = Mat::zeros(3, 1, CV_32F); + Mat img_k = Mat::zeros(3, 1, CV_32FC1); for (size_t i = 0; i < rmats.size(); ++i) img_k += rmats[i].col(2); Mat rg0 = rg1.cross(img_k); @@ -951,7 +951,7 @@ void waveCorrect(std::vector &rmats, WaveCorrectKind kind) } } - Mat R = Mat::zeros(3, 3, CV_32F); + Mat R = Mat::zeros(3, 3, CV_32FC1); Mat tmp = R.row(0); Mat(rg0.t()).copyTo(tmp); tmp = R.row(1); diff --git a/modules/stitching/src/seam_finders.cpp b/modules/stitching/src/seam_finders.cpp index 4a1f86a33d79..b3ccee47cdb9 100644 --- a/modules/stitching/src/seam_finders.cpp +++ b/modules/stitching/src/seam_finders.cpp @@ -112,8 +112,8 @@ void VoronoiSeamFinder::find(const std::vector &sizes, const std::vector

control = Mat::zeros(roi.size(), CV_8U); - Mat_ reachable = Mat::zeros(roi.size(), CV_8U); - Mat_ cost = Mat::zeros(roi.size(), CV_32F); + Mat_ control = Mat::zeros(roi.size(), CV_8UC1); + Mat_ reachable = Mat::zeros(roi.size(), CV_8UC1); + Mat_ cost = Mat::zeros(roi.size(), CV_32FC1); reachable(src) = 1; cost(src) = 0.f; @@ -937,7 +937,7 @@ void DpSeamFinder::updateLabelsUsingSeam( int comp1, int comp2, const std::vector &seam, bool isHorizontalSeam) { Mat_ mask = Mat::zeros(brs_[comp1].y - tls_[comp1].y, - brs_[comp1].x - tls_[comp1].x, CV_32S); + brs_[comp1].x - tls_[comp1].x, CV_32SC1); for (size_t i = 0; i < contours_[comp1].size(); ++i) mask(contours_[comp1][i] - tls_[comp1]) = 255; @@ -1106,8 +1106,8 @@ void GraphCutSeamFinder::Impl::find(const std::vector &src, const std::vec CV_Assert(src[i].channels() == 3); Sobel(src[i], dx, CV_32F, 1, 0); Sobel(src[i], dy, CV_32F, 0, 1); - dx_[i].create(src[i].size(), CV_32F); - dy_[i].create(src[i].size(), CV_32F); + dx_[i].create(src[i].size(), CV_32FC1); + dy_[i].create(src[i].size(), CV_32FC1); for (int y = 0; y < src[i].rows; ++y) { const Point3f* dx_row = dx.ptr(y); @@ -1238,12 +1238,12 @@ void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi) const int gap = 10; Mat subimg1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC3); Mat subimg2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC3); - Mat submask1(roi.height + 2 * gap, roi.width + 2 * gap, CV_8U); - Mat submask2(roi.height + 2 * gap, roi.width + 2 * gap, CV_8U); - Mat subdx1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); - Mat subdy1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); - Mat subdx2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); - Mat subdy2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); + Mat submask1(roi.height + 2 * gap, roi.width + 2 * gap, CV_8UC1); + Mat submask2(roi.height + 2 * gap, roi.width + 2 * gap, CV_8UC1); + Mat subdx1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); + Mat subdy1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); + Mat subdx2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); + Mat subdy2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); // Cut subimages and submasks with some gap for (int y = -gap; y < roi.height + gap; ++y) @@ -1351,8 +1351,8 @@ void GraphCutSeamFinderGpu::find(const std::vector &src, const std::vector CV_Assert(src[i].channels() == 3); Sobel(src[i], dx, CV_32F, 1, 0); Sobel(src[i], dy, CV_32F, 0, 1); - dx_[i].create(src[i].size(), CV_32F); - dy_[i].create(src[i].size(), CV_32F); + dx_[i].create(src[i].size(), CV_32FC1); + dy_[i].create(src[i].size(), CV_32FC1); for (int y = 0; y < src[i].rows; ++y) { const Point3f* dx_row = dx.ptr(y); @@ -1381,12 +1381,12 @@ void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi) const int gap = 10; Mat subimg1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC3); Mat subimg2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC3); - Mat submask1(roi.height + 2 * gap, roi.width + 2 * gap, CV_8U); - Mat submask2(roi.height + 2 * gap, roi.width + 2 * gap, CV_8U); - Mat subdx1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); - Mat subdy1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); - Mat subdx2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); - Mat subdy2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32F); + Mat submask1(roi.height + 2 * gap, roi.width + 2 * gap, CV_8UC1); + Mat submask2(roi.height + 2 * gap, roi.width + 2 * gap, CV_8UC1); + Mat subdx1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); + Mat subdy1(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); + Mat subdx2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); + Mat subdy2(roi.height + 2 * gap, roi.width + 2 * gap, CV_32FC1); // Cut subimages and submasks with some gap for (int y = -gap; y < roi.height + gap; ++y) @@ -1479,11 +1479,11 @@ void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img { const Size img_size = img1.size(); - terminals.create(img_size, CV_32S); - leftT.create(Size(img_size.height, img_size.width), CV_32S); - rightT.create(Size(img_size.height, img_size.width), CV_32S); - top.create(img_size, CV_32S); - bottom.create(img_size, CV_32S); + terminals.create(img_size, CV_32SC1); + leftT.create(Size(img_size.height, img_size.width), CV_32SC1); + rightT.create(Size(img_size.height, img_size.width), CV_32SC1); + top.create(img_size, CV_32SC1); + bottom.create(img_size, CV_32SC1); Mat_ terminals_(terminals); Mat_ leftT_(leftT); @@ -1571,11 +1571,11 @@ void GraphCutSeamFinderGpu::setGraphWeightsColorGrad( { const Size img_size = img1.size(); - terminals.create(img_size, CV_32S); - leftT.create(Size(img_size.height, img_size.width), CV_32S); - rightT.create(Size(img_size.height, img_size.width), CV_32S); - top.create(img_size, CV_32S); - bottom.create(img_size, CV_32S); + terminals.create(img_size, CV_32SC1); + leftT.create(Size(img_size.height, img_size.width), CV_32SC1); + rightT.create(Size(img_size.height, img_size.width), CV_32SC1); + top.create(img_size, CV_32SC1); + bottom.create(img_size, CV_32SC1); Mat_ terminals_(terminals); Mat_ leftT_(leftT); diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index e328d67ab9b0..b0277299f34f 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -205,7 +205,7 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra // Prepare image masks for (size_t i = 0; i < imgs_.size(); ++i) { - masks[i].create(seam_est_imgs_[i].size(), CV_8U); + masks[i].create(seam_est_imgs_[i].size(), CV_8UC1); masks[i].setTo(Scalar::all(255)); } @@ -339,7 +339,7 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra #endif // Warp the current image mask - mask.create(img_size, CV_8U); + mask.create(img_size, CV_8UC1); mask.setTo(Scalar::all(255)); w->warp(mask, K, cameras_[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped); LOGLN(" warp the current image mask: " << ((getTickCount() - pt) / getTickFrequency()) << " sec"); diff --git a/modules/stitching/src/warpers.cpp b/modules/stitching/src/warpers.cpp index e39384e87528..b50784701049 100644 --- a/modules/stitching/src/warpers.cpp +++ b/modules/stitching/src/warpers.cpp @@ -50,9 +50,9 @@ void ProjectorBase::setCameraParams(InputArray _K, InputArray _R, InputArray _T) { Mat K = _K.getMat(), R = _R.getMat(), T = _T.getMat(); - CV_Assert(K.size() == Size(3, 3) && K.type() == CV_32F); - CV_Assert(R.size() == Size(3, 3) && R.type() == CV_32F); - CV_Assert((T.size() == Size(1, 3) || T.size() == Size(3, 1)) && T.type() == CV_32F); + CV_Assert(K.size() == Size(3, 3) && K.type() == CV_32FC1); + CV_Assert(R.size() == Size(3, 3) && R.type() == CV_32FC1); + CV_Assert((T.size() == Size(1, 3) || T.size() == Size(3, 1)) && T.type() == CV_32FC1); Mat_ K_(K); k[0] = K_(0,0); k[1] = K_(0,1); k[2] = K_(0,2); @@ -258,9 +258,9 @@ Rect AffineWarper::warpRoi(Size src_size, InputArray K, InputArray H) void AffineWarper::getRTfromHomogeneous(InputArray H_, Mat &R, Mat &T) { Mat H = H_.getMat(); - CV_Assert(H.size() == Size(3, 3) && H.type() == CV_32F); + CV_Assert(H.size() == Size(3, 3) && H.type() == CV_32FC1); - T = Mat::zeros(3, 1, CV_32F); + T = Mat::zeros(3, 1, CV_32FC1); R = H.clone(); T.at(0,0) = R.at(0,2); diff --git a/modules/stitching/src/warpers_cuda.cpp b/modules/stitching/src/warpers_cuda.cpp index 680f4f9e0f3e..bcdc92d48fdb 100644 --- a/modules/stitching/src/warpers_cuda.cpp +++ b/modules/stitching/src/warpers_cuda.cpp @@ -149,7 +149,7 @@ static void buildWarpCylindricalMaps(Size src_size, Rect dst_roi, InputArray _K, Rect cv::detail::PlaneWarperGpu::buildMaps(Size src_size, InputArray K, InputArray R, cuda::GpuMat & xmap, cuda::GpuMat & ymap) { - return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32F), xmap, ymap); + return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32FC1), xmap, ymap); } Rect cv::detail::PlaneWarperGpu::buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, @@ -180,7 +180,7 @@ Point cv::detail::PlaneWarperGpu::warp(const cuda::GpuMat & src, InputArray K, I int interp_mode, int border_mode, cuda::GpuMat & dst) { - return warp(src, K, R, Mat::zeros(3, 1, CV_32F), interp_mode, border_mode, dst); + return warp(src, K, R, Mat::zeros(3, 1, CV_32FC1), interp_mode, border_mode, dst); } diff --git a/modules/stitching/test/test_blenders.cpp b/modules/stitching/test/test_blenders.cpp index ddd4d5ce900c..31d02aaa9367 100644 --- a/modules/stitching/test/test_blenders.cpp +++ b/modules/stitching/test/test_blenders.cpp @@ -53,11 +53,11 @@ TEST(MultiBandBlender, CanBlendTwoImages) image1.convertTo(image1s, CV_16S); image2.convertTo(image2s, CV_16S); - Mat mask1(image1s.size(), CV_8U); + Mat mask1(image1s.size(), CV_8UC1); mask1(Rect(0, 0, mask1.cols/2, mask1.rows)).setTo(255); mask1(Rect(mask1.cols/2, 0, mask1.cols - mask1.cols/2, mask1.rows)).setTo(0); - Mat mask2(image2s.size(), CV_8U); + Mat mask2(image2s.size(), CV_8UC1); mask2(Rect(0, 0, mask2.cols/2, mask2.rows)).setTo(0); mask2(Rect(mask2.cols/2, 0, mask2.cols - mask2.cols/2, mask2.rows)).setTo(255); diff --git a/modules/stitching/test/test_blenders.cuda.cpp b/modules/stitching/test/test_blenders.cuda.cpp index 0a3f61e2e47a..00861533894c 100644 --- a/modules/stitching/test/test_blenders.cuda.cpp +++ b/modules/stitching/test/test_blenders.cuda.cpp @@ -72,11 +72,11 @@ TEST(CUDA_MultiBandBlender, Accuracy) image1.convertTo(image1s, CV_16S); image2.convertTo(image2s, CV_16S); - Mat mask1(image1s.size(), CV_8U); + Mat mask1(image1s.size(), CV_8UC1); mask1(Rect(0, 0, mask1.cols/2, mask1.rows)).setTo(255); mask1(Rect(mask1.cols/2, 0, mask1.cols - mask1.cols/2, mask1.rows)).setTo(0); - Mat mask2(image2s.size(), CV_8U); + Mat mask2(image2s.size(), CV_8UC1); mask2(Rect(0, 0, mask2.cols/2, mask2.rows)).setTo(0); mask2(Rect(mask2.cols/2, 0, mask2.cols - mask2.cols/2, mask2.rows)).setTo(255); diff --git a/modules/superres/perf/perf_superres.cpp b/modules/superres/perf/perf_superres.cpp index 3fdbbfa8045c..fe10cc1b8563 100644 --- a/modules/superres/perf/perf_superres.cpp +++ b/modules/superres/perf/perf_superres.cpp @@ -116,13 +116,17 @@ namespace } // namespace PERF_TEST_P(Size_MatType, SuperResolution_BTVL1, - Combine(Values(szSmall64, szSmall128), - Values(MatType(CV_8UC1), MatType(CV_8UC3)))) + Combine + ( + Values(szSmall64, szSmall128), + Values(CV_8UC1, CV_8UC3) + ) +) { declare.time(5 * 60); const Size size = get<0>(GetParam()); - const int type = get<1>(GetParam()); + const ElemType type = get<1>(GetParam()); Mat frame(size, type); declare.in(frame, WARMUP_RNG); @@ -178,14 +182,14 @@ typedef Size_MatType SuperResolution_BTVL1; OCL_PERF_TEST_P(SuperResolution_BTVL1 ,BTVL1, Combine(Values(szSmall64, szSmall128), - Values(MatType(CV_8UC1), MatType(CV_8UC3)))) + Values(CV_8UC1, CV_8UC3))) { Size_MatType_t params = GetParam(); const Size size = get<0>(params); - const int type = get<1>(params); + const ElemType type = get<1>(params); Mat frame(size, type); - UMat dst(1, 1, 0); + UMat dst(1, 1, CV_8UC1); declare.in(frame, WARMUP_RNG); const int scale = 2; diff --git a/modules/superres/src/btv_l1.cpp b/modules/superres/src/btv_l1.cpp index cf2ca58ceb57..c7c537587fb3 100644 --- a/modules/superres/src/btv_l1.cpp +++ b/modules/superres/src/btv_l1.cpp @@ -244,7 +244,8 @@ namespace static bool ocl_upscale(InputArray _src, OutputArray _dst, int scale) { - int type = _src.type(), cn = CV_MAT_CN(type); + ElemType type = _src.type(); + int cn = CV_MAT_CN(type); ocl::Kernel k("upscale", ocl::superres::superres_btvl1_oclsrc, format("-D cn=%d", cn)); if (k.empty()) diff --git a/modules/superres/src/btv_l1_cuda.cpp b/modules/superres/src/btv_l1_cuda.cpp index dd8c305035f6..9ac53cb62d0e 100644 --- a/modules/superres/src/btv_l1_cuda.cpp +++ b/modules/superres/src/btv_l1_cuda.cpp @@ -321,7 +321,7 @@ namespace { filters_.resize(src.size()); for (size_t i = 0; i < src.size(); ++i) - filters_[i] = cuda::createGaussianFilter(src[0].type(), -1, Size(blurKernelSize_, blurKernelSize_), blurSigma_); + filters_[i] = cuda::createGaussianFilter(src[0].type(), CV_TYPE_AUTO, Size(blurKernelSize_, blurKernelSize_), blurSigma_); curBlurKernelSize_ = blurKernelSize_; curBlurSigma_ = blurSigma_; curSrcType_ = src[0].type(); diff --git a/modules/superres/src/input_array_utility.cpp b/modules/superres/src/input_array_utility.cpp index fd60c20bd927..e9c77c30b831 100644 --- a/modules/superres/src/input_array_utility.cpp +++ b/modules/superres/src/input_array_utility.cpp @@ -198,9 +198,9 @@ namespace } } - void convertToDepth(InputArray src, OutputArray dst, int depth) + void convertToDepth(InputArray src, OutputArray dst, ElemDepth depth) { - const int sdepth = src.depth(); + const ElemDepth sdepth = src.depth(); CV_Assert( sdepth <= CV_64F ); CV_Assert( depth == CV_8U || depth == CV_32F ); @@ -241,7 +241,7 @@ Mat cv::superres::convertToType(const Mat& src, int type, Mat& buf0, Mat& buf1) if (src.type() == type) return src; - const int depth = CV_MAT_DEPTH(type); + const ElemDepth depth = CV_MAT_DEPTH(type); const int cn = CV_MAT_CN(type); if (src.depth() == depth) @@ -268,7 +268,7 @@ UMat cv::superres::convertToType(const UMat& src, int type, UMat& buf0, UMat& bu if (src.type() == type) return src; - const int depth = CV_MAT_DEPTH(type); + const ElemDepth depth = CV_MAT_DEPTH(type); const int cn = CV_MAT_CN(type); if (src.depth() == depth) @@ -293,7 +293,7 @@ GpuMat cv::superres::convertToType(const GpuMat& src, int type, GpuMat& buf0, Gp if (src.type() == type) return src; - const int depth = CV_MAT_DEPTH(type); + const ElemDepth depth = CV_MAT_DEPTH(type); const int cn = CV_MAT_CN(type); if (src.depth() == depth) diff --git a/modules/superres/test/test_superres.cpp b/modules/superres/test/test_superres.cpp index b0d4122f6e2a..8e926b056c1f 100644 --- a/modules/superres/test/test_superres.cpp +++ b/modules/superres/test/test_superres.cpp @@ -115,7 +115,9 @@ DegradeFrameSource::DegradeFrameSource(const cv::Ptr& static void addGaussNoise(cv::OutputArray _image, double sigma) { - int type = _image.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + ElemType type = _image.type(); + ElemDepth depth = CV_MAT_DEPTH(type); + int cn = CV_MAT_CN(type); cv::Mat noise(_image.size(), CV_32FC(cn)); cvtest::TS::ptr()->get_rng().fill(noise, cv::RNG::NORMAL, 0.0, sigma); @@ -157,7 +159,7 @@ double MSSIM(cv::InputArray _i1, cv::InputArray _i2) const double C1 = 6.5025; const double C2 = 58.5225; - const int depth = CV_32F; + const ElemDepth depth = CV_32F; cv::Mat I1, I2; _i1.getMat().convertTo(I1, depth); diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index be08238336a4..2989308f17d2 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -179,20 +179,20 @@ inline int clipInt( int val, int min_val, int max_val ) return val; } -double getMinVal(int depth); -double getMaxVal(int depth); +double getMinVal(ElemDepth depth); +double getMaxVal(ElemDepth depth); Size randomSize(RNG& rng, double maxSizeLog); void randomSize(RNG& rng, int minDims, int maxDims, double maxSizeLog, vector& sz); -int randomType(RNG& rng, cv::_OutputArray::DepthMask typeMask, int minChannels, int maxChannels); -Mat randomMat(RNG& rng, Size size, int type, double minVal, double maxVal, bool useRoi); -Mat randomMat(RNG& rng, const vector& size, int type, double minVal, double maxVal, bool useRoi); +ElemType randomType(RNG& rng, cv::_OutputArray::DepthMask typeMask, int minChannels, int maxChannels); +Mat randomMat(RNG& rng, Size size, ElemType type, double minVal, double maxVal, bool useRoi); +Mat randomMat(RNG& rng, const vector& size, ElemType type, double minVal, double maxVal, bool useRoi); void add(const Mat& a, double alpha, const Mat& b, double beta, - Scalar gamma, Mat& c, int ctype, bool calcAbs=false); + Scalar gamma, Mat& c, ElemDepth cdepth, bool calcAbs=false); void multiply(const Mat& a, const Mat& b, Mat& c, double alpha=1); void divide(const Mat& a, const Mat& b, Mat& c, double alpha=1); -void convert(const Mat& src, cv::OutputArray dst, int dtype, double alpha=1, double beta=0); +void convert(const Mat& src, cv::OutputArray dst, ElemDepth ddepth, double alpha=1, double beta=0); void copy(const Mat& src, Mat& dst, const Mat& mask=Mat(), bool invertMask=false); void set(Mat& dst, const Scalar& gamma, const Mat& mask=Mat()); @@ -212,7 +212,7 @@ void erode(const Mat& src, Mat& dst, const Mat& _kernel, Point anchor=Point(-1,- int borderType=0, const Scalar& borderValue=Scalar()); void dilate(const Mat& src, Mat& dst, const Mat& _kernel, Point anchor=Point(-1,-1), int borderType=0, const Scalar& borderValue=Scalar()); -void filter2D(const Mat& src, Mat& dst, int ddepth, const Mat& kernel, +void filter2D(const Mat& src, Mat& dst, ElemDepth ddepth, const Mat& kernel, Point anchor, double delta, int borderType, const Scalar& borderValue=Scalar()); void copyMakeBorder(const Mat& src, Mat& dst, int top, int bottom, int left, int right, @@ -546,11 +546,11 @@ class ArrayTest : public BaseTest virtual int prepare_test_case( int test_case_idx ) CV_OVERRIDE; virtual int validate_test_results( int test_case_idx ) CV_OVERRIDE; - virtual void prepare_to_validation( int test_case_idx ); - virtual void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - virtual void fill_array( int test_case_idx, int i, int j, Mat& arr ); - virtual void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ); - virtual double get_success_error_level( int test_case_idx, int i, int j ); + virtual void prepare_to_validation(int test_case_idx); + virtual void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types); + virtual void fill_array(int test_case_idx, int i, int j, Mat& arr); + virtual void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high); + virtual double get_success_error_level(int test_case_idx, int i, int j); bool cvmat_allowed; bool iplimage_allowed; diff --git a/modules/ts/include/opencv2/ts/cuda_test.hpp b/modules/ts/include/opencv2/ts/cuda_test.hpp index 53bdbc8a4f10..e45239790af2 100644 --- a/modules/ts/include/opencv2/ts/cuda_test.hpp +++ b/modules/ts/include/opencv2/ts/cuda_test.hpp @@ -57,12 +57,12 @@ namespace cvtest double randomDouble(double minVal, double maxVal); cv::Size randomSize(int minVal, int maxVal); cv::Scalar randomScalar(double minVal, double maxVal); - cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0); + cv::Mat randomMat(cv::Size size, ElemType type, double minVal = 0.0, double maxVal = 255.0); ////////////////////////////////////////////////////////////////////// // GpuMat create - cv::cuda::GpuMat createMat(cv::Size size, int type, bool useRoi = false); + cv::cuda::GpuMat createMat(cv::Size size, ElemType type, bool useRoi = false); cv::cuda::GpuMat loadMat(const cv::Mat& m, bool useRoi = false); ////////////////////////////////////////////////////////////////////// @@ -72,7 +72,7 @@ namespace cvtest cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR); //! read image from testdata folder and convert it to specified type - cv::Mat readImageType(const std::string& fname, int type); + cv::Mat readImageType(const std::string& fname, ElemType type); ////////////////////////////////////////////////////////////////////// // Gpu devices @@ -248,9 +248,9 @@ namespace cvtest using perf::MatType; //! return vector with types from specified range. - std::vector types(int depth_start, int depth_end, int cn_start, int cn_end); + std::vector types(ElemDepth depth_start, ElemDepth depth_end, int cn_start, int cn_end); - //! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4). + //! return vector with all types const std::vector& all_types(); #define ALL_TYPES testing::ValuesIn(all_types()) diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp index 11572e9f4899..f303b4c1070c 100644 --- a/modules/ts/include/opencv2/ts/ocl_test.hpp +++ b/modules/ts/include/opencv2/ts/ocl_test.hpp @@ -135,7 +135,7 @@ do \ cv::threshold(diff, binary, (double)eps, 255, cv::THRESH_BINARY); \ EXPECT_LE(countNonZero(binary.reshape(1)), (int)(binary.cols*binary.rows*5/1000)) \ << "Size: " << name ## _roi.size() << std::endl; \ - binary.convertTo(binary_8, mask.type()); \ + binary.convertTo(binary_8, mask.depth()); \ binary_8 = binary_8 & mask; \ EXPECT_LE(countNonZero(binary_8.reshape(1)), (int)((binary_8.cols+binary_8.rows)/100)) \ << "Size: " << name ## _roi.size() << std::endl; \ @@ -263,7 +263,7 @@ struct TestUtils return Scalar(randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal)); } - Mat randomMat(Size size, int type, double minVal, double maxVal, bool useRoi = false) + Mat randomMat(Size size, ElemType type, double minVal, double maxVal, bool useRoi = false) { RNG dataRng(rng.next()); return cvtest::randomMat(dataRng, size, type, minVal, maxVal, useRoi); @@ -285,7 +285,7 @@ struct TestUtils return border; } - void randomSubMat(Mat& whole, Mat& subMat, const Size& roiSize, const Border& border, int type, double minVal, double maxVal) + void randomSubMat(Mat& whole, Mat& subMat, const Size& roiSize, const Border& border, ElemType type, double minVal, double maxVal) { Size wholeSize = Size(roiSize.width + border.lef + border.rig, roiSize.height + border.top + border.bot); whole = randomMat(wholeSize, type, minVal, maxVal, false); diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 586d83fae687..5c93872072a9 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -91,13 +91,28 @@ const static cv::Size szSmall128 = cv::Size(128, 128); class MatType { public: - MatType(int val=0) : _type(val) {} - operator int() const {return _type;} + MatType(int val = 0) : _type(static_cast(val)) {} + operator ElemType() const { return _type; } private: - int _type; + ElemType _type; }; + +/*****************************************************************************************\ +* MatDepth - printable wrapper over integer 'depth' of Mat * +\*****************************************************************************************/ +class MatDepth +{ +public: + MatDepth(int val = 0) : _depth(static_cast(val)) {} + operator ElemDepth() const { return _depth; } + +private: + ElemDepth _depth; +}; + + /*****************************************************************************************\ * CV_ENUM and CV_FLAGS - macro to create printable wrappers for defines and enums * \*****************************************************************************************/ @@ -137,7 +152,7 @@ class MatType class_name(int val = 0) : val_(val) {} \ operator int() const { return val_; } \ void PrintTo(std::ostream* os) const { \ - using namespace cv;using namespace cv::cuda; using namespace cv::ocl; \ + using namespace cv; using namespace cv::cuda; using namespace cv::ocl; \ const int vals[] = { __VA_ARGS__ }; \ const char* svals = #__VA_ARGS__; \ int value = val_; \ @@ -160,7 +175,6 @@ class MatType }; \ static inline void PrintTo(const class_name& t, std::ostream* os) { t.PrintTo(os); } } -CV_ENUM(MatDepth, CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F, CV_16F) /*****************************************************************************************\ * Regression control utility for performance testing * @@ -507,6 +521,7 @@ typedef TestBaseWithParam Size_MatType; * Print functions for googletest * \*****************************************************************************************/ void PrintTo(const MatType& t, std::ostream* os); +void PrintTo(const MatDepth& t, std::ostream* os); } //namespace perf @@ -606,9 +621,9 @@ void PrintTo(const Size& sz, ::std::ostream* os); // typedef ::perf::TestBaseWithParam FooTest; // // PERF_TEST_P(FooTest, DoTestingRight, ::testing::Values(::perf::szVGA, ::perf::sz720p) { -// cv::Mat b(GetParam(), CV_8U, cv::Scalar(10)); -// cv::Mat a(GetParam(), CV_8U, cv::Scalar(20)); -// cv::Mat c(GetParam(), CV_8U, cv::Scalar(0)); +// cv::Mat b(GetParam(), CV_8UC1, cv::Scalar(10)); +// cv::Mat a(GetParam(), CV_8UC1, cv::Scalar(20)); +// cv::Mat c(GetParam(), CV_8UC1, cv::Scalar(0)); // // declare.in(a, b).out(c).time(0.5); // diff --git a/modules/ts/src/cuda_test.cpp b/modules/ts/src/cuda_test.cpp index ca48d0631ede..62243d06f107 100644 --- a/modules/ts/src/cuda_test.cpp +++ b/modules/ts/src/cuda_test.cpp @@ -81,7 +81,7 @@ namespace cvtest return Scalar(randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal)); } - Mat randomMat(Size size, int type, double minVal, double maxVal) + Mat randomMat(Size size, ElemType type, double minVal, double maxVal) { return randomMat(TS::ptr()->get_rng(), size, type, minVal, maxVal, false); } @@ -89,7 +89,7 @@ namespace cvtest ////////////////////////////////////////////////////////////////////// // GpuMat create - GpuMat createMat(Size size, int type, bool useRoi) + GpuMat createMat(Size size, ElemType type, bool useRoi) { Size size0 = size; @@ -122,7 +122,7 @@ namespace cvtest return imread(TS::ptr()->get_data_path() + fileName, flags); } - Mat readImageType(const std::string& fname, int type) + Mat readImageType(const std::string& fname, ElemType type) { Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR); if (CV_MAT_CN(type) == 4) @@ -370,17 +370,17 @@ namespace cvtest ////////////////////////////////////////////////////////////////////// // Helper structs for value-parameterized tests - vector types(int depth_start, int depth_end, int cn_start, int cn_end) + vector types(ElemDepth depth_start, ElemDepth depth_end, int cn_start, int cn_end) { vector v; v.reserve((depth_end - depth_start + 1) * (cn_end - cn_start + 1)); - for (int depth = depth_start; depth <= depth_end; ++depth) + for (int depth = static_cast(depth_start); depth <= static_cast(depth_end); ++depth) { for (int cn = cn_start; cn <= cn_end; ++cn) { - v.push_back(MatType(CV_MAKE_TYPE(depth, cn))); + v.push_back(CV_MAKE_TYPE(depth, cn)); } } @@ -389,7 +389,9 @@ namespace cvtest const vector& all_types() { - static vector v = types(CV_8U, CV_64F, 1, 4); + // return vector with all types + // (depth: CV_8U - CV_64F, channels : 1 - 4) + static vector v = cvtest::types(CV_8U, CV_64F, 1, 4); return v; } diff --git a/modules/ts/src/ts_arrtest.cpp b/modules/ts/src/ts_arrtest.cpp index 365cf1550e4c..19de5d34b3ac 100644 --- a/modules/ts/src/ts_arrtest.cpp +++ b/modules/ts/src/ts_arrtest.cpp @@ -99,7 +99,7 @@ int ArrayTest::read_params( CvFileStorage* fs ) } -void ArrayTest::get_test_array_types_and_sizes( int /*test_case_idx*/, vector >& sizes, vector >& types ) +void ArrayTest::get_test_array_types_and_sizes( int /*test_case_idx*/, vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); Size size; @@ -136,7 +136,7 @@ int ArrayTest::prepare_test_case( int test_case_idx ) size_t max_arr = test_array.size(); vector > sizes(max_arr); vector > whole_sizes(max_arr); - vector > types(max_arr); + vector > types(max_arr); size_t i, j; RNG& rng = ts->get_rng(); bool is_image = false; @@ -145,7 +145,7 @@ int ArrayTest::prepare_test_case( int test_case_idx ) { size_t sizei = std::max(test_array[i].size(), (size_t)1); sizes[i].resize(sizei); - types[i].resize(sizei); + types[i].resize(static_cast(sizei)); whole_sizes[i].resize(sizei); } @@ -172,7 +172,7 @@ int ArrayTest::prepare_test_case( int test_case_idx ) cvRelease( &test_array[i][j] ); if( size.width > 0 && size.height > 0 && - types[i][j] >= 0 && (i != MASK || create_mask) ) + types[i][j] >= CV_8UC1 && (i != MASK || create_mask)) { if( use_roi ) { @@ -225,10 +225,9 @@ int ArrayTest::prepare_test_case( int test_case_idx ) } -void ArrayTest::get_minmax_bounds( int i, int /*j*/, int type, Scalar& low, Scalar& high ) +void ArrayTest::get_minmax_bounds(int i, int /*j*/, ElemDepth depth, Scalar& low, Scalar& high) { double l, u; - int depth = CV_MAT_DEPTH(type); if( i == MASK ) { @@ -237,8 +236,8 @@ void ArrayTest::get_minmax_bounds( int i, int /*j*/, int type, Scalar& low, Scal } else if( depth < CV_32S ) { - l = getMinVal(type); - u = getMaxVal(type); + l = getMinVal(depth); + u = getMaxVal(depth); } else { @@ -259,7 +258,8 @@ void ArrayTest::fill_array( int /*test_case_idx*/, int i, int j, Mat& arr ) { Scalar low, high; - get_minmax_bounds( i, j, arr.type(), low, high ); + ElemDepth depth = arr.depth(); + get_minmax_bounds( i, j, depth, low, high ); randUni( ts->get_rng(), arr, low, high ); } } @@ -267,7 +267,7 @@ void ArrayTest::fill_array( int /*test_case_idx*/, int i, int j, Mat& arr ) double ArrayTest::get_success_error_level( int /*test_case_idx*/, int i, int j ) { - int elem_depth = CV_MAT_DEPTH(cvGetElemType(test_array[i][j])); + ElemDepth elem_depth = CV_MAT_DEPTH(cvGetElemType(test_array[i][j])); assert( i == OUTPUT || i == INPUT_OUTPUT ); return elem_depth < CV_32F ? 0 : elem_depth == CV_32F ? FLT_EPSILON*100: DBL_EPSILON*5000; } diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp index c404759fd4eb..27a09496babe 100644 --- a/modules/ts/src/ts_func.cpp +++ b/modules/ts/src/ts_func.cpp @@ -68,23 +68,22 @@ void randomSize(RNG& rng, int minDims, int maxDims, double maxSizeLog, vector(rng.uniform(CV_8U, CV_64F + 1)); if( ((1 << depth) & typeMask) != 0 ) break; } return CV_MAKETYPE(depth, channels); } -double getMinVal(int depth) +double getMinVal(ElemDepth depth) { - depth = CV_MAT_DEPTH(depth); double val = depth == CV_8U ? 0 : depth == CV_8S ? SCHAR_MIN : depth == CV_16U ? 0 : depth == CV_16S ? SHRT_MIN : depth == CV_32S ? INT_MIN : depth == CV_32F ? -FLT_MAX : depth == CV_64F ? -DBL_MAX : -1; @@ -92,7 +91,7 @@ double getMinVal(int depth) return val; } -double getMaxVal(int depth) +double getMaxVal(ElemDepth depth) { depth = CV_MAT_DEPTH(depth); double val = depth == CV_8U ? UCHAR_MAX : depth == CV_8S ? SCHAR_MAX : depth == CV_16U ? USHRT_MAX : @@ -102,7 +101,7 @@ double getMaxVal(int depth) return val; } -Mat randomMat(RNG& rng, Size size, int type, double minVal, double maxVal, bool useRoi) +Mat randomMat(RNG& rng, Size size, ElemType type, double minVal, double maxVal, bool useRoi) { Size size0 = size; if( useRoi ) @@ -119,7 +118,7 @@ Mat randomMat(RNG& rng, Size size, int type, double minVal, double maxVal, bool return m(Rect((size0.width-size.width)/2, (size0.height-size.height)/2, size.width, size.height)); } -Mat randomMat(RNG& rng, const vector& size, int type, double minVal, double maxVal, bool useRoi) +Mat randomMat(RNG& rng, const vector& size, ElemType type, double minVal, double maxVal, bool useRoi) { int i, dims = (int)size.size(); vector size0(dims); @@ -146,13 +145,13 @@ Mat randomMat(RNG& rng, const vector& size, int type, double minVal, double } void add(const Mat& _a, double alpha, const Mat& _b, double beta, - Scalar gamma, Mat& c, int ctype, bool calcAbs) + Scalar gamma, Mat& c, ElemDepth cdepth, bool calcAbs) { Mat a = _a, b = _b; if( a.empty() || alpha == 0 ) { // both alpha and beta can be 0, but at least one of a and b must be non-empty array, - // otherwise we do not know the size of the output (and may be type of the output, when ctype<0) + // otherwise we do not know the size of the output (and may be type of the output, when cdepth == CV_DEPTH_AUTO) CV_Assert( !a.empty() || !b.empty() ); if( !b.empty() ) { @@ -170,10 +169,9 @@ void add(const Mat& _a, double alpha, const Mat& _b, double beta, else CV_Assert(a.size == b.size); - if( ctype < 0 ) - ctype = a.depth(); - ctype = CV_MAKETYPE(CV_MAT_DEPTH(ctype), a.channels()); - c.create(a.dims, &a.size[0], ctype); + if (cdepth == CV_DEPTH_AUTO) + cdepth = a.depth(); + c.create(a.dims, &a.size[0], CV_MAKETYPE(cdepth, a.channels())); const Mat *arrays[] = {&a, &b, &c, 0}; Mat planes[3], buf[3]; @@ -198,7 +196,7 @@ void add(const Mat& _a, double alpha, const Mat& _b, double beta, Mat cpart0 = planes[2].colRange(j, j2); Mat apart = buf[0].colRange(0, j2 - j); - apart0.convertTo(apart, apart.type(), alpha); + apart0.convertTo(apart, apart.depth(), alpha); size_t k, n = (j2 - j)*cn; double* aptr = apart.ptr(); const double* gptr = buf[2].ptr(); @@ -212,7 +210,7 @@ void add(const Mat& _a, double alpha, const Mat& _b, double beta, { Mat bpart0 = planes[1].colRange((int)j, (int)j2); Mat bpart = buf[1].colRange(0, (int)(j2 - j)); - bpart0.convertTo(bpart, bpart.type(), beta); + bpart0.convertTo(bpart, bpart.depth(), beta); const double* bptr = bpart.ptr(); for( k = 0; k < n; k++ ) @@ -221,7 +219,7 @@ void add(const Mat& _a, double alpha, const Mat& _b, double beta, if( calcAbs ) for( k = 0; k < n; k++ ) aptr[k] = fabs(aptr[k]); - apart.convertTo(cpart0, cpart0.type(), 1, 0); + apart.convertTo(cpart0, cpart0.depth(), 1, 0); } } } @@ -243,9 +241,9 @@ convert_(const _Tp1* src, _Tp2* dst, size_t total, double alpha, double beta) } template inline void -convertTo(const _Tp* src, void* dst, int dtype, size_t total, double alpha, double beta) +convertTo(const _Tp* src, void* dst, ElemDepth ddepth, size_t total, double alpha, double beta) { - switch( CV_MAT_DEPTH(dtype) ) + switch (CV_MAT_DEPTH(ddepth)) { case CV_8U: convert_(src, (uchar*)dst, total, alpha, beta); @@ -273,11 +271,12 @@ convertTo(const _Tp* src, void* dst, int dtype, size_t total, double alpha, doub } } -void convert(const Mat& src, cv::OutputArray _dst, int dtype, double alpha, double beta) +void convert(const Mat& src, cv::OutputArray _dst, ElemDepth ddepth, double alpha, double beta) { - if (dtype < 0) dtype = _dst.depth(); + if (ddepth == CV_DEPTH_AUTO) ddepth = _dst.depth(); + ddepth = CV_MAT_DEPTH(ddepth); /* backwards compatibility */ - dtype = CV_MAKETYPE(CV_MAT_DEPTH(dtype), src.channels()); + ElemType dtype = CV_MAKETYPE(ddepth, src.channels()); _dst.create(src.dims, &src.size[0], dtype); Mat dst = _dst.getMat(); if( alpha == 0 ) @@ -305,27 +304,29 @@ void convert(const Mat& src, cv::OutputArray _dst, int dtype, double alpha, doub switch( src.depth() ) { - case CV_8U: - convertTo((const uchar*)sptr, dptr, dtype, total, alpha, beta); + case CV_8U: + convertTo((const uchar*)sptr, dptr, ddepth, total, alpha, beta); break; - case CV_8S: - convertTo((const schar*)sptr, dptr, dtype, total, alpha, beta); + case CV_8S: + convertTo((const schar*)sptr, dptr, ddepth, total, alpha, beta); break; - case CV_16U: - convertTo((const ushort*)sptr, dptr, dtype, total, alpha, beta); + case CV_16U: + convertTo((const ushort*)sptr, dptr, ddepth, total, alpha, beta); break; - case CV_16S: - convertTo((const short*)sptr, dptr, dtype, total, alpha, beta); + case CV_16S: + convertTo((const short*)sptr, dptr, ddepth, total, alpha, beta); break; - case CV_32S: - convertTo((const int*)sptr, dptr, dtype, total, alpha, beta); + case CV_32S: + convertTo((const int*)sptr, dptr, ddepth, total, alpha, beta); break; - case CV_32F: - convertTo((const float*)sptr, dptr, dtype, total, alpha, beta); + case CV_32F: + convertTo((const float*)sptr, dptr, ddepth, total, alpha, beta); break; - case CV_64F: - convertTo((const double*)sptr, dptr, dtype, total, alpha, beta); + case CV_64F: + convertTo((const double*)sptr, dptr, ddepth, total, alpha, beta); break; + case CV_16F: + break; //unhandled } } } @@ -485,7 +486,7 @@ void insert(const Mat& src, Mat& dst, int coi) void extract(const Mat& src, Mat& dst, int coi) { - dst.create( src.dims, &src.size[0], src.depth() ); + dst.create( src.dims, &src.size[0], CV_MAKETYPE(src.depth(), 1) ); CV_Assert( 0 <= coi && coi < src.channels() ); const Mat* arrays[] = {&src, &dst, 0}; @@ -577,7 +578,8 @@ void randUni( RNG& rng, Mat& a, const Scalar& param0, const Scalar& param1 ) NAryMatIterator it(arrays, &plane); size_t i, nplanes = it.nplanes; - int depth = a.depth(), cn = a.channels(); + ElemDepth depth = a.depth(); + int cn = a.channels(); size_t total = plane.total()*cn; for( i = 0; i < nplanes; i++, ++it ) @@ -664,10 +666,10 @@ void erode(const Mat& _src, Mat& dst, const Mat& _kernel, Point anchor, Mat kernel = _kernel, src; Scalar borderValue = _borderValue; if( kernel.empty() ) - kernel = Mat::ones(3, 3, CV_8U); + kernel = Mat::ones(3, 3, CV_8UC1); else { - CV_Assert( kernel.type() == CV_8U ); + CV_Assert( kernel.type() == CV_8UC1 ); } if( anchor == Point(-1,-1) ) anchor = Point(kernel.cols/2, kernel.rows/2); @@ -721,10 +723,10 @@ void dilate(const Mat& _src, Mat& dst, const Mat& _kernel, Point anchor, Mat kernel = _kernel, src; Scalar borderValue = _borderValue; if( kernel.empty() ) - kernel = Mat::ones(3, 3, CV_8U); + kernel = Mat::ones(3, 3, CV_8UC1); else { - CV_Assert( kernel.type() == CV_8U ); + CV_Assert( kernel.type() == CV_8UC1 ); } if( anchor == Point(-1,-1) ) anchor = Point(kernel.cols/2, kernel.rows/2); @@ -796,12 +798,12 @@ filter2D_(const Mat& src, Mat& dst, const vector& ofsvec, const vector ofs; vector coeff(kernel.rows*kernel.cols); - Mat cmat(kernel.rows, kernel.cols, CV_64F, &coeff[0]); - convert(kernel, cmat, cmat.type()); + Mat cmat(kernel.rows, kernel.cols, CV_64FC1, &coeff[0]); + convert(kernel, cmat, cmat.depth()); int step = (int)(src.step/src.elemSize1()), cn = src.channels(); for( int i = 0; i < kernel.rows; i++ ) @@ -1070,7 +1072,7 @@ void minMaxLoc(const Mat& src, double* _minval, double* _maxval, NAryMatIterator it(arrays, planes); size_t startidx = 1, total = planes[0].total(); size_t i, nplanes = it.nplanes; - int depth = src.depth(); + ElemDepth depth = src.depth(); double minval = 0; double maxval = 0; size_t maxidx = 0, minidx = 0; @@ -1294,7 +1296,7 @@ double norm(InputArray _src, int normType, InputArray _mask) int normType0 = normType; normType = normType == NORM_L2SQR ? NORM_L2 : normType; - CV_Assert( mask.empty() || (src.size == mask.size && mask.type() == CV_8U) ); + CV_Assert( mask.empty() || (src.size == mask.size && mask.type() == CV_8UC1) ); CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 ); const Mat *arrays[]={&src, &mask, 0}; @@ -1303,7 +1305,8 @@ double norm(InputArray _src, int normType, InputArray _mask) NAryMatIterator it(arrays, planes); size_t total = planes[0].total(); size_t i, nplanes = it.nplanes; - int depth = src.depth(), cn = planes[0].channels(); + ElemDepth depth = src.depth(); + int cn = planes[0].channels(); double result = 0; for( i = 0; i < nplanes; i++, ++it ) @@ -1384,7 +1387,7 @@ double norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask) normType = normType == NORM_L2SQR ? NORM_L2 : normType; CV_Assert( src1.type() == src2.type() && src1.size == src2.size ); - CV_Assert( mask.empty() || (src1.size == mask.size && mask.type() == CV_8U) ); + CV_Assert( mask.empty() || (src1.size == mask.size && mask.type() == CV_8UC1) ); CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 ); const Mat *arrays[]={&src1, &src2, &mask, 0}; Mat planes[3]; @@ -1392,7 +1395,8 @@ double norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask) NAryMatIterator it(arrays, planes); size_t total = planes[0].total(); size_t i, nplanes = it.nplanes; - int depth = src1.depth(), cn = planes[0].channels(); + ElemDepth depth = src1.depth(); + int cn = planes[0].channels(); double result = 0; for( i = 0; i < nplanes; i++, ++it ) @@ -1458,7 +1462,7 @@ double crossCorr(const Mat& src1, const Mat& src2) NAryMatIterator it(arrays, planes); size_t total = planes[0].total()*planes[0].channels(); size_t i, nplanes = it.nplanes; - int depth = src1.depth(); + ElemDepth depth = src1.depth(); double result = 0; for( i = 0; i < nplanes; i++, ++it ) @@ -1667,14 +1671,14 @@ compareS_(const _Tp* src1, _WTp value, uchar* dst, size_t total, int cmpop) void compare(const Mat& src1, const Mat& src2, Mat& dst, int cmpop) { CV_Assert( src1.type() == src2.type() && src1.channels() == 1 && src1.size == src2.size ); - dst.create( src1.dims, &src1.size[0], CV_8U ); + dst.create( src1.dims, &src1.size[0], CV_8UC1 ); const Mat *arrays[]={&src1, &src2, &dst, 0}; Mat planes[3]; NAryMatIterator it(arrays, planes); size_t total = planes[0].total(); size_t i, nplanes = it.nplanes; - int depth = src1.depth(); + ElemDepth depth = src1.depth(); for( i = 0; i < nplanes; i++, ++it ) { @@ -1714,14 +1718,14 @@ void compare(const Mat& src1, const Mat& src2, Mat& dst, int cmpop) void compare(const Mat& src, double value, Mat& dst, int cmpop) { CV_Assert( src.channels() == 1 ); - dst.create( src.dims, &src.size[0], CV_8U ); + dst.create( src.dims, &src.size[0], CV_8UC1 ); const Mat *arrays[]={&src, &dst, 0}; Mat planes[2]; NAryMatIterator it(arrays, planes); size_t total = planes[0].total(); size_t i, nplanes = it.nplanes; - int depth = src.depth(); + ElemDepth depth = src.depth(); int ivalue = saturate_cast(value); for( i = 0; i < nplanes; i++, ++it ) @@ -1852,7 +1856,7 @@ bool cmpUlps(const Mat& src1, const Mat& src2, int imaxDiff, double* _realmaxdif NAryMatIterator it(arrays, planes); size_t total = planes[0].total()*planes[0].channels(); size_t i, nplanes = it.nplanes; - int depth = src1.depth(); + ElemDepth depth = src1.depth(); size_t startidx = 1, idx = 0; if(_realmaxdiff) *_realmaxdiff = 0; @@ -1938,7 +1942,7 @@ int check( const Mat& a, double fmin, double fmax, vector* _idx ) NAryMatIterator it(arrays, &plane); size_t total = plane.total()*plane.channels(); size_t i, nplanes = it.nplanes; - int depth = a.depth(); + ElemDepth depth = a.depth(); size_t startidx = 1, idx = 0; int imin = 0, imax = 0; @@ -2012,7 +2016,7 @@ int cmpEps( const Mat& arr_, const Mat& refarr_, double* _realmaxdiff, refarr = refarr32f; } - int ilevel = refarr.depth() <= CV_32S ? cvFloor(success_err_level) : 0; + int ilevel = refarr.depth() <= CV_32S ? cvFloor(success_err_level) : 0; int result = CMP_EPS_OK; const Mat *arrays[]={&arr, &refarr, 0}; @@ -2020,7 +2024,7 @@ int cmpEps( const Mat& arr_, const Mat& refarr_, double* _realmaxdiff, NAryMatIterator it(arrays, planes); size_t total = planes[0].total()*planes[0].channels(), j = total; size_t i, nplanes = it.nplanes; - int depth = arr.depth(); + ElemDepth depth = arr.depth(); size_t startidx = 1, idx = 0; double realmaxdiff = 0, maxval = 0; @@ -2188,8 +2192,8 @@ int cmpEps2( TS* ts, const Mat& a, const Mat& b, double success_err_level, int cmpEps2_64f( TS* ts, const double* val, const double* refval, int len, double eps, const char* param_name ) { - Mat _val(1, len, CV_64F, (void*)val); - Mat _refval(1, len, CV_64F, (void*)refval); + Mat _val(1, len, CV_64FC1, (void*)val); + Mat _refval(1, len, CV_64FC1, (void*)refval); return cmpEps2( ts, _val, _refval, eps, true, param_name ); } @@ -2336,7 +2340,7 @@ void transform( const Mat& src, Mat& dst, const Mat& transmat, const Mat& _shift int scn = src.channels(); int dcn = dst.channels(); - int depth = src.depth(); + ElemDepth depth = src.depth(); int mattype = transmat.depth(); Mat shift = _shift.reshape(1, 0); bool haveShift = !shift.empty(); @@ -2645,7 +2649,7 @@ mean_(const _Tp* src, const uchar* mask, size_t total, int cn, Scalar& sum, int& Scalar mean(const Mat& src, const Mat& mask) { - CV_Assert(mask.empty() || (mask.type() == CV_8U && mask.size == src.size)); + CV_Assert(mask.empty() || (mask.type() == CV_8UC1 && mask.size == src.size)); Scalar sum; int nz = 0; @@ -2655,7 +2659,8 @@ Scalar mean(const Mat& src, const Mat& mask) NAryMatIterator it(arrays, planes); size_t total = planes[0].total(); size_t i, nplanes = it.nplanes; - int depth = src.depth(), cn = src.channels(); + ElemDepth depth = src.depth(); + int cn = src.channels(); for( i = 0; i < nplanes; i++, ++it ) { @@ -2697,7 +2702,7 @@ Scalar mean(const Mat& src, const Mat& mask) void patchZeros( Mat& mat, double level ) { int j, ncols = mat.cols * mat.channels(); - int depth = mat.depth(); + ElemDepth depth = mat.depth(); CV_Assert( depth == CV_32F || depth == CV_64F ); for( int i = 0; i < mat.rows; i++ ) @@ -2769,7 +2774,7 @@ Mat calcSobelKernel2D( int dx, int dy, int _aperture_size, int origin ) Size ksize = _aperture_size == -1 ? Size(3,3) : _aperture_size > 1 ? Size(_aperture_size, _aperture_size) : dx > 0 ? Size(3, 1) : Size(1, 3); - Mat kernel(ksize, CV_32F); + Mat kernel(ksize, CV_32FC1); vector kx, ky; calcSobelKernel1D( dx, _aperture_size, ksize.width, kx ); @@ -2789,7 +2794,7 @@ Mat calcSobelKernel2D( int dx, int dy, int _aperture_size, int origin ) Mat calcLaplaceKernel2D( int aperture_size ) { int ksize = aperture_size == 1 ? 3 : aperture_size; - Mat kernel(ksize, ksize, CV_32F); + Mat kernel(ksize, ksize, CV_32FC1); vector kx, ky; @@ -2812,11 +2817,11 @@ Mat calcLaplaceKernel2D( int aperture_size ) void initUndistortMap( const Mat& _a0, const Mat& _k0, Size sz, Mat& _mapx, Mat& _mapy ) { - _mapx.create(sz, CV_32F); - _mapy.create(sz, CV_32F); + _mapx.create(sz, CV_32FC1); + _mapy.create(sz, CV_32FC1); double a[9], k[5]={0,0,0,0,0}; - Mat _a(3, 3, CV_64F, a); + Mat _a(3, 3, CV_64FC1, a); Mat _k(_k0.rows,_k0.cols, CV_MAKETYPE(CV_64F,_k0.channels()),k); double fx, fy, cx, cy, ifx, ify, cxn, cyn; @@ -2896,7 +2901,7 @@ writeElems(std::ostream& out, const void* data, int nelems, int starpos) } -static void writeElems(std::ostream& out, const void* data, int nelems, int depth, int starpos) +static void writeElems(std::ostream& out, const void* data, int nelems, ElemDepth depth, int starpos) { if(depth == CV_8U) writeElems(out, data, nelems, starpos); @@ -2942,7 +2947,9 @@ static std::ostream& operator << (std::ostream& out, const MatPart& m) out << *m.m; else { - int i, depth = m.m->depth(), cn = m.m->channels(), width = m.m->cols*cn; + int i; + ElemDepth depth = m.m->depth(); + int cn = m.m->channels(), width = m.m->cols*cn; for( i = 0; i < m.m->rows; i++ ) { writeElems(out, m.m->ptr(i), width, depth, i == (*m.loc)[0] ? (*m.loc)[1] : -1); @@ -2980,8 +2987,8 @@ MatComparator::operator()(const char* expr1, const char* expr2, if( border == 0 ) { loc = loc0; - m1part = Mat(1, 1, m[0].depth(), m[0].ptr(&loc[0])); - m2part = Mat(1, 1, m[1].depth(), m[1].ptr(&loc[0])); + m1part = Mat(1, 1, CV_MAKETYPE(m[0].depth(), 1), m[0].ptr(&loc[0])); + m2part = Mat(1, 1, CV_MAKETYPE(m[1].depth(), 1), m[1].ptr(&loc[0])); } else { @@ -3001,7 +3008,8 @@ void threshold( const Mat& _src, Mat& _dst, double thresh, double maxval, int thresh_type ) { int i, j; - int depth = _src.depth(), cn = _src.channels(); + ElemDepth depth = _src.depth(); + int cn = _src.channels(); int width_n = _src.cols*cn, height = _src.rows; int ithresh = cvFloor(thresh); int imaxval, ithresh2; diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 59d2e929dff4..59234a5fa31f 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -97,22 +97,22 @@ static void randu(cv::Mat& m) if (m.depth() < CV_32F) { int minmax[] = {0, 256}; - cv::Mat mr = cv::Mat(m.rows, (int)(m.cols * m.elemSize()), CV_8U, m.ptr(), m.step[0]); - cv::randu(mr, cv::Mat(1, 1, CV_32S, minmax), cv::Mat(1, 1, CV_32S, minmax + 1)); + cv::Mat mr = cv::Mat(m.rows, (int)(m.cols * m.elemSize()), CV_8UC1, m.ptr(), m.step[0]); + cv::randu(mr, cv::Mat(1, 1, CV_32SC1, minmax), cv::Mat(1, 1, CV_32SC1, minmax + 1)); } else if (m.depth() == CV_32F) { //float minmax[] = {-FLT_MAX, FLT_MAX}; float minmax[] = {-bigValue, bigValue}; cv::Mat mr = m.reshape(1); - cv::randu(mr, cv::Mat(1, 1, CV_32F, minmax), cv::Mat(1, 1, CV_32F, minmax + 1)); + cv::randu(mr, cv::Mat(1, 1, CV_32FC1, minmax), cv::Mat(1, 1, CV_32FC1, minmax + 1)); } else { //double minmax[] = {-DBL_MAX, DBL_MAX}; double minmax[] = {-bigValue, bigValue}; cv::Mat mr = m.reshape(1); - cv::randu(mr, cv::Mat(1, 1, CV_64F, minmax), cv::Mat(1, 1, CV_64F, minmax + 1)); + cv::randu(mr, cv::Mat(1, 1, CV_64FC1, minmax), cv::Mat(1, 1, CV_64FC1, minmax + 1)); } } @@ -141,7 +141,7 @@ Regression& Regression::add(TestBase* test, const std::string& name, cv::InputAr Regression& Regression::addMoments(TestBase* test, const std::string& name, const cv::Moments& array, double eps, ERROR_TYPE err) { int len = (int)sizeof(cv::Moments) / sizeof(double); - cv::Mat m(1, len, CV_64F, (void*)&array); + cv::Mat m(1, len, CV_64FC1, (void*)&array); return Regression::add(test, name, m, eps, err); } @@ -1200,8 +1200,8 @@ int64 TestBase::_calibrate() { //the whole system warmup SetUp(); - cv::Mat a(2048, 2048, CV_32S, cv::Scalar(1)); - cv::Mat b(2048, 2048, CV_32S, cv::Scalar(2)); + cv::Mat a(2048, 2048, CV_32SC1, cv::Scalar(1)); + cv::Mat b(2048, 2048, CV_32SC1, cv::Scalar(2)); declare.time(30); double s = 0; for(declare.iterations(20); next() && startTimer(); stopTimer()) @@ -1215,10 +1215,10 @@ int64 TestBase::_calibrate() }; // Initialize ThreadPool - class _dummyParallel : public ParallelLoopBody + class _dummyParallel : public cv::ParallelLoopBody { public: - void operator()(const cv::Range& range) const + void operator()(const cv::Range& range) const CV_OVERRIDE { // nothing CV_UNUSED(range); @@ -1276,7 +1276,7 @@ void TestBase::warmup(cv::InputOutputArray a, WarmUpType wtype) { if (wtype == WARMUP_RNG || wtype == WARMUP_WRITE) { - int depth = a.depth(); + ElemDepth depth = a.depth(); if (depth == CV_8U) cv::randu(a, 0, 256); else if (depth == CV_8S) @@ -2198,7 +2198,16 @@ namespace perf void PrintTo(const MatType& t, ::std::ostream* os) { - String name = typeToString(t); + cv::String name = cv::typeToString(t); + if (name.size() > 3 && name[0] == 'C' && name[1] == 'V' && name[2] == '_') + *os << name.substr(3); + else + *os << name; +} + +void PrintTo(const MatDepth& d, ::std::ostream* os) +{ + cv::String name(cv::depthToString(d)); if (name.size() > 3 && name[0] == 'C' && name[1] == 'V' && name[2] == '_') *os << name.substr(3); else diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp index 228548924b0d..c7ca948ceaaf 100644 --- a/modules/video/include/opencv2/video/tracking.hpp +++ b/modules/video/include/opencv2/video/tracking.hpp @@ -346,7 +346,7 @@ class CV_EXPORTS_W KalmanFilter @param controlParams Dimensionality of the control vector. @param type Type of the created matrices that should be CV_32F or CV_64F. */ - CV_WRAP KalmanFilter( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); + CV_WRAP KalmanFilter(int dynamParams, int measureParams, int controlParams = 0, ElemType type = CV_32FC1); /** @brief Re-initializes Kalman filter. The previous content is destroyed. @@ -355,7 +355,7 @@ class CV_EXPORTS_W KalmanFilter @param controlParams Dimensionality of the control vector. @param type Type of the created matrices that should be CV_32F or CV_64F. */ - void init( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); + void init(int dynamParams, int measureParams, int controlParams = 0, ElemType type = CV_32FC1); /** @brief Computes a predicted state. diff --git a/modules/video/perf/perf_ecc.cpp b/modules/video/perf/perf_ecc.cpp index ab38868c828b..d70721341b73 100644 --- a/modules/video/perf/perf_ecc.cpp +++ b/modules/video/perf/perf_ecc.cpp @@ -58,9 +58,9 @@ PERF_TEST_P(TransformationType, findTransformECC, /*testing::ValuesIn(MotionType TEST_CYCLE() { if (transform_type<3) - warpMat = Mat::eye(2,3, CV_32F); + warpMat = Mat::eye(2, 3, CV_32FC1); else - warpMat = Mat::eye(3,3, CV_32F); + warpMat = Mat::eye(3, 3, CV_32FC1); findTransformECC(templateImage, img, warpMat, transform_type, TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 5, -1)); diff --git a/modules/video/src/bgfg_KNN.cpp b/modules/video/src/bgfg_KNN.cpp index 39cd6457e927..fc80783b2aa9 100755 --- a/modules/video/src/bgfg_KNN.cpp +++ b/modules/video/src/bgfg_KNN.cpp @@ -71,7 +71,7 @@ class BackgroundSubtractorKNNImpl CV_FINAL : public BackgroundSubtractorKNN BackgroundSubtractorKNNImpl() { frameSize = Size(0,0); - frameType = 0; + frameType = CV_8UC1; nframes = 0; history = defaultHistory2; @@ -102,7 +102,7 @@ class BackgroundSubtractorKNNImpl CV_FINAL : public BackgroundSubtractorKNN BackgroundSubtractorKNNImpl(int _history, float _dist2Threshold, bool _bShadowDetection=true) { frameSize = Size(0,0); - frameType = 0; + frameType = CV_8UC1; nframes = 0; history = _history > 0 ? _history : defaultHistory2; @@ -136,7 +136,7 @@ class BackgroundSubtractorKNNImpl CV_FINAL : public BackgroundSubtractorKNN virtual void getBackgroundImage(OutputArray backgroundImage) const CV_OVERRIDE; //! re-initialization method - void initialize(Size _frameSize, int _frameType) + void initialize(Size _frameSize, ElemType _frameType) { frameSize = _frameSize; frameType = _frameType; @@ -193,17 +193,17 @@ class BackgroundSubtractorKNNImpl CV_FINAL : public BackgroundSubtractorKNN { // for each sample of 3 speed pixel models each pixel bg model we store ... // values + flag (nchannels+1 values) - bgmodel.create( 1,(nN * 3) * (nchannels+1)* size,CV_8U); + bgmodel.create( 1,(nN * 3) * (nchannels+1)* size,CV_8UC1); bgmodel = Scalar::all(0); //index through the three circular lists - aModelIndexShort.create(1,size,CV_8U); - aModelIndexMid.create(1,size,CV_8U); - aModelIndexLong.create(1,size,CV_8U); + aModelIndexShort.create(1,size,CV_8UC1); + aModelIndexMid.create(1,size,CV_8UC1); + aModelIndexLong.create(1,size,CV_8UC1); //when to update next - nNextShortUpdate.create(1,size,CV_8U); - nNextMidUpdate.create(1,size,CV_8U); - nNextLongUpdate.create(1,size,CV_8U); + nNextShortUpdate.create(1,size,CV_8UC1); + nNextMidUpdate.create(1,size,CV_8UC1); + nNextLongUpdate.create(1,size,CV_8UC1); aModelIndexShort = Scalar::all(0);//random? //((m_nN)*rand())/(RAND_MAX+1);//0...m_nN-1 aModelIndexMid = Scalar::all(0); @@ -274,7 +274,7 @@ class BackgroundSubtractorKNNImpl CV_FINAL : public BackgroundSubtractorKNN protected: Size frameSize; - int frameType; + ElemType frameType; int nframes; ///////////////////////// //very important parameters - things you will change @@ -638,7 +638,7 @@ bool BackgroundSubtractorKNNImpl::ocl_apply(InputArray _image, OutputArray _fgma learningRate = learningRate >= 0 && nframes > 1 ? learningRate : 1./std::min( 2*nframes, history ); CV_Assert(learningRate >= 0); - _fgmask.create(_image.size(), CV_8U); + _fgmask.create(_image.size(), CV_8UC1); UMat fgmask = _fgmask.getUMat(); UMat frame = _image.getUMat(); @@ -752,7 +752,7 @@ void BackgroundSubtractorKNNImpl::apply(InputArray _image, OutputArray _fgmask, initialize(_image.size(), _image.type()); Mat image = _image.getMat(); - _fgmask.create( image.size(), CV_8U ); + _fgmask.create( image.size(), CV_8UC1 ); Mat fgmask = _fgmask.getMat(); ++nframes; diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp index 4241670f1c39..8b7153189103 100644 --- a/modules/video/src/bgfg_gaussmix2.cpp +++ b/modules/video/src/bgfg_gaussmix2.cpp @@ -125,7 +125,7 @@ class BackgroundSubtractorMOG2Impl CV_FINAL : public BackgroundSubtractorMOG2 BackgroundSubtractorMOG2Impl() { frameSize = Size(0,0); - frameType = 0; + frameType = CV_8UC1; nframes = 0; history = defaultHistory2; @@ -151,7 +151,7 @@ class BackgroundSubtractorMOG2Impl CV_FINAL : public BackgroundSubtractorMOG2 BackgroundSubtractorMOG2Impl(int _history, float _varThreshold, bool _bShadowDetection=true) { frameSize = Size(0,0); - frameType = 0; + frameType = CV_8UC1; nframes = 0; history = _history > 0 ? _history : defaultHistory2; @@ -182,7 +182,7 @@ class BackgroundSubtractorMOG2Impl CV_FINAL : public BackgroundSubtractorMOG2 virtual void getBackgroundImage(OutputArray backgroundImage) const CV_OVERRIDE; //! re-initiaization method - void initialize(Size _frameSize, int _frameType) + void initialize(Size _frameSize, ElemType _frameType) { frameSize = _frameSize; frameType = _frameType; @@ -229,9 +229,9 @@ class BackgroundSubtractorMOG2Impl CV_FINAL : public BackgroundSubtractorMOG2 // the mixture weight (w), // the mean (nchannels values) and // the covariance - bgmodel.create( 1, frameSize.height*frameSize.width*nmixtures*(2 + nchannels), CV_32F ); + bgmodel.create( 1, frameSize.height*frameSize.width*nmixtures*(2 + nchannels), CV_32FC1 ); //make the array for keeping track of the used modes per pixel - all zeros at start - bgmodelUsedModes.create(frameSize,CV_8U); + bgmodelUsedModes.create(frameSize,CV_8UC1); bgmodelUsedModes = Scalar::all(0); } } @@ -321,7 +321,7 @@ class BackgroundSubtractorMOG2Impl CV_FINAL : public BackgroundSubtractorMOG2 protected: Size frameSize; - int frameType; + ElemType frameType; Mat bgmodel; Mat bgmodelUsedModes;//keep track of number of modes per pixel @@ -779,7 +779,7 @@ bool BackgroundSubtractorMOG2Impl::ocl_apply(InputArray _image, OutputArray _fgm learningRate = learningRate >= 0 && nframes > 1 ? learningRate : 1./std::min( 2*nframes, history ); CV_Assert(learningRate >= 0); - _fgmask.create(_image.size(), CV_8U); + _fgmask.create(_image.size(), CV_8UC1); UMat fgmask = _fgmask.getUMat(); const double alpha1 = 1.0f - learningRate; @@ -862,7 +862,7 @@ void BackgroundSubtractorMOG2Impl::apply(InputArray _image, OutputArray _fgmask, initialize(_image.size(), _image.type()); Mat image = _image.getMat(); - _fgmask.create( image.size(), CV_8U ); + _fgmask.create( image.size(), CV_8UC1 ); Mat fgmask = _fgmask.getMat(); ++nframes; @@ -937,20 +937,39 @@ void BackgroundSubtractorMOG2Impl::getBackgroundImage(OutputArray backgroundImag } #endif - switch(frameType) + const ElemDepth frameDepth = CV_MAT_DEPTH(frameType); + const int frameChannels = CV_MAT_CN(frameType); + switch (frameDepth) { - case CV_8UC1: - getBackgroundImage_intern(backgroundImage); - break; - case CV_8UC3: - getBackgroundImage_intern(backgroundImage); - break; - case CV_32FC1: - getBackgroundImage_intern(backgroundImage); - break; - case CV_32FC3: - getBackgroundImage_intern(backgroundImage); - break; + case CV_8U: + switch (frameChannels) + { + case 1: + getBackgroundImage_intern(backgroundImage); + break; + case 3: + getBackgroundImage_intern(backgroundImage); + break; + } + break; + case CV_32F: + switch (frameChannels) + { + case 1: + getBackgroundImage_intern(backgroundImage); + break; + case 3: + getBackgroundImage_intern(backgroundImage); + break; + } + break; + case CV_8S: + case CV_16U: + case CV_16S: + case CV_32S: + case CV_64F: + case CV_16F: + break; //unhandled } } diff --git a/modules/video/src/compat_video.cpp b/modules/video/src/compat_video.cpp index da3996a0123d..994a81e93822 100644 --- a/modules/video/src/compat_video.cpp +++ b/modules/video/src/compat_video.cpp @@ -278,9 +278,9 @@ cvCalcOpticalFlowPyrLK( const void* arrA, const void* arrB, cv::Mat st, err; if( status ) - st = cv::Mat(count, 1, CV_8U, (void*)status); + st = cv::Mat(count, 1, CV_8UC1, (void*)status); if( error ) - err = cv::Mat(count, 1, CV_32F, (void*)error); + err = cv::Mat(count, 1, CV_32FC1, (void*)error); cv::calcOpticalFlowPyrLK( A, B, ptA, ptB, st, error ? cv::_OutputArray(err) : (cv::_OutputArray)cv::noArray(), winSize, level, criteria, flags); diff --git a/modules/video/src/ecc.cpp b/modules/video/src/ecc.cpp index aabb317b65f6..b879c261ff85 100644 --- a/modules/video/src/ecc.cpp +++ b/modules/video/src/ecc.cpp @@ -333,7 +333,7 @@ double cv::findTransformECC(InputArray templateImage, warpMatrix.create(rowCount, 3, CV_32FC1); map = warpMatrix.getMat(); - map = Mat::eye(rowCount, 3, CV_32F); + map = Mat::eye(rowCount, 3, CV_32FC1); } if( ! (src.type()==dst.type())) @@ -381,10 +381,10 @@ double cv::findTransformECC(InputArray templateImage, const int wd = dst.cols; const int hd = dst.rows; - Mat Xcoord = Mat(1, ws, CV_32F); - Mat Ycoord = Mat(hs, 1, CV_32F); - Mat Xgrid = Mat(hs, ws, CV_32F); - Mat Ygrid = Mat(hs, ws, CV_32F); + Mat Xcoord = Mat(1, ws, CV_32FC1); + Mat Ycoord = Mat(hs, 1, CV_32FC1); + Mat Xgrid = Mat(hs, ws, CV_32FC1); + Mat Ygrid = Mat(hs, ws, CV_32FC1); float* XcoPtr = Xcoord.ptr(0); float* YcoPtr = Ycoord.ptr(0); @@ -400,22 +400,22 @@ double cv::findTransformECC(InputArray templateImage, Xcoord.release(); Ycoord.release(); - Mat templateZM = Mat(hs, ws, CV_32F);// to store the (smoothed)zero-mean version of template - Mat templateFloat = Mat(hs, ws, CV_32F);// to store the (smoothed) template - Mat imageFloat = Mat(hd, wd, CV_32F);// to store the (smoothed) input image - Mat imageWarped = Mat(hs, ws, CV_32F);// to store the warped zero-mean input image - Mat imageMask = Mat(hs, ws, CV_8U); // to store the final mask + Mat templateZM = Mat(hs, ws, CV_32FC1);// to store the (smoothed)zero-mean version of template + Mat templateFloat = Mat(hs, ws, CV_32FC1);// to store the (smoothed) template + Mat imageFloat = Mat(hd, wd, CV_32FC1);// to store the (smoothed) input image + Mat imageWarped = Mat(hs, ws, CV_32FC1);// to store the warped zero-mean input image + Mat imageMask = Mat(hs, ws, CV_8UC1); // to store the final mask Mat inputMaskMat = inputMask.getMat(); //to use it for mask warping Mat preMask; if(inputMask.empty()) - preMask = Mat::ones(hd, wd, CV_8U); + preMask = Mat::ones(hd, wd, CV_8UC1); else threshold(inputMask, preMask, 0, 1, THRESH_BINARY); //gaussian filtering is optional - src.convertTo(templateFloat, templateFloat.type()); + src.convertTo(templateFloat, templateFloat.depth()); GaussianBlur(templateFloat, templateFloat, Size(5, 5), 0, 0); Mat preMaskFloat; @@ -424,10 +424,10 @@ double cv::findTransformECC(InputArray templateImage, // Change threshold. preMaskFloat *= (0.5/0.95); // Rounding conversion. - preMaskFloat.convertTo(preMask, preMask.type()); - preMask.convertTo(preMaskFloat, preMaskFloat.type()); + preMaskFloat.convertTo(preMask, preMask.depth()); + preMask.convertTo(preMaskFloat, preMaskFloat.depth()); - dst.convertTo(imageFloat, imageFloat.type()); + dst.convertTo(imageFloat, imageFloat.depth()); GaussianBlur(imageFloat, imageFloat, Size(5, 5), 0, 0); // needed matrices for gradients and warped gradients @@ -440,23 +440,23 @@ double cv::findTransformECC(InputArray templateImage, // calculate first order image derivatives Matx13f dx(-0.5f, 0.0f, 0.5f); - filter2D(imageFloat, gradientX, -1, dx); - filter2D(imageFloat, gradientY, -1, dx.t()); + filter2D(imageFloat, gradientX, CV_DEPTH_AUTO, dx); + filter2D(imageFloat, gradientY, CV_DEPTH_AUTO, dx.t()); gradientX = gradientX.mul(preMaskFloat); gradientY = gradientY.mul(preMaskFloat); // matrices needed for solving linear equation system for maximizing ECC - Mat jacobian = Mat(hs, ws*numberOfParameters, CV_32F); - Mat hessian = Mat(numberOfParameters, numberOfParameters, CV_32F); - Mat hessianInv = Mat(numberOfParameters, numberOfParameters, CV_32F); - Mat imageProjection = Mat(numberOfParameters, 1, CV_32F); - Mat templateProjection = Mat(numberOfParameters, 1, CV_32F); - Mat imageProjectionHessian = Mat(numberOfParameters, 1, CV_32F); - Mat errorProjection = Mat(numberOfParameters, 1, CV_32F); - - Mat deltaP = Mat(numberOfParameters, 1, CV_32F);//transformation parameter correction - Mat error = Mat(hs, ws, CV_32F);//error as 2D matrix + Mat jacobian = Mat(hs, ws*numberOfParameters, CV_32FC1); + Mat hessian = Mat(numberOfParameters, numberOfParameters, CV_32FC1); + Mat hessianInv = Mat(numberOfParameters, numberOfParameters, CV_32FC1); + Mat imageProjection = Mat(numberOfParameters, 1, CV_32FC1); + Mat templateProjection = Mat(numberOfParameters, 1, CV_32FC1); + Mat imageProjectionHessian = Mat(numberOfParameters, 1, CV_32FC1); + Mat errorProjection = Mat(numberOfParameters, 1, CV_32FC1); + + Mat deltaP = Mat(numberOfParameters, 1, CV_32FC1);//transformation parameter correction + Mat error = Mat(hs, ws, CV_32FC1);//error as 2D matrix const int imageFlags = INTER_LINEAR + WARP_INVERSE_MAP; const int maskFlags = INTER_NEAREST + WARP_INVERSE_MAP; diff --git a/modules/video/src/kalman.cpp b/modules/video/src/kalman.cpp index f90f9f7b9e7d..2bbf70f75777 100644 --- a/modules/video/src/kalman.cpp +++ b/modules/video/src/kalman.cpp @@ -44,15 +44,15 @@ namespace cv { KalmanFilter::KalmanFilter() {} -KalmanFilter::KalmanFilter(int dynamParams, int measureParams, int controlParams, int type) +KalmanFilter::KalmanFilter(int dynamParams, int measureParams, int controlParams, ElemType type) { init(dynamParams, measureParams, controlParams, type); } -void KalmanFilter::init(int DP, int MP, int CP, int type) +void KalmanFilter::init(int DP, int MP, int CP, ElemType type) { CV_Assert( DP > 0 && MP > 0 ); - CV_Assert( type == CV_32F || type == CV_64F ); + CV_Assert(type == CV_32FC1 || type == CV_64FC1); CP = std::max(CP, 0); statePre = Mat::zeros(DP, 1, type); diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp index b61163639ebc..603008647cd0 100644 --- a/modules/video/src/lkpyramid.cpp +++ b/modules/video/src/lkpyramid.cpp @@ -704,9 +704,9 @@ int cv::buildOpticalFlowPyramid(InputArray _img, OutputArrayOfArrays pyramid, Si CV_Assert(img.depth() == CV_8U && winSize.width > 2 && winSize.height > 2 ); int pyrstep = withDerivatives ? 2 : 1; - pyramid.create(1, (maxLevel + 1) * pyrstep, 0 /*type*/, -1, true); + pyramid.create(1, (maxLevel + 1) * pyrstep, CV_8UC1, -1, true); - int derivType = CV_MAKETYPE(DataType::depth, img.channels() * 2); + ElemType derivType = CV_MAKETYPE(DataType::depth, img.channels() * 2); //level 0 bool lvl0IsSet = false; @@ -783,7 +783,7 @@ int cv::buildOpticalFlowPyramid(InputArray _img, OutputArrayOfArrays pyramid, Si sz = Size((sz.width+1)/2, (sz.height+1)/2); if( sz.width <= winSize.width || sz.height <= winSize.height ) { - pyramid.create(1, (level + 1) * pyrstep, 0 /*type*/, -1, true);//check this + pyramid.create(1, (level + 1) * pyrstep, CV_8UC1, -1, true);//check this return level; } @@ -1096,7 +1096,7 @@ namespace Mat nextPtsMat = _nextPts.getMat(); CV_Assert( nextPtsMat.checkVector(2, CV_32F, false) == (int)npoints ); - _status.create((int)npoints, 1, CV_8U, -1, true); + _status.create((int)npoints, 1, CV_8UC1, -1, true); Mat statusMat = _status.getMat(); uchar* status = statusMat.ptr(); for(size_t i = 0; i < npoints; i++ ) @@ -1258,7 +1258,7 @@ void SparsePyrLKOpticalFlowImpl::calc( InputArray _prevImg, InputArray _nextImg, const Point2f* prevPts = prevPtsMat.ptr(); Point2f* nextPts = nextPtsMat.ptr(); - _status.create((int)npoints, 1, CV_8U, -1, true); + _status.create((int)npoints, 1, CV_8UC1, -1, true); Mat statusMat = _status.getMat(), errMat; CV_Assert( statusMat.isContinuous() ); uchar* status = statusMat.ptr(); @@ -1269,7 +1269,7 @@ void SparsePyrLKOpticalFlowImpl::calc( InputArray _prevImg, InputArray _nextImg, if( _err.needed() ) { - _err.create((int)npoints, 1, CV_32F, -1, true); + _err.create((int)npoints, 1, CV_32FC1, -1, true); errMat = _err.getMat(); CV_Assert( errMat.isContinuous() ); err = errMat.ptr(); diff --git a/modules/video/src/optflowgf.cpp b/modules/video/src/optflowgf.cpp index 2e6251b210e1..693ef35fc274 100644 --- a/modules/video/src/optflowgf.cpp +++ b/modules/video/src/optflowgf.cpp @@ -646,8 +646,8 @@ class FarnebackOpticalFlowImpl : public FarnebackOpticalFlow Size size = frame0.size(); UMat prevFlowX, prevFlowY, curFlowX, curFlowY; - flowx.create(size, CV_32F); - flowy.create(size, CV_32F); + flowx.create(size, CV_32FC1); + flowy.create(size, CV_32FC1); UMat flowx0 = flowx; UMat flowy0 = flowy; @@ -701,8 +701,8 @@ class FarnebackOpticalFlowImpl : public FarnebackOpticalFlow if (k > 0) { - curFlowX.create(height, width, CV_32F); - curFlowY.create(height, width, CV_32F); + curFlowX.create(height, width, CV_32FC1); + curFlowY.create(height, width, CV_32FC1); } else { @@ -733,12 +733,12 @@ class FarnebackOpticalFlowImpl : public FarnebackOpticalFlow multiply(1./pyrScale_, curFlowY, curFlowY); } - UMat M = allocMatFromBuf(5*height, width, CV_32F, M_); - UMat bufM = allocMatFromBuf(5*height, width, CV_32F, bufM_); + UMat M = allocMatFromBuf(5*height, width, CV_32FC1, M_); + UMat bufM = allocMatFromBuf(5*height, width, CV_32FC1, bufM_); UMat R[2] = { - allocMatFromBuf(5*height, width, CV_32F, R_[0]), - allocMatFromBuf(5*height, width, CV_32F, R_[1]) + allocMatFromBuf(5*height, width, CV_32FC1, R_[0]), + allocMatFromBuf(5*height, width, CV_32FC1, R_[1]) }; if (fastPyramids_) @@ -752,13 +752,13 @@ class FarnebackOpticalFlowImpl : public FarnebackOpticalFlow { UMat blurredFrame[2] = { - allocMatFromBuf(size.height, size.width, CV_32F, blurredFrame_[0]), - allocMatFromBuf(size.height, size.width, CV_32F, blurredFrame_[1]) + allocMatFromBuf(size.height, size.width, CV_32FC1, blurredFrame_[0]), + allocMatFromBuf(size.height, size.width, CV_32FC1, blurredFrame_[1]) }; UMat pyrLevel[2] = { - allocMatFromBuf(height, width, CV_32F, pyrLevel_[0]), - allocMatFromBuf(height, width, CV_32F, pyrLevel_[1]) + allocMatFromBuf(height, width, CV_32FC1, pyrLevel_[0]), + allocMatFromBuf(height, width, CV_32FC1, pyrLevel_[1]) }; setGaussianBlurKernel(smoothSize, sigma); @@ -847,7 +847,7 @@ class FarnebackOpticalFlowImpl : public FarnebackOpticalFlow UMat m_gKer; inline void setGaussianBlurKernel(int smoothSize, double sigma) { - Mat g = getGaussianKernel(smoothSize, sigma, CV_32F); + Mat g = getGaussianKernel(smoothSize, sigma, CV_32FC1); Mat gKer(1, smoothSize/2 + 1, CV_32FC1, g.ptr(smoothSize/2)); gKer.copyTo(m_gKer); } @@ -856,7 +856,7 @@ class FarnebackOpticalFlowImpl : public FarnebackOpticalFlow UMat pyrLevel_[2], M_, bufM_, R_[2], blurredFrame_[2]; std::vector pyramid0_, pyramid1_; - static UMat allocMatFromBuf(int rows, int cols, int type, UMat &mat) + static UMat allocMatFromBuf(int rows, int cols, ElemType type, UMat &mat) { if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols) return mat(Rect(0, 0, cols, rows)); diff --git a/modules/video/test/test_accum.cpp b/modules/video/test/test_accum.cpp index 9941f2035911..3ee7688ec252 100644 --- a/modules/video/test/test_accum.cpp +++ b/modules/video/test/test_accum.cpp @@ -50,8 +50,8 @@ class CV_AccumBaseTest : public cvtest::ArrayTest CV_AccumBaseTest(); protected: - void get_test_array_types_and_sizes( int test_case_idx, vector >& sizes, vector >& types ); - double get_success_error_level( int test_case_idx, int i, int j ); + void get_test_array_types_and_sizes(int test_case_idx, vector >& sizes, vector >& types) CV_OVERRIDE; + double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE; double alpha; }; @@ -68,7 +68,7 @@ CV_AccumBaseTest::CV_AccumBaseTest() void CV_AccumBaseTest::get_test_array_types_and_sizes( int test_case_idx, - vector >& sizes, vector >& types ) + vector >& sizes, vector >& types ) { RNG& rng = ts->get_rng(); int depth = cvtest::randInt(rng) % 4, cn = cvtest::randInt(rng) & 1 ? 3 : 1; @@ -102,7 +102,7 @@ class CV_AccTest : public CV_AccumBaseTest CV_AccTest() { } protected: void run_func(); - void prepare_to_validation( int ); + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -118,7 +118,7 @@ void CV_AccTest::prepare_to_validation( int ) Mat& dst = test_mat[REF_INPUT_OUTPUT][0]; const Mat& mask = test_array[MASK][0] ? test_mat[MASK][0] : Mat(); Mat temp; - cvtest::add( src, 1, dst, 1, cvScalarAll(0.), temp, dst.type() ); + cvtest::add(src, 1, dst, 1, cvScalarAll(0.), temp, dst.depth()); cvtest::copy( temp, dst, mask ); } @@ -130,7 +130,7 @@ class CV_SquareAccTest : public CV_AccumBaseTest CV_SquareAccTest(); protected: void run_func(); - void prepare_to_validation( int ); + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -152,9 +152,9 @@ void CV_SquareAccTest::prepare_to_validation( int ) const Mat& mask = test_array[MASK][0] ? test_mat[MASK][0] : Mat(); Mat temp; - cvtest::convert( src, temp, dst.type() ); + cvtest::convert( src, temp, dst.depth() ); cvtest::multiply( temp, temp, temp, 1 ); - cvtest::add( temp, 1, dst, 1, cvScalarAll(0.), temp, dst.depth() ); + cvtest::add(temp, 1, dst, 1, cvScalarAll(0.), temp, dst.depth()); cvtest::copy( temp, dst, mask ); } @@ -166,7 +166,7 @@ class CV_MultiplyAccTest : public CV_AccumBaseTest CV_MultiplyAccTest(); protected: void run_func(); - void prepare_to_validation( int ); + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -191,11 +191,11 @@ void CV_MultiplyAccTest::prepare_to_validation( int ) const Mat& mask = test_array[MASK][0] ? test_mat[MASK][0] : Mat(); Mat temp1, temp2; - cvtest::convert( src1, temp1, dst.type() ); - cvtest::convert( src2, temp2, dst.type() ); + cvtest::convert(src1, temp1, dst.depth()); + cvtest::convert(src2, temp2, dst.depth()); cvtest::multiply( temp1, temp2, temp1, 1 ); - cvtest::add( temp1, 1, dst, 1, cvScalarAll(0.), temp1, dst.depth() ); + cvtest::add(temp1, 1, dst, 1, cvScalarAll(0.), temp1, dst.depth()); cvtest::copy( temp1, dst, mask ); } @@ -207,7 +207,7 @@ class CV_RunningAvgTest : public CV_AccumBaseTest CV_RunningAvgTest(); protected: void run_func(); - void prepare_to_validation( int ); + void prepare_to_validation( int ) CV_OVERRIDE; }; @@ -235,7 +235,7 @@ void CV_RunningAvgTest::prepare_to_validation( int ) cvSetReal1D( &A, 0, alpha); cvSetReal1D( &B, 0, 1 - cvGetReal1D(&A, 0)); - cvtest::convert( src, temp, dst.type() ); + cvtest::convert(src, temp, dst.depth()); cvtest::add( src, cvGetReal1D(&A, 0), dst, cvGetReal1D(&B, 0), cvScalarAll(0.), temp, temp.depth() ); cvtest::copy( temp, dst, mask ); } diff --git a/modules/video/test/test_ecc.cpp b/modules/video/test/test_ecc.cpp index 913cd59b87a7..73a30a76f6d5 100644 --- a/modules/video/test/test_ecc.cpp +++ b/modules/video/test/test_ecc.cpp @@ -364,7 +364,7 @@ bool CV_ECC_Test_Homography::testHomography(int from) warpPerspective(testImg, warpedImage, homoGround, Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); - Mat mapHomography = Mat::eye(3, 3, CV_32F); + Mat mapHomography = Mat::eye(3, 3, CV_32FC1); findTransformECC(warpedImage, testImg, mapHomography, 3, TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, ECC_iterations, ECC_epsilon)); @@ -420,7 +420,7 @@ bool CV_ECC_Test_Mask::testMask(int from) resize(img, scaledImage, Size(216, 216), 0, 0, INTER_LINEAR_EXACT ); Mat_ testImg; - scaledImage.convertTo(testImg, testImg.type()); + scaledImage.convertTo(testImg, testImg.depth()); cv::RNG rng = ts->get_rng(); diff --git a/modules/video/test/test_optflowpyrlk.cpp b/modules/video/test/test_optflowpyrlk.cpp index 1f08270ec747..28547905369b 100644 --- a/modules/video/test/test_optflowpyrlk.cpp +++ b/modules/video/test/test_optflowpyrlk.cpp @@ -101,8 +101,8 @@ void CV_OptFlowPyrLKTest::run( int ) goto _exit_; } - if( _u->cols != 2 || CV_MAT_TYPE(_u->type) != CV_32F || - _v->cols != 2 || CV_MAT_TYPE(_v->type) != CV_32F || _v->rows != _u->rows ) + if (_u->cols != 2 || CV_MAT_TYPE(_u->type) != CV_32FC1 || + _v->cols != 2 || CV_MAT_TYPE(_v->type) != CV_32FC1 || _v->rows != _u->rows) { ts->printf( cvtest::TS::LOG, "the loaded matrices of points are not valid\n" ); code = cvtest::TS::FAIL_MISSING_TEST_DATA; diff --git a/modules/videoio/src/cap_ios_video_camera.mm b/modules/videoio/src/cap_ios_video_camera.mm index c1282ecbd898..fdded1684a58 100644 --- a/modules/videoio/src/cap_ios_video_camera.mm +++ b/modules/videoio/src/cap_ios_video_camera.mm @@ -475,7 +475,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM CGColorSpaceRef colorSpace; CGContextRef context; - int format_opencv; + ElemType format_opencv; OSType format = CVPixelBufferGetPixelFormatType(imageBuffer); if (format == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) { @@ -575,7 +575,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM recordingCountDown--; if (self.recordVideo == YES && recordingCountDown < 0) { lastSampleTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); -// CMTimeShow(lastSampleTime); +// CMTimeShow(lastSampleTime); if (self.recordAssetWriter.status != AVAssetWriterStatusWriting) { [self.recordAssetWriter startWriting]; [self.recordAssetWriter startSessionAtSourceTime:lastSampleTime]; diff --git a/modules/videoio/src/cap_v4l.cpp b/modules/videoio/src/cap_v4l.cpp index 5eaca3ae12f4..ebe6aa77d788 100644 --- a/modules/videoio/src/cap_v4l.cpp +++ b/modules/videoio/src/cap_v4l.cpp @@ -1022,7 +1022,7 @@ move_411_block(int yTL, int yTR, int yBL, int yBR, int u, int v, static inline void yuv420p_to_rgb24(int width, int height, uchar* src, uchar* dst, bool isYUV) { - cvtColor(Mat(height * 3 / 2, width, CV_8U, src), Mat(height, width, CV_8UC3, dst), + cvtColor(Mat(height * 3 / 2, width, CV_8UC1, src), Mat(height, width, CV_8UC3, dst), isYUV ? COLOR_YUV2BGR_IYUV : COLOR_YUV2BGR_YV12); } @@ -1107,7 +1107,7 @@ y8_to_rgb24 (int width, int height, unsigned char* src, unsigned char* dst) static bool mjpeg_to_rgb24(int width, int height, unsigned char* src, int length, IplImage* dst) { Mat temp = cvarrToMat(dst); - imdecode(Mat(1, length, CV_8U, src), IMREAD_COLOR, &temp); + imdecode(Mat(1, length, CV_8UC1, src), IMREAD_COLOR, &temp); return temp.data && temp.cols == width && temp.rows == height; } diff --git a/modules/videoio/src/cap_vfw.cpp b/modules/videoio/src/cap_vfw.cpp index f62baf4e7192..44a50e25c2ad 100644 --- a/modules/videoio/src/cap_vfw.cpp +++ b/modules/videoio/src/cap_vfw.cpp @@ -228,7 +228,7 @@ IplImage* CvCaptureAVI_VFW::retrieveFrame(int) if( !frame || frame->width != src.width || frame->height != src.height ) { cvReleaseImage( &frame ); - frame = cvCreateImage( cvGetSize(&src), 8, nChannels ); + frame = cvCreateImage(cvGetSize(&src), IPL_DEPTH_8U, nChannels); } cvFlip( &src, frame, 0 ); @@ -503,7 +503,7 @@ IplImage* CvCaptureCAM_VFW::retrieveFrame(int) if( !frame || frame->width != vfmt0.biWidth || frame->height != vfmt0.biHeight ) { cvReleaseImage( &frame ); - frame = cvCreateImage( cvSize( vfmt0.biWidth, vfmt0.biHeight ), 8, 3 ); + frame = cvCreateImage(cvSize(vfmt0.biWidth, vfmt0.biHeight), IPL_DEPTH_8U, 3); } if ( vfmt0.biCompression == MAKEFOURCC('N','V','1','2') ) @@ -813,7 +813,7 @@ bool CvVideoWriter_VFW::createStreams( CvSize frameSize, bool isColor ) fps = fps; fourcc = (int)copts.fccHandler; frameSize = frameSize; - tempFrame = cvCreateImage( frameSize, 8, (isColor ? 3 : 1) ); + tempFrame = cvCreateImage(frameSize, IPL_DEPTH_8U, (isColor ? 3 : 1)); return true; } } diff --git a/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp b/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp index fdd488aac80b..09f4e1d9f1e8 100644 --- a/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp +++ b/modules/videostab/include/opencv2/videostab/fast_marching_inl.hpp @@ -55,7 +55,7 @@ Inpaint FastMarchingMethod::run(const cv::Mat &mask, Inpaint inpaint) { using namespace cv; - CV_Assert(mask.type() == CV_8U); + CV_Assert(mask.type() == CV_8UC1); static const int lut[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}}; diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index ac4ca4d2e18c..c9544f8e00e2 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -62,7 +62,7 @@ static void compactPoints(GpuMat &points0, GpuMat &points1, const GpuMat &mask) { CV_Assert(points0.rows == 1 && points1.rows == 1 && mask.rows == 1); - CV_Assert(points0.type() == CV_32FC2 && points1.type() == CV_32FC2 && mask.type() == CV_8U); + CV_Assert(points0.type() == CV_32FC2 && points1.type() == CV_32FC2 && mask.type() == CV_8UC1); CV_Assert(points0.cols == mask.cols && points1.cols == mask.cols); int npoints = points0.cols; @@ -109,7 +109,7 @@ static Mat normalizePoints(int npoints, Point2f *points) points[i].y *= s; } - Mat_ T = Mat::eye(3, 3, CV_32F); + Mat_ T = Mat::eye(3, 3, CV_32FC1); T(0,0) = T(1,1) = s; T(0,2) = -cx*s; T(1,2) = -cy*s; @@ -120,7 +120,7 @@ static Mat normalizePoints(int npoints, Point2f *points) static Mat estimateGlobMotionLeastSquaresTranslation( int npoints, Point2f *points0, Point2f *points1, float *rmse) { - Mat_ M = Mat::eye(3, 3, CV_32F); + Mat_ M = Mat::eye(3, 3, CV_32FC1); for (int i = 0; i < npoints; ++i) { M(0,2) += points1[i].x - points0[i].x; @@ -170,7 +170,7 @@ static Mat estimateGlobMotionLeastSquaresTranslationAndScale( if (rmse) *rmse = static_cast(norm(A*sol, b, NORM_L2) / std::sqrt(static_cast(npoints))); - Mat_ M = Mat::eye(3, 3, CV_32F); + Mat_ M = Mat::eye(3, 3, CV_32FC1); M(0,0) = M(1,1) = sol(0,0); M(0,2) = sol(1,0); M(1,2) = sol(2,0); @@ -194,7 +194,7 @@ static Mat estimateGlobMotionLeastSquaresRotation( // A*sin(alpha) + B*cos(alpha) = 0 float C = std::sqrt(A*A + B*B); - Mat_ M = Mat::eye(3, 3, CV_32F); + Mat_ M = Mat::eye(3, 3, CV_32FC1); if ( C != 0 ) { float sinAlpha = - B / C; @@ -237,7 +237,7 @@ static Mat estimateGlobMotionLeastSquaresRigid( mean0 *= 1.f / npoints; mean1 *= 1.f / npoints; - Mat_ A = Mat::zeros(2, 2, CV_32F); + Mat_ A = Mat::zeros(2, 2, CV_32FC1); Point2f pt0, pt1; for (int i = 0; i < npoints; ++i) @@ -250,7 +250,7 @@ static Mat estimateGlobMotionLeastSquaresRigid( A(1,1) += pt1.y * pt0.y; } - Mat_ M = Mat::eye(3, 3, CV_32F); + Mat_ M = Mat::eye(3, 3, CV_32FC1); SVD svd(A); Mat_ R = svd.u * svd.vt; @@ -305,7 +305,7 @@ static Mat estimateGlobMotionLeastSquaresSimilarity( if (rmse) *rmse = static_cast(norm(A*sol, b, NORM_L2) / std::sqrt(static_cast(npoints))); - Mat_ M = Mat::eye(3, 3, CV_32F); + Mat_ M = Mat::eye(3, 3, CV_32FC1); M(0,0) = M(1,1) = sol(0,0); M(0,1) = sol(1,0); M(1,0) = -sol(1,0); @@ -344,7 +344,7 @@ static Mat estimateGlobMotionLeastSquaresAffine( if (rmse) *rmse = static_cast(norm(A*sol, b, NORM_L2) / std::sqrt(static_cast(npoints))); - Mat_ M = Mat::eye(3, 3, CV_32F); + Mat_ M = Mat::eye(3, 3, CV_32FC1); for (int i = 0, k = 0; i < 2; ++i) for (int j = 0; j < 3; ++j, ++k) M(i,j) = sol(k,0); @@ -390,7 +390,7 @@ Mat estimateGlobalMotionRansac( CV_Assert(points1.getMat().checkVector(2) == npoints); if (npoints < params.size) - return Mat::eye(3, 3, CV_32F); + return Mat::eye(3, 3, CV_32FC1); const Point2f *points0_ = points0.getMat().ptr(); const Point2f *points1_ = points1.getMat().ptr(); @@ -523,7 +523,7 @@ Mat MotionEstimatorRansacL2::estimate(InputArray points0, InputArray points1, bo if (ok) *ok = true; if (static_cast(ninliers) / npoints < minInlierRatio_) { - M = Mat::eye(3, 3, CV_32F); + M = Mat::eye(3, 3, CV_32FC1); if (ok) *ok = false; } @@ -554,7 +554,7 @@ Mat MotionEstimatorL1::estimate(InputArray points0, InputArray points1, bool *ok CV_Assert(motionModel() <= MM_AFFINE && motionModel() != MM_RIGID); if(npoints <= 0) - return Mat::eye(3, 3, CV_32F); + return Mat::eye(3, 3, CV_32FC1); // prepare LP problem @@ -651,7 +651,7 @@ Mat MotionEstimatorL1::estimate(InputArray points0, InputArray points1, bool *ok const double *sol = model.getColSolution(); - Mat_ M = Mat::eye(3, 3, CV_32F); + Mat_ M = Mat::eye(3, 3, CV_32FC1); M(0,0) = sol[0]; M(0,1) = sol[1]; M(0,2) = sol[2]; @@ -727,7 +727,7 @@ Mat KeypointBasedMotionEstimator::estimate(InputArray frame0, InputArray frame1, // find keypoints detector_->detect(frame0, keypointsPrev_); if (keypointsPrev_.empty()) - return Mat::eye(3, 3, CV_32F); + return Mat::eye(3, 3, CV_32FC1); // extract points from keypoints pointsPrev_.resize(keypointsPrev_.size()); @@ -863,7 +863,7 @@ Mat getMotion(int from, int to, const std::vector &motions) { CV_INSTRUMENT_REGION(); - Mat M = Mat::eye(3, 3, CV_32F); + Mat M = Mat::eye(3, 3, CV_32FC1); if (to > from) { for (int i = from; i < to; ++i) diff --git a/modules/videostab/src/inpainting.cpp b/modules/videostab/src/inpainting.cpp index 5ca6a4bf8115..a87ae97e2642 100644 --- a/modules/videostab/src/inpainting.cpp +++ b/modules/videostab/src/inpainting.cpp @@ -129,7 +129,7 @@ void ConsistentMosaicInpainter::inpaint(int idx, Mat &frame, Mat &mask) CV_INSTRUMENT_REGION(); CV_Assert(frame.type() == CV_8UC3); - CV_Assert(mask.size() == frame.size() && mask.type() == CV_8U); + CV_Assert(mask.size() == frame.size() && mask.type() == CV_8UC1); Mat invS = at(idx, *stabilizationMotions_).inv(); std::vector > vmotions(2*radius_ + 1); @@ -204,9 +204,9 @@ static float alignementError( const Mat &M, const Mat &frame0, const Mat &mask0, const Mat &frame1) { CV_Assert(frame0.type() == CV_8UC3 && frame1.type() == CV_8UC3); - CV_Assert(mask0.type() == CV_8U && mask0.size() == frame0.size()); + CV_Assert(mask0.type() == CV_8UC1 && mask0.size() == frame0.size()); CV_Assert(frame0.size() == frame1.size()); - CV_Assert(M.size() == Size(3,3) && M.type() == CV_32F); + CV_Assert(M.size() == Size(3,3) && M.type() == CV_32FC1); Mat_ mask0_(mask0); Mat_ M_(M); @@ -489,16 +489,16 @@ void calcFlowMask( { CV_INSTRUMENT_REGION(); - CV_Assert(flowX.type() == CV_32F && flowX.size() == mask0.size()); - CV_Assert(flowY.type() == CV_32F && flowY.size() == mask0.size()); - CV_Assert(errors.type() == CV_32F && errors.size() == mask0.size()); - CV_Assert(mask0.type() == CV_8U); - CV_Assert(mask1.type() == CV_8U && mask1.size() == mask0.size()); + CV_Assert(flowX.type() == CV_32FC1 && flowX.size() == mask0.size()); + CV_Assert(flowY.type() == CV_32FC1 && flowY.size() == mask0.size()); + CV_Assert(errors.type() == CV_32FC1 && errors.size() == mask0.size()); + CV_Assert(mask0.type() == CV_8UC1); + CV_Assert(mask1.type() == CV_8UC1 && mask1.size() == mask0.size()); Mat_ flowX_(flowX), flowY_(flowY), errors_(errors); Mat_ mask0_(mask0), mask1_(mask1); - flowMask.create(mask0.size(), CV_8U); + flowMask.create(mask0.size(), CV_8UC1); flowMask.setTo(0); Mat_ flowMask_(flowMask); @@ -525,13 +525,13 @@ void completeFrameAccordingToFlow( { CV_INSTRUMENT_REGION(); - CV_Assert(flowMask.type() == CV_8U); - CV_Assert(flowX.type() == CV_32F && flowX.size() == flowMask.size()); - CV_Assert(flowY.type() == CV_32F && flowY.size() == flowMask.size()); + CV_Assert(flowMask.type() == CV_8UC1); + CV_Assert(flowX.type() == CV_32FC1 && flowX.size() == flowMask.size()); + CV_Assert(flowY.type() == CV_32FC1 && flowY.size() == flowMask.size()); CV_Assert(frame1.type() == CV_8UC3 && frame1.size() == flowMask.size()); - CV_Assert(mask1.type() == CV_8U && mask1.size() == flowMask.size()); + CV_Assert(mask1.type() == CV_8UC1 && mask1.size() == flowMask.size()); CV_Assert(frame0.type() == CV_8UC3 && frame0.size() == flowMask.size()); - CV_Assert(mask0.type() == CV_8U && mask0.size() == flowMask.size()); + CV_Assert(mask0.type() == CV_8UC1 && mask0.size() == flowMask.size()); Mat_ flowMask_(flowMask), mask1_(mask1), mask0_(mask0); Mat_ flowX_(flowX), flowY_(flowY); diff --git a/modules/videostab/src/motion_stabilizing.cpp b/modules/videostab/src/motion_stabilizing.cpp index 2314f26a9ee8..a57cffe596f8 100644 --- a/modules/videostab/src/motion_stabilizing.cpp +++ b/modules/videostab/src/motion_stabilizing.cpp @@ -61,7 +61,7 @@ void MotionStabilizationPipeline::stabilize( std::vector stabilizationMotions_(size); for (int i = 0; i < size; ++i) - stabilizationMotions[i] = Mat::eye(3, 3, CV_32F); + stabilizationMotions[i] = Mat::eye(3, 3, CV_32FC1); for (size_t i = 0; i < stabilizers_.size(); ++i) { @@ -555,7 +555,7 @@ void LpMotionStabilizer::stabilize( for (int t = 0; t < N; ++t, c += 4) { - Mat_ S0 = Mat::eye(3, 3, CV_32F); + Mat_ S0 = Mat::eye(3, 3, CV_32FC1); S0(1,1) = S0(0,0) = sol[c]; S0(0,1) = sol[c+1]; S0(1,0) = -sol[c+1]; @@ -639,7 +639,7 @@ Mat ensureInclusionConstraint(const Mat &M, Size size, float trimRatio) { CV_INSTRUMENT_REGION(); - CV_Assert(M.size() == Size(3,3) && M.type() == CV_32F); + CV_Assert(M.size() == Size(3,3) && M.type() == CV_32FC1); const float w = static_cast(size.width); const float h = static_cast(size.height); @@ -667,7 +667,7 @@ Mat ensureInclusionConstraint(const Mat &M, Size size, float trimRatio) l = t; } - return (1 - r) * M + r * Mat::eye(3, 3, CV_32F); + return (1 - r) * M + r * Mat::eye(3, 3, CV_32FC1); } @@ -676,7 +676,7 @@ float estimateOptimalTrimRatio(const Mat &M, Size size) { CV_INSTRUMENT_REGION(); - CV_Assert(M.size() == Size(3,3) && M.type() == CV_32F); + CV_Assert(M.size() == Size(3,3) && M.type() == CV_32FC1); const float w = static_cast(size.width); const float h = static_cast(size.height); diff --git a/modules/videostab/src/outlier_rejection.cpp b/modules/videostab/src/outlier_rejection.cpp index b6d7d64fcf29..8c60cf1dc988 100644 --- a/modules/videostab/src/outlier_rejection.cpp +++ b/modules/videostab/src/outlier_rejection.cpp @@ -57,7 +57,7 @@ void NullOutlierRejector::process( CV_Assert(points0.getMat().checkVector(2) == points1.getMat().checkVector(2)); int npoints = points0.getMat().checkVector(2); - mask.create(1, npoints, CV_8U); + mask.create(1, npoints, CV_8UC1); Mat mask_ = mask.getMat(); mask_.setTo(1); } @@ -82,7 +82,7 @@ void TranslationBasedLocalOutlierRejector::process( const Point2f* points0_ = points0.getMat().ptr(); const Point2f* points1_ = points1.getMat().ptr(); - mask.create(1, npoints, CV_8U); + mask.create(1, npoints, CV_8UC1); uchar* mask_ = mask.getMat().ptr(); Size ncells((frameSize.width + cellSize_.width - 1) / cellSize_.width, diff --git a/modules/videostab/src/stabilizer.cpp b/modules/videostab/src/stabilizer.cpp index cf25b4820c98..740454cc1e7b 100644 --- a/modules/videostab/src/stabilizer.cpp +++ b/modules/videostab/src/stabilizer.cpp @@ -148,7 +148,7 @@ bool StabilizerBase::doOneIteration() { curStabilizedPos_++; at(curStabilizedPos_ + radius_, frames_) = at(curPos_, frames_); - at(curStabilizedPos_ + radius_ - 1, motions_) = Mat::eye(3, 3, CV_32F); + at(curStabilizedPos_ + radius_ - 1, motions_) = Mat::eye(3, 3, CV_32FC1); stabilizeFrame(); log_->print("."); @@ -271,7 +271,7 @@ void OnePassStabilizer::reset() void OnePassStabilizer::setUp(const Mat &firstFrame) { frameSize_ = firstFrame.size(); - frameMask_.create(frameSize_, CV_8U); + frameMask_.create(frameSize_, CV_8UC1); frameMask_.setTo(255); int cacheSize = 2*radius_ + 1; @@ -283,7 +283,7 @@ void OnePassStabilizer::setUp(const Mat &firstFrame) for (int i = -radius_; i < 0; ++i) { - at(i, motions_) = Mat::eye(3, 3, CV_32F); + at(i, motions_) = Mat::eye(3, 3, CV_32FC1); at(i, frames_) = firstFrame; } @@ -412,7 +412,7 @@ void TwoPassStabilizer::runPrePassIfNecessary() else { frameSize_ = frame.size(); - frameMask_.create(frameSize_, CV_8U); + frameMask_.create(frameSize_, CV_8UC1); frameMask_.setTo(255); } @@ -427,7 +427,7 @@ void TwoPassStabilizer::runPrePassIfNecessary() // add aux. motions for (int i = 0; i < radius_; ++i) - motions_.push_back(Mat::eye(3, 3, CV_32F)); + motions_.push_back(Mat::eye(3, 3, CV_32FC1)); // stabilize diff --git a/modules/videostab/src/wobble_suppression.cpp b/modules/videostab/src/wobble_suppression.cpp index 079c511b5d89..ba66fa378cd5 100644 --- a/modules/videostab/src/wobble_suppression.cpp +++ b/modules/videostab/src/wobble_suppression.cpp @@ -66,11 +66,11 @@ int left, int idx, int right, Size size, const Mat &ml, const Mat &mr, GpuMat &mapx, GpuMat &mapy) { - CV_Assert(ml.size() == Size(3, 3) && ml.type() == CV_32F && ml.isContinuous()); - CV_Assert(mr.size() == Size(3, 3) && mr.type() == CV_32F && mr.isContinuous()); + CV_Assert(ml.size() == Size(3, 3) && ml.type() == CV_32FC1 && ml.isContinuous()); + CV_Assert(mr.size() == Size(3, 3) && mr.type() == CV_32FC1 && mr.isContinuous()); - mapx.create(size, CV_32F); - mapy.create(size, CV_32F); + mapx.create(size, CV_32FC1); + mapy.create(size, CV_32FC1); cv::cuda::device::globmotion::calcWobbleSuppressionMaps( left, idx, right, size.width, size.height, diff --git a/modules/videostab/test/test_motion_estimation.cpp b/modules/videostab/test/test_motion_estimation.cpp index 9a1ea1decd29..4efa0c0ab83c 100644 --- a/modules/videostab/test/test_motion_estimation.cpp +++ b/modules/videostab/test/test_motion_estimation.cpp @@ -57,7 +57,7 @@ cv::Mat testUtil::generateTransform(const cv::videostab::MotionModel model) const float affineCoeff = 3.f; /*----------Params----------*/ - cv::Mat transform = cv::Mat::eye(3, 3, CV_32F); + cv::Mat transform = cv::Mat::eye(3, 3, CV_32FC1); if(model != cv::videostab::MM_ROTATION) { @@ -116,7 +116,7 @@ double testUtil::performTest(const cv::videostab::MotionModel model, int size) const int pointsNumber = testUtil::rng.uniform(10, 100); - cv::Mat points(3, pointsNumber, CV_32F); + cv::Mat points(3, pointsNumber, CV_32FC1); testUtil::generatePoints(points); diff --git a/modules/viz/src/vizcore.cpp b/modules/viz/src/vizcore.cpp index a0ca4980a2d8..bcb49d01d0bf 100644 --- a/modules/viz/src/vizcore.cpp +++ b/modules/viz/src/vizcore.cpp @@ -345,7 +345,7 @@ void cv::viz::computeNormals(const Mesh& mesh, OutputArray _normals) for(int i = 0; i < generic_normals->GetNumberOfTuples(); ++i, ++optr) generic_normals->GetTuple(i, optr->val); - normals.convertTo(_normals, mesh.cloud.type()); + normals.convertTo(_normals, mesh.cloud.depth()); } else _normals.release(); diff --git a/samples/cpp/3calibration.cpp b/samples/cpp/3calibration.cpp index 4f96d403c6c4..0760c5311927 100644 --- a/samples/cpp/3calibration.cpp +++ b/samples/cpp/3calibration.cpp @@ -82,11 +82,11 @@ static bool run3Calibration(vector > imagePoints1, objpt.resize(imgpt.size(),objpt[0]); - Mat cameraMatrix = Mat::eye(3, 3, CV_64F); + Mat cameraMatrix = Mat::eye(3, 3, CV_64FC1); if( flags & CALIB_FIX_ASPECT_RATIO ) cameraMatrix.at(0,0) = aspectRatio; - Mat distCoeffs = Mat::zeros(5, 1, CV_64F); + Mat distCoeffs = Mat::zeros(5, 1, CV_64FC1); double err = calibrateCamera(objpt, imgpt, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index 251ab83e720a..7209b2495f94 100644 --- a/samples/cpp/calibration.cpp +++ b/samples/cpp/calibration.cpp @@ -142,11 +142,11 @@ static bool runCalibration( vector > imagePoints, vector& reprojErrs, double& totalAvgErr) { - cameraMatrix = Mat::eye(3, 3, CV_64F); + cameraMatrix = Mat::eye(3, 3, CV_64FC1); if( flags & CALIB_FIX_ASPECT_RATIO ) cameraMatrix.at(0,0) = aspectRatio; - distCoeffs = Mat::zeros(8, 1, CV_64F); + distCoeffs = Mat::zeros(8, 1, CV_64FC1); vector > objectPoints(1); calcChessboardCorners(boardSize, squareSize, objectPoints[0], patternType); diff --git a/samples/cpp/camshiftdemo.cpp b/samples/cpp/camshiftdemo.cpp index 22ce7f8488f0..96ea41295c92 100644 --- a/samples/cpp/camshiftdemo.cpp +++ b/samples/cpp/camshiftdemo.cpp @@ -129,7 +129,7 @@ int main( int argc, const char** argv ) inRange(hsv, Scalar(0, smin, MIN(_vmin,_vmax)), Scalar(180, 256, MAX(_vmin, _vmax)), mask); int ch[] = {0, 0}; - hue.create(hsv.size(), hsv.depth()); + hue.create(hsv.size(), CV_MAKETYPE(hsv.depth(), 1)); mixChannels(&hsv, 1, &hue, 1, ch, 1); if( trackObject < 0 ) diff --git a/samples/cpp/connected_components.cpp b/samples/cpp/connected_components.cpp index 711b0a97c835..291116832056 100644 --- a/samples/cpp/connected_components.cpp +++ b/samples/cpp/connected_components.cpp @@ -14,7 +14,7 @@ int threshval = 100; static void on_trackbar(int, void*) { Mat bw = threshval < 128 ? (img < threshval) : (img > threshval); - Mat labelImage(img.size(), CV_32S); + Mat labelImage(img.size(), CV_32SC1); int nLabels = connectedComponents(bw, labelImage, 8); std::vector colors(nLabels); colors[0] = Vec3b(0, 0, 0);//background diff --git a/samples/cpp/cout_mat.cpp b/samples/cpp/cout_mat.cpp index 8315d7b78073..1be212f56271 100644 --- a/samples/cpp/cout_mat.cpp +++ b/samples/cpp/cout_mat.cpp @@ -33,7 +33,7 @@ int main(int argc, char** argv) help(); return 0; } - Mat I = Mat::eye(4, 4, CV_64F); + Mat I = Mat::eye(4, 4, CV_64FC1); I.at(1,1) = CV_PI; cout << "I = \n" << I << ";" << endl << endl; diff --git a/samples/cpp/demhist.cpp b/samples/cpp/demhist.cpp index d4a4c920427d..be48bd4c8820 100644 --- a/samples/cpp/demhist.cpp +++ b/samples/cpp/demhist.cpp @@ -43,7 +43,7 @@ static void updateBrightnessContrast( int /*arg*/, void* ) imshow("image", dst); calcHist(&dst, 1, 0, Mat(), hist, 1, &histSize, 0); - Mat histImage = Mat::ones(200, 320, CV_8U)*255; + Mat histImage = Mat::ones(200, 320, CV_8UC1)*255; normalize(hist, hist, 0, histImage.rows, NORM_MINMAX, CV_32F); diff --git a/samples/cpp/dft.cpp b/samples/cpp/dft.cpp index ddb56acf09f1..c17c33422686 100644 --- a/samples/cpp/dft.cpp +++ b/samples/cpp/dft.cpp @@ -44,7 +44,7 @@ int main(int argc, const char ** argv) Mat padded; copyMakeBorder(img, padded, 0, M - img.rows, 0, N - img.cols, BORDER_CONSTANT, Scalar::all(0)); - Mat planes[] = {Mat_(padded), Mat::zeros(padded.size(), CV_32F)}; + Mat planes[] = {Mat_(padded), Mat::zeros(padded.size(), CV_32FC1)}; Mat complexImg; merge(planes, 2, complexImg); diff --git a/samples/cpp/ela.cpp b/samples/cpp/ela.cpp index ca98bf9f85e6..8a3a21300faf 100644 --- a/samples/cpp/ela.cpp +++ b/samples/cpp/ela.cpp @@ -39,7 +39,7 @@ static void processImage(int , void*) Mat output; absdiff(image,compressed_img,output); - output.convertTo(Ela, CV_8UC3, scale_value); + output.convertTo(Ela, CV_8U, scale_value); // Shows processed image imshow(decodedwin, compressed_img); diff --git a/samples/cpp/image.cpp b/samples/cpp/image.cpp index fc57738a77af..36769779c373 100644 --- a/samples/cpp/image.cpp +++ b/samples/cpp/image.cpp @@ -87,7 +87,7 @@ int main( int argc, char** argv ) } #else - Mat noise(img.size(), CV_8U); // another Mat constructor; allocates a matrix of the specified size and type + Mat noise(img.size(), CV_8UC1); // another Mat constructor; allocates a matrix of the specified size and type randn(noise, Scalar::all(128), Scalar::all(20)); // fills the matrix with normally distributed random values; // there is also randu() for uniformly distributed random number generation GaussianBlur(noise, noise, Size(3, 3), 0.5, 0.5); // blur the noise a bit, kernel size is 3x3 and both sigma's are set to 0.5 diff --git a/samples/cpp/image_alignment.cpp b/samples/cpp/image_alignment.cpp index c55d1d6ac214..cb9ab75092c5 100644 --- a/samples/cpp/image_alignment.cpp +++ b/samples/cpp/image_alignment.cpp @@ -133,10 +133,10 @@ static void draw_warped_roi(Mat& image, const int width, const int height, Mat& { Point2f top_left, top_right, bottom_left, bottom_right; - Mat H = Mat (3, 1, CV_32F); - Mat U = Mat (3, 1, CV_32F); + Mat H = Mat (3, 1, CV_32FC1); + Mat U = Mat (3, 1, CV_32FC1); - Mat warp_mat = Mat::eye (3, 3, CV_32F); + Mat warp_mat = Mat::eye (3, 3, CV_32FC1); for (int y = 0; y < W.rows; y++) for (int x = 0; x < W.cols; x++) @@ -277,9 +277,9 @@ int main (const int argc, const char * argv[]) // initialize or load the warp matrix Mat warp_matrix; if (warpType == "homography") - warp_matrix = Mat::eye(3, 3, CV_32F); + warp_matrix = Mat::eye(3, 3, CV_32FC1); else - warp_matrix = Mat::eye(2, 3, CV_32F); + warp_matrix = Mat::eye(2, 3, CV_32FC1); if (inWarpFile!=""){ int readflag = readWarp(inWarpFile, warp_matrix, warp_mode); @@ -361,7 +361,7 @@ int main (const int argc, const char * argv[]) moveWindow ("error (black: no error)", 900, 300); // draw boundaries of corresponding regions - Mat identity_matrix = Mat::eye(3,3,CV_32F); + Mat identity_matrix = Mat::eye(3,3,CV_32FC1); draw_warped_roi (target_image, template_image.cols-2, template_image.rows-2, warp_matrix); draw_warped_roi (template_image, template_image.cols-2, template_image.rows-2, identity_matrix); diff --git a/samples/cpp/inpaint.cpp b/samples/cpp/inpaint.cpp index 61c4c45cbd7a..bb93933269bf 100644 --- a/samples/cpp/inpaint.cpp +++ b/samples/cpp/inpaint.cpp @@ -61,7 +61,7 @@ int main( int argc, char** argv ) namedWindow( "image", 1 ); img = img0.clone(); - inpaintMask = Mat::zeros(img.size(), CV_8U); + inpaintMask = Mat::zeros(img.size(), CV_8UC1); imshow("image", img); setMouseCallback( "image", onMouse, 0 ); diff --git a/samples/cpp/kalman.cpp b/samples/cpp/kalman.cpp index 501a749124c6..dcdddda518cb 100644 --- a/samples/cpp/kalman.cpp +++ b/samples/cpp/kalman.cpp @@ -32,9 +32,9 @@ int main(int, char**) help(); Mat img(500, 500, CV_8UC3); KalmanFilter KF(2, 1, 0); - Mat state(2, 1, CV_32F); /* (phi, delta_phi) */ - Mat processNoise(2, 1, CV_32F); - Mat measurement = Mat::zeros(1, 1, CV_32F); + Mat state(2, 1, CV_32FC1); /* (phi, delta_phi) */ + Mat processNoise(2, 1, CV_32FC1); + Mat measurement = Mat::zeros(1, 1, CV_32FC1); char code = (char)-1; for(;;) diff --git a/samples/cpp/letter_recog.cpp b/samples/cpp/letter_recog.cpp index 32ccf6b09b24..00948cb72bb5 100644 --- a/samples/cpp/letter_recog.cpp +++ b/samples/cpp/letter_recog.cpp @@ -42,7 +42,7 @@ read_num_class_data( const string& filename, int var_count, const int M = 1024; char buf[M+2]; - Mat el_ptr(1, var_count, CV_32F); + Mat el_ptr(1, var_count, CV_32FC1); int i; vector responses; @@ -97,12 +97,12 @@ static Ptr load_classifier(const string& filename_to_load) static Ptr prepare_train_data(const Mat& data, const Mat& responses, int ntrain_samples) { - Mat sample_idx = Mat::zeros( 1, data.rows, CV_8U ); + Mat sample_idx = Mat::zeros( 1, data.rows, CV_8UC1); Mat train_samples = sample_idx.colRange(0, ntrain_samples); train_samples.setTo(Scalar::all(1)); int nvars = data.cols; - Mat var_type( nvars + 1, 1, CV_8U ); + Mat var_type( nvars + 1, 1, CV_8UC1); var_type.setTo(Scalar::all(VAR_ORDERED)); var_type.at(nvars) = VAR_CATEGORICAL; @@ -256,8 +256,8 @@ build_boost_classifier( const string& data_filename, // // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - Mat new_data( ntrain_samples*class_count, var_count + 1, CV_32F ); - Mat new_responses( ntrain_samples*class_count, 1, CV_32S ); + Mat new_data( ntrain_samples*class_count, var_count + 1, CV_32FC1); + Mat new_responses( ntrain_samples*class_count, 1, CV_32SC1); // 1. unroll the database type mask printf( "Unrolling the database...\n"); @@ -273,7 +273,7 @@ build_boost_classifier( const string& data_filename, } } - Mat var_type( 1, var_count + 2, CV_8U ); + Mat var_type( 1, var_count + 2, CV_8UC1); var_type.setTo(Scalar::all(VAR_ORDERED)); var_type.at(var_count) = var_type.at(var_count+1) = VAR_CATEGORICAL; @@ -295,7 +295,7 @@ build_boost_classifier( const string& data_filename, cout << endl; } - Mat temp_sample( 1, var_count + 1, CV_32F ); + Mat temp_sample( 1, var_count + 1, CV_32FC1); float* tptr = temp_sample.ptr(); // compute prediction error on train and test data @@ -380,7 +380,7 @@ build_mlp_classifier( const string& data_filename, // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Mat train_data = data.rowRange(0, ntrain_samples); - Mat train_responses = Mat::zeros( ntrain_samples, class_count, CV_32F ); + Mat train_responses = Mat::zeros( ntrain_samples, class_count, CV_32FC1); // 1. unroll the responses cout << "Unrolling the responses...\n"; @@ -393,7 +393,7 @@ build_mlp_classifier( const string& data_filename, // 2. train classifier int layer_sz[] = { data.cols, 100, 100, class_count }; int nlayers = (int)(sizeof(layer_sz)/sizeof(layer_sz[0])); - Mat layer_sizes( 1, nlayers, CV_32S, layer_sz ); + Mat layer_sizes( 1, nlayers, CV_32SC1, layer_sz ); #if 1 int method = ANN_MLP::BACKPROP; diff --git a/samples/cpp/matchmethod_orb_akaze_brisk.cpp b/samples/cpp/matchmethod_orb_akaze_brisk.cpp index 7d39bae443e9..1099f559ec5d 100644 --- a/samples/cpp/matchmethod_orb_akaze_brisk.cpp +++ b/samples/cpp/matchmethod_orb_akaze_brisk.cpp @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) // Match method loop for (itMatcher = typeAlgoMatch.begin(); itMatcher != typeAlgoMatch.end(); ++itMatcher){ descriptorMatcher = DescriptorMatcher::create(*itMatcher); - if ((*itMatcher == "BruteForce-Hamming" || *itMatcher == "BruteForce-Hamming(2)") && (b->descriptorType() == CV_32F || b->defaultNorm() <= NORM_L2SQR)) + if ((*itMatcher == "BruteForce-Hamming" || *itMatcher == "BruteForce-Hamming(2)") && (b->descriptorType() == CV_32FC1 || b->defaultNorm() <= NORM_L2SQR)) { cout << "**************************************************************************\n"; cout << "It's strange. You should use Hamming distance only for a binary descriptor\n"; @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) // We sort distance between descriptor matches Mat index; int nbMatch=int(matches.size()); - Mat tab(nbMatch, 1, CV_32F); + Mat tab(nbMatch, 1, CV_32FC1); for (int i = 0; i(i, 0) = matches[i].distance; diff --git a/samples/cpp/openni_capture.cpp b/samples/cpp/openni_capture.cpp index 9323626a4939..ee504ffd61d0 100644 --- a/samples/cpp/openni_capture.cpp +++ b/samples/cpp/openni_capture.cpp @@ -237,7 +237,7 @@ int main( int argc, char* argv[] ) if( retrievedImageFlags[0] && capture.retrieve( depthMap, CAP_OPENNI_DEPTH_MAP ) ) { const float scaleFactor = 0.05f; - Mat show; depthMap.convertTo( show, CV_8UC1, scaleFactor ); + Mat show; depthMap.convertTo( show, CV_8U, scaleFactor ); imshow( "depth map", show ); } diff --git a/samples/cpp/pca.cpp b/samples/cpp/pca.cpp index fb2f585af847..faf9c5cce991 100644 --- a/samples/cpp/pca.cpp +++ b/samples/cpp/pca.cpp @@ -65,7 +65,7 @@ static void read_imgList(const string& filename, vector& images) { static Mat formatImagesForPCA(const vector &data) { - Mat dst(static_cast(data.size()), data[0].rows*data[0].cols, CV_32F); + Mat dst(static_cast(data.size()), data[0].rows*data[0].cols, CV_32FC1); for(unsigned int i = 0; i < data.size(); i++) { Mat image_row = data[i].clone().reshape(1,1); @@ -83,7 +83,7 @@ static Mat toGrayscale(InputArray _src) { } // create and return normalized image Mat dst; - cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1); + cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8U); return dst; } diff --git a/samples/cpp/phase_corr.cpp b/samples/cpp/phase_corr.cpp index f7356666c4fc..a7adb4a34c1b 100644 --- a/samples/cpp/phase_corr.cpp +++ b/samples/cpp/phase_corr.cpp @@ -19,7 +19,7 @@ int main(int, char* []) if(prev.empty()) { prev = curr.clone(); - createHanningWindow(hann, curr.size(), CV_64F); + createHanningWindow(hann, curr.size(), CV_64FC1); } prev.convertTo(prev64f, CV_64F); diff --git a/samples/cpp/select3dobj.cpp b/samples/cpp/select3dobj.cpp index dda4e770f12b..14e9f4145c7d 100644 --- a/samples/cpp/select3dobj.cpp +++ b/samples/cpp/select3dobj.cpp @@ -93,9 +93,9 @@ static bool readCameraMatrix(const string& filename, fs["distortion_coefficients"] >> distCoeffs; fs["camera_matrix"] >> cameraMatrix; - if( distCoeffs.type() != CV_64F ) + if( distCoeffs.type() != CV_64FC1 ) distCoeffs = Mat_(distCoeffs); - if( cameraMatrix.type() != CV_64F ) + if( cameraMatrix.type() != CV_64FC1 ) cameraMatrix = Mat_(cameraMatrix); return true; @@ -176,7 +176,7 @@ static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFram return Rect(); vector hull; convexHull(Mat_(Mat(imgpt)), hull); - Mat selectedObjMask = Mat::zeros(frame.size(), CV_8U); + Mat selectedObjMask = Mat::zeros(frame.size(), CV_8UC1); fillConvexPoly(selectedObjMask, &hull[0], (int)hull.size(), Scalar::all(255), 8, 0); Rect roi = boundingRect(Mat(hull)) & Rect(Point(), frame.size()); @@ -530,7 +530,7 @@ int main(int argc, char** argv) initUndistortRectifyMap(cameraMatrix, distCoeffs, Mat(), cameraMatrix, frame0.size(), CV_32FC2, mapxy, dummy ); - distCoeffs = Mat::zeros(5, 1, CV_64F); + distCoeffs = Mat::zeros(5, 1, CV_64FC1); } remap(frame0, frame, mapxy, Mat(), INTER_LINEAR); vector foundBoardCorners; @@ -582,9 +582,9 @@ int main(int argc, char** argv) roiList.push_back(r); float p[6]; - Mat RV(3, 1, CV_32F, p), TV(3, 1, CV_32F, p+3); - rvec.convertTo(RV, RV.type()); - tvec.convertTo(TV, TV.type()); + Mat RV(3, 1, CV_32FC1, p), TV(3, 1, CV_32FC1, p + 3); + rvec.convertTo(RV, RV.depth()); + tvec.convertTo(TV, TV.depth()); poseList.push_back(Vec6f(p[0], p[1], p[2], p[3], p[4], p[5])); } } diff --git a/samples/cpp/squares.cpp b/samples/cpp/squares.cpp index 480fe0a029ec..556a9abeb6f7 100644 --- a/samples/cpp/squares.cpp +++ b/samples/cpp/squares.cpp @@ -45,7 +45,7 @@ static void findSquares( const Mat& image, vector >& squares ) { squares.clear(); - Mat pyr, timg, gray0(image.size(), CV_8U), gray; + Mat pyr, timg, gray0(image.size(), CV_8UC1), gray; // down-scale and upscale the image to filter out the noise pyrDown(image, pyr, Size(image.cols/2, image.rows/2)); diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index 27b6e024f891..8af4c4dc443a 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -531,7 +531,7 @@ int main(int argc, char* argv[]) return -1; } adjuster->setConfThresh(conf_thresh); - Mat_ refine_mask = Mat::zeros(3, 3, CV_8U); + Mat_ refine_mask = Mat::zeros(3, 3, CV_8UC1); if (ba_refine_mask[0] == 'x') refine_mask(0,0) = 1; if (ba_refine_mask[1] == 'x') refine_mask(0,1) = 1; if (ba_refine_mask[2] == 'x') refine_mask(0,2) = 1; @@ -584,7 +584,7 @@ int main(int argc, char* argv[]) // Preapre images masks for (int i = 0; i < num_images; ++i) { - masks[i].create(images[i].size(), CV_8U); + masks[i].create(images[i].size(), CV_8UC1); masks[i].setTo(Scalar::all(255)); } @@ -779,7 +779,7 @@ int main(int argc, char* argv[]) warper->warp(img, K, cameras[img_idx].R, INTER_LINEAR, BORDER_REFLECT, img_warped); // Warp the current image mask - mask.create(img_size, CV_8U); + mask.create(img_size, CV_8UC1); mask.setTo(Scalar::all(255)); warper->warp(mask, K, cameras[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped); diff --git a/samples/cpp/train_HOG.cpp b/samples/cpp/train_HOG.cpp index 3a1527d8f422..10d78d451c94 100644 --- a/samples/cpp/train_HOG.cpp +++ b/samples/cpp/train_HOG.cpp @@ -27,9 +27,9 @@ vector< float > get_svm_detector( const Ptr< SVM >& svm ) double rho = svm->getDecisionFunction( 0, alpha, svidx ); CV_Assert( alpha.total() == 1 && svidx.total() == 1 && sv_total == 1 ); - CV_Assert( (alpha.type() == CV_64F && alpha.at(0) == 1.) || - (alpha.type() == CV_32F && alpha.at(0) == 1.f) ); - CV_Assert( sv.type() == CV_32F ); + CV_Assert( (alpha.type() == CV_64FC1 && alpha.at(0) == 1.) || + (alpha.type() == CV_32FC1 && alpha.at(0) == 1.f) ); + CV_Assert(sv.type() == CV_32FC1); vector< float > hog_detector( sv.cols + 1 ); memcpy( &hog_detector[0], sv.ptr(), sv.cols*sizeof( hog_detector[0] ) ); diff --git a/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp b/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp index f2f0ec03c5e3..474672f3e40d 100644 --- a/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp +++ b/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp @@ -105,7 +105,7 @@ void MatchingMethod( int, void* ) //! [match_template] //! [normalize] - normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() ); + normalize( result, result, 0, 1, NORM_MINMAX, CV_DEPTH_AUTO, Mat() ); //! [normalize] //! [best_match] diff --git a/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo1.cpp b/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo1.cpp index 61b6d607ceb6..3c4391823e23 100644 --- a/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo1.cpp +++ b/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo1.cpp @@ -42,7 +42,7 @@ int main( int argc, char* argv[] ) //! [Transform it to HSV] //! [Use only the Hue value] - hue.create(hsv.size(), hsv.depth()); + hue.create(hsv.size(), CV_MAKETYPE(hsv.depth(), 1)); int ch[] = { 0, 0 }; mixChannels( &hsv, 1, &hue, 1, ch, 1 ); //! [Use only the Hue value] @@ -78,7 +78,7 @@ void Hist_and_Backproj(int, void* ) //! [Get the Histogram and normalize it] Mat hist; calcHist( &hue, 1, 0, Mat(), hist, 1, &histSize, &ranges, true, false ); - normalize( hist, hist, 0, 255, NORM_MINMAX, -1, Mat() ); + normalize(hist, hist, 0, 255, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); //! [Get the Histogram and normalize it] //! [Get Backprojection] diff --git a/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo2.cpp b/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo2.cpp index 9c42c0fcecdd..9e181ff2e94d 100644 --- a/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo2.cpp +++ b/samples/cpp/tutorial_code/Histograms_Matching/calcBackProject_Demo2.cpp @@ -67,7 +67,7 @@ void pickPoint (int event, int x, int y, int, void* ) int connectivity = 8; int flags = connectivity + (newMaskVal << 8 ) + FLOODFILL_FIXED_RANGE + FLOODFILL_MASK_ONLY; - Mat mask2 = Mat::zeros( src.rows + 2, src.cols + 2, CV_8U ); + Mat mask2 = Mat::zeros( src.rows + 2, src.cols + 2, CV_8UC1); floodFill( src, mask2, seed, newVal, 0, Scalar( low, low, low ), Scalar( up, up, up), flags ); mask = mask2( Range( 1, mask2.rows - 1 ), Range( 1, mask2.cols - 1 ) ); @@ -94,7 +94,7 @@ void Hist_and_Backproj( ) /// Get the Histogram and normalize it calcHist( &hsv, 1, channels, mask, hist, 2, histSize, ranges, true, false ); - normalize( hist, hist, 0, 255, NORM_MINMAX, -1, Mat() ); + normalize(hist, hist, 0, 255, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); /// Get Backprojection Mat backproj; diff --git a/samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp b/samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp index fc45fc24dca8..fb212695a9d3 100644 --- a/samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp +++ b/samples/cpp/tutorial_code/Histograms_Matching/calcHist_Demo.cpp @@ -59,9 +59,9 @@ int main(int argc, char** argv) //! [Draw the histograms for B, G and R] //! [Normalize the result to ( 0, histImage.rows )] - normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() ); - normalize(g_hist, g_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() ); - normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() ); + normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); + normalize(g_hist, g_hist, 0, histImage.rows, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); + normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); //! [Normalize the result to ( 0, histImage.rows )] //! [Draw for each channel] diff --git a/samples/cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp b/samples/cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp index 73aa3c981935..bb0752d1cc89 100644 --- a/samples/cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp +++ b/samples/cpp/tutorial_code/Histograms_Matching/compareHist_Demo.cpp @@ -65,16 +65,16 @@ int main( int argc, char** argv ) Mat hist_base, hist_half_down, hist_test1, hist_test2; calcHist( &hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false ); - normalize( hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat() ); + normalize(hist_base, hist_base, 0, 1, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); calcHist( &hsv_half_down, 1, channels, Mat(), hist_half_down, 2, histSize, ranges, true, false ); - normalize( hist_half_down, hist_half_down, 0, 1, NORM_MINMAX, -1, Mat() ); + normalize(hist_half_down, hist_half_down, 0, 1, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); calcHist( &hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false ); - normalize( hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat() ); + normalize(hist_test1, hist_test1, 0, 1, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); calcHist( &hsv_test2, 1, channels, Mat(), hist_test2, 2, histSize, ranges, true, false ); - normalize( hist_test2, hist_test2, 0, 1, NORM_MINMAX, -1, Mat() ); + normalize(hist_test2, hist_test2, 0, 1, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); //! [Calculate the histograms for the HSV images] //! [Apply the histogram comparison methods] diff --git a/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp b/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp index 7c977a37b9db..344638d233ea 100644 --- a/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp +++ b/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp @@ -18,7 +18,7 @@ Mat img_original, img_corrected, img_gamma_corrected; void basicLinearTransform(const Mat &img, const double alpha_, const int beta_) { Mat res; - img.convertTo(res, -1, alpha_, beta_); + img.convertTo(res, CV_DEPTH_AUTO, alpha_, beta_); hconcat(img, res, img_corrected); imshow("Brightness and contrast adjustments", img_corrected); @@ -28,7 +28,7 @@ void gammaCorrection(const Mat &img, const double gamma_) { CV_Assert(gamma_ >= 0); //! [changing-contrast-brightness-gamma-correction] - Mat lookUpTable(1, 256, CV_8U); + Mat lookUpTable(1, 256, CV_8UC1); uchar* p = lookUpTable.ptr(); for( int i = 0; i < 256; ++i) p[i] = saturate_cast(pow(i / 255.0, gamma_) * 255.0); diff --git a/samples/cpp/tutorial_code/ImgProc/motion_deblur_filter/motion_deblur_filter.cpp b/samples/cpp/tutorial_code/ImgProc/motion_deblur_filter/motion_deblur_filter.cpp index f1ea892c89d3..184f393033f8 100755 --- a/samples/cpp/tutorial_code/ImgProc/motion_deblur_filter/motion_deblur_filter.cpp +++ b/samples/cpp/tutorial_code/ImgProc/motion_deblur_filter/motion_deblur_filter.cpp @@ -89,7 +89,7 @@ void help() //! [calcPSF] void calcPSF(Mat& outputImg, Size filterSize, int len, double theta) { - Mat h(filterSize, CV_32F, Scalar(0)); + Mat h(filterSize, CV_32FC1, Scalar(0)); Point point(filterSize.width / 2, filterSize.height / 2); ellipse(h, point, Size(0, cvRound(float(len) / 2.0)), 90.0 - theta, 0, 360, Scalar(255), FILLED); Scalar summa = sum(h); @@ -120,12 +120,12 @@ void fftshift(const Mat& inputImg, Mat& outputImg) //! [filter2DFreq] void filter2DFreq(const Mat& inputImg, Mat& outputImg, const Mat& H) { - Mat planes[2] = { Mat_(inputImg.clone()), Mat::zeros(inputImg.size(), CV_32F) }; + Mat planes[2] = { Mat_(inputImg.clone()), Mat::zeros(inputImg.size(), CV_32FC1) }; Mat complexI; merge(planes, 2, complexI); dft(complexI, complexI, DFT_SCALE); - Mat planesH[2] = { Mat_(H.clone()), Mat::zeros(H.size(), CV_32F) }; + Mat planesH[2] = { Mat_(H.clone()), Mat::zeros(H.size(), CV_32FC1) }; Mat complexH; merge(planesH, 2, complexH); Mat complexIH; @@ -142,7 +142,7 @@ void calcWnrFilter(const Mat& input_h_PSF, Mat& output_G, double nsr) { Mat h_PSF_shifted; fftshift(input_h_PSF, h_PSF_shifted); - Mat planes[2] = { Mat_(h_PSF_shifted.clone()), Mat::zeros(h_PSF_shifted.size(), CV_32F) }; + Mat planes[2] = { Mat_(h_PSF_shifted.clone()), Mat::zeros(h_PSF_shifted.size(), CV_32FC1) }; Mat complexI; merge(planes, 2, complexI); dft(complexI, complexI); @@ -159,8 +159,8 @@ void edgetaper(const Mat& inputImg, Mat& outputImg, double gamma, double beta) { int Nx = inputImg.cols; int Ny = inputImg.rows; - Mat w1(1, Nx, CV_32F, Scalar(0)); - Mat w2(Ny, 1, CV_32F, Scalar(0)); + Mat w1(1, Nx, CV_32FC1, Scalar(0)); + Mat w2(Ny, 1, CV_32FC1, Scalar(0)); float* p1 = w1.ptr(0); float* p2 = w2.ptr(0); diff --git a/samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp b/samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp index 059df8bd5517..00d538ea5717 100755 --- a/samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp +++ b/samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp @@ -83,7 +83,7 @@ void help() //! [calcPSF] void calcPSF(Mat& outputImg, Size filterSize, int R) { - Mat h(filterSize, CV_32F, Scalar(0)); + Mat h(filterSize, CV_32FC1, Scalar(0)); Point point(filterSize.width / 2, filterSize.height / 2); circle(h, point, R, 255, -1, 8); Scalar summa = sum(h); @@ -114,12 +114,12 @@ void fftshift(const Mat& inputImg, Mat& outputImg) //! [filter2DFreq] void filter2DFreq(const Mat& inputImg, Mat& outputImg, const Mat& H) { - Mat planes[2] = { Mat_(inputImg.clone()), Mat::zeros(inputImg.size(), CV_32F) }; + Mat planes[2] = { Mat_(inputImg.clone()), Mat::zeros(inputImg.size(), CV_32FC1) }; Mat complexI; merge(planes, 2, complexI); dft(complexI, complexI, DFT_SCALE); - Mat planesH[2] = { Mat_(H.clone()), Mat::zeros(H.size(), CV_32F) }; + Mat planesH[2] = { Mat_(H.clone()), Mat::zeros(H.size(), CV_32FC1) }; Mat complexH; merge(planesH, 2, complexH); Mat complexIH; @@ -136,7 +136,7 @@ void calcWnrFilter(const Mat& input_h_PSF, Mat& output_G, double nsr) { Mat h_PSF_shifted; fftshift(input_h_PSF, h_PSF_shifted); - Mat planes[2] = { Mat_(h_PSF_shifted.clone()), Mat::zeros(h_PSF_shifted.size(), CV_32F) }; + Mat planes[2] = { Mat_(h_PSF_shifted.clone()), Mat::zeros(h_PSF_shifted.size(), CV_32FC1) }; Mat complexI; merge(planes, 2, complexI); dft(complexI, complexI); diff --git a/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp index 80b6e84344f0..815577f983c9 100644 --- a/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp @@ -21,7 +21,7 @@ int main( int argc, char** argv ) int kernel_size = 3; int scale = 1; int delta = 0; - int ddepth = CV_16S; + ElemDepth ddepth = CV_16S; const char* window_name = "Laplace Demo"; //![variables] diff --git a/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp index 16661d8d3105..54a3364d7e10 100644 --- a/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp @@ -37,7 +37,7 @@ int main( int argc, char** argv ) int ksize = parser.get("ksize"); int scale = parser.get("scale"); int delta = parser.get("delta"); - int ddepth = CV_16S; + ElemDepth ddepth = CV_16S; //![variables] //![load] diff --git a/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp b/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp index 3b7f3a96b5c4..4d32fd084771 100644 --- a/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp @@ -21,7 +21,7 @@ int main ( int argc, char** argv ) Mat kernel; Point anchor; double delta; - int ddepth; + ElemDepth ddepth; int kernel_size; const char* window_name = "filter2D Demo"; @@ -43,7 +43,7 @@ int main ( int argc, char** argv ) // Initialize arguments for the filter anchor = Point( -1, -1 ); delta = 0; - ddepth = -1; + ddepth = CV_DEPTH_AUTO; //![init_arguments] // Loop - Will filter the image with different kernel sizes each 0.5 seconds @@ -53,7 +53,7 @@ int main ( int argc, char** argv ) //![update_kernel] // Update kernel size for a normalized box filter kernel_size = 3 + 2*( ind%5 ); - kernel = Mat::ones( kernel_size, kernel_size, CV_32F )/ (float)(kernel_size*kernel_size); + kernel = Mat::ones( kernel_size, kernel_size, CV_32FC1)/ (float)(kernel_size*kernel_size); //![update_kernel] //![apply_filter] diff --git a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp index d038cbd8744c..0bd5d9b5a18d 100644 --- a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp +++ b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp @@ -66,8 +66,8 @@ int main(int argc, char *argv[]) Mat imgResult = sharp - imgLaplacian; // convert back to 8bits gray scale - imgResult.convertTo(imgResult, CV_8UC3); - imgLaplacian.convertTo(imgLaplacian, CV_8UC3); + imgResult.convertTo(imgResult, CV_8U); + imgLaplacian.convertTo(imgLaplacian, CV_8U); // imshow( "Laplace Filtered Image", imgLaplacian ); imshow( "New Sharped Image", imgResult ); @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) threshold(dist, dist, 0.4, 1.0, THRESH_BINARY); // Dilate a bit the dist image - Mat kernel1 = Mat::ones(3, 3, CV_8U); + Mat kernel1 = Mat::ones(3, 3, CV_8UC1); dilate(dist, dist, kernel1); imshow("Peaks", dist); //! [peaks] @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) findContours(dist_8u, contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE); // Create the marker image for the watershed algorithm - Mat markers = Mat::zeros(dist.size(), CV_32S); + Mat markers = Mat::zeros(dist.size(), CV_32SC1); // Draw the foreground markers for (size_t i = 0; i < contours.size(); i++) diff --git a/samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp b/samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp index e62dc8471b73..de0e1a725430 100644 --- a/samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp +++ b/samples/cpp/tutorial_code/ShapeDescriptors/pointPolygonTest_demo.cpp @@ -18,7 +18,7 @@ int main( void ) { /// Create an image const int r = 100; - Mat src = Mat::zeros( Size( 4*r, 4*r ), CV_8U ); + Mat src = Mat::zeros( Size( 4*r, 4*r ), CV_8UC1); /// Create a sequence of points to make a contour vector vert(6); @@ -40,7 +40,7 @@ int main( void ) findContours( src, contours, RETR_TREE, CHAIN_APPROX_SIMPLE); /// Calculate the distances to the contour - Mat raw_dist( src.size(), CV_32F ); + Mat raw_dist( src.size(), CV_32FC1); for( int i = 0; i < src.rows; i++ ) { for( int j = 0; j < src.cols; j++ ) diff --git a/samples/cpp/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp b/samples/cpp/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp index 35672706bc14..a74f3138f097 100644 --- a/samples/cpp/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp +++ b/samples/cpp/tutorial_code/TrackingMotion/cornerHarris_Demo.cpp @@ -66,7 +66,7 @@ void cornerHarris_demo( int, void* ) /// Normalizing Mat dst_norm, dst_norm_scaled; - normalize( dst, dst_norm, 0, 255, NORM_MINMAX, CV_32FC1, Mat() ); + normalize( dst, dst_norm, 0, 255, NORM_MINMAX, CV_32F, Mat() ); convertScaleAbs( dst_norm, dst_norm_scaled ); /// Drawing a circle around corners diff --git a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp index 87fb4604e279..5f2951c188c4 100644 --- a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp +++ b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp @@ -518,14 +518,14 @@ static bool runCalibration( Settings& s, Size& imageSize, Mat& cameraMatrix, Mat vector& reprojErrs, double& totalAvgErr) { //! [fixed_aspect] - cameraMatrix = Mat::eye(3, 3, CV_64F); + cameraMatrix = Mat::eye(3, 3, CV_64FC1); if( s.flag & CALIB_FIX_ASPECT_RATIO ) cameraMatrix.at(0,0) = s.aspectRatio; //! [fixed_aspect] if (s.useFisheye) { - distCoeffs = Mat::zeros(4, 1, CV_64F); + distCoeffs = Mat::zeros(4, 1, CV_64FC1); } else { - distCoeffs = Mat::zeros(8, 1, CV_64F); + distCoeffs = Mat::zeros(8, 1, CV_64FC1); } vector > objectPoints(1); diff --git a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp index a53250ab865d..471ad5f174ed 100644 --- a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp +++ b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp @@ -205,7 +205,7 @@ bool PnPProblem::backproject2DPoint(const Mesh *mesh, const cv::Point2f &point2d double v = point2d.y; // Point in vector form - cv::Mat point2d_vec = cv::Mat::ones(3, 1, CV_64F); // 3x1 + cv::Mat point2d_vec = cv::Mat::ones(3, 1, CV_64FC1); // 3x1 point2d_vec.at(0) = u * lambda; point2d_vec.at(1) = v * lambda; point2d_vec.at(2) = lambda; diff --git a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp index 1945a2eb8bb1..f8cfe4e14196 100644 --- a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp +++ b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Utils.cpp @@ -191,7 +191,7 @@ double get_rotation_error(const cv::Mat &R_true, const cv::Mat &R) // https://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm cv::Mat rot2euler(const cv::Mat & rotationMatrix) { - cv::Mat euler(3,1,CV_64F); + cv::Mat euler(3,1,CV_64FC1); double m00 = rotationMatrix.at(0,0); double m02 = rotationMatrix.at(0,2); @@ -234,7 +234,7 @@ cv::Mat rot2euler(const cv::Mat & rotationMatrix) // https://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/index.htm cv::Mat euler2rot(const cv::Mat & euler) { - cv::Mat rotationMatrix(3,3,CV_64F); + cv::Mat rotationMatrix(3,3,CV_64FC1); double bank = euler.at(0); double attitude = euler.at(1); diff --git a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/main_detection.cpp b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/main_detection.cpp index 2ed4ce2d9037..8f2a9f8e3d7b 100644 --- a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/main_detection.cpp +++ b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/main_detection.cpp @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) double dt = 0.125; // time between measurements (1/FPS) initKalmanFilter(KF, nStates, nMeasurements, nInputs, dt); // init function - Mat measurements(nMeasurements, 1, CV_64F); measurements.setTo(Scalar(0)); + Mat measurements(nMeasurements, 1, CV_64FC1); measurements.setTo(Scalar(0)); bool good_measurement = false; @@ -251,11 +251,11 @@ int main(int argc, char *argv[]) { // Get the measured translation - Mat translation_measured(3, 1, CV_64F); + Mat translation_measured(3, 1, CV_64FC1); translation_measured = pnp_detection.get_t_matrix(); // Get the measured rotation - Mat rotation_measured(3, 3, CV_64F); + Mat rotation_measured(3, 3, CV_64FC1); rotation_measured = pnp_detection.get_R_matrix(); // fill the measurements vector @@ -266,8 +266,8 @@ int main(int argc, char *argv[]) } // Instantiate estimated translation and rotation - Mat translation_estimated(3, 1, CV_64F); - Mat rotation_estimated(3, 3, CV_64F); + Mat translation_estimated(3, 1, CV_64FC1); + Mat rotation_estimated(3, 3, CV_64FC1); // update the Kalman filter with good measurements updateKalmanFilter( KF, measurements, @@ -357,7 +357,7 @@ cout void initKalmanFilter(KalmanFilter &KF, int nStates, int nMeasurements, int nInputs, double dt) { - KF.init(nStates, nMeasurements, nInputs, CV_64F); // init Kalman Filter + KF.init(nStates, nMeasurements, nInputs, CV_64FC1); // init Kalman Filter setIdentity(KF.processNoiseCov, Scalar::all(1e-5)); // set process noise setIdentity(KF.measurementNoiseCov, Scalar::all(1e-2)); // set measurement noise @@ -443,7 +443,7 @@ void updateKalmanFilter( KalmanFilter &KF, Mat &measurement, translation_estimated.at(2) = estimated.at(2); // Estimated euler angles - Mat eulers_estimated(3, 1, CV_64F); + Mat eulers_estimated(3, 1, CV_64FC1); eulers_estimated.at(0) = estimated.at(9); eulers_estimated.at(1) = estimated.at(10); eulers_estimated.at(2) = estimated.at(11); @@ -458,7 +458,7 @@ void fillMeasurements( Mat &measurements, const Mat &translation_measured, const Mat &rotation_measured) { // Convert rotation matrix to euler angles - Mat measured_eulers(3, 1, CV_64F); + Mat measured_eulers(3, 1, CV_64FC1); measured_eulers = rot2euler(rotation_measured); // Set measurement to predict diff --git a/samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp b/samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp index 7121b16b356a..02f338bc7af0 100644 --- a/samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp +++ b/samples/cpp/tutorial_code/core/discrete_fourier_transform/discrete_fourier_transform.cpp @@ -37,7 +37,7 @@ int main(int argc, char ** argv) //! [expand] //! [complex_and_real] - Mat planes[] = {Mat_(padded), Mat::zeros(padded.size(), CV_32F)}; + Mat planes[] = {Mat_(padded), Mat::zeros(padded.size(), CV_32FC1)}; Mat complexI; merge(planes, 2, complexI); // Add to the expanded another plane with zeros //! [complex_and_real] diff --git a/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp b/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp index 47a5547837da..5cf36ffdc0a0 100644 --- a/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp +++ b/samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp @@ -109,7 +109,7 @@ int main( int argc, char* argv[]) << times << " runs): " << t << " milliseconds."<< endl; //! [table-init] - Mat lookUpTable(1, 256, CV_8U); + Mat lookUpTable(1, 256, CV_8UC1); uchar* p = lookUpTable.ptr(); for( int i = 0; i < 256; ++i) p[i] = table[i]; diff --git a/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp b/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp index 2dcc1ff107c6..7a973cf04529 100644 --- a/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp +++ b/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp @@ -93,7 +93,7 @@ void sequentialMandelbrot(Mat &img, const float x1, const float y1, const float int main() { //! [mandelbrot-transformation] - Mat mandelbrotImg(4800, 5400, CV_8U); + Mat mandelbrotImg(4800, 5400, CV_8UC1); float x1 = -2.1f, x2 = 0.6f; float y1 = -1.2f, y2 = 1.2f; float scaleX = mandelbrotImg.cols / (x2 - x1); @@ -133,7 +133,7 @@ int main() t1 = ((double) getTickCount() - t1) / getTickFrequency(); cout << "Parallel Mandelbrot: " << t1 << " s" << endl; - Mat mandelbrotImgSequential(4800, 5400, CV_8U); + Mat mandelbrotImgSequential(4800, 5400, CV_8UC1); double t2 = (double) getTickCount(); sequentialMandelbrot(mandelbrotImgSequential, x1, y1, scaleX, scaleY); t2 = ((double) getTickCount() - t2) / getTickFrequency(); diff --git a/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp b/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp index 4a65456a8932..bb4570bb6936 100644 --- a/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp +++ b/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp @@ -89,7 +89,7 @@ int main( int argc, char** argv ) #else //! [noisy] - Mat noisyI(I.size(), CV_8U); // Create a matrix of the specified size and type + Mat noisyI(I.size(), CV_8UC1); // Create a matrix of the specified size and type // Fills the matrix with normally distributed random values (around number with deviation off). // There is also randu() for uniformly distributed random number generation diff --git a/samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp b/samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp index f40c804cf49c..843167cebda3 100644 --- a/samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp +++ b/samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp @@ -27,14 +27,14 @@ int main(int,char**) CV_UNUSED(img); } { - Mat img(4,4,CV_8U); + Mat img(4,4,CV_8UC1); //! [Save image] imwrite(filename, img); //! [Save image] } // Accessing pixel intensity values { - Mat img(4,4,CV_8U); + Mat img(4,4,CV_8UC1); int y = 0, x = 0; { //! [Pixel access 1] diff --git a/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp b/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp index ac1c205258e3..c9c51e6cf13d 100644 --- a/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp +++ b/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp @@ -45,9 +45,9 @@ int main(int,char**) // Create using MATLAB style eye, ones or zero matrix //! [matlab] - Mat E = Mat::eye(4, 4, CV_64F); + Mat E = Mat::eye(4, 4, CV_64FC1); cout << "E = " << endl << " " << E << endl << endl; - Mat O = Mat::ones(2, 2, CV_32F); + Mat O = Mat::ones(2, 2, CV_32FC1); cout << "O = " << endl << " " << O << endl << endl; Mat Z = Mat::zeros(3,3, CV_8UC1); cout << "Z = " << endl << " " << Z << endl << endl; diff --git a/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp b/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp index b5b1b9229e75..f800b0164dc2 100755 --- a/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp +++ b/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) vector good_matches; vector inliers1, inliers2; for(size_t i = 0; i < matched1.size(); i++) { - Mat col = Mat::ones(3, 1, CV_64F); + Mat col = Mat::ones(3, 1, CV_64FC1); col.at(0) = matched1[i].pt.x; col.at(1) = matched1[i].pt.y; diff --git a/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp b/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp index 3673c3f63241..6c7eeaf20fa1 100644 --- a/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp +++ b/samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp @@ -101,7 +101,7 @@ void decomposeHomography(const string &img1Path, const string &img2Path, const S //! [compute-plane-normal-at-camera-pose-1] //! [compute-plane-distance-to-the-camera-frame-1] - Mat origin(3, 1, CV_64F, Scalar(0)); + Mat origin(3, 1, CV_64FC1, Scalar(0)); Mat origin1 = R1*origin + tvec1; double d_inv1 = 1.0 / normal1.dot(origin1); //! [compute-plane-distance-to-the-camera-frame-1] diff --git a/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp b/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp index ce2f76fa3897..f64d1afc5675 100644 --- a/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp +++ b/samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp @@ -120,7 +120,7 @@ void homographyFromCameraDisplacement(const string &img1Path, const string &img2 //! [compute-plane-normal-at-camera-pose-1] //! [compute-plane-distance-to-the-camera-frame-1] - Mat origin(3, 1, CV_64F, Scalar(0)); + Mat origin(3, 1, CV_64FC1, Scalar(0)); Mat origin1 = R1*origin + tvec1; double d_inv1 = 1.0 / normal1.dot(origin1); //! [compute-plane-distance-to-the-camera-frame-1] diff --git a/samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp b/samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp index 50a16c223e2d..fb13bf4d8063 100644 --- a/samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp +++ b/samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp @@ -100,7 +100,7 @@ void poseEstimationFromCoplanarPoints(const string &imgPath, const string &intri Mat c3 = c1.cross(c2); Mat tvec = H.col(2); - Mat R(3, 3, CV_64F); + Mat R(3, 3, CV_64FC1); for (int i = 0; i < 3; i++) { diff --git a/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp b/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp index c80799828ca8..a651096779c4 100644 --- a/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp +++ b/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp @@ -250,7 +250,7 @@ Scalar getMSSIM( const Mat& i1, const Mat& i2) { const double C1 = 6.5025, C2 = 58.5225; /***************************** INITS **********************************/ - int d = CV_32F; + ElemDepth d = CV_32F; Mat I1, I2; i1.convertTo(I1, d); // cannot calculate on one byte large values @@ -310,15 +310,15 @@ Scalar getMSSIM_CUDA( const Mat& i1, const Mat& i2) gI1.upload(i1); gI2.upload(i2); - gI1.convertTo(tmp1, CV_MAKE_TYPE(CV_32F, gI1.channels())); - gI2.convertTo(tmp2, CV_MAKE_TYPE(CV_32F, gI2.channels())); + gI1.convertTo(tmp1, CV_32F); + gI2.convertTo(tmp2, CV_32F); vector vI1, vI2; cuda::split(tmp1, vI1); cuda::split(tmp2, vI2); Scalar mssim; - Ptr gauss = cuda::createGaussianFilter(vI2[0].type(), -1, Size(11, 11), 1.5); + Ptr gauss = cuda::createGaussianFilter(vI2[0].type(), CV_TYPE_AUTO, Size(11, 11), 1.5); for( int i = 0; i < gI1.channels(); ++i ) { @@ -352,8 +352,8 @@ Scalar getMSSIM_CUDA( const Mat& i1, const Mat& i2) ///////////////////////////////// FORMULA //////////////////////////////// cuda::GpuMat t1, t2, t3; - mu1_mu2.convertTo(t1, -1, 2, C1); // t1 = 2 * mu1_mu2 + C1; - sigma12.convertTo(t2, -1, 2, C2); // t2 = 2 * sigma12 + C2; + mu1_mu2.convertTo(t1, CV_DEPTH_AUTO, 2, C1); // t1 = 2 * mu1_mu2 + C1; + sigma12.convertTo(t2, CV_DEPTH_AUTO, 2, C2); // t2 = 2 * sigma12 + C2; cuda::multiply(t1, t2, t3); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2)) cuda::addWeighted(mu1_2, 1.0, mu2_2, 1.0, C1, t1); // t1 = mu1_2 + mu2_2 + C1; @@ -389,50 +389,50 @@ Scalar getMSSIM_CUDA_optimized( const Mat& i1, const Mat& i2, BufferMSSIM& b) cuda::split(b.t2, b.vI2, stream); Scalar mssim; - Ptr gauss = cuda::createGaussianFilter(b.vI1[0].type(), -1, Size(11, 11), 1.5); + Ptr gauss = cuda::createGaussianFilter(b.vI1[0].type(), CV_TYPE_AUTO, Size(11, 11), 1.5); for( int i = 0; i < b.gI1.channels(); ++i ) { - cuda::multiply(b.vI2[i], b.vI2[i], b.I2_2, 1, -1, stream); // I2^2 - cuda::multiply(b.vI1[i], b.vI1[i], b.I1_2, 1, -1, stream); // I1^2 - cuda::multiply(b.vI1[i], b.vI2[i], b.I1_I2, 1, -1, stream); // I1 * I2 + cuda::multiply(b.vI2[i], b.vI2[i], b.I2_2, 1, CV_DEPTH_AUTO, stream); // I2^2 + cuda::multiply(b.vI1[i], b.vI1[i], b.I1_2, 1, CV_DEPTH_AUTO, stream); // I1^2 + cuda::multiply(b.vI1[i], b.vI2[i], b.I1_I2, 1, CV_DEPTH_AUTO, stream); // I1 * I2 gauss->apply(b.vI1[i], b.mu1, stream); gauss->apply(b.vI2[i], b.mu2, stream); - cuda::multiply(b.mu1, b.mu1, b.mu1_2, 1, -1, stream); - cuda::multiply(b.mu2, b.mu2, b.mu2_2, 1, -1, stream); - cuda::multiply(b.mu1, b.mu2, b.mu1_mu2, 1, -1, stream); + cuda::multiply(b.mu1, b.mu1, b.mu1_2, 1, CV_DEPTH_AUTO, stream); + cuda::multiply(b.mu2, b.mu2, b.mu2_2, 1, CV_DEPTH_AUTO, stream); + cuda::multiply(b.mu1, b.mu2, b.mu1_mu2, 1, CV_DEPTH_AUTO, stream); gauss->apply(b.I1_2, b.sigma1_2, stream); - cuda::subtract(b.sigma1_2, b.mu1_2, b.sigma1_2, cuda::GpuMat(), -1, stream); + cuda::subtract(b.sigma1_2, b.mu1_2, b.sigma1_2, cuda::GpuMat(), CV_DEPTH_AUTO, stream); //b.sigma1_2 -= b.mu1_2; - This would result in an extra data transfer operation gauss->apply(b.I2_2, b.sigma2_2, stream); - cuda::subtract(b.sigma2_2, b.mu2_2, b.sigma2_2, cuda::GpuMat(), -1, stream); + cuda::subtract(b.sigma2_2, b.mu2_2, b.sigma2_2, cuda::GpuMat(), CV_DEPTH_AUTO, stream); //b.sigma2_2 -= b.mu2_2; gauss->apply(b.I1_I2, b.sigma12, stream); - cuda::subtract(b.sigma12, b.mu1_mu2, b.sigma12, cuda::GpuMat(), -1, stream); + cuda::subtract(b.sigma12, b.mu1_mu2, b.sigma12, cuda::GpuMat(), CV_DEPTH_AUTO, stream); //b.sigma12 -= b.mu1_mu2; //here too it would be an extra data transfer due to call of operator*(Scalar, Mat) - cuda::multiply(b.mu1_mu2, 2, b.t1, 1, -1, stream); //b.t1 = 2 * b.mu1_mu2 + C1; - cuda::add(b.t1, C1, b.t1, cuda::GpuMat(), -1, stream); - cuda::multiply(b.sigma12, 2, b.t2, 1, -1, stream); //b.t2 = 2 * b.sigma12 + C2; - cuda::add(b.t2, C2, b.t2, cuda::GpuMat(), -12, stream); + cuda::multiply(b.mu1_mu2, 2, b.t1, 1, CV_DEPTH_AUTO, stream); //b.t1 = 2 * b.mu1_mu2 + C1; + cuda::add(b.t1, C1, b.t1, cuda::GpuMat(), CV_DEPTH_AUTO, stream); + cuda::multiply(b.sigma12, 2, b.t2, 1, CV_DEPTH_AUTO, stream); //b.t2 = 2 * b.sigma12 + C2; + cuda::add(b.t2, C2, b.t2, cuda::GpuMat(), CV_DEPTH_AUTO, stream); - cuda::multiply(b.t1, b.t2, b.t3, 1, -1, stream); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2)) + cuda::multiply(b.t1, b.t2, b.t3, 1, CV_DEPTH_AUTO, stream); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2)) - cuda::add(b.mu1_2, b.mu2_2, b.t1, cuda::GpuMat(), -1, stream); - cuda::add(b.t1, C1, b.t1, cuda::GpuMat(), -1, stream); + cuda::add(b.mu1_2, b.mu2_2, b.t1, cuda::GpuMat(), CV_DEPTH_AUTO, stream); + cuda::add(b.t1, C1, b.t1, cuda::GpuMat(), CV_DEPTH_AUTO, stream); - cuda::add(b.sigma1_2, b.sigma2_2, b.t2, cuda::GpuMat(), -1, stream); - cuda::add(b.t2, C2, b.t2, cuda::GpuMat(), -1, stream); + cuda::add(b.sigma1_2, b.sigma2_2, b.t2, cuda::GpuMat(), CV_DEPTH_AUTO, stream); + cuda::add(b.t2, C2, b.t2, cuda::GpuMat(), CV_DEPTH_AUTO, stream); - cuda::multiply(b.t1, b.t2, b.t1, 1, -1, stream); // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2)) - cuda::divide(b.t3, b.t1, b.ssim_map, 1, -1, stream); // ssim_map = t3./t1; + cuda::multiply(b.t1, b.t2, b.t1, 1, CV_DEPTH_AUTO, stream); // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2)) + cuda::divide(b.t3, b.t1, b.ssim_map, 1, CV_DEPTH_AUTO, stream); // ssim_map = t3./t1; stream.waitForCompletion(); diff --git a/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp b/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp index aa6107c120cd..ead4484acea5 100644 --- a/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp +++ b/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp @@ -49,7 +49,7 @@ double getOrientation(const vector &pts, Mat &img) //! [pca] //Construct a buffer used by the pca analysis int sz = static_cast(pts.size()); - Mat data_pts = Mat(sz, 2, CV_64F); + Mat data_pts = Mat(sz, 2, CV_64FC1); for (int i = 0; i < data_pts.rows; i++) { data_pts.at(i, 0) = pts[i].x; diff --git a/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp b/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp index a5bcf98cc0b0..6f0d4b6f6052 100644 --- a/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp +++ b/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp @@ -15,7 +15,7 @@ int main(int, char**) float trainingData[4][2] = { {501, 10}, {255, 10}, {501, 255}, {10, 501} }; //! [setup1] //! [setup2] - Mat trainingDataMat(4, 2, CV_32F, trainingData); + Mat trainingDataMat(4, 2, CV_32FC1, trainingData); Mat labelsMat(4, 1, CV_32SC1, labels); //! [setup2] diff --git a/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp b/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp index f8b7a373cc8c..e3ae7801b115 100644 --- a/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp +++ b/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp @@ -29,8 +29,8 @@ int main() Mat I = Mat::zeros(HEIGHT, WIDTH, CV_8UC3); //--------------------- 1. Set up training data randomly --------------------------------------- - Mat trainData(2*NTRAINING_SAMPLES, 2, CV_32F); - Mat labels (2*NTRAINING_SAMPLES, 1, CV_32S); + Mat trainData(2*NTRAINING_SAMPLES, 2, CV_32FC1); + Mat labels (2*NTRAINING_SAMPLES, 1, CV_32SC1); RNG rng(100); // Random value generation class diff --git a/samples/cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp b/samples/cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp index be0b1a8a21d6..d11f2e52d082 100644 --- a/samples/cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp +++ b/samples/cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp @@ -157,7 +157,7 @@ Scalar getMSSIM( const Mat& i1, const Mat& i2) { const double C1 = 6.5025, C2 = 58.5225; /***************************** INITS **********************************/ - int d = CV_32F; + ElemDepth d = CV_32F; Mat I1, I2; i1.convertTo(I1, d); // cannot calculate on one byte large values diff --git a/samples/cpp/tutorial_code/viz/histo3D.cpp b/samples/cpp/tutorial_code/viz/histo3D.cpp index a3ef0aacba5f..6d030dba0b65 100644 --- a/samples/cpp/tutorial_code/viz/histo3D.cpp +++ b/samples/cpp/tutorial_code/viz/histo3D.cpp @@ -153,7 +153,7 @@ int main (int argc,char **argv) int histSize[] = { hBins, hBins , hBins }; int channel[] = { 2, 1,0 }; calcHist(&img, 1, channel, Mat(), h.histogram, 3, histSize, etendu, true, false); - normalize(h.histogram, h.histogram, 100.0/(img.total()), 0, NORM_MINMAX, -1, Mat()); + normalize(h.histogram, h.histogram, 100.0 / (img.total()), 0, NORM_MINMAX, CV_DEPTH_AUTO, Mat()); minMaxIdx(h.histogram,NULL,&h.maxH,NULL,NULL); //! [calchist_for_histo3d] //! [slide_bar_for_thresh] diff --git a/samples/cpp/tutorial_code/viz/widget_pose.cpp b/samples/cpp/tutorial_code/viz/widget_pose.cpp index 5de82bd3858b..730905b2af11 100644 --- a/samples/cpp/tutorial_code/viz/widget_pose.cpp +++ b/samples/cpp/tutorial_code/viz/widget_pose.cpp @@ -50,7 +50,7 @@ int main() myWindow.showWidget("Cube Widget", cube_widget); /// Rodrigues vector - Mat rot_vec = Mat::zeros(1,3,CV_32F); + Mat rot_vec = Mat::zeros(1,3,CV_32FC1); float translation_phase = 0.0, translation = 0.0; while(!myWindow.wasStopped()) { diff --git a/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp b/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp index 2d1282d89de0..4437b2919646 100644 --- a/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp +++ b/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) } for (unsigned i = 0; i < matched1.size(); i++) { - Mat col = Mat::ones(3, 1, CV_64F); + Mat col = Mat::ones(3, 1, CV_64FC1); col.at(0) = matched1[i].pt.x; col.at(1) = matched1[i].pt.y; diff --git a/samples/cpp/videostab.cpp b/samples/cpp/videostab.cpp index 15d68dc2dd07..f998c286eb1f 100644 --- a/samples/cpp/videostab.cpp +++ b/samples/cpp/videostab.cpp @@ -350,7 +350,7 @@ int main(int argc, const char **argv) if (arg("gpu") == "yes") { cout << "initializing GPU..."; cout.flush(); - Mat hostTmp = Mat::zeros(1, 1, CV_32F); + Mat hostTmp = Mat::zeros(1, 1, CV_32FC1); cuda::GpuMat deviceTmp; deviceTmp.upload(hostTmp); cout << endl; diff --git a/samples/cpp/watershed.cpp b/samples/cpp/watershed.cpp index 0991bb04240c..eda77b87c5d3 100644 --- a/samples/cpp/watershed.cpp +++ b/samples/cpp/watershed.cpp @@ -96,7 +96,7 @@ int main( int argc, char** argv ) if( contours.empty() ) continue; - Mat markers(markerMask.size(), CV_32S); + Mat markers(markerMask.size(), CV_32SC1); markers = Scalar::all(0); int idx = 0; for( ; idx >= 0; idx = hierarchy[idx][0], compCount++ ) diff --git a/samples/dnn/colorization.cpp b/samples/dnn/colorization.cpp index 3f1c66127fb1..48ce92897b52 100644 --- a/samples/dnn/colorization.cpp +++ b/samples/dnn/colorization.cpp @@ -90,11 +90,11 @@ int main(int argc, char **argv) // setup additional layers: int sz[] = {2, 313, 1, 1}; - const Mat pts_in_hull(4, sz, CV_32F, hull_pts); + const Mat pts_in_hull(4, sz, CV_32FC1, hull_pts); Ptr class8_ab = net.getLayer("class8_ab"); class8_ab->blobs.push_back(pts_in_hull); Ptr conv8_313_rh = net.getLayer("conv8_313_rh"); - conv8_313_rh->blobs.push_back(Mat(1, 313, CV_32F, Scalar(2.606))); + conv8_313_rh->blobs.push_back(Mat(1, 313, CV_32FC1, Scalar(2.606))); // extract L channel and subtract mean Mat lab, L, input; @@ -111,8 +111,8 @@ int main(int argc, char **argv) // retrieve the calculated a,b channels from the network output Size siz(result.size[2], result.size[3]); - Mat a = Mat(siz, CV_32F, result.ptr(0,0)); - Mat b = Mat(siz, CV_32F, result.ptr(0,1)); + Mat a = Mat(siz, CV_32FC1, result.ptr(0,0)); + Mat b = Mat(siz, CV_32FC1, result.ptr(0,1)); resize(a, a, img.size()); resize(b, b, img.size()); diff --git a/samples/dnn/openpose.cpp b/samples/dnn/openpose.cpp index da9315426ad3..df121af53fac 100644 --- a/samples/dnn/openpose.cpp +++ b/samples/dnn/openpose.cpp @@ -129,7 +129,7 @@ int main(int argc, char **argv) for (int n=0; n 0.0: noise = np.zeros((h, w, 3), np.int8) cv.randn(noise, np.zeros(3), np.ones(3)*255*self.noise) - buf = cv.add(buf, noise, dtype=cv.CV_8UC3) + buf = cv.add(buf, noise, ddepth=cv.CV_8U) return True, buf def isOpened(self): diff --git a/samples/python/watershed.py b/samples/python/watershed.py index 9ca254ed8a37..20204b3995e6 100755 --- a/samples/python/watershed.py +++ b/samples/python/watershed.py @@ -51,7 +51,7 @@ def watershed(self): m = self.markers.copy() cv.watershed(self.img, m) overlay = self.colors[np.maximum(m, 0)] - vis = cv.addWeighted(self.img, 0.5, overlay, 0.5, 0.0, dtype=cv.CV_8UC3) + vis = cv.addWeighted(self.img, 0.5, overlay, 0.5, 0.0, ddepth=cv.CV_8U) cv.imshow('watershed', vis) def run(self): diff --git a/samples/tapi/camshift.cpp b/samples/tapi/camshift.cpp index 324e07340051..4e89c2b60053 100644 --- a/samples/tapi/camshift.cpp +++ b/samples/tapi/camshift.cpp @@ -125,7 +125,7 @@ int main(int argc, const char ** argv) cv::Scalar(180, 256, std::max(_vmin, _vmax)), mask); int fromTo[2] = { 0,0 }; - hue.create(hsv.size(), hsv.depth()); + hue.create(hsv.size(), CV_MAKETYPE(hsv.depth(), 1)); cv::mixChannels(std::vector(1, hsv), std::vector(1, hue), fromTo, 1); if (trackObject < 0) diff --git a/samples/tapi/opencl_custom_kernel.cpp b/samples/tapi/opencl_custom_kernel.cpp index 2395061a9a08..abb184093698 100644 --- a/samples/tapi/opencl_custom_kernel.cpp +++ b/samples/tapi/opencl_custom_kernel.cpp @@ -82,7 +82,7 @@ int main(int argc, char** argv) } else { - Mat frame(cv::Size(640, 480), CV_8U, Scalar::all(128)); + Mat frame(cv::Size(640, 480), CV_8UC1, Scalar::all(128)); Point p(frame.cols / 2, frame.rows / 2); line(frame, Point(0, frame.rows / 2), Point(frame.cols, frame.rows / 2), 1); circle(frame, p, 200, Scalar(32, 32, 32), 8, LINE_AA); diff --git a/samples/tapi/squares.cpp b/samples/tapi/squares.cpp index 42a40c3f6fe0..275b9e97c027 100644 --- a/samples/tapi/squares.cpp +++ b/samples/tapi/squares.cpp @@ -30,7 +30,7 @@ static double angle( Point pt1, Point pt2, Point pt0 ) static void findSquares( const UMat& image, vector >& squares ) { squares.clear(); - UMat pyr, timg, gray0(image.size(), CV_8U), gray; + UMat pyr, timg, gray0(image.size(), CV_8UC1), gray; // down-scale and upscale the image to filter out the noise pyrDown(image, pyr, Size(image.cols/2, image.rows/2));