mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
hopefully fixed test failures and complains from the doc builder
This commit is contained in:
parent
a760c454dd
commit
e97dd57dc7
@ -2261,7 +2261,7 @@ void _OutputArray::release() const
|
||||
((Mat*)obj)->release();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( k == UMAT )
|
||||
{
|
||||
((UMat*)obj)->release();
|
||||
|
@ -370,14 +370,14 @@ static bool ocl_moments( InputArray _src, Moments& m)
|
||||
ocl::Kernel k("moments", ocl::imgproc::moments_oclsrc, format("-D TILE_SIZE=%d", TILE_SIZE));
|
||||
if( k.empty() )
|
||||
return false;
|
||||
|
||||
|
||||
UMat src = _src.getUMat();
|
||||
Size sz = src.size();
|
||||
int xtiles = (sz.width + TILE_SIZE-1)/TILE_SIZE;
|
||||
int ytiles = (sz.height + TILE_SIZE-1)/TILE_SIZE;
|
||||
int ntiles = xtiles*ytiles;
|
||||
UMat umbuf(1, ntiles*K, CV_32S);
|
||||
|
||||
|
||||
size_t globalsize[] = {xtiles, ytiles};
|
||||
bool ok = k.args(ocl::KernelArg::ReadOnly(src),
|
||||
ocl::KernelArg::PtrWriteOnly(umbuf),
|
||||
@ -390,43 +390,43 @@ static bool ocl_moments( InputArray _src, Moments& m)
|
||||
double x = (i % xtiles)*TILE_SIZE, y = (i / xtiles)*TILE_SIZE;
|
||||
const int* mom = mbuf.ptr<int>() + i*K;
|
||||
double xm = x * mom[0], ym = y * mom[0];
|
||||
|
||||
|
||||
// accumulate moments computed in each tile
|
||||
|
||||
|
||||
// + m00 ( = m00' )
|
||||
m.m00 += mom[0];
|
||||
|
||||
|
||||
// + m10 ( = m10' + x*m00' )
|
||||
m.m10 += mom[1] + xm;
|
||||
|
||||
|
||||
// + m01 ( = m01' + y*m00' )
|
||||
m.m01 += mom[2] + ym;
|
||||
|
||||
|
||||
// + m20 ( = m20' + 2*x*m10' + x*x*m00' )
|
||||
m.m20 += mom[3] + x * (mom[1] * 2 + xm);
|
||||
|
||||
|
||||
// + m11 ( = m11' + x*m01' + y*m10' + x*y*m00' )
|
||||
m.m11 += mom[4] + x * (mom[2] + ym) + y * mom[1];
|
||||
|
||||
|
||||
// + m02 ( = m02' + 2*y*m01' + y*y*m00' )
|
||||
m.m02 += mom[5] + y * (mom[2] * 2 + ym);
|
||||
|
||||
|
||||
// + m30 ( = m30' + 3*x*m20' + 3*x*x*m10' + x*x*x*m00' )
|
||||
m.m30 += mom[6] + x * (3. * mom[3] + x * (3. * mom[1] + xm));
|
||||
|
||||
|
||||
// + m21 ( = m21' + x*(2*m11' + 2*y*m10' + x*m01' + x*y*m00') + y*m20')
|
||||
m.m21 += mom[7] + x * (2 * (mom[4] + y * mom[1]) + x * (mom[2] + ym)) + y * mom[3];
|
||||
|
||||
|
||||
// + m12 ( = m12' + y*(2*m11' + 2*x*m01' + y*m10' + x*y*m00') + x*m02')
|
||||
m.m12 += mom[8] + y * (2 * (mom[4] + x * mom[2]) + y * (mom[1] + xm)) + x * mom[5];
|
||||
|
||||
|
||||
// + m03 ( = m03' + 3*y*m02' + 3*y*y*m01' + y*y*y*m00' )
|
||||
m.m03 += mom[9] + y * (3. * mom[5] + y * (3. * mom[2] + ym));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -441,13 +441,10 @@ cv::Moments cv::moments( InputArray _src, bool binary )
|
||||
int cn = CV_MAT_CN( type );
|
||||
Size size = _src.size();
|
||||
|
||||
if( cn > 1 )
|
||||
CV_Error( CV_StsBadArg, "Invalid image type (must be single-channel)" );
|
||||
|
||||
if( size.width <= 0 || size.height <= 0 )
|
||||
return m;
|
||||
|
||||
if( ocl::useOpenCL() && depth == CV_8U && !binary &&
|
||||
|
||||
if( ocl::useOpenCL() && type == CV_8UC1 && !binary &&
|
||||
_src.isUMat() && ocl_moments(_src, m) )
|
||||
;
|
||||
else
|
||||
@ -456,6 +453,9 @@ cv::Moments cv::moments( InputArray _src, bool binary )
|
||||
if( mat.checkVector(2) >= 0 && (depth == CV_32F || depth == CV_32S))
|
||||
return contourMoments(mat);
|
||||
|
||||
if( cn > 1 )
|
||||
CV_Error( CV_StsBadArg, "Invalid image type (must be single-channel)" );
|
||||
|
||||
if( binary || depth == CV_8U )
|
||||
func = momentsInTile<uchar, int, int>;
|
||||
else if( depth == CV_16U )
|
||||
|
@ -31,17 +31,17 @@ __kernel void moments(__global const uchar* src, int src_step, int src_offset,
|
||||
{
|
||||
p = convert_int4(vload4(0, ptr));
|
||||
S += SUM_ELEM(p.s0, 0) + SUM_ELEM(p.s1, 1) + SUM_ELEM(p.s2, 2) + SUM_ELEM(p.s3, 3);
|
||||
|
||||
|
||||
if( x_max >= 8 )
|
||||
{
|
||||
p = convert_int4(vload4(0, ptr+4));
|
||||
S += SUM_ELEM(p.s0, 4) + SUM_ELEM(p.s1, 5) + SUM_ELEM(p.s2, 6) + SUM_ELEM(p.s3, 7);
|
||||
|
||||
|
||||
if( x_max >= 12 )
|
||||
{
|
||||
p = convert_int4(vload4(0, ptr+8));
|
||||
S += SUM_ELEM(p.s0, 8) + SUM_ELEM(p.s1, 9) + SUM_ELEM(p.s2, 10) + SUM_ELEM(p.s3, 11);
|
||||
|
||||
|
||||
if( x_max >= 16 )
|
||||
{
|
||||
p = convert_int4(vload4(0, ptr+12));
|
||||
@ -50,7 +50,7 @@ __kernel void moments(__global const uchar* src, int src_step, int src_offset,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( x < x_max )
|
||||
{
|
||||
int ps = ptr[x];
|
||||
@ -66,7 +66,7 @@ __kernel void moments(__global const uchar* src, int src_step, int src_offset,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int sy = y*y;
|
||||
m00 += S.s0;
|
||||
m10 += S.s1;
|
||||
|
@ -113,16 +113,16 @@ void CV_MomentsTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
int cn = (cvtest::randInt(rng) % 4) + 1;
|
||||
int depth = 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;
|
||||
if( depth == 0 && !is_binary )
|
||||
try_umat = cvtest::randInt(rng) % 5 != 0;
|
||||
else
|
||||
try_umat = cvtest::randInt(rng) % 2 != 0;
|
||||
|
||||
|
||||
if( cn == 2 || try_umat )
|
||||
cn = 1;
|
||||
|
||||
|
||||
OCL_TUNING_MODE_ONLY(
|
||||
cn = 1;
|
||||
depth = CV_8U;
|
||||
@ -136,7 +136,7 @@ void CV_MomentsTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(MOMENT_COUNT,1);
|
||||
if(CV_MAT_DEPTH(types[INPUT][0])>=CV_32S)
|
||||
sizes[INPUT][0].width = MAX(sizes[INPUT][0].width, 3);
|
||||
|
||||
|
||||
coi = 0;
|
||||
cvmat_allowed = true;
|
||||
if( cn > 1 )
|
||||
@ -189,7 +189,7 @@ void CV_MomentsTest::run_func()
|
||||
}
|
||||
else
|
||||
cvMoments( test_array[INPUT][0], m, is_binary );
|
||||
|
||||
|
||||
others[0] = cvGetNormalizedCentralMoment( m, 2, 0 );
|
||||
others[1] = cvGetNormalizedCentralMoment( m, 1, 1 );
|
||||
others[2] = cvGetNormalizedCentralMoment( m, 0, 2 );
|
||||
|
Loading…
Reference in New Issue
Block a user