编辑对应的源文件即可;
sudo vim /etc/pacman.conf文件末尾添加以下两行:
[archlinuxcn] Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch之后运行:
pacman -S archlinuxcn-keyring pacman -Syu执行命令:
pacman -S opencv hdf5 vtk如果在这里发现了你的libIlmImf库找不到,建议再次执行之前的步骤;
运行结果:main.cpp对应的内容为:
#include <iostream> #include <opencv4/opencv2/opencv.hpp> #include <opencv4/opencv2/highgui.hpp> #include <opencv4/opencv2/core.hpp> #include <opencv2/core.hpp> using namespace cv; using namespace std; int main() { string filename = "/home/liushuai/cpp_branch/logo.jpeg"; Mat img = imread(filename); auto size = img.size(); int w = size.width; int h = size.height; Mat re_image; resize(img,re_image,Size(w/2, h/2)); while(true) { imshow(filename,re_image); int k = waitKey(0); if(k == 27){ break; } } destroyAllWindows(); }对应的CMakeLists.txt 内容为:
project(test) find_package(OpenCV REQUIRED) LINK_DIRECTORIES( /usr/lib) add_executable(test main.cpp) target_link_libraries(test ${OpenCV_LIBS} -lIlmImf )