热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linux(Ubuntu18.04)中安装OpenCV+OpenCV_Contrib

从github中down下OPenCV+OpenCV_Contrib库,可以从https:github.comopencv上下载(注意版本对应)cd~

从github中down下OPenCV + OpenCV_Contrib库,可以从https://github.com/opencv上下载(注意版本对应)

cd ~/
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

将opencv_contrib目录移到opencv目录下

添加opencv所需要的依赖库:


Required Packages



  • GCC 4.4.x or later

  • CMake 2.8.7 or higher

  • Git

  • GTK+2.x or higher, including headers (libgtk2.0-dev)

  • pkg-config

  • Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)

  • ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev(一些开发用视频解码)

  • [optional] libtbb2 libtbb-dev

  • [optional] libdc1394 2.x

  • [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev

  • [optional] CUDA Toolkit 6.5 or higher

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 install libjaster-dev

出现:errorE: unable to locate libjasper-dev时,执行

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

 

进入opencv文件夹,打开terminal

mkdir build
cd build

cmake编译(后面的两个点不能丢)

cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..

make -j8

python
import cv2

如果出现"No module named cv2",请执行

sudo apt-get install python-opencv

 



推荐阅读
author-avatar
RvJ手机用户2997047695f
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有