简体   繁体   中英

Converting a cv::Mat into a vector<int>

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 ?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM