qt creator创建opencv工程

1.创建新工程

qt creator创建opencv工程

qt creator创建opencv工程

qt creator创建opencv工程

qt creator创建opencv工程

qt creator创建opencv工程

附源码

CMakeLists.txt文件

cmake_minimum_required(VERSION 3.9.5)
project(tests)

set(CMAKE_CXX_STANDARD 14)
set(OpenCV_DIR "/home/navy/Desktop/workspace/build")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} "main.cpp")
set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

main.cpp文件

#include<opencv2/opencv.hpp>
#include <iostream>
#include <math.h>

using namespace cv;

int main(){
    Mat src = imread("/home/navy/Desktop/workspace/opencv_extra/testdata/gpu/caltech/image_00000009_0.png",0);
    if(src.empty()){
        printf("load fail\n");
    }
    namedWindow("test");
    imshow("test",src);
    waitKey(0);
    return 0;
}