Commit c473718b authored by Maksim Shabunin's avatar Maksim Shabunin

Check for empty Mat in compare, operator= and RNG::fill, fixed related tests

parent 1da46fe6
......@@ -1233,7 +1233,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
CV_Assert( op == CMP_LT || op == CMP_LE || op == CMP_EQ ||
op == CMP_NE || op == CMP_GE || op == CMP_GT );
if(_src1.empty() && _src2.empty())
if(_src1.empty() || _src2.empty())
{
_dst.release();
return;
......
......@@ -411,6 +411,8 @@ Mat& Mat::operator = (const Scalar& s)
{
CV_INSTRUMENT_REGION()
if (empty()) return *this;
const Mat* arrays[] = { this };
uchar* dptr;
NAryMatIterator it(arrays, &dptr, 1);
......
......@@ -511,6 +511,8 @@ static RandnScaleFunc randnScaleTab[] =
void RNG::fill( InputOutputArray _mat, int disttype,
InputArray _param1arg, InputArray _param2arg, bool saturateRange )
{
if (_mat.empty())
return;
Mat mat = _mat.getMat(), _param1 = _param1arg.getMat(), _param2 = _param2arg.getMat();
int depth = mat.depth(), cn = mat.channels();
AutoBuffer<double> _parambuf;
......
......@@ -168,11 +168,12 @@ void Core_RandTest::run( int )
{
tested_rng = saved_rng;
int sz = 0, dsz = 0, slice;
for( slice = 0; slice < maxSlice; slice++, sz += dsz )
for( slice = 0; slice < maxSlice && sz < SZ; slice++, sz += dsz )
{
dsz = slice+1 < maxSlice ? (int)(cvtest::randInt(rng) % (SZ - sz + 1)) : SZ - sz;
dsz = slice+1 < maxSlice ? (int)(cvtest::randInt(rng) % (SZ - sz) + 1) : SZ - sz;
Mat aslice = arr[k].colRange(sz, sz + dsz);
tested_rng.fill(aslice, dist_type, A, B);
printf("%d - %d\n", sz, sz + dsz);
}
}
......
......@@ -89,7 +89,6 @@ void CV_GrabcutTest::run( int /* start_from */)
Mat exp_bgdModel, exp_fgdModel;
Mat mask;
mask = Scalar(0);
Mat bgdModel, fgdModel;
grabCut( img, mask, rect, bgdModel, fgdModel, 0, GC_INIT_WITH_RECT );
bgdModel.copyTo(exp_bgdModel);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment