ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

这篇具有很好参考价值的文章主要介绍了ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

参考:Ubuntu系统---配置OpenCV 

一、下载和安装依赖包

1、首先更新 apt-get,在安装前最好先更新一下系统,不然有可能会安装失败。在终端输入:

sudo apt-get update
sudo apt-get upgrade

2、接着安装官方给的opencv依赖包,在终端输入:

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get -y install libgstreamer-plugins-base1.0-dev
sudo apt-get -y install libgstreamer1.0-dev
sudo apt-get install libvtk6-dev

OpenCV3.4.x版本+Opencv_contrib+Ubuntu16.04安装记录_YuYunTan的博客-CSDN博客

安装前的必备包

  这些安装不算十分完全,我只安装自己够用就成的某些包。
  安装一些必要的库,还有cmake,git,g++。

sudo apt-get install build-essential 
sudo apt-get install cmake git g++

安装依赖包

  安装一些依赖包。

sudo apt-get install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
sudo apt-get install checkinstall yasm libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libfaac-dev libmp3lame-dev libtheora-dev
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev libavresample-dev x264 v4l-utils

处理图像所需的包

sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev 

处理视频所需包

sudo apt-get install libxvidcore-dev libx264-dev ffmpeg

opencv功能优化

sudo apt-get install libatlas-base-dev gfortran 

部分依赖包

sudo apt-get install libopencv-dev  libqt4-dev qt4-qmake libqglviewer-dev libsuitesparse-dev libcxsparse3.1.4 libcholmod3.0.6 
sudo apt-get install python-dev python-numpy

可选依赖

sudo apt-get install libprotobuf-dev protobuf-compiler
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

3.下载cmake-gui工具和mingw-w64

sudo apt install cmake-qt-gui
sudo apt install mingw-w64

二、下载opencv4.2.0和opencv_contrib-4.2.0源码压缩包 

opencv4.2.0 地址https://github.com/opencv/opencv/tree/4.2.0

opencv_contrib-4.2.0地址https://github.com/opencv/opencv_contrib

首先在终端中输入如下命令来安装依赖包:

sudo apt  install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev  
sudo apt install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev  
sudo apt  install build-essential qt5-default ccache libv4l-dev libavresample-dev  libgphoto2-dev libopenblas-base libopenblas-dev doxygen  openjdk-8-jdk pylint libvtk6-dev

三、配置opencv

1、将opencv4.2.0和opencv_contrib-4.2.0解压(提取),放在一个文件夹opencv-4.2.0下,如下图所示:

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

 2、双击进入解压出来的opencv-4.2.0文件夹,右键打开终端(或者在别处打开终端,通过输入cd opencv-4.2.0进入当前目录下),然后依次输入(不要忘了第三行的最后的空格和两个点):

mkdir build
cd build 

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6​ 

3.然后进行cmake编译,参数可自行调整:

build目录内执行以下命令(注意contrib路径换成自己的):
下面的参数是带cuda和contrib扩展包的:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
 -D CMAKE_INSTALL_PREFIX=/usr/local \
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D INSTALL_C_EXAMPLES=ON \
 -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.2.0/modules \
 -D PYTHON3_EXECUTABLE=/usr/bin/python3 \
 -D PYTHON_EXECUTABLE=/usr/bin/python \
 -D WITH_TBB=ON \
 -D WITH_V4L=ON \
 -D WITH_QT=ON \
 -D WITH_GTK=ON \
 -D WITH_VTK=ON \
 -D WITH_OPENGL=ON \
 -D WITH_OPENMP=ON\
 -D BUILD_EXAMPLES=ON \
 -D WITH_CUDA=ON \
 -D BUILD_TIFF=ON \
 -D ENABLE_PRECOMPILED_HEADERS=OFF\
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D OPENCV_GENERATE_PKGCONFIG=ON \
 -DOPENCV_ENABLE_NONFREE=ON \
 -D CUDA_nppicom_LIBRARY=stdc++ \
 -D CUDA_ARCH_BIN="8.6" ..
  • CUDA_ARCH_BIN一般需要指定,且最好不要把所有版本都编译,如CUDA_ARCH_BIN="3.0 3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5 8.6"
    最好根据上面的说明,查一下当前显卡的型号,以及对应的显卡算力,然后在这里指定一个即可,如3060显卡可以保持 CUDA_ARCH_BIN="8.6"。否则全部编译一遍速度会很慢。

     3060显卡不加这条命令: -D CUDA_ARCH_BIN="8.6" ,会报错如下:

    nvcc fatal   : Unsupported gpu architecture 'compute_30'
    CMake Error at cuda_compile_1_generated_gpu_mat.cu.o.RELEASE.cmake:222 (message):
      Error generating
      /home/cgm/opencv-4.2.0/opencv-4.2.0/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o
    

    原因: 我的3060显卡不支持compute_30的GPU构架

    GPU Compute Capability
    Geforce RTX 3060 8.6

    算力 CUDA GPUs - Compute Capability | NVIDIA Developer

     nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).

    nvcc警告:“compute_35”、“compute_3 7”、“compute_50”、“sm_35”,“sm_37”和“sm_50”体系结构已弃用,可能会在将来的版本中删除(使用-Wno弃用的gpu目标来抑制警告)。

cuda 11已经废弃 compute_30了,所以需要把compute_30给去掉

 ​ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

  •  CMAKE_INSTALL_PREFIX指定了编译好的库的目录,也就是说编译完成的OpenCV库文件会在该目录下
  • OPENCV_GENERATE_PKGCONFIG指定了生成pkgconfig配置文件,这个文件在后续创建OpenCV工程的时会很有用。
  • 如果没有  -D OPENCV_GENERATE_PKGCONFIG=ON ,后面查看配置时会找不到:
$ pkg-config --cflags --libs opencv4

Package opencv4 was not found in the pkg-config search path.

Perhaps you should add the directory containing `opencv4.pc'

to the PKG_CONFIG_PATH environment variable

No package 'opencv4' found
  •   增加 这个命令  -DOPENCV_ENABLE_NONFREE=ON \  是为了不出现下面那这样的结果
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.2.0) /home/cgm/opencv-4.2.0/opencv_contrib-4.2.0/modules/xfeatures2d/src/surf.cpp:1027: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'

“此算法已获得专利,在此配置中被排除在外;”

“设置OPENCV_ENABLE_NONFREE CMake选项并重建库”);

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

3.编译成功

最后会列出其编译后的模块列表。

--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 quality reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab viz xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj java js matlab ovis
--     Applications:                tests perf_tests examples apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     QT:                          YES (ver 5.12.8)
--       QT OpenGL support:         YES (Qt5::OpenGL 5.12.8)
--     GTK+:                        NO
--     OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
--     VTK support:                 YES (ver 7.1.1)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.0.10)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      YES (2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (58.54.100)
--       avformat:                  YES (58.29.100)
--       avutil:                    YES (56.31.100)
--       swscale:                   YES (5.5.100)
--       avresample:                YES (4.0.0)
--     GStreamer:                   YES (1.16.3)
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            TBB (ver 2020.1 interface 11101)
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2019.0.0 Gold [2019.0.0]
--            at:                   /home/cgm/opencv-4.2.0/opencv-4.2.0/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2019.0.0)
--               at:                /home/cgm/opencv-4.2.0/opencv-4.2.0/build/3rdparty/ippicv/ippicv_lnx/iw
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.3.7)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   NVIDIA CUDA:                   YES (ver 11.4, CUFFT CUBLAS)
--     NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         NO
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/cgm/opencv-4.2.0/opencv-4.2.0/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 2:
--     Interpreter:                 /usr/bin/python (ver 2.7.18)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.18)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.5)
--     install path:                lib/python2.7/dist-packages/cv2/python-2.7
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.8.10)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.8.so (ver 3.8.10)
--     numpy:                       /home/cgm/.local/lib/python3.8/site-packages/numpy/core/include (ver 1.23.3)
--     install path:                lib/python3.8/dist-packages/cv2/python-3.8
-- 
--   Python (for build):            /usr/bin/python
--     Pylint:                      /usr/bin/pylint (ver: 3.8.10, checks: 163)
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         /usr/lib/jvm/java-8-openjdk-amd64/include /usr/lib/jvm/java-8-openjdk-amd64/include/linux /usr/lib/jvm/java-8-openjdk-amd64/include
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cgm/opencv-4.2.0/opencv-4.2.0/build

 我们可以发现,我们编译已经成功,可以进行下一步,即make,但是值得注意的是,如果用多核make可能会报错

sudo make -j6

j6表示6核运行,查看自己 CPU 的核数:

# uniq 可以去重连续出现的相同记录
cat /proc/cpuinfo | grep "cpu cores" | uniq

报错:

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

 In file included from /home/cgm/opencv-4.2.0/opencv-4.2.0/modules/python/src2/cv2.cpp:35:
/home/cgm/opencv-4.2.0/opencv-4.2.0/build/modules/python_bindings_generator/pyopencv_generated_include.h:44:10: fatal error: opencv2/viz/types.hpp: 没有那个文件或目录
   44 | #include "opencv2/viz/types.hpp"

原因:仔细分析发现这个文件是 /home/cgm/opencv-4.2.0/opencv-4.2.0/modules/python/src2/cv2.cpp第35行包含了一个头文件 #include "pyopencv_generated_include.h"

然后搜索打开这个头文件 pyopencv_generated_include.h发现第44行就是出错没有找到的那个头文件#include "opencv2/viz/types.hpp"

然后make时在 opencv-4.2.0 里没有找到这个头文件,确实也没有,我搜索后发现这个文件在opencv_contrib-4.2.0里面.

/home/cgm/opencv-4.2.0/opencv_contrib-4.2.0/modules/viz/src
 ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

解决办法: 将/home/cgm/opencv-4.2.0/opencv_contrib-4.2.0/modules/viz/include/opencv2/viz 添加进 /home/cgm/opencv-4.2.0/opencv-4.2.0/modules/python 的 CMakeLists.txt 里面.

include_directories("/home/cgm/opencv-4.2.0/opencv_contrib-4.2.0/modules/viz/include/opencv2/viz")

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

再重新cmake和make..........

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

4.安装

sudo make install

5.安装完成后还要配置环境变量

终端输入或用gedit(替换vim)打开:

sudo gedit /etc/ld.so.conf.d/opencv.conf

在里面添加:

/usr/local/lib

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6保存退出,配置库:这里报错参考 sudo ldconfig报错

sudo ldconfig

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

添加修改环境变量

sudo gedit ~/.bashrc

在末尾添加如下内容

#opencv4.2.0环境变量
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

保存退出,最后source一下,让更改立即生效:

source ~/.bashrc

因为,对于OpenCV4以上的版本要使用OpenCV4才能正确查询到其版本,库以及头文件目录的值。具体命令如下所示:

pkg-config --modversion opencv4
pkg-config --cflags opencv4
pkg-config --libs   opencv4

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

注意:opencv4以上才是pkg-config --cflags --libs opencv4,之前版本是pkg-config --cflags --libs opencv

四.运行测试

我安装这个的目的暂时是为了运行 SIFT,SURE,FREAK特征提取算法.

你们可以去测试自己的.

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

五.2023年3月17日遇到的问题记录

今天运行orb slam2,发现运行不了了

报错:make[2]: *** 没有规则可制作目标“/usr/lib/libOpenNI.so”,由“../lib/libORB_SSLAM2.so" 需求。停止。

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

解决:

sudo apt-get install libopenni-dev libopenni2-dev 

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

 在编译时Cmake警告:

CMake Warning at CMakeLists.txt:123 (add_executable):
  Cannot generate a safe runtime search path for target mono_euroc because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libopencv_stitching.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_aruco.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_bgsegm.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_bioinspired.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_ccalib.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_dnn_objdetect.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_dnn_superres.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_dpm.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_highgui.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_face.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_freetype.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_fuzzy.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_hdf.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_hfs.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_img_hash.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_line_descriptor.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_quality.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_reg.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_rgbd.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_saliency.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_shape.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_stereo.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_structured_light.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_phase_unwrapping.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_superres.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_optflow.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_surface_matching.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_tracking.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_datasets.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_plot.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_text.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_dnn.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_ml.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_videostab.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_videoio.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_viz.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_ximgproc.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_video.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_xobjdetect.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_imgcodecs.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_objdetect.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_calib3d.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_features2d.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_flann.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_xphoto.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_photo.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_imgproc.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libopencv_core.so.4.2] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

CMakeLists.txt里是这样的

find_package(OpenCV QUIET)
if(NOT OpenCV_FOUND)
   find_package(OpenCV 2.4.3 QUIET)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
   endif()
endif()

增加一些message命令查看OpenCV的信息

# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")  
message(STATUS "    config: ${OpenCV_DIR}")  
message(STATUS "    version: ${OpenCV_VERSION}")  
message(STATUS "    libraries: ${OpenCV_LIBS}")  
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

 OpenCV_DIR /usr/lib/x86_64-linux-gnu/cmake/opencv4,并且有警告信息

解决:

设置OpenCV_DIR的路径,重新编译运行./build.sh

SET(OpenCV_DIR /usr/local/lib/cmake/opencv4/)   # 设置OpenCV_DIR
SET(OpenCV_DIR /usr/local/lib/cmake/opencv4/)   # 设置OpenCV_DIR
find_package(OpenCV QUIET)
if(NOT OpenCV_FOUND)
   find_package(OpenCV 2.4.3 QUIET)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
   endif()
endif()

# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS "    config: ${OpenCV_DIR}")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

 

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6 

ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6

 

TO BE CONTINUED...文章来源地址https://www.toymoban.com/news/detail-429250.html

到了这里,关于ubuntu20.0.4安装opencv4.2.0和opencv_contrib-4.2.0并支持CUDA,Geforce RTX 3060显卡,算力8.6的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ubuntu18.04系统安装opencv及opencv_contrib

    这篇文章博主是正在学习的过程中总结的,有什么问题请各位提出,便于博主改正。 博主使用的 ubuntu 系统是 18.04 , opencv 和 opencv_contrib 均是 4.6.0 版本的,使用 Qt 编写使用opencv的程序。 安装任意版本都是通用的,如果有问题,欢迎各位提出修改建议。 1.opencv安装包 下载地

    2024年02月04日
    浏览(61)
  • ubuntu安装opencv_contrib扩展库,附踩坑+测试

    博主昨晚需要用到OpenCV的SURF接口,但是发现无法调用,因为没有头文件。于是查阅了下资料,发现这些库已经被美国买下专利,成为付费库,都在opencv_contrib中。如果你已经安装了OpenCV,或者还没有安装OpenCV,都可以跟随本教程安装好opencv_contrib。 如果还没有安装过OpenCV,可

    2023年04月13日
    浏览(47)
  • Ubuntu18.04,opencv-4.3.0和opencv_contrib-4.3.0安装(填坑)

    如果觉得本篇文章对您的学习起到帮助作用,请 点赞 + 关注 + 评论 ,留下您的足迹💪💪💪 本文主要Ubuntu18.04安装opencv-4.3.0和opencv_contrib-4.3.0,坑巨多,因此记录以备日后查看,同时,如果能够帮助到更多人,也不胜荣幸。 本文所使用安装包,百度网盘: 链接:https://pan.

    2024年02月12日
    浏览(75)
  • 如何安装 OpenCV 和 OpenCV_contrib

    首先,从opencv官网下载opencv3.4.0以及opencv_contrib压缩包: https://opencv.org/releases/ 在页面下找到3.4.0版本并下载Sources压缩包 opencv_contrib下载网址 https://github.com/opencv/opencv_contrib

    2024年02月16日
    浏览(45)
  • ubuntu20.04安装opencv4.7

    执行以下命令安装最新的cmake https://opencv.org/releases/ 1. 将下载的文件【opencv-4.7.0.zip】解压到需要安装的目录,解压后会得到【opencv-4.7.0】文件夹。 2. 打开【opencv-4.7.0】文件夹,并新建build文件夹。 (我是装在/home/user_name/app目录下,其中user_name是我的用户名) 打开刚才新建的

    2024年02月02日
    浏览(66)
  • ubuntu20.04安装opencv4库

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 opencv官方网站:https://opencv.org/releases/ 终端输入: 在最下面添加: 若显示如下,则成功安装。 上述步骤运行无误后,基本完成了 opencv 4 的安装,接下来使用以下命令验证: 问题解析: 未安装apache an

    2024年02月21日
    浏览(57)
  • Opencv+Visual studio +cmake配置+Opencv_contrib库安装(详细级)

    目的:安装Opencv, Opencv_contrib库,配置Visual studio,用cmake编译配置 这里我选择下载Visual studio2022版本的:官网下载 选择社区版Community下载(社区版Community是对个人免费的,一共有三个版本),这里下载的是.exe 可执行文件 ,比较小,大约1.57M 启动安装 ,配置工作负荷(按照自

    2024年02月15日
    浏览(61)
  • opencv_contrib扩展模块的安装(CMake编译器)及解决文件下载失败的问题(超详细)

    上篇文章介绍了Windows 10 64位系统下 Visual Studio 2015+OpenCV4.1.0下载安装及环境配置, Visual Studio 2015+OpenCV4.1.0 下载安装及环境配置_专注专心的博客-CSDN博客 本篇文章继续介绍,opencv_contrib扩展模块的安装(CMake编译器),并详细说明了“ffmpeg”、 “ippicv”、“data”、“xfeatures2d”等

    2024年02月14日
    浏览(92)
  • OpenCV_contrib配置教程(详细版)

    个人笔记: 操作系统:Windows 10或Windows 11 软件:Visual Studio 2017、OpenCV4.5.1、OpenCV_contrib4.5.1扩展库、Cmake3.19.3. 个人用到是vs2017,这里vs版本也可以用2015,2019,等,自己尝试即可。 注意:OpenCV基础库和contrib扩展库的版本一定要一致!!! 1:OpenCV4.5.1、OpenCV_contrib4.5.1扩展库下载

    2024年02月09日
    浏览(50)
  • RK3588移植opencv(包含opencv_contrib)过程

    后面给大家准备了我自己编译好的(百度云链接),如果有用,麻烦点个赞!!! PC端:Ubuntu 16.04  opencv 版本: 3.4.13 编译器:aarch64-linux-gnu 工具:cmake opencv-3.4.13 http://链接:https://pan.baidu.com/s/1YBohe41YuOhBZ2iCIupmLA 提取码:0012 --来自百度网盘超级会员V4的分享 opencv_contrib-3.4.

    2024年02月16日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包