项目结构:
设置CMainLists.txt文件中的内容:
cmake_minimum_required(VERSION 3.13) project(cv_test) ) 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(); ; }
因为要显示分辨率大于屏幕分辨率的图片,多了第6行和第7行两行代码。
效果如下图所示: