I have a varbinary(BLOB) data as a string (image data)
for example,
std::string ByteStr = "FF-D8-E0-FF-85 ... " ;
I want to convert this string to byte array(or something usefull) then use as cv::Mat
format. I get the string from another method. I tried to convert but i get OpenCV error.
Error I get,
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, >>file ........\opencv\modules\highgui\src\window.cpp
C++ code,
std::string ByteStr = obj->GetBinaryStr(); // this provide varbinary string
std::vector<uchar> vct;
std::string delimiter = "-";
size_t pos = 0;
std::string token;
while ((pos = ByteStr.find(delimiter)) != std::string::npos) {
token = ByteStr.substr(0, pos);
vct.push_back((uchar)(token.c_str()));
ByteStr.erase(0, pos + delimiter.length());
}
cv::Mat img = cv::imdecode(vct,CV_BGR2GRAY );
cv::namedWindow("MyWindow");
cv::imshow("MyWindow",img);
How can i convert this string to cv::Mat
format. Any advice?
Thanks in advance