Ubuntu中Qt+opencv图像显示

先抛出一个疑问,知道的希望留言解答下

(创建Application->Qt Console Application,代码与下面2、3一样,运行有时会显示图片,但大多数不显示,为什么?)

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;
}

posted @ 2016-12-05 17:46  夕西行  阅读(2568)  评论(0编辑  收藏  举报