zoukankan      html  css  js  c++  java
  • UBUNTU 下安装opencv

    form step 1 to step 7 you can reference to http://docs.opencv.org/2.4.13/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation

    the installation guide is in the opencv online documentation which is very clear, choose which version of opencv you need, and find the installation guide from introduction documentation.

    1.从opencv官网下载源代码。

    2.解压到任意文件夹

    tar zxvf opencv..

    3. 进入源码目录,创建release目录

    cd opencv[Tab]
    mkdir release

    4.事先安装下列软件:

    sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev

    5.

    cd release

    6.cmake编译OpenCV源码,安装所有的lib文件都会被安装到/usr/local目录下 /*也可以安装在 /usr/local/opencv/目录下*/

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

     /*注意,后面有两个" .. "*/

    7.

    sudo make install  

    8. 配置library 

    sudo gedit /etc/ld.so.conf.d/opencv.conf

    添加:

      /usr/local/lib   /*或者/usr/local/lib/opencv,总之要与安装路径对应起来*/

    9. update config

    sudo ldconfig
    

     10. add these two lines to "~/.bashrc":

    export PKG_CONFIG_PATH="/usr/local/opencv/lib/pkgconfig:$PKG_CONFIG_PATH"

    PKG_CONFIG_PATH is the path to opencv.pc, export the path to your system  

    so that ervery time you boot your computer it will know where the opcncv.pc is.

    11. make the path valid:

    sudo source ~/.bashrc

    12. 测试,在某个目录下建立一个DisplayImage.cpp文件

     1 #include <cv.h>
     2 #include <highgui.h>
     3 
     4 using namespace cv;
     5 
     6 int main(int argc, char* argv[])
     7 {
     8     Mat image;
     9     image = imread(argv[1], 1);
    10 
    11     if (argc != 2 || !image.data) 
    12     {
    13         printf("No image data
    ");
    14         return -1;
    15     }
    16 
    17     namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
    18     imshow("Display Image", image);
    19     waitKey(0);
    20     return 0;
    21 }

    13. 编译:

      g++ DisplayImage.cpp -o DisplayImage `pkg-config opencv --cflags --libs`

    14. 运行:

      ./DisplayImage lena.jpg

  • 相关阅读:
    Intel x86
    FPGA自计数六位共阳极数码管动态显示2(调用task的方法)
    FPGA六位共阳极数码管动态显示
    运算放大器是模拟电路的基石,模拟电路设计
    这样讲你就懂了!大牛给你介绍《信号与系统》
    电容计算公式
    fork...join的用法
    芯片电源管脚的去耦电容究竟要用多大的?
    Blog Contents
    linux grep 命令常见用法
  • 原文地址:https://www.cnblogs.com/yongjiuzhizhen/p/3439541.html
Copyright © 2011-2022 走看看