Skip to content

Instantly share code, notes, and snippets.

@Mambix
Last active October 7, 2018 12:47
Show Gist options
  • Save Mambix/75a70271a147e77d896c87f9bd024ee7 to your computer and use it in GitHub Desktop.
Save Mambix/75a70271a147e77d896c87f9bd024ee7 to your computer and use it in GitHub Desktop.
compile OpenCV 3.4 on tegra TX1 with Cuda9.0
#run with sudo!
apt-get purge -y libopencv*
apt-get install -y cmake libavcodec-dev libavformat-dev libavutil-dev libeigen3-dev libglew-dev libgtk2.0-dev libgtk-3-dev libjasper-dev libjpeg-dev libpng12-dev libpostproc-dev libswscale-dev libtbb-dev libtiff5-dev libv4l-dev libxvidcore-dev libx264-dev qt5-default zlib1g-dev pkg-config
apt-get install -y python-dev python-numpy python-py python-pytest
apt-get install -y python3-dev python3-numpy python3-py python3-pytest
apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
cd /opt
git clone https://github.com/opencv/opencv_extra.git
cd opencv_extra
git checkout -b v3.4.0 3.4.0
cd ..
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout -b v3.4.0 3.4.0
git merge ec0bb66
git cherry-pick 549b5df
mkdir build
cd build
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_python2=ON \
-DBUILD_opencv_python3=ON \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DWITH_OPENCL=OFF \
-DWITH_OPENMP=OFF \
-DWITH_FFMPEG=OFF \
-DWITH_GSTREAMER=ON \
-DWITH_GSTREAMER_0_10=OFF \
-DWITH_CUDA=ON \
-DCUDA_FAST_MATH=ON \
-DWITH_CUBLAS=ON \
-DWITH_LIBV4L=ON \
-DWITH_V4L=OFF \
-DWITH_QT=ON \
-DWITH_OPENGL=ON \
-DWITH_GTK=ON \
-DWITH_VTK=OFF \
-DWITH_TBB=ON \
-DWITH_1394=OFF \
-DWITH_OPENEXR=OFF \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-9.0 \
-DCUDA_ARCH_BIN=5.3 \
-DCUDA_ARCH_PTX="" \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_TESTS=OFF \
-DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
..
make -j4
make test
make install
@Mambix
Copy link
Author

Mambix commented Oct 7, 2018

Need to comment out lines in /usr/local/cuda-9.0/include/cuda_gl_interop.h so it looks like this:


#if defined(__APPLE__)

#include <OpenGL/gl.h>

#else /* __APPLE__ */

//#if defined(__arm__) || defined(__aarch64__)
//#ifndef GL_VERSION
//#error Please include the appropriate gl headers before including cuda_gl_interop.h
//#endif
//#else
#include <GL/gl.h>
//#endif

#endif /* __APPLE__ */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment