简体   繁体   English

将cv :: Mat转换为向量<int>

[英]Converting a cv::Mat into a vector<int>

I want to put the data from a cv:Mat into a normal C++ vector . 我想将cv:Mat的数据放入普通的C ++ vector I know that I can reshape the cv::Mat into a vector with mat.reshape ( 0, 1 ) 我知道我可以将cv::Mat重塑为具有mat.reshape ( 0, 1 )的向量

How can put the data into a vector ? 如何将数据放入vector

cv::Mat has a conversion operator to std::vector , provided the vector has the proper data type. cv::Mat可以将转换操作符转换为std::vector ,前提是该向量具有正确的数据类型。

cv::Mat m = cv::Mat::eye(3, 3, CV_8UC1);
std::vector<uchar> v = m.reshape(0, 1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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