OpenCV|Qt OpenCV imread 中文路径

xiaoxiao2021-02-27  440

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);  //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);  //>0 Return a 3-channel color image         file.close();   }  

解决办法2:

QString strPath = 中文路径地址 std::string path = strPath.toLocal8Bit().toStdString(); //关键是这个 cv::Mat image = cv::imread(path,1 ); //成功了
转载请注明原文地址: https://www.6miu.com/read-2953.html

最新回复(0)