forked from dusty-nv/jetson-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_deb.sh
executable file
·78 lines (59 loc) · 2.08 KB
/
install_deb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
OPENCV_URL=${1:-"$OPENCV_URL"}
OPENCV_DEB=${2:-"OpenCV-${OPENCV_VERSION}-aarch64.tar.gz"}
echo "OPENCV_URL=$OPENCV_URL"
echo "OPENCV_DEB=$OPENCV_DEB"
if [[ -z ${OPENCV_URL} || -z ${OPENCV_DEB} ]]; then
echo "OPENCV_URL and OPENCV_DEB must be set as environment variables or as command-line arguments"
exit 255
fi
ARCH=$(uname -i)
echo "ARCH: $ARCH"
set -x
# install numpy if needed
python3 -c 'import numpy'
if [ $? != 0 ]; then
apt-get update
apt-get install -y --no-install-recommends python3-numpy
fi
set -e
# remove previous OpenCV installation if it exists
apt-get purge -y '.*opencv.*' || echo "previous OpenCV installation not found"
# download and extract the deb packages
mkdir opencv
cd opencv
wget --quiet --show-progress --progress=bar:force:noscroll --no-check-certificate ${OPENCV_URL} -O ${OPENCV_DEB}
tar -xzvf ${OPENCV_DEB}
# install the packages and their dependencies
dpkg -i --force-depends *.deb
apt-get update
apt-get install -y -f --no-install-recommends
dpkg -i *.deb
rm -rf /var/lib/apt/lists/*
apt-get clean
# remove the original downloads
cd ../
rm -rf opencv
# manage some install paths
PYTHON3_VERSION=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))'`
if [ $ARCH = "aarch64" ]; then
local_include_path="/usr/local/include/opencv4"
local_python_path="/usr/local/lib/python${PYTHON3_VERSION}/dist-packages/cv2"
if [ -d "$local_include_path" ]; then
echo "$local_include_path already exists, replacing..."
rm -rf $local_include_path
fi
if [ -d "$local_python_path" ]; then
echo "$local_python_path already exists, replacing..."
rm -rf $local_python_path
fi
ln -s /usr/include/opencv4 $local_include_path
ln -s /usr/lib/python${PYTHON3_VERSION}/dist-packages/cv2 $local_python_path
elif [ $ARCH = "x86_64" ]; then
opencv_conda_path="/opt/conda/lib/python${PYTHON3_VERSION}/site-packages/cv2"
if [ -d "$opencv_conda_path" ]; then
echo "$opencv_conda_path already exists, replacing..."
rm -rf $opencv_conda_path
ln -s /usr/lib/python${PYTHON3_VERSION}/site-packages/cv2 $opencv_conda_path
fi
fi