pro文件
QT += core
QT -= gui
TARGET = untitled111CONFIG += consoleCONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:Program Files (x86)opencvuildinclude
C:Program Files (x86)opencvuildincludeopencv
C:Program Files (x86)opencvuildincludeopencv2
源文件
#include <opencv2/opencv.hpp> //显示找不到文件
using namespace cv;
int main()
{
Mat img = imread("D:untitled2.jpg");
if(img.empty())
{ fprintf(stderr,"Error: load image failed."); return -1; }
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", img);
waitKey();
return 0;
}
原因:Windows的路径都要用双引号包起来,有空格的路径里,空格会截断路径,会将空格前后拆分为两个路径,涉及有空格的路径要用双引号包装。