Skip to content

Instantly share code, notes, and snippets.

@kochie
Last active May 14, 2020 11:58
Show Gist options
  • Select an option

  • Save kochie/2679f66cd1ae83c6a8d8ee286116988a to your computer and use it in GitHub Desktop.

Select an option

Save kochie/2679f66cd1ae83c6a8d8ee286116988a to your computer and use it in GitHub Desktop.

Revisions

  1. kochie revised this gist Oct 12, 2017. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,9 @@
    VERSION=3.3.0
    PYTHON=/usr/bin/python3

    if [[ $1=="arm" ]]; then
    if [ $1 == "arm" ]; then
    echo "Compiling for ARM (Raspberry Pi)"

    sudo apt-get install gcc-arm-linux-gnueabi
    sudo apt-get install gcc-arm-linux-gnueabihf

    @@ -20,12 +22,12 @@ export $(cat /etc/lsb-release | grep DISTRIB_RELEASE)
    export $(cat /etc/lsb-release | grep DISTRIB_ID)

    # Install Caffe for some libraries to compile correctly.
    if [[ $DISTRIB_ID=="Ubuntu" && $DISTRIB_RELEASE < 17.04 ]]; then
    if [ $DISTRIB_ID=="Ubuntu" && $DISTRIB_RELEASE < 17.04 ]; then
    sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
    sudo apt-get install --no-install-recommends libboost-all-dev
    fi

    if [[ -x "usr/bin/nvcc" ]]; then
    if [ -x "usr/bin/nvcc" ]; then
    sudo apt install caffe-cuda
    else
    sudo apt install caffe-cpu
    @@ -73,11 +75,11 @@ cmake -D CMAKE_BUILD_TYPE=RELEASE \

    make -j$(nproc)

    if [[ -n $CROSS_COMPILE ]]; then
    if [ -n $CROSS_COMPILE ]; then
    echo "Installing as local binaries"
    sudo make install -j$(nproc)
    sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
    sudo ldconfig
    else
    echo "Since you are specifically compiling for ARM the binaries will not be installed"
    fi
    fi
  2. kochie revised this gist Oct 12, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    #!/bin/bash
    VERSION=3.3.0
    PYTHON=/usr/bin/python3

    if [[ $1=="arm" ]]; then
    sudo apt-get install gcc-arm-linux-gnueabi
  3. kochie revised this gist Oct 12, 2017. 1 changed file with 17 additions and 3 deletions.
    20 changes: 17 additions & 3 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,13 @@
    #!/bin/bash
    VERSION=3.3.0

    if [[ $1=="arm" ]]; then
    sudo apt-get install gcc-arm-linux-gnueabi
    sudo apt-get install gcc-arm-linux-gnueabihf

    CROSS_COMPILE="-D CMAKE_TOOLCHAIN_FILE=$(pwd)/opencv/platforms/linux/arm-gnueabi.toolchain.cmake"
    fi

    sudo apt-get install -y libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libv4l-dev libqt4-dev libgtk2.0-dev libtbb-dev libatlas-base-dev libfaac-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev libopencore-amrnb-dev libopencore-amrwb-dev x264 v4l-utils
    sudo apt-get install -y libprotobuf-dev protobuf-compiler libgoogle-glog-dev libgflags-dev libgphoto2-dev libeigen3-dev libhdf5-dev doxygen
    sudo apt-get install -y gcc-5
    @@ -60,9 +67,16 @@ cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D WITH_OPENGL=ON \
    -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
    -D CUDA_NVCC_FLAGS="-ccbin gcc-5" \
    $CROSS_COMPILE \
    -D BUILD_EXAMPLES=ON ..

    make -j$(nproc)
    sudo make install -j$(nproc)
    sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
    sudo ldconfig

    if [[ -n $CROSS_COMPILE ]]; then
    echo "Installing as local binaries"
    sudo make install -j$(nproc)
    sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
    sudo ldconfig
    else
    echo "Since you are specifically compiling for ARM the binaries will not be installed"
    fi
  4. kochie revised this gist Oct 12, 2017. 1 changed file with 9 additions and 7 deletions.
    16 changes: 9 additions & 7 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,11 @@ sudo apt-get install -y gcc-5
    sudo apt-get install -y python-dev python-pip python3-dev python3-pip
    sudo -H pip3 install -U pip numpy

    # Install Caffe for some libraries to compile correctly.
    # Get linux distribution.
    export $(cat /etc/lsb-release | grep DISTRIB_RELEASE)
    export $(cat /etc/lsb-release | grep DISTRIB_ID)

    # Install Caffe for some libraries to compile correctly.
    if [[ $DISTRIB_ID=="Ubuntu" && $DISTRIB_RELEASE < 17.04 ]]; then
    sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
    sudo apt-get install --no-install-recommends libboost-all-dev
    @@ -22,36 +23,37 @@ else
    sudo apt install caffe-cpu
    fi


    # Clone OpenCV and checlout wanted version.
    if [ ! -d opencv ]; then
    git clone https://github.com/opencv/opencv.git
    fi

    cd opencv
    git checkout $VERSION
    cd ..

    # Clone OpenCV Contrib and checlout wanted version.
    if [ ! -d opencv_contrib ]; then
    git clone https://github.com/opencv/opencv_contrib.git
    fi

    cd opencv_contrib
    git checkout $VERSION
    cd ..


    cd opencv

    if [ ! -d build ]; then
    mkdir build
    fi

    cd build

    pwd

    cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D PYTHON_EXECUTABLE=$(which python3) \
    -D PYTHON_EXECUTABLE=$(PYTHON) \
    -D WITH_TBB=ON \
    -D WITH_V4L=ON \
    -D WITH_QT=ON \
    @@ -61,6 +63,6 @@ cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D BUILD_EXAMPLES=ON ..

    make -j$(nproc)
    sudo make install
    sudo make install -j$(nproc)
    sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
    sudo ldconfig
  5. kochie revised this gist Oct 12, 2017. 1 changed file with 17 additions and 4 deletions.
    21 changes: 17 additions & 4 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -2,15 +2,27 @@
    VERSION=3.3.0

    sudo apt-get install -y libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libv4l-dev libqt4-dev libgtk2.0-dev libtbb-dev libatlas-base-dev libfaac-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev libopencore-amrnb-dev libopencore-amrwb-dev x264 v4l-utils

    sudo apt-get install -y libprotobuf-dev protobuf-compiler libgoogle-glog-dev libgflags-dev libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

    sudo apt-get install -y gcc-5

    sudo apt-get install -y python-dev python-pip python3-dev python3-pip
    sudo -H pip2 install -U pip numpy
    sudo -H pip3 install -U pip numpy

    # Install Caffe for some libraries to compile correctly.
    export $(cat /etc/lsb-release | grep DISTRIB_RELEASE)
    export $(cat /etc/lsb-release | grep DISTRIB_ID)

    if [[ $DISTRIB_ID=="Ubuntu" && $DISTRIB_RELEASE < 17.04 ]]; then
    sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
    sudo apt-get install --no-install-recommends libboost-all-dev
    fi

    if [[ -x "usr/bin/nvcc" ]]; then
    sudo apt install caffe-cuda
    else
    sudo apt install caffe-cpu
    fi


    if [ ! -d opencv ]; then
    git clone https://github.com/opencv/opencv.git
    fi
    @@ -39,6 +51,7 @@ cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D PYTHON_EXECUTABLE=$(which python3) \
    -D WITH_TBB=ON \
    -D WITH_V4L=ON \
    -D WITH_QT=ON \
  6. kochie created this gist Oct 11, 2017.
    53 changes: 53 additions & 0 deletions install.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    #!/bin/bash
    VERSION=3.3.0

    sudo apt-get install -y libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libv4l-dev libqt4-dev libgtk2.0-dev libtbb-dev libatlas-base-dev libfaac-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev libopencore-amrnb-dev libopencore-amrwb-dev x264 v4l-utils

    sudo apt-get install -y libprotobuf-dev protobuf-compiler libgoogle-glog-dev libgflags-dev libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

    sudo apt-get install -y gcc-5

    sudo apt-get install -y python-dev python-pip python3-dev python3-pip
    sudo -H pip2 install -U pip numpy
    sudo -H pip3 install -U pip numpy

    if [ ! -d opencv ]; then
    git clone https://github.com/opencv/opencv.git
    fi
    cd opencv
    git checkout $VERSION
    cd ..

    if [ ! -d opencv_contrib ]; then
    git clone https://github.com/opencv/opencv_contrib.git
    fi
    cd opencv_contrib
    git checkout $VERSION
    cd ..


    cd opencv
    if [ ! -d build ]; then
    mkdir build
    fi

    cd build

    pwd

    cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D WITH_TBB=ON \
    -D WITH_V4L=ON \
    -D WITH_QT=ON \
    -D WITH_OPENGL=ON \
    -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
    -D CUDA_NVCC_FLAGS="-ccbin gcc-5" \
    -D BUILD_EXAMPLES=ON ..

    make -j$(nproc)
    sudo make install
    sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
    sudo ldconfig