ubuntu20.04编译opencv3.4.0记录

更新源:

sudo apt update

安装依赖:

sudo apt-get install build-essential cmake git
sudo apt-get install pkg-config libavcodec-dev libavformat-dev libswscale-dev libatlas-base-dev gfortran zlib1g-dev ccache
#这些可先不安装,后面看是否会报错
sudo apt-get install autoconf automake libtool checkinstall

添加新的源:

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update

安装libjasper(若不添加源会报错找不到libjasper):

sudo apt install libjasper1 libjasper-dev

安装常用图像工具包:

 sudo apt-get install libjpeg-dev libjpeg8-dev libtiff5-dev libjasper-dev libpng-dev

安装视频IO包:

sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

xfeatures2d模块缺失boostdesc_bgm.i文件,下载超时:

修改opencv_contrib下面的modules/xfeatures2d/cmake/download_boostdesc.cmake文件,将下载地址https://raw.githubusercontent.com/opencv/opencv_3rdparty/ 修改为:

https://ghproxy.com//https://raw.githubusercontent.com/opencv/opencv_3rdparty/

vgg文件下载错误同理(即在原地址前加上https://ghproxy.com//)。

然后CMAKE的时候又会报一堆错,一个一个解决:

1、No package ‘libavresample’ found:

sudo apt-get -y install libavresample-dev

2、error:No package ‘libgphoto2’ found:

sudo apt-get -y install libgphoto2-dev

3、No package ‘gtk±3.0’ found,No package ‘gtk±2.0’ found:

sudo apt-get install libgtk-3-dev
apt-get install libgtk2.0-dev

4、-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
– Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
– Could NOT find Atlas (missing: Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY)
– Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
– Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
– Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
– VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file:

apt安装的openblas似乎不行,只能自己下载源码编译,很简单,只需要注意提前安装fortran编译器

sudo apt-get install gfortran

然后去https://github.com/xianyi/OpenBLAS下载下来源码编译安装,但我操作完之后还是有版本问题。

sudo apt install doxygen openjdk-8-jdk libvtk7-dev

5、Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version “2.7”):

cmake编译命令加上新参数不编译python包,不然编译阶段很可能会报错(也可以忽略这个警告,加上参数更保险):

cmake -DBUILD_opencv_python3=OFF DBUILD_opencv_python2=OFF -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../opencv

6、Looking for linux/videodev.h - not found:

忽略

7、Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS)

sudo apt install libhdf5-dev

8、Failed to find gflags:

sudo apt-get install libgflags-dev

9、Failed to find glog:

sudo apt-get install libgoogle-glog-dev

10、The imported target “vtk” references the file “/usr/bin/vtk” but this file does not exist:

sudo ln -s /usr/bin/vtk7 /usr/bin/vtk

11、No package ‘tesseract’ found:

cd ~
git clone https://ghproxy.com//https://github.com/tesseract-ocr/tesseract.git
cd tesseract
./autogen.sh
./configure
make -j4
sudo make install
sudo ldconfig

若报错:CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Tesseract_INCLUDE_DIR

则删除build文件夹下的所有东西重新编译

12、No package ‘gstreamer-base-1.0’ found:

sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

13、No package ‘libdc1394-2’ found:

sudo apt-get install libdc1394-22-dev

14、最后还是剩下了一些问题没有解决,忽略:
[外链图片转存中...(img-PoWTFWTT-1679023588034)]

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值