• 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

  • 相关阅读:
    Urlrewrite 配置信息写在另外的文件
    maven项目动态替换配置中的值
    搭建一个java博客
    那个不嫌弃你穷的姑娘,如果有一天真的离开了你,那只是因为,你把她弄哭了。
    常规工作流模型
    浅谈https(创建、传输、断开)
    日志相关杂
    主键生成
    自动化部署脚本(windows上传到linux)
    简述IO
  • 原文地址:https://www.cnblogs.com/cxxszz/p/7338909.html
Copyright © 2020-2023  润新知