当前位置:   article > 正文

OpenCV+Python教程之1-Ubuntu16.04下安装OpenCV教程_ubuntu16.04 python hello opencv !

ubuntu16.04 python hello opencv !

1.安装依赖库

[compiler]sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
  • 1
  • 2
  • 3

标签:sudo apt-get install libgtk2.0-dev出现以下问题:
The following packages have unmet dependencies:
libgtk2.0-dev : Depends: libglib2.0-dev (>= 2.27.3) but it is not going to be installed
Depends: libgdk-pixbuf2.0-dev (>= 2.21.0) but it is not going to be installed
Depends: libpango1.0-dev (>= 1.20) but it is not going to be installed
Depends: libatk1.0-dev (>= 1.29.2) but it is not going to be installed
Depends: libcairo2-dev (>= 1.6.4-6.1) but it is not going to be installed
解决方法[1]:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libgtk2.0-dev
  • 1
  • 2
  • 3

2.下载OpenCV安装包并解压

OpenCV安装包下载

unzip opencv-3.2.0.zip
  • 1

3.安装

cd /opencv-3.2.0
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
  • 1
  • 2
  • 3
  • 4

4.测试

1)test.py文件[2]

# -*- coding: utf-8 -*-
"""
Created on Tue Dec 31 19:16:05 2013

@author: duan
"""
import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('figure_1-1.png',1)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

2)在终端运行test.py

python test.py
  • 1

3)运行结果:
这里写图片描述
4)安装成功!

参考资料

1.Unable to insall libgtk2.0-dev on ubuntu 12.04
2.Getting Started with Images
3.Installation in LinuxUbuntu Ubuntu

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/396767?site
推荐阅读
相关标签
  

闽ICP备14008679号