0

I want to put the data from a cv:Mat into a normal C++ vector. I know that I can reshape the cv::Mat into a vector with mat.reshape ( 0, 1 )

How can put the data into a vector?

Aurelius
  • 11,111
  • 3
  • 52
  • 69
501 - not implemented
  • 2,638
  • 4
  • 39
  • 74
  • possible duplicate of [Converting a row of cv::Mat to std::vector](http://stackoverflow.com/questions/9790124/converting-a-row-of-cvmat-to-stdvector) – Aurelius Jul 24 '13 at 22:36

1 Answers1

4

cv::Mat has a conversion operator to std::vector, provided the vector has the proper data type.

cv::Mat m = cv::Mat::eye(3, 3, CV_8UC1);
std::vector<uchar> v = m.reshape(0, 1);
Aurelius
  • 11,111
  • 3
  • 52
  • 69