先抛出一个疑问,知道的希望留言解答下
(创建Application->Qt Console Application,main.cpp与下面main.cpp相同代码,*.pro中在已有代码后加入相同的代码,已有代码不改动,运行有时会显示图片,但大多数不显示)
1、打开qt->创建工程->Non-Qi Project->Plain C++ Applicaton->完成
2、在.pro文件中加入如下
INCLUDEPATH += /usr/local/include/opencv/
/usr/local/include/opencv2/
/usr/local/include
LIBS += -lopencv_core\
-lopencv_imgproc\
-lopencv_highgui\
-lopencv_ml\
-lopencv_video\
-lopencv_features2d\
-lopencv_calib3d\
-lopencv_objdetect\
-lopencv_contrib\
-lopencv_legacy\
-lopencv_flann
3、.cpp中代码如下
#include<opencv2/opencv.hpp>
using namespace cv;
int main()
{
Mat I=imread("/home/jv/桌面/lena.png"); //桌面上放lena.png图片
namedWindow("1");
imshow("1",I);
waitKey(0);
return 0;
}
时间: 2024-10-14 20:26:55