zoukankan      html  css  js  c++  java
  • c++ opencv 3.3.0 install on ubuntu 16.04

    In Ubuntu 16.04, install the dependencies first

    sudo apt-get install --assume-yes build-essential cmake git
    sudo apt-get install --assume-yes pkg-config unzip ffmpeg qtbase5-dev python-dev python3-dev python-numpy python3-numpy
    sudo apt-get install --assume-yes libopencv-dev libgtk-3-dev libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev
    sudo apt-get install --assume-yes libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
    sudo apt-get install --assume-yes libv4l-dev libtbb-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev
    sudo apt-get install --assume-yes libvorbis-dev libxvidcore-dev v4l-utils python-vtk
    sudo apt-get install --assume-yes liblapacke-dev libopenblas-dev checkinstall
    sudo apt-get install --assume-yes libgdal-dev
    

    Download opencv 3.3.0 from 

    http://opencv.org/releases.html

    Build opencv using cmake

    Unzip opencv-3.3.0 and rename the generated file as opencv

    cd ~/opencv
    mkdir build
    cd build

    Configue

    cmake -D CMAKE_BUILD_TYPE=Release -D WITH_IPP=OFF  -D CMAKE_INSTALL_PREFIX=/usr/local ..
    

     Build

    make -j7 # runs 7 jobs in parallel

    Install

    sudo make install

    ##Note:

    If you want to uninstall opencv-3.3.0, you can simply enter ~/opencv/build and run the command below

    sudo make uninstall

    We can have a try

    mkdir ~/cmk_learning
    gedit main.cpp

    Paste the codes below into main.cpp

    #include <stdio.h>
    #include <opencv2/opencv.hpp>
    #include <unistd.h>
    using namespace cv;
    
    int main(int argc, char** argv )
    {
        if ( argc != 2 )
        {
            printf("usage: DisplayImage.out <Image_Path>
    ");
            return -1;
        }
    
        Mat image;
        image = imread( argv[1], 1 );
    
        if ( !image.data )
        {
            printf("No image data 
    ");
            return -1;
        }
        namedWindow("Display Image", WINDOW_AUTOSIZE );
        imshow("Display Image", image);
    
        waitKey(0);
    
        return 0;
    }

    Create CMakeLists.txt and edit it:

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

    Build this project:

    cd ~/cmk_learning
    cmake .
    make

    After running the commands above, we have an executable file DisplayImage in ~/cmk_learning

    Result

    ./DisplayImage emt.jpg

  • 相关阅读:
    爱她就用python给她画个小心心 ♥(ˆ◡ˆԅ)
    用python画小猪佩奇(非原创)
    (解释文)My SQL中主键为0和主键自排约束的关系
    (细节)My SQL中主键为0和主键自排约束的关系
    My SQL常用操作汇总
    博客搬运同步至腾讯云+社区声明
    mysql在ubuntu中的操作笔记(详)
    vim编辑器操作汇总
    linux常用命令汇总
    在python中单线程,多线程,多进程对CPU的利用率实测以及GIL原理分析
  • 原文地址:https://www.cnblogs.com/cxxszz/p/7338909.html
Copyright © 2011-2022 走看看