http://blog.csdn.net/u011430225/article/details/53809494
开发环境: Qt5.7 Creator + OpenCV2.4.9(自己编译的);
问题:imread中文路径无法成功,英文路径就可以。很奇怪
解决办法1:
[cpp]
view plain
copy
cv::Mat image ; QFile file(strFilePath);
if(file.open(QIODevice::ReadOnly )) { QByteArray byteArray = file.readAll(); std::vector<
char> data(byteArray.data(),byteArray.data()+ byteArray.size()); image = cv::imdecode(cv::Mat(data),1); file.close(); }
解决办法2:
QString strPath = 中文路径地址
std::string path = strPath.toLocal8Bit().toStdString(); //关键是这个
cv::Mat image = cv::imread(path,1 ); //成功了