opencv-3.4在ubuntu16安装

http://www.python36.com/how-to-install-opencv340-on-ubuntu1604/


Step #1:stepUpdate and Upgrade and Cleanup (Required for error-free installation)

$ sudo apt-get update
$ sudo apt-get upgrade




Step #2:Install Dependencies
$ 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 libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev


$ sudo apt-get install libgtk-3-dev


$ sudo apt-get install libatlas-base-dev gfortran pylint
(*)have new


$ sudo apt-get install python2.7-dev python3.5-dev




Step #2:Download and Build OpenCV
$ wget https://github.com/opencv/opencv/archive/3.4.0.zip -O opencv-3.4.0.zip
$ wget https://github.com/opencv/opencv_contrib/archive/3.4.0.zip -O opencv_contrib-3.4.0.zip
$ sudo apt-get install unzip
$ unzip opencv-3.4.0.zip
$ unzip opencv_contrib-3.4.0.zip


$ cd  opencv-3.4.0
$ mkdir build
$ cd build


$ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.0/modules -DOPENCV_ENABLE_NONFREE=True ..


$ make -j4 (where 4 is number of cores)


$ sudo make install


$ sudo ldconfig


Check if the OpenCV file exists


python2
“/usr/local/lib/python2.7/dist-packages/cv2.so”
python3.5
“/usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-x86_64-linux-gnu.so”
python3.6
“/usr/local/lib/python3.6/dist-packages/cv2.cpython-36m-x86_64-linux-gnu.so”
To use OpenCV 3.4.0 in virtual environment like virtualenv, conda or any other, copy related .so file in your virtual environment python directory


“lib/site-packages/”
Finally, check OpenCV version. Go to the terminal and typepython
On the python terminal, type


import cv2
cv2.__version__


If you ran into any problem while installing OpenCV or have any query related to OpenCV then feel free to comment below. I will try my best to solve it.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值