c++ 代码:
#include "opencv2/opencv.hpp"
using namespace cv;
int main()
{
Mat src;
src = imread("../1.jpg");
imshow("img_text",src);
waitKey(6000);
return 0;
}
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project( test1 )
set(OpenCV_DIR ~/app/opencv-4.3.0/build)
find_package(OpenCV REQUIRED)
message(status ${OpenCV_INCLUCE_DIRS})
message(status ${OpenCV_LIBS})
include_directories(${OpenCV_INCLUCE_DIRS})
add_executable( test1 main.cpp )
target_link_libraries( test1 ${OpenCV_LIBS} )
执行命令编译:
make build & cd build
cmake .. && make
运行:
./test
|