Skip to content

Commit 98bb628

Browse files
authored
Merge pull request #870 from luxonis/feature/demo_app_installation
entrypoint folder added to depthai
2 parents 4bdce89 + e3aa237 commit 98bb628

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

entrypoint/depthai_launcher

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
DEPTHAI_DIR="$(dirname "$SCRIPT_DIR")"
5+
LUXONIS_DEPTHAI_HOME="$(dirname "$DEPTHAI_DIR")"
6+
VENV_DIR="$LUXONIS_DEPTHAI_HOME/venv"
7+
echo "running demo app"
8+
echo "$SCRIPT_DIR"
9+
10+
if [ "$LUXONIS_DEPTHAI_HOME" = "" ]; then
11+
echo ':::::::::::::::::::::::::::::::::::::::'
12+
echo "Something is worng."
13+
echo "SCRIPT_DIR = $SCRIPT_DIR"
14+
echo "LUXONIS_DEPTHAI_HOME = $LUXONIS_DEPTHAI_HOME"
15+
echo '\nLSCRIPT_DIR is probably wrong, see:.\n'
16+
echo 'Using following script to find the location of this script.'
17+
echo 'SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )'
18+
echo "https://stackoverflow.com/questions/59895/how-do-i-get-the-directory-where-a-bash-script-is-located-from-within-the-script"
19+
echo ':::::::::::::::::::::::::::::::::::::::'
20+
exit 1
21+
fi
22+
23+
# check depthai directory exists
24+
if [ -d "$DEPTHAI_DIR" ]; then
25+
echo "OK. Depthai dir exists on $DEPTHAI_DIR."
26+
else
27+
echo "Depthai repo should be on $LUXONIS_DEPTHAI_HOME/$APP_NAME, but it does not exist."
28+
echo "git clone depthai in this directory, or use the installation script again."
29+
echo "git clone https://github.com/luxonis/depthai.git $LUXONIS_DEPTHAI_HOME/$APP_NAME"
30+
exit 3
31+
fi
32+
33+
echo ""
34+
35+
# check venv exists
36+
venv_chosen="false"
37+
while [ "$venv_chosen" = "false" ]
38+
do
39+
if [ -d "$VENV_DIR" ]; then
40+
echo "OK. Virtual environment dir exists on $VENV_DIR."
41+
venv_chosen="true"
42+
else
43+
echo "Virtual environment not found in $VENV_DIR"
44+
echo "Input depthai venv absolute path, e.g. [~/luxonis/venv] or re-run the depthai installation script."
45+
read -p $'Input path to venv and press ANY key or just press ANY key to exit\n' -r venv_path
46+
if [ "$venv_path" = "" ]; then
47+
exit 3
48+
fi
49+
if [ -f "$venv_path/bin/activate" ]; then
50+
venv_chosen="true"
51+
fi
52+
VENV_DIR=venv_path
53+
fi
54+
done
55+
56+
source "$VENV_DIR/bin/activate"
57+
58+
# add pyqt5 to pythonpath if on arm
59+
python_version=$(python3 --version)
60+
nr_1="${python_version:7:1}"
61+
nr_2=$(echo "${python_version:9:2}" | tr -d -c 0-9)
62+
63+
if [[ $(uname -m) == 'arm64' ]]; then
64+
#if [[ $(uname -s) == "Darwin" ]]; then
65+
if [[ ":$PYTHONPATH:" == *":/opt/homebrew/lib/python3.10/site-packages:"* ]]; then
66+
echo "/opt/homebrew/lib/python$nr_1.$nr_2/site-packages already in PYTHONPATH"
67+
else
68+
export "PYTHONPATH=/opt/homebrew/lib/python$nr_1.$nr_2/site-packages:"$PYTHONPATH
69+
echo "/opt/homebrew/lib/pythonv$nr_1.$nr_2/site-packages added to PYTHONPATH"
70+
fi
71+
fi
72+
73+
echo "running launcher with python version"
74+
echo python --version
75+
python "$DEPTHAI_DIR"/launcher/launcher.py

0 commit comments

Comments
 (0)