CLion使用OpenCV(Ubuntu 18.04)
阿新 • • 發佈:2019-01-08
專案結構:
設定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行兩行程式碼。
效果如下圖所示: