Ubuntu16.04的Opencv源码安装3.2.0 和 3.0.0-alpha详细安装教程(ubuntu18.04安装opencv)

网友投稿 337 2022-09-07


Ubuntu16.04的Opencv源码安装3.2.0 和 3.0.0-alpha详细安装教程(ubuntu18.04安装opencv)

教程1: Opencv3.0.0-alpha在ubuntu16.04的安装

# step 1 # 安装依赖 (太多了,自己相应替换)sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip --fix-missing# step 2# 下载解包wget opencv-3.0.0-alpha.zip# step 3# 编译cd opencv-3.0.0-alphamkdir buildcd buildcmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..# step 4#安装make sudo make install# step 5# 安装完成,进行整理 sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'sudo ldconfigsudo apt-get update

教程2:

今天重装了Opencv3.20 和Opencv3.2.0conbtrib,将安装日志记录如下:

1. 查询自己的Opencv版本 ​​pkg-config --modversion opencv​​

2. 下载​​Opencv3.2.0 和Opencv contrib3.2.0​​ 对于opencv3.2.0 ​​​对于Opencv3.2.0 contrib

3. 卸载当前的Opencv ,进入安装的build目录,执行 ​​sudo make uninstall​​ ,然后​​cd ..​​ 执行​​rm -rf build​​

4. 清理/usr中所有的opencv相关选项 ​​rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*​​

5. 执行 ​​sudo make -j16​​ 和 ​​sudo make install​​ , 在make的时候我遇到一个问题就是​​fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h​​: ​​No such file or directory #include “LAPACKE_H_PATH-NOTFOUND/lapacke.h​​” 原因:未找到lapacke.h文件 ,只需要​​sudo apt-get install liblapacke-dev checkinstall​​就可以解决继续make了。成功后进行第5步。

6. ​​cd /usr​​

7. ​​find . -name "*opencv*" | xargs sudo rm -rf​​

8. 成功后在终端中打开 /etc/ld.conf.d/opencv.conf 文件,并在最后一行添加 /usr/local/lib,如果没有这个文件那就新建一个。然后打开 /etc/bash.bashrc 文件,在最后一行中添加

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv320/lib/pkgconfigexport PKG_CONFIG_PATH

最后. ​​sudo ldconfig​​生效

备注:最后使用​​pkg-config --modversion opencv​​查询版本如果报错为:

Package opencv was not found in the pkg-config search path.Perhaps you should add the directory containing `opencv.pc'to the PKG_CONFIG_PATH environment variableNo package 'opencv' found

则需要运行下边语句:

sudo cp /usr/local/opencv320/lib/pkgconfig/opencv.pc /usr/lib/pkgconfig


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringBoot:JPA + AuditingEntityListener时区设置方式
下一篇:Python的7大就业方向!小白适合哪个方向?学了Python能干什么?(python就业方向和工作内容)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~