Commit 4a9b2445 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

hopefully, fixed crash in sparse mat test

parent 66eb270c
...@@ -4816,7 +4816,8 @@ void SparseMat::copyTo( SparseMat& m ) const ...@@ -4816,7 +4816,8 @@ void SparseMat::copyTo( SparseMat& m ) const
void SparseMat::copyTo( Mat& m ) const void SparseMat::copyTo( Mat& m ) const
{ {
CV_Assert( hdr ); CV_Assert( hdr );
m.create( dims(), hdr->size, type() ); int ndims = dims();
m.create( ndims, hdr->size, type() );
m = Scalar(0); m = Scalar(0);
SparseMatConstIterator from = begin(); SparseMatConstIterator from = begin();
...@@ -4825,7 +4826,7 @@ void SparseMat::copyTo( Mat& m ) const ...@@ -4825,7 +4826,7 @@ void SparseMat::copyTo( Mat& m ) const
for( i = 0; i < N; i++, ++from ) for( i = 0; i < N; i++, ++from )
{ {
const Node* n = from.node(); const Node* n = from.node();
copyElem( from.ptr, m.ptr(n->idx), esz); copyElem( from.ptr, (ndims > 1 ? m.ptr(n->idx) : m.ptr(n->idx[0])), esz);
} }
} }
......
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