Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

fail case 2:

vector<uchar> v2 = { 2, 3, 9, 6 };
mat.push_back(v2);

there is a conversion operator to Mat for your vector, but it makes a single column (4 rows) of it, while you would need a single row (the transposed version of it) for push_back:

mat.push_back(Mat(v2).t());

fail case 1:

vector<vector<uchar>> v1 = { { 5, 77, 0, 4 },{ 2, 3, 9, 6 } };
mat.push_back(v1);

yes, you can have a vector<T> here, but not a vector<vector<T>>

fail case 2:

vector<uchar> v2 = { 2, 3, 9, 6 };
mat.push_back(v2);

there is a conversion operator to Mat for your vector, but it makes a single column (4 rows) of it, while you would need a single row (the transposed version of it) for push_back:

mat.push_back(Mat(v2).t());

fail case 1:

vector<vector<uchar>> v1 = { { 5, 77, 0, 4 },{ 2, 3, 9, 6 } };
mat.push_back(v1);

yes, you can have a vector<T> here, but not a vector<vector<T>>

(there needs to be a defined DataType for everything, that can be in a Mat)

fail case 2:

vector<uchar> v2 = { 2, 3, 9, 6 };
mat.push_back(v2);

there is a conversion operator to Mat for your vector, but it makes a single column (4 rows) of it, while you would need a single row (the transposed version of it) for push_back:

// clumsy, but works:
mat.push_back(Mat(v2).t());

fail case 1:

// will never  work
vector<vector<uchar>> v1 = { { 5, 77, 0, 4 },{ 2, 3, 9, 6 } };
mat.push_back(v1);

yes, you can have a vector<T> here, but not a vector<vector<T>>

(there needs to be a defined DataType for everything, that can be in a Mat)