1 | initial version |
In any case you can try the following:
//create Mat from vector vector<uchar> vec; // vector with your data int rows = 3; int cols = 4;
if(vec.size() == rowscols) // check that the rows and cols match the size of your vector { Mat m = Mat(rows, cols, CV_8UC1); // initialize matrix of uchar of 1-channel where you will store vec data //copy vector to mat memcpy(m.data, vec.data(), vec.size()sizeof(uchar)); // change uchar to any type of data values that you want to use instead }
the above code should do the trick.
2 | No.2 Revision |
In any case you can try the following:
//create Mat from vector
vector<uchar> vec; // vector with your data
int rows = 3;
int cols = the above code should do the trick.