zoukankan      html  css  js  c++  java
  • Firefly-RK3399 上编译安装 OpenCV 3

    原文转自:http://dev.t-firefly.com/thread-12143-1-1.html

    OS:官方固件 Xubuntu 16.04


    1) Install

    1.1) Required Packages

    # 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

    1.2) Getting OpenCV Source Code

    $ git clone https://github.com/opencv/opencv.git
    $ cd opencv/
    $ git checkout 3.2.0

    If use extra modules:

    $ git clone https://github.com/opencv/opencv_contrib.git
    $ cd opencv_contrib/
    $ git checkout 3.2.0

    1.3) Building OpenCV from Source

    $ cd opencv/
    $ mkdir build
    $ cd build/
    
    $ export PY_NAME=$(python -c 'from sys import version_info as v; print("python%d.%d" % v[:2])')
    $ export PY_NUMPY_DIR=$(python -c 'import os.path, numpy.core; print(os.path.dirname(numpy.core.__file__))')
    
    $ cmake -DCMAKE_BUILD_TYPE=RELEASE 
    -DCMAKE_INSTALL_PREFIX=/usr/local 
    
    -DPYTHON2_EXECUTABLE=$(which python) 
    -DPYTHON_INCLUDE_DIR=/usr/include/$PY_NAME 
    -DPYTHON_INCLUDE_DIR2=/usr/include/aarch64-linux-gnu/$PY_NAME 
    -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/lib$PY_NAME.so 
    -DPYTHON2_NUMPY_INCLUDE_DIRS=/usr/lib/$PY_NAME/dist-packages/numpy/core/include/ 
    
    -DBUILD_DOCS=OFF 
    -DBUILD_EXAMPLES=OFF 
    -DBUILD_TESTS=OFF 
    -DBUILD_PERF_TESTS=OFF 
    
    -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules 
    ..
    
    $ make -j$(nproc --all)
    $ sudo make install

    2) Examples

    2.1) Canny Edge Detection

    `canny.py`:

    #!/usr/bin/env python
    
    import cv2
    import numpy as np
    
    def main():
        img = cv2.imread('../data/messi5.jpg', 0)
        edges = cv2.Canny(img, 100, 200)
    
        cv2.imshow('Original & Edge', np.vstack((img, edges)))
        cv2.waitKey()
        cv2.destroyAllWindows()
    
    if __name__ == '__main__':
        main()

     

    3) Appendix

    3.1) Install pip

    $ python --version
    Python 2.7.12
    
    $ curl -O https://bootstrap.pypa.io/get-pip.py
    $ python get-pip.py
    
    $ vi ~/.pip/pip.conf
    [global]
    format=columns
    index-url=http://mirrors.aliyun.com/pypi/simple/
    [install]
    trusted-host=mirrors.aliyun.com

    ===================================================================

    从这一刻开始努力也不晚,所以我决定留下我学习的痕迹

    ===================================================================

  • 相关阅读:
    Java框架之Mybatis(一)
    Java框架之Hibernate(四)
    Java框架之Hibernate(三)
    递归与分治
    散列
    绪论
    系统的分类(二)
    系统的定义与分类(一)
    Guess My Number 游戏
    2.5 随机数的生成
  • 原文地址:https://www.cnblogs.com/svenwu/p/9558342.html
Copyright © 2011-2022 走看看