当前位置: 代码迷 >> 综合 >> opencv3.3 install in ubuntu
  详细解决方案

opencv3.3 install in ubuntu

热度:102   发布时间:2023-10-12 04:08:05.0

下载opencv :https://opencv.org/opencv-3-3.html


解压: tar -zxvf opencv-3.3.0.tar.gz


将解压文件复制到所需路径: sudo mv opencv-3.3.0 /opencv


进入opencv-3.3.0的目录下新建build文件: cd /opencv/opencv-3.3.0

                                                                                    mkdir build

                                                                                    cd build

                                                                                    cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local  ..

                                                                                    注意:上面cmake 最后一定是 空格+..


                     make -j8


                                                                                    sudo make install


在这里 -DCUDA_NVCC_FLAGS=--Wno-deprecated-gpu-targets用于指定CUDA编译器(nvcc)的编译选项,如果不指定--Wno-deprecated-gpu-targets选项则在编译Caffe时会产生如下编译警告

执行下面命令可消除警告: cmake -DBLAS=Open -DCUDA_NVCC_FLAGS=--Wno-deprecated-gpu-targets ..


注意:如果編譯caffe,可能存在下面的錯誤

OpenCV: error while loading shared libraries: libopencv_core.so.3.2: cannot open shared object file: No such file or directory

##解决方法:

  • 1 打开路径:

    /etc/ld.so.conf.d

  • 2 创建文件:

    OpenCV.conf

    • 或者不创建文件:直接下载OpenCV.conf,将该文件放在第1步的路径下,然后直接进行第四步(注意:OpenCV.conf中的路径一定要是自己opencv的install路径,具体参看步骤3)
  • 3 在OpenCV.conf中写入:

    /usr/local/opencv320/lib

    注:该路径为opencv install之后的路径,一般默认的路径为/usr/local/lib,即lib*.so库文件所在的路径。

  • 4 在终端执行命令:

    sudo ldconfig