Mat to vector [closed]
I am trying to copy elements from a Mat to a vector. I tried the below method, but the vector has weird values which I am sure are actually the memory values.
vector<int> vec;
Mat v = preds[n];
vec.assign(v.begin<int>(), v.end<int>());
//cout<<v<<"\n";
cout<<vec[k]<<"\n";
I also tried at but that doesn't return anything.
what does
v.type()
return ? you have to use the correct type for those iterators. (and, ofc., the vector)It returns 5
you can try :
@teevan95 -- 5 means
float
, not int (which would have been 4)so you have to change all the types from
int
tofloat