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

标签: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

2.下载OpenCV安装包并解压

OpenCV安装包下载

unzip opencv-3.2.0.zip

3.安装

cd /opencv-3.2.0
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

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()

2)在终端运行test.py

python test.py

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

参考资料

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

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐