1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Partially back-port #25075 to 4.x

This commit is contained in:
Alexander Smorkalov
2024-03-04 15:51:05 +03:00
parent ef611df09b
commit daa8f7dfc6
111 changed files with 1124 additions and 1124 deletions
+49 -49
View File
@@ -1005,7 +1005,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
else if( depth == CV_32F )
calcHist_<float>(ptrs, deltas, imsize, ihist, dims, ranges, _uniranges, uniform );
else
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(cv::Error::StsUnsupportedFormat, "");
ihist.convertTo(hist, CV_32F);
}
@@ -1182,7 +1182,7 @@ static void calcHist( const Mat* images, int nimages, const int* channels,
else if( depth == CV_32F )
calcSparseHist_<float>(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, uniform );
else
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(cv::Error::StsUnsupportedFormat, "");
if( !keepInt )
{
@@ -1637,7 +1637,7 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels,
else if( depth == CV_32F )
calcBackProj_<float, float>(ptrs, deltas, imsize, hist, dims, ranges, _uniranges, (float)scale, uniform );
else
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(cv::Error::StsUnsupportedFormat, "");
}
@@ -1810,7 +1810,7 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels,
calcSparseBackProj_<float, float>(ptrs, deltas, imsize, hist, dims, ranges,
_uniranges, (float)scale, uniform );
else
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(cv::Error::StsUnsupportedFormat, "");
}
#ifdef HAVE_OPENCL
@@ -2211,7 +2211,7 @@ double cv::compareHist( InputArray _H1, InputArray _H2, int method )
}
}
else
CV_Error( CV_StsBadArg, "Unknown comparison method" );
CV_Error( cv::Error::StsBadArg, "Unknown comparison method" );
}
if( method == CV_COMP_CHISQR_ALT )
@@ -2350,7 +2350,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
}
}
else
CV_Error( CV_StsBadArg, "Unknown comparison method" );
CV_Error( cv::Error::StsBadArg, "Unknown comparison method" );
if( method == CV_COMP_CHISQR_ALT )
result *= 2;
@@ -2387,7 +2387,7 @@ cvCreateHist( int dims, int *sizes, CvHistType type, float** ranges, int uniform
else if( type == CV_HIST_SPARSE )
hist->bins = cvCreateSparseMat( dims, sizes, CV_HIST_DEFAULT_TYPE );
else
CV_Error( CV_StsBadArg, "Invalid histogram type" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram type" );
if( ranges )
cvSetHistBinRanges( hist, ranges, uniform );
@@ -2402,10 +2402,10 @@ cvMakeHistHeaderForArray( int dims, int *sizes, CvHistogram *hist,
float *data, float **ranges, int uniform )
{
if( !hist )
CV_Error( CV_StsNullPtr, "Null histogram header pointer" );
CV_Error( cv::Error::StsNullPtr, "Null histogram header pointer" );
if( !data )
CV_Error( CV_StsNullPtr, "Null data pointer" );
CV_Error( cv::Error::StsNullPtr, "Null data pointer" );
hist->thresh2 = 0;
hist->type = CV_HIST_MAGIC_VAL;
@@ -2414,7 +2414,7 @@ cvMakeHistHeaderForArray( int dims, int *sizes, CvHistogram *hist,
if( ranges )
{
if( !uniform )
CV_Error( CV_StsBadArg, "Only uniform bin ranges can be used here "
CV_Error( cv::Error::StsBadArg, "Only uniform bin ranges can be used here "
"(to avoid memory allocation)" );
cvSetHistBinRanges( hist, ranges, uniform );
}
@@ -2427,14 +2427,14 @@ CV_IMPL void
cvReleaseHist( CvHistogram **hist )
{
if( !hist )
CV_Error( CV_StsNullPtr, "" );
CV_Error( cv::Error::StsNullPtr, "" );
if( *hist )
{
CvHistogram* temp = *hist;
if( !CV_IS_HIST(temp))
CV_Error( CV_StsBadArg, "Invalid histogram header" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header" );
*hist = 0;
if( CV_IS_SPARSE_HIST( temp ))
@@ -2455,7 +2455,7 @@ CV_IMPL void
cvClearHist( CvHistogram *hist )
{
if( !CV_IS_HIST(hist) )
CV_Error( CV_StsBadArg, "Invalid histogram header" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header" );
cvZero( hist->bins );
}
@@ -2465,7 +2465,7 @@ CV_IMPL void
cvThreshHist( CvHistogram* hist, double thresh )
{
if( !CV_IS_HIST(hist) )
CV_Error( CV_StsBadArg, "Invalid histogram header" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header" );
if( !CV_IS_SPARSE_MAT(hist->bins) )
{
@@ -2497,7 +2497,7 @@ cvNormalizeHist( CvHistogram* hist, double factor )
double sum = 0;
if( !CV_IS_HIST(hist) )
CV_Error( CV_StsBadArg, "Invalid histogram header" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header" );
if( !CV_IS_SPARSE_HIST(hist) )
{
@@ -2544,7 +2544,7 @@ cvGetMinMaxHistValue( const CvHistogram* hist,
int dims, size[CV_MAX_DIM];
if( !CV_IS_HIST(hist) )
CV_Error( CV_StsBadArg, "Invalid histogram header" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header" );
dims = cvGetDims( hist->bins, size );
@@ -2662,10 +2662,10 @@ cvCompareHist( const CvHistogram* hist1,
int size1[CV_MAX_DIM], size2[CV_MAX_DIM], total = 1;
if( !CV_IS_HIST(hist1) || !CV_IS_HIST(hist2) )
CV_Error( CV_StsBadArg, "Invalid histogram header[s]" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header[s]" );
if( CV_IS_SPARSE_MAT(hist1->bins) != CV_IS_SPARSE_MAT(hist2->bins))
CV_Error(CV_StsUnmatchedFormats, "One of histograms is sparse and other is not");
CV_Error(cv::Error::StsUnmatchedFormats, "One of histograms is sparse and other is not");
if( !CV_IS_SPARSE_MAT(hist1->bins) )
{
@@ -2678,13 +2678,13 @@ cvCompareHist( const CvHistogram* hist1,
int dims2 = cvGetDims( hist2->bins, size2 );
if( dims1 != dims2 )
CV_Error( CV_StsUnmatchedSizes,
CV_Error( cv::Error::StsUnmatchedSizes,
"The histograms have different numbers of dimensions" );
for( i = 0; i < dims1; i++ )
{
if( size1[i] != size2[i] )
CV_Error( CV_StsUnmatchedSizes, "The histograms have different sizes" );
CV_Error( cv::Error::StsUnmatchedSizes, "The histograms have different sizes" );
total *= size1[i];
}
@@ -2804,7 +2804,7 @@ cvCompareHist( const CvHistogram* hist1,
result = cv::compareHist( sH1, sH2, CV_COMP_KL_DIV );
}
else
CV_Error( CV_StsBadArg, "Unknown comparison method" );
CV_Error( cv::Error::StsBadArg, "Unknown comparison method" );
if( method == CV_COMP_CHISQR_ALT )
result *= 2;
@@ -2817,12 +2817,12 @@ CV_IMPL void
cvCopyHist( const CvHistogram* src, CvHistogram** _dst )
{
if( !_dst )
CV_Error( CV_StsNullPtr, "Destination double pointer is NULL" );
CV_Error( cv::Error::StsNullPtr, "Destination double pointer is NULL" );
CvHistogram* dst = *_dst;
if( !CV_IS_HIST(src) || (dst && !CV_IS_HIST(dst)) )
CV_Error( CV_StsBadArg, "Invalid histogram header[s]" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header[s]" );
bool eq = false;
int size1[CV_MAX_DIM];
@@ -2887,10 +2887,10 @@ cvSetHistBinRanges( CvHistogram* hist, float** ranges, int uniform )
int i, j;
if( !ranges )
CV_Error( CV_StsNullPtr, "NULL ranges pointer" );
CV_Error( cv::Error::StsNullPtr, "NULL ranges pointer" );
if( !CV_IS_HIST(hist) )
CV_Error( CV_StsBadArg, "Invalid histogram header" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header" );
dims = cvGetDims( hist->bins, size );
for( i = 0; i < dims; i++ )
@@ -2901,7 +2901,7 @@ cvSetHistBinRanges( CvHistogram* hist, float** ranges, int uniform )
for( i = 0; i < dims; i++ )
{
if( !ranges[i] )
CV_Error( CV_StsNullPtr, "One of <ranges> elements is NULL" );
CV_Error( cv::Error::StsNullPtr, "One of <ranges> elements is NULL" );
hist->thresh[i][0] = ranges[i][0];
hist->thresh[i][1] = ranges[i][1];
}
@@ -2925,13 +2925,13 @@ cvSetHistBinRanges( CvHistogram* hist, float** ranges, int uniform )
float val0 = -FLT_MAX;
if( !ranges[i] )
CV_Error( CV_StsNullPtr, "One of <ranges> elements is NULL" );
CV_Error( cv::Error::StsNullPtr, "One of <ranges> elements is NULL" );
for( j = 0; j <= size[i]; j++ )
{
float val = ranges[i][j];
if( val <= val0 )
CV_Error(CV_StsOutOfRange, "Bin ranges should go in ascenting order");
CV_Error(cv::Error::StsOutOfRange, "Bin ranges should go in ascenting order");
val0 = dim_ranges[j] = val;
}
@@ -2949,10 +2949,10 @@ CV_IMPL void
cvCalcArrHist( CvArr** img, CvHistogram* hist, int accumulate, const CvArr* mask )
{
if( !CV_IS_HIST(hist))
CV_Error( CV_StsBadArg, "Bad histogram pointer" );
CV_Error( cv::Error::StsBadArg, "Bad histogram pointer" );
if( !img )
CV_Error( CV_StsNullPtr, "Null double array pointer" );
CV_Error( cv::Error::StsNullPtr, "Null double array pointer" );
int size[CV_MAX_DIM];
int i, dims = cvGetDims( hist->bins, size);
@@ -3015,10 +3015,10 @@ CV_IMPL void
cvCalcArrBackProject( CvArr** img, CvArr* dst, const CvHistogram* hist )
{
if( !CV_IS_HIST(hist))
CV_Error( CV_StsBadArg, "Bad histogram pointer" );
CV_Error( cv::Error::StsBadArg, "Bad histogram pointer" );
if( !img )
CV_Error( CV_StsNullPtr, "Null double array pointer" );
CV_Error( cv::Error::StsNullPtr, "Null double array pointer" );
int size[CV_MAX_DIM];
int i, dims = cvGetDims( hist->bins, size );
@@ -3078,21 +3078,21 @@ cvCalcArrBackProjectPatch( CvArr** arr, CvArr* dst, CvSize patch_size, CvHistogr
cv::Size size;
if( !CV_IS_HIST(hist))
CV_Error( CV_StsBadArg, "Bad histogram pointer" );
CV_Error( cv::Error::StsBadArg, "Bad histogram pointer" );
if( !arr )
CV_Error( CV_StsNullPtr, "Null double array pointer" );
CV_Error( cv::Error::StsNullPtr, "Null double array pointer" );
if( norm_factor <= 0 )
CV_Error( CV_StsOutOfRange,
CV_Error( cv::Error::StsOutOfRange,
"Bad normalization factor (set it to 1.0 if unsure)" );
if( patch_size.width <= 0 || patch_size.height <= 0 )
CV_Error( CV_StsBadSize, "The patch width and height must be positive" );
CV_Error( cv::Error::StsBadSize, "The patch width and height must be positive" );
dims = cvGetDims( hist->bins );
if (dims < 1)
CV_Error( CV_StsOutOfRange, "Invalid number of dimensions");
CV_Error( cv::Error::StsOutOfRange, "Invalid number of dimensions");
cvNormalizeHist( hist, norm_factor );
for( i = 0; i < dims; i++ )
@@ -3105,11 +3105,11 @@ cvCalcArrBackProjectPatch( CvArr** arr, CvArr* dst, CvSize patch_size, CvHistogr
dstmat = cvGetMat( dst, &dststub, 0, 0 );
if( CV_MAT_TYPE( dstmat->type ) != CV_32FC1 )
CV_Error( CV_StsUnsupportedFormat, "Resultant image must have 32fC1 type" );
CV_Error( cv::Error::StsUnsupportedFormat, "Resultant image must have 32fC1 type" );
if( dstmat->cols != img[0]->width - patch_size.width + 1 ||
dstmat->rows != img[0]->height - patch_size.height + 1 )
CV_Error( CV_StsUnmatchedSizes,
CV_Error( cv::Error::StsUnmatchedSizes,
"The output map must be (W-w+1 x H-h+1), "
"where the input images are (W x H) each and the patch is (w x h)" );
@@ -3146,18 +3146,18 @@ cvCalcBayesianProb( CvHistogram** src, int count, CvHistogram** dst )
int i;
if( !src || !dst )
CV_Error( CV_StsNullPtr, "NULL histogram array pointer" );
CV_Error( cv::Error::StsNullPtr, "NULL histogram array pointer" );
if( count < 2 )
CV_Error( CV_StsOutOfRange, "Too small number of histograms" );
CV_Error( cv::Error::StsOutOfRange, "Too small number of histograms" );
for( i = 0; i < count; i++ )
{
if( !CV_IS_HIST(src[i]) || !CV_IS_HIST(dst[i]) )
CV_Error( CV_StsBadArg, "Invalid histogram header" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram header" );
if( !CV_IS_MATND(src[i]->bins) || !CV_IS_MATND(dst[i]->bins) )
CV_Error( CV_StsBadArg, "The function supports dense histograms only" );
CV_Error( cv::Error::StsBadArg, "The function supports dense histograms only" );
}
cvZero( dst[0]->bins );
@@ -3178,10 +3178,10 @@ cvCalcProbDensity( const CvHistogram* hist, const CvHistogram* hist_mask,
CvHistogram* hist_dens, double scale )
{
if( scale <= 0 )
CV_Error( CV_StsOutOfRange, "scale must be positive" );
CV_Error( cv::Error::StsOutOfRange, "scale must be positive" );
if( !CV_IS_HIST(hist) || !CV_IS_HIST(hist_mask) || !CV_IS_HIST(hist_dens) )
CV_Error( CV_StsBadArg, "Invalid histogram pointer[s]" );
CV_Error( cv::Error::StsBadArg, "Invalid histogram pointer[s]" );
{
CvArr* arrs[] = { hist->bins, hist_mask->bins, hist_dens->bins };
@@ -3191,7 +3191,7 @@ cvCalcProbDensity( const CvHistogram* hist, const CvHistogram* hist_mask,
cvInitNArrayIterator( 3, arrs, 0, stubs, &iterator );
if( CV_MAT_TYPE(iterator.hdr[0]->type) != CV_32FC1 )
CV_Error( CV_StsUnsupportedFormat, "All histograms must have 32fC1 type" );
CV_Error( cv::Error::StsUnsupportedFormat, "All histograms must have 32fC1 type" );
do
{
@@ -3533,7 +3533,7 @@ static void *icvReadHist( CvFileStorage * fs, CvFileNode * node )
int i, sizes[CV_MAX_DIM];
if(!CV_IS_MATND(mat))
CV_Error( CV_StsError, "Expected CvMatND");
CV_Error( cv::Error::StsError, "Expected CvMatND");
for(i=0; i<mat->dims; i++)
sizes[i] = mat->dim[i].size;
@@ -3554,7 +3554,7 @@ static void *icvReadHist( CvFileStorage * fs, CvFileNode * node )
{
h->bins = cvReadByName( fs, node, "bins" );
if(!CV_IS_SPARSE_MAT(h->bins)){
CV_Error( CV_StsError, "Unknown Histogram type");
CV_Error( cv::Error::StsError, "Unknown Histogram type");
}
}
@@ -3571,7 +3571,7 @@ static void *icvReadHist( CvFileStorage * fs, CvFileNode * node )
thresh_node = cvGetFileNodeByName( fs, node, "thresh" );
if(!thresh_node)
CV_Error( CV_StsError, "'thresh' node is missing");
CV_Error( cv::Error::StsError, "'thresh' node is missing");
cvStartReadRawData( fs, thresh_node, &reader );
if(is_uniform)