pro文件
QT += core
QT -= gui
TARGET = untitled111CONFIG += consoleCONFIG -= app_bundle
TEMPLATE = app

SOURCES += main.cpp
INCLUDEPATH += C:\Program Files (x86)\opencv\build\include\
C:\Program Files (x86)\opencv\build\include\opencv\
C:\Program Files (x86)\opencv\build\include\opencv2

 

源文件
#include <opencv2/opencv.hpp>  //显示找不到文件
using namespace cv;
int main()
{
Mat img = imread("D:\untitled\2.jpg");
if(img.empty())
{ fprintf(stderr,"Error: load image failed."); return -1; }
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", img);
waitKey();
return 0;
}

 

 

 

原因:Windows的路径都要用双引号包起来,有空格的路径里,空格会截断路径,会将空格前后拆分为两个路径,涉及有空格的路径要用双引号包装。

相关文章:

  • 2021-05-31
  • 2022-12-23
  • 2021-07-14
  • 2021-08-20
  • 2022-01-15
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2021-04-08
  • 2021-04-07
  • 2021-05-01
  • 2021-08-30
  • 2021-04-17
相关资源
相似解决方案