Skip to content

Instantly share code, notes, and snippets.

@linknum23
Created June 23, 2017 21:31
Show Gist options
  • Save linknum23/3ca07abb0841677595c507d5283f924c to your computer and use it in GitHub Desktop.
Save linknum23/3ca07abb0841677595c507d5283f924c to your computer and use it in GitHub Desktop.
Building opencv on the Drive PX 2
#!/bin/bash
# fresh start
rm -rf build_opencv
mkdir build_opencv
# grab all of opencv
# git clone https://github.com/opencv/opencv.git
# git clone https://github.com/opencv/opencv_extra.git
# git clone https://github.com/opencv/opencv_contrib.git
# checkout latest 2.4, recommended from http://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html for DRIVE PX 2
cd opencv \
&& git reset --hard \
&& git clean -df \
&& git checkout -b v2.4 2.4
cd ..
cd opencv_extra \
&& git reset --hard \
&& git clean -df \
&& git checkout -b v2.4 2.4
cd ..
PYTHON_SUPPORT='-DBUILD_opencv_python=ON'
echo "checked out latest commits on 2.4"
# # checkout 3.1.0, the latest tested the Drive PX 2 according to http://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html for DRIVE PX 2
# cd opencv \
# && git reset --hard && git clean -df \
# && git checkout -b v3.1.0 3.1.0 \
# && git cherry-pick 10896 \
# && git cherry-pick cdb9c \
# && git cherry-pick 24dbb
# cd ..
# cd opencv_extra \
# && git reset --hard \
# && git clean -df \
# && git checkout -b v3.1.0 3.1.0
# cd ..
# PYTHON_SUPPORT='-DBUILD_opencv_python2=ON -DBUILD_opencv_python3=OFF'
# echo "checked out latest commits on 3.1.0"
# add required packages on ubuntu
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install \
libglew-dev \
libtiff5-dev \
zlib1g-dev \
libjpeg-dev \
libpng12-dev \
libjasper-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libpostproc-dev \
libswscale-dev \
libeigen3-dev \
libtbb-dev \
libgtk2.0-dev \
pkg-config
# lazily using configuration from http://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html for DRIVE PX 2
# this configures, compiles, tests and installs opencv
cd build_opencv
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_PNG=OFF \
-DBUILD_TIFF=OFF \
-DBUILD_TBB=OFF \
-DBUILD_JPEG=OFF \
-DBUILD_JASPER=OFF \
-DBUILD_ZLIB=OFF \
-DBUILD_EXAMPLES=ON \
-DBUILD_opencv_java=OFF \
-DBUILD_opencv_nonfree=OFF \
$PYTHON_SUPPORT \
-DENABLE_NEON=ON \
-DWITH_OPENCL=OFF \
-DWITH_OPENMP=OFF \
-DWITH_FFMPEG=ON \
-DWITH_GSTREAMER=OFF \
-DWITH_GSTREAMER_0_10=OFF \
-DWITH_CUDA=ON \
-DWITH_GTK=ON \
-DWITH_VTK=OFF \
-DWITH_TBB=ON \
-DWITH_1394=OFF \
-DWITH_OPENEXR=OFF \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
-DCUDA_ARCH_BIN=6.2 \
-DCUDA_ARCH_PTX="" \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_TESTS=ON \
-DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
-DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9 \
../opencv \
&& make -j4 \
&& make test ARGS="--verbose --parallel 2" \
# && sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment