-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathinstall_depthai.sh
More file actions
executable file
·252 lines (212 loc) · 7.8 KB
/
install_depthai.sh
File metadata and controls
executable file
·252 lines (212 loc) · 7.8 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/bin/bash
APP_NAME="depthai"
WORKING_DIR_NAME="Luxonis"
WORKING_DIR="$HOME/$WORKING_DIR_NAME"
mkdir "$WORKING_DIR"
install_path=""
path_correct="false"
trap 'RET=$? ; echo -e >&2 "\n\x1b[31mFailed installing depthai. Could be a bug in the installer or unsupported platform. Open a bug report over at https://github.com/luxonis/depthai - exited with status $RET at line $LINENO \x1b[0m\n" ; exit $RET' ERR
while [ "$path_correct" = "false" ]
do
echo ""
echo 'ENTER absolute installation path for depthai or leave empty and default path: $HOME will be used.'
read -e install_path < /dev/tty
echo ""
if [ "$install_path" = "" ]; then
echo "Using default installation path: $WORKING_DIR"
mkdir -p "$WORKING_DIR"
else
echo "Using given installation path: $install_path"
WORKING_DIR="$install_path"
fi
if [ -d "$WORKING_DIR" ]; then
echo "Directory: $WORKING_DIR is OK"
path_correct="true"
else
echo "Directory: $WORKING_DIR is not valid. Try again!"
fi
done
DEPTHAI_DIR="$WORKING_DIR/$APP_NAME"
VENV_DIR="$WORKING_DIR/venv"
ENTRYPOINT_DIR="$DEPTHAI_DIR/entrypoint"
# Get Python version or find out that python 3.10 must be installed
python_executable=$(which python3)
python_chosen="false"
install_python="false"
python_version=$(python3 --version)
python_version_number=""
if [[ "$python_version" != 'Python'* ]]; then
python_version=""
fi
echo ""
# check default python version, offer it to the user or get another one
while [ "$python_chosen" = "false" ]
do
if [[ "$python_version" == "" ]]; then
echo "No python version found."
echo "Input path for python binary, version 3.8 or higher, or leave empty and python 3.10 will be installed for you."
echo "Press ENTER key to continue"
read -e python_binary_path < /dev/tty
# python not found and user wants to install python 3.10
if [ "$python_binary_path" = "" ]; then
install_python="true"
python_chosen="true"
fi
else
# E.g Python 3.10 -> nr_1=3, nr_2=10, for Python 3.7.5 -> nr_1=r, nr_2=7
nr_1="${python_version:7:1}"
nr_2=$(echo "${python_version:9:2}" | tr -d -c 0-9)
echo "Python version: $python_version found."
if [ "$nr_1" -gt 2 ] && [ "$nr_2" -gt 7 ]; then # first two digits of python version greater then 3.7 -> python version 3.8 or greater is allowed.
echo "If you want to use it for installation, press ENTER key, otherwise input path to python binary."
echo "Press ENTER key to continue"
read -e python_binary_path < /dev/tty
# user wants to use already installed python whose version is high enough
if [ "$python_binary_path" = "" ]; then
python_chosen="true"
fi
else
echo "This python version is not supported by depthai. Enter path to python binary version et least 3.8, or leave empty and python 3.10 will be installed automatically."
echo "Press ENTER key to continue"
read -e python_binary_path < /dev/tty
# python version is too low and user wants to install python 3.10
if [ "$python_binary_path" = "" ]; then
install_python="true"
python_chosen="true"
fi
fi
fi
# User entered some path that should lead to python binary, save python --version output and the rest is dealt in the while loop logic.
if [ "$python_binary_path" != "" ]; then
python_executable="$python_binary_path"
python_version=$($python_binary_path --version)
if [[ "$python_version" != 'Python'* ]]; then
python_version=""
fi
fi
done
write_in_file () {
# just make sure only strings are appended which are not in there yet
# first arg is text to write, second arg is the file path
if ! grep -Fxq "$1" "$2"
then
echo "$1" >> "$2"
fi
}
COMMENT='# Entry point for Depthai demo app, enables to run <depthai_launcher> in terminal'
BASHRC="$HOME/.bashrc"
ZSHRC="$HOME/.zshrc"
ADD_ENTRYPOINT_TO_PATH='export PATH=$PATH'":$ENTRYPOINT_DIR"
# Function to set crash reporting environment variable in shell configuration files
set_crash_reporting_env() {
local consent_value="$1"
local env_line="export DEPTHAI_ENABLE_ANALYTICS_COLLECTION=$consent_value"
write_in_file "$env_line" "$BASHRC"
if [ -f "$ZSHRC" ]; then
write_in_file "$env_line" "$ZSHRC"
fi
}
# Prompt for user consent to enable crash reporting
echo ""
echo "DepthAI can collect anonymous crash reports to help improve the software."
echo "Do you agree to enable crash reporting? (y/n)"
read -n 1 crash_report_consent < /dev/tty
echo ""
if [[ "$crash_report_consent" == "y" || "$crash_report_consent" == "Y" ]]; then
echo "Crash reporting enabled."
set_crash_reporting_env "1"
else
echo "Crash reporting disabled."
set_crash_reporting_env "0"
fi
# add to .bashrc only if it is not in there already
write_in_file "$COMMENT" "$BASHRC"
write_in_file "$ADD_ENTRYPOINT_TO_PATH" "$BASHRC"
if [ -f "$ZSHRC" ]; then
write_in_file "$COMMENT" "$ZSHRC"
write_in_file "$ADD_ENTRYPOINT_TO_PATH" "$ZSHRC"
fi
if [[ $(uname -s) == "Darwin" ]]; then
echo _____________________________
echo "Calling macOS_installer.sh"
echo _____________________________
echo "Running macOS installer."
echo "Installing global dependencies."
bash -c "$(curl -fL https://docs.luxonis.com/install_dependencies.sh)"
# clone depthai form git
if [ -d "$DEPTHAI_DIR" ]; then
echo "Demo app already downloaded. Checking out main and updating."
else
echo "Downloading demo app."
git clone https://github.com/luxonis/depthai.git "$DEPTHAI_DIR"
fi
cd "$DEPTHAI_DIR"
git fetch
git checkout main
git pull
if [ "$install_python" == "true" ]; then
echo "installing python 3.10"
brew install python@3.10
python_executable=$(which python3.10)
fi
# create python virtual environment
echo "Creating python virtual environment in $VENV_DIR"
echo "$python_executable"
"$python_executable" -m venv "$VENV_DIR"
# activate environment
source "$VENV_DIR/bin/activate"
python -m pip install --upgrade pip
# install launcher dependencies
pip install pyqt5
pip install packaging
elif [[ $(uname -s) == "Linux" ]]; then
echo _____________________________
echo "Calling linux_installer.sh"
echo _____________________________
echo "Updating sudo-apt."
sudo apt-get update
echo "Installing global dependencies."
sudo wget -qO- https://docs.luxonis.com/install_dependencies.sh | bash
echo -e '\nRunning Linux installer.'
# clone depthai form git
if [ -d "$DEPTHAI_DIR" ]; then
echo "Demo app already downloaded. Checking out main and updating."
else
echo "Downloading demo app."
git clone https://github.com/luxonis/depthai.git "$DEPTHAI_DIR"
fi
cd "$DEPTHAI_DIR"
git fetch
git checkout main
git pull
# install python 3.10
if [ "$install_python" == "true" ]; then
echo "installing python 3.10"
sudo yes "" | sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt -y install python3.10
sudo apt -y install python3.10-venv
python_executable=$(which python3.10)
fi
echo "Creating python virtual environment in $VENV_DIR"
machine=$(uname -m)
if [[ $machine != 'armv6l' && $machine != 'armv7l' && $machine != 'aarch64' && $machine != 'arm64' ]]; then
"$python_executable" -m venv "$VENV_DIR"
else
"$python_executable" -m venv "$VENV_DIR" --system-site-packages
fi
source "$VENV_DIR/bin/activate"
python -m pip install --upgrade pip
pip install packaging
if [[ $machine != 'armv6l' && $machine != 'armv7l' && $machine != 'aarch64' && $machine != 'arm64' ]]; then
pip install pyqt5
fi
else
echo "Error: Host $(uname -s) not supported."
exit 99
fi
echo -e '\n\n:::::::::::::::: INSTALATION COMPLETE ::::::::::::::::\n'
echo -e '\nTo run demo app write <depthai_launcher> in terminal.'
echo "Press ENTER KEY to finish and run the demo app..."
read -n1 key < /dev/tty
echo "STARTING DEMO APP."
python "$DEPTHAI_DIR/launcher/launcher.py" -r "$DEPTHAI_DIR"