CentOS7安装opencv

  1. 安装前的准备

    yum -y install git
    yum -y install gcc
    yum -y install numpy
    yum -y install gcc-c++
    yum -y install tbb-devel
    yum -y install gtk2-devel
    yum -y install epel-release
    yum -y install eigen3-devel
    yum -y install libv4l-devel
    yum -y install libpng-devel
    yum -y install jasper-devel
    yum -y install openexr-devel
    yum -y install libwebp-devel
    yum -y install libtiff-devel 
    yum -y install libdc1394-devel
    yum -y install qt5-qtbase-devel
    yum -y install libjpeg-turbo-devel
    yum -y install boost boost-thread boost-devel
    yum -y install boost boost-thread boost-devel
    yum -y install python python-devel python-pip
    yum -y install python34 python34-devel python34-pip python34-numpyx
    yum -y install freeglut-devel mesa-libGL mesa-libGL-devel
    rpm                 --import     https://note.so1234.top/network/opencv/RPM-GPG-KEY-nux.ro
    rpm                 -Uvh         https://note.so1234.top/network/opencv/nux-dextop.noarch.rpm
    yum -y localinstall --nogpgcheck https://note.so1234.top/network/opencv/rpmfusion-free-7.noarch.rpm
    yum -y localinstall --nogpgcheck https://note.so1234.top/network/opencv/rpmfusion-nonfree-7.noarch.rpm
    
  2. 安装ffmpeg

  3. 安装gcc10.1

  4. 安装cmake3.16

  5. 安装python3.6

  6. 安装opencv

    cd /root
    git clone https://github.com/opencv/opencv.git
    git clone https://github.com/opencv/opencv_contrib.git
    mkdir /root/opencv/build
    cd /root/opencv/build
    
    cmake \
    -D CMAKE_INSTALL_PREFIX=/usr/local/opencv \
    -D OPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib/modules\
    /root/opencv
    
    make -j$(nproc)
    make install
    opencv_version
    echo '/usr/local/lib' > /etc/ld.so.conf.d/opencv.conf
    
  7. 测试C程序

    mkdir /root/test
    cd /root/test
    vim DisplayImage.cpp
    
    #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;
    }
    
    ESC
    :wq
    
    vim CMakeLists.txt
    
    set(CMAKE_CXX_STANDARD 14)
    cmake_minimum_required(VERSION 2.8)
    project(DisplayImage)
    find_package(OpenCV REQUIRED)
    include_directories(${OpenCV_INCLUDE_DIRS})
    add_executable(DisplayImage DisplayImage.cpp)
    target_link_libraries(DisplayImage ${OpenCV_LIBS})
    
    ESC
    :wq
    
    cmake /root/test
    
    ./DisplayImage /xxx/test.jpg
    
Copyright © 豆包嘿嘿~ 2012-∞ 冀ICP备17033181号 all right reserved,powered by Gitbook修订: 2020-10-10 10:02:50

results matching ""

    No results matching ""