Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

copy vector of mat to vector of mat

(This is related to this )

I have a vector<Mat> src which is filled with data. It's size is src.resize( N )

I have another vector<mat> dest; I am declaring it's size to be dest.resize( N )

1) What is the right way to copy src to dest?Just dest=src?

2) If I want to copy to dest ,only the 1st row and all columns of src vector, then what size the dest vector should be?

dest = src;
src[0]( Range(0, 1),Range::all() ).copyTo( dest[0](Range::all(), Range::all() ) ); //for the 1st array of vector

If ,for example src is 4x4 , then ,since I want to keep only 1st row and all columns,the dest size should be 1x4. Is there a way to do this ?Using the src[0]( Range(0, 1),Range::all() ).copyTo( dest[0](Range::all(), Range::all() ) )?

Or,another idea , is to have the dest the same size with src ,but fill all the rest elements with zero for example?

copy vector of mat to vector of mat

(This is related to this )

I have a vector<Mat> src which is filled with data. It's size is src.resize( N )

I have another vector<mat> dest; I am declaring it's size to be dest.resize( N )

1) What is the right way to copy src to dest?Just dest=src?

2) If I want to copy to dest ,only the 1st row and all columns of src vector, then what size the dest vector should be?

dest = src;
src[0]( Range(0, 1),Range::all() ).copyTo( dest[0](Range::all(), Range::all() ) ); //for the 1st array of vector

If ,for example src is 4x4 , then ,since I want to keep only 1st row and all columns,the dest size should be 1x4. Is there a way to do this ?Using the src[0]( Range(0, 1),Range::all() ).copyTo( dest[0](Range::all(), Range::all() ) )?

Or,another idea , is to have the dest the same size with src ,but fill all the rest elements with zero for example?

=====UPDATE================

I figured this:

    dest[0] = src[0 ]( Range(0, 1),Range::all() );

for first row and all columns.

( I can't make it an answer yet ,but if there is another way please share )