Opencv
functions like cv::imread()
take as arguments only strings
. So, if I write:
cv::Mat image = cv::imread("C:\\folder\\image.jpg");
everything is fine and it will load the image. But, if the path contains wide characters (for example greek letters):
wstring path = L"C:\\folder\\εικονα.jpg";
I can't just write:
cv::Mat image = cv::imread( path );
I already tried (and obviously failed) this:
cv::Mat image = cv::imread( string(path.begin(), path.end()) );
Is there any solution? Or I'll just have to leave opencv
and use something else?
The current answer is NO, as discussed in Issue #4292 of the official OpenCV repo.
One possible workaround for now using Boost and a memory mapped file:
mapped_file map(path(L"filename"), ios::in); Mat file(1, numeric_cast<int>(map.size()), CV_8S, const_cast<char*>(map.const_data()), CV_AUTOSTEP); Mat image(imdecode(file, 1));