提前安装GTK库,不然不能用imshow这些显示的功能。
sudo apt install libgtk2.0-dev
# git clone https://github.com/opencv/opencv.git
# git clone https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=/home/xp/3rd_party/opencv_contrib-4.6.0/modules \
..
make -j$(nproc)
sudo make install
如果出现
Gtk-Message: 17:32:19.416: Failed to load module “canberra-gtk-module”
则
sudo apt-get install libcanberra-gtk-module