CLion使用OpenCV(Ubuntu 18.04)

项目结构:

CLion使用OpenCV(Ubuntu 18.04)_第1张图片

设置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
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行两行代码。

效果如下图所示:

CLion使用OpenCV(Ubuntu 18.04)_第2张图片

 

转载于:https://www.cnblogs.com/fuzhihong0917/p/10241325.html

你可能感兴趣的:(CLion使用OpenCV(Ubuntu 18.04))