- OpenCV4.6.0
注意opencv的版本和opencv_contrib的版本需要一致,反正我编译opencv-4.6.0和opencv_contrib_4.x不成功。
提前安装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