CLion使用OpenCV(Ubuntu 18.04)

项目结构:

设置CMainLists.txt文件中的内容:

cmake_minimum_required(VERSION 3.13)
project(cv_test)

set(CMAKE_CXX_STANDARD 17)


find_package(OpenCV REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(cv_test ${SOURCE_FILES})
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(cv_test ${OpenCV_LIBS})

测试代码:

#include<opencv2/opencv.hpp>
using namespace cv;

int main() {
    Mat image = imread("/home/fuzhihong/Pictures/Wallpapers/mbuntu-1.jpg");
    namedWindow("Display frame", WINDOW_NORMAL);
    cv::resizeWindow("Display frame", image.cols, image.rows);
    imshow("Display frame", image);
    waitKey(0);
    return 0;
}

因为要显示分辨率大于屏幕分辨率的图片,多了第6行和第7行两行代码。

效果如下图所示:

 

posted @ 2019-01-08 20:41 fuzhihong0917 阅读(...) 评论(...) 编辑 收藏