Commit a74a2302 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed bug #2331

parent a08290d8
...@@ -209,6 +209,7 @@ void Mat::copyTo( OutputArray _dst ) const ...@@ -209,6 +209,7 @@ void Mat::copyTo( OutputArray _dst ) const
int dtype = _dst.type(); int dtype = _dst.type();
if( _dst.fixedType() && dtype != type() ) if( _dst.fixedType() && dtype != type() )
{ {
CV_Assert( channels() == CV_MAT_CN(dtype) );
convertTo( _dst, dtype ); convertTo( _dst, dtype );
return; return;
} }
......
...@@ -766,6 +766,19 @@ bool CV_OperationsTest::TestTemplateMat() ...@@ -766,6 +766,19 @@ bool CV_OperationsTest::TestTemplateMat()
Mat c = (a*b.t()).t(); Mat c = (a*b.t()).t();
CV_Assert( norm(c, CV_L1) == 4. ); CV_Assert( norm(c, CV_L1) == 4. );
} }
bool badarg_catched = false;
try
{
Mat m1 = Mat::zeros(1, 10, CV_8UC1);
Mat m2 = Mat::zeros(10, 10, CV_8UC3);
m1.copyTo(m2.row(1));
}
catch(const Exception& e)
{
badarg_catched = true;
}
CV_Assert( badarg_catched );
} }
catch (const test_excep& e) catch (const test_excep& e)
{ {
......
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