[C++, OpenCV] Wczytanie std::string do klasy cv::Mat
Ostatnio zmodyfikowano 2013-12-23 00:40
roserek Temat założony przez niniejszego użytkownika |
[C++, OpenCV] Wczytanie std::string do klasy cv::Mat » 2013-12-13 15:12:54 Witam. Mam histogram w stringu i chcę go przekazać do zmiennej Mat. Jak to można zrobić ?? |
|
MrPoxipol |
» 2013-12-17 19:22:48 |
|
DejaVu |
» 2013-12-23 00:40:04 Podsumowując, z powyższego linka chodzi o posta: OpenCV Mat has a constructor from vector<byte>, but this is not so intuitive. You need to convert from string to vector this way first:[
std::vector < byte > vectordata( data.begin(), data.end() );
Then you can create a cv::Mat from the vector:
cv::Mat data_mat( vectordata, true );
You also need to decode the image (check documentation for which types are allowed, png, jpg, depending on the OpenCV version)
cv::Mat image( cv::imdecode( data_mat, 1 ) );
Now you can check if the resulting size of the image is the same as the one you sent:
cout << "Height: " << image.rows << " Width: " << image.cols << endl;
|
|
|
« 1 » |