美文网首页深度学习-推荐系统-CV-NLP
Ubuntu16.04快速安装OpenCV 2.4

Ubuntu16.04快速安装OpenCV 2.4

作者: CristinaXu | 来源:发表于2017-04-27 10:10 被阅读0次

已安装

-Python 2.7

-Numpy

安装OpenCV

之前使用很受欢迎的GITHUB脚本安装OpenCV (https://github.com/jayrambhia/Install-OpenCV), 但是发现问题比较多。

StackOverflow上的回答是,一些文件已经过期。

所以我照着高票答案的命令安装,过程意外的顺利,除了下载会花一些时间

sudo apt-get install build-essential make cmake git libgtk2.0-dev pkg-config python python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev

cd ~/Downloads

git clone https://github.com/itseez/opencv

mv opencv /opt

cd /opt/opencv

git checkout 2.4.10.1 #or whatever version you want

sudo mkdir build

cd build

sudo cmake -j4 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

sudo make -j4

sudo make -j4 install

sudo ldconfig


安装完成后,做安装测试。

直接做摄像头的实例(原文:#http://blog.csdn.net/huanglu_thu13/article/details/52337013):

import cv2

import numpy as np

cap = cv2.VideoCapture(0)

while(1):

# get a frame

ret, frame = cap.read()

# show a frame

cv2.imshow("capture", frame)

if cv2.waitKey(1) & 0xFF == ord('q'):

break

cap.release()

cv2.destroyAllWindows()

这样,OpenCV的安装就基本完成了。

相关文章

网友评论

    本文标题:Ubuntu16.04快速安装OpenCV 2.4

    本文链接:https://www.haomeiwen.com/subject/duzizttx.html