Ubuntu 14.04下OpenCV 3.0+Python 2.7安装测试

Ubuntu16.04+python2.7搭建opencv3.2.0 在安装opencv3.2.0的过程中,我遇到了好多坑,特此记录一下。建议安装了Anaconda的朋友们找一找网上的方法,直接利用它进行安装,可以避免很多坑。 下面结合参考的网上的教程,说一说我的安装过程和解决办法。 一、准备工作 提前下载好三个文件,https://github.com/hanxuan123/opencv3.2/tree/master/all,这里给出网上分享的一... 阅读详情

本文记录了Ubuntu 14.04下使用源码手动安装OpenCV 3.0的过程。此外记录了在Python中安装及载入OpenCV的方法。

1、安装OpenCV所需的库(编译器、必须库、可选库)

  • GCC 4.4.x or later
  • CMake 2.6 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

[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

2、从官网下载最新opencv源码(2.4以上)http://sourceforge.net/projects/opencvlibrary/

或者github

3、编译opencv

将opencv放至任意目录,解压

  unzip opencv-3.0.0-rc1.zip

创建编译目录,编译

cd ~/opencv-3.0.0-rc1
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

4、测试opencv

1) 创建工作目录

mkdir ~/opencv-lena
cd ~/opencv-lena
gedit DisplayImage.cpp

2) 编辑如下代码

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{
    if ( argc != 2 )
    {
        printf("usage: DisplayImage.out <Image_Path>\n");
        return -1;
    }

    Mat image;
    image = imread( argv[1], 1 );

    if ( !image.data )
    {
        printf("No image data \n");
        return -1;
    }
    namedWindow("Display Image", WINDOW_AUTOSIZE );
    imshow("Display Image", image);

    waitKey(0);

    return 0;
}

3) 创建CMake编译文件

gedit CMakeLists.txt

写入如下内容

cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )

4) 编译

cd ~/opencv-lena
cmake .
make

5) 执行

此时opencv-lena文件夹中已经产生了可执行文件DisplayImage,下载lena.jpg放在opencv-lena下,运行

./DisplayImage lena.jpg

6) 结果

5、安装python-opencv

可直接使用apt安装

sudo apt-get install python-opencv
sudo apt-get install python-numpy

测试:

打开python,import cv模块成功即可。

import cv

--------------------------------------分割线 --------------------------------------

Ubuntu Linux下安装OpenCV2.4.1所需包 http://www.linuxidc.com/Linux/2012-08/68184.htm

Ubuntu 12.04 安装 OpenCV2.4.2 http://www.linuxidc.com/Linux/2012-09/70158.htm

CentOS下OpenCV无法读取视频文件 http://www.linuxidc.com/Linux/2011-07/39295.htm

Ubuntu 12.04下安装OpenCV 2.4.5总结 http://www.linuxidc.com/Linux/2013-06/86704.htm

Ubuntu 10.04中安装OpenCv2.1九步曲 http://www.linuxidc.com/Linux/2010-09/28678.htm

基于QT和OpenCV的人脸识别系统 http://www.linuxidc.com/Linux/2011-11/47806.htm

[翻译]Ubuntu 14.04, 13.10 下安装 OpenCV 2.4.9  http://www.linuxidc.com/Linux/2014-12/110045.htm

--------------------------------------分割线 --------------------------------------

OpenCV的详细介绍:请点这里
OpenCV的下载地址:请点这里

Ubuntu14.04 64位+Python3.4环境下安装opencv3.0的方法 折腾了估计得有1个星期,终于把opencv安装好了。     安装的过程主要是参考了这篇文章:https://github.com/rainyear/lolita/issues/18    但是实际安装过程中,还是出现了错误,主要是编译opencv的时候,我选择了用 make -j4 这个命令来编译,这个命令是允许用4个cpu做并行编译处理,但实际上由于我的Ubuntu只有一个cpu,因此执行 阅读详情

相关推荐

ubuntu 16.04 配置Python2.7 和 Python3.5 同时调用OpenCV

安装OpenCVOpenCV 官网,下载见 SourceForge and GitHub。若使用官网版本安装不成功,则可试试Github版本。 或者git clone https://github.com/Itseez/opencv.git安装依赖库sudo apt-get -y install libopencv-dev sudo apt-get -y install build-essenti

jiandanjinxin的专栏 7862

OpenCV——基于Python开发的OpenCV安装教程

1 前言 今天在学习R2CNN~ 2 安装步骤 使用pip命令在Anaconda环境中进行安装;(不需要使用源码编译进行安装,网上的教程简直是醉了,一大堆源码编译的教程,把人都弄昏了) 3 验证安装 step 2: 打开终端; step 3: 输入python,进入Python编译环境; step 4: 粘贴以下代码,用来查看当前Python环境中OpenCV的版本号, import cv2 as......

墨门 3万+

Ubuntu18.04安装OpenCV4.1.0

Ubuntu18.04安装OpenCV4.1.0 Ubuntu18.04安装OpenCV4.1.0 1.首先要安装依赖 sudo apt-get install build-essential \ cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale...

Youpeng 5889

ubuntu下Opencv安装步骤,亲测可用

【代码】ubuntu下Opencv安装步骤,亲测可用。

qq_38828688的博客 618

在装有Ubuntu16.04的VMware虚拟机下安装OpenCV3.2.0

引言最近因为学习需要,要在VMware虚拟机下安装OpenCV,在网上查了一下OpenCV3.3.0目前已经出来了,但是考虑到稳定性问题,决定先装一个3.2.0版本的。需要注意的是,pip可以安装的opencv-python安装并不依赖opencv,只是封装了opencv的Python API,一般情况下也够用。但是如果准备安装完整版本的opencv,这里比较建议将opencv-python卸载,以

楼上小宇___home 4641

ubuntu中卸载opencv2,安装opencv3.2.0和contrib组件,并使用python进行开发

ubuntu中卸载opencv2,安装opencv3.2.0和contrib组件,并使用python进行开发

sinat_21258931的博客 5710

openCV-python安装

搭建openCV-python环境

weixin_43737866的博客 9461

OpenCV-Python 安装教程

pip 是 Python 的软件包管理器,我们将使用它来安装 OpenCV-Python。OpenCV-Python 需要依赖于 NumPy 库,因此在安装 OpenCV-Python 之前,我们需要先安装 NumPy。至此,您已经成功安装并配置了 OpenCV-Python。如果您看到 pip 的版本信息,则表示已经安装了 pip。安装完成后,我们可以验证 OpenCV-Python 是否成功安装。现在,我们可以安装 OpenCV-Python 了。按照安装向导的指示完成 Python 的安装过程。

UtiExamples的博客 5021

ubuntu14.04+opencv 3.0+python2.7安装及测试

ubuntu14.04+opencv 3.0+python2.7安装及测试本文记录了ubuntu下使用源码手动安装opencv的过程。步骤来自opencv官网此外记录了在python中安装及载入opencv的方法。1、安装opencv所需的库(编译器、必须库、可选库)转载请说明http://www.cnblogs.com/llxrl/p/4471831.htmlGCC 4.4.x or later...

ZHI11235813的博客 419

使用Python安装OpenCV

大多数情况下,当您安装Python时,pip也会被自动安装。在开始安装OpenCV之前,您需要先安装Python。您可以从Python官方网站(https://www.python.org)下载适合您操作系统的安装程序,并按照安装向导进行安装。OpenCV是一个广泛使用的开源计算机视觉库,它提供了许多用于图像和视频处理的功能。在Python中使用OpenCV,您需要先安装它。现在,您已经成功安装了OpenCV,可以开始使用它来进行图像和视频处理。如果OpenCV成功安装,将打印出OpenCV的版本号。

WELL_CODER的博客 5071

Hi3516CV610开发板ISP调优实战——从在线调试到参数固化部署全流程

本文详细介绍了Hi3516CV610开发板ISP参数从在线调试到固化部署的全流程。针对调试参数重启丢失的痛点,重点解析了如何从PQTools安全导出参数、进行格式转换与适配,并通过烧录工具或系统更新两种路径将参数永久固化至Flash。最后提供了双重验证与常见问题排查方法,确保调优效果在产品中稳定生效。

weixin_29169505的博客 435

ubuntu如何训练测试python_Ubuntu 14.04下OpenCV 3.0+Python 2.7安装测试

本文记录了Ubuntu 14.04下使用源码手动安装OpenCV 3.0的过程。此外记录了在Python中安装及载入OpenCV的方法。1、安装OpenCV所需的库(编译器、必须库、可选库)GCC 4.4.x or laterCMake 2.6 or higherGitGTK+2.x or higher, including headers (libgtk2.0-dev)pkg-configPyt...

weixin_39894104的博客 110

MATLAB PDE工具箱电磁场仿真平行电容板及电偶极子详解

首先打开matlab,在命令行输入pdetool打开PDE工具箱 工具箱的功能我就不赘述了,大概就是以有限元的数值计算方法,计算二阶偏微分方程,因此可以解决电磁场、热力学等问题。 首先点击左上角按钮,画三个矩形 画完一个后可以双击矩形编辑,参数如下: 其中R1表示上极板,R2表示下极板,R3表示整个空间区域。 在上方Set formula为R3-R2-R1,表示求解区域是整个空间区域减去两个极板。下拉框选择Electrostatics表示求解的是静电场问题。 接下来点击上方菜单栏中的这个按钮,表

weixin_42845306的博客 1万+

python2.7安装opencv_ubuntu14.04+opencv 3.0+python2.7安装及测试

本文记录了ubuntu下使用源码手动安装opencv的过程。步骤来自opencv官网此外记录了在python中安装及载入opencv的方法。1、安装opencv所需的库(编译器、必须库、可选库)GCC 4.4.x or laterCMake 2.6 or higherGitGTK+2.x or higher, including headers (libgtk2.0-dev)pkg-configP...

weixin_40005437的博客 265

Nacos2.3.0与vastBase数据库的集成实践指南

本文详细介绍了将Nacos 2.3.0的默认数据库从MySQL迁移至vastBase数据库的完整实践指南。内容涵盖前期环境准备、源码改造、依赖配置、SQL适配、数据库初始化以及最终的编译打包与部署验证,旨在帮助开发者在国产化或特定技术栈场景下,实现微服务配置中心与vastBase数据库的自主可控集成。

plant的博客 281

ABAP 系统里使用 SAP Joule 辅助编程的前提条件

只是说这些大语言模型是针对互联网上能够挖掘到的所有数据进行训练,不像 SAP Joule 那样术业有专攻,仅仅深耕 SAP 技术和业务领域,因此大伙儿对 SAP Joule 的期望值,也远远高于通过大语言模型。SAP Joule 从 ABAP Development Tool 的 Chat 窗口中接收到的对话请求,都会路由到 SAP BTP 上的 AI Foundation.在上述 ABAP 环境中启用 SAP Joule,需要购买额外的 license:8019124.

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 810

ubuntu14.04中tensorflow和caffe的配置

1:python2.7+cuda8.0+cudnn6.0+tensorflow1.4.0 python2.7依赖库安装: sudo pip install imutils sudo apt-get install build-essential python-dev python-numpy python-setuptools python-scipy libatlas-dev libatl...

落叶知秋了哟的博客 294

在ros中进行多传感器融合定位

ROS 中的 robots_localization 包是一个非常有用的包,可以使用各种卡尔曼滤波器融合任意数量的传感器!我们将使用它将全局姿势数据(x、y、z 和orientation)与机器人上的现有传感器融合,以实现更强大的定位!

如果想成为中心,那么就到中心去吧。 3008

OpenCV 4.2.0 + opencv_contrib安装 (ubuntu16.04)

官方发布版本: https://opencv.org/releases/ 官方教程地址: http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/tutorials.html 中文安装教程: ubuntu16.04 下安装openCV 4.2步骤 1、 安装依赖 # ubuntu16.04 默认自带安装 sudo apt-get in...

youlinhuanyan的博客 9959

海康威视iVMS-8700综合安防管理平台 文件读取漏洞复现

HIKVISION iVMS 综合安防管理平台download接口处存在任意文件读取漏洞,攻击者通过构造token绕过身份认证,读取服务器中的目录信息与敏感文件。使系统处于极不安全的状态。

0xSec 3323

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: error LNK1104: cannot open file 'opencv_calib3d300.lib'
下一篇: 利用Eclipse使用Java OpenCV
南山牧笛
博客等级 码龄13年 384粉丝 75原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值