forked from jkjung-avt/jetson_nano
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76438b9
commit 3a93c28
Showing
1 changed file
with
30 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,31 @@ | |
# The orginal script 'install_opencv4.0.0_Nano.sh' could be found here: | ||
# https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh | ||
# | ||
# I did some modification so that it installs opencv-3.4.7 instead. Refer | ||
# I did some modification so that it installs opencv-3.4.8 instead. Refer | ||
# to my blog posts for more details. | ||
# | ||
# JK Jung, [email protected] | ||
|
||
set -e | ||
|
||
chip_id=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) | ||
case ${chip_id} in | ||
"33" ) # Nano and TX1 | ||
cuda_compute=5.3 | ||
;; | ||
"24" ) # TX2 | ||
cuda_compute=6.2 | ||
;; | ||
"25" ) # AGX Xavier | ||
cuda_compute=7.2 | ||
;; | ||
* ) # default | ||
cuda_compute=5.3,6.2,7.2 | ||
;; | ||
esac | ||
|
||
py3_ver=$(python3 -c "import sys; print(sys.version_info[1])") | ||
|
||
folder=${HOME}/src | ||
mkdir -p $folder | ||
|
||
|
@@ -37,7 +55,7 @@ sudo apt-get install -y libxvidcore-dev libx264-dev libgtk-3-dev | |
sudo apt-get install -y libatlas-base-dev libopenblas-dev liblapack-dev liblapacke-dev gfortran | ||
sudo apt-get install -y qt5-default | ||
|
||
sudo apt-get install -y python2.7-dev python3.6-dev python3-testresources | ||
sudo apt-get install -y python2.7-dev python3.${py3_ver}-dev python3-testresources | ||
rm -f $folder/get-pip.py | ||
wget https://bootstrap.pypa.io/get-pip.py -O $folder/get-pip.py | ||
sudo python3 $folder/get-pip.py | ||
|
@@ -50,30 +68,30 @@ sudo pip3 install -U numpy matplotlib | |
if [ ! -f /usr/local/cuda/include/cuda_gl_interop.h.bak ]; then | ||
sudo cp /usr/local/cuda/include/cuda_gl_interop.h /usr/local/cuda/include/cuda_gl_interop.h.bak | ||
fi | ||
sudo patch -N /usr/local/cuda/include/cuda_gl_interop.h < opencv/cuda_gl_interop.h.patch && echo "** '/usr/local/cuda/include/cuda_gl_interop.h' appears to be patched already. Continue..." | ||
sudo patch -N -r - /usr/local/cuda/include/cuda_gl_interop.h < opencv/cuda_gl_interop.h.patch && echo "** '/usr/local/cuda/include/cuda_gl_interop.h' appears to be patched already. Continue..." | ||
|
||
echo "** Download opencv-3.4.7" | ||
echo "** Download opencv-3.4.8" | ||
cd $folder | ||
if [ ! -f opencv-3.4.7.zip ]; then | ||
wget https://github.com/opencv/opencv/archive/3.4.7.zip -O opencv-3.4.7.zip | ||
if [ ! -f opencv-3.4.8.zip ]; then | ||
wget https://github.com/opencv/opencv/archive/3.4.8.zip -O opencv-3.4.8.zip | ||
fi | ||
if [ -d opencv-3.4.7 ]; then | ||
echo "** ERROR: opencv-3.4.7 directory already exists" | ||
if [ -d opencv-3.4.8 ]; then | ||
echo "** ERROR: opencv-3.4.8 directory already exists" | ||
exit | ||
fi | ||
unzip opencv-3.4.7.zip | ||
cd opencv-3.4.7/ | ||
unzip opencv-3.4.8.zip | ||
cd opencv-3.4.8/ | ||
|
||
echo "** Building opencv..." | ||
mkdir build | ||
cd build/ | ||
|
||
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D ENABLE_NEON=ON -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D WITH_QT=ON -D WITH_OPENGL=ON .. | ||
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D CUDA_ARCH_BIN=${cuda_compute} -D CUDA_ARCH_PTX="" -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D ENABLE_NEON=ON -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D WITH_QT=ON -D WITH_OPENGL=ON .. | ||
make -j3 | ||
sudo make install | ||
sudo ldconfig | ||
|
||
python3 -c 'import cv2; print("python3 cv2 version: %s" % cv2.__version__)' | ||
python2 -c 'import cv2; print("python2 cv2 version: %s" % cv2.__version__)' | ||
|
||
echo "** Install opencv-3.4.7 successfully" | ||
echo "** Install opencv-3.4.8 successfully" |