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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh -eu
|
2 |
+
#
|
3 |
+
# script to build the AR SDK sample apps
|
4 |
+
#
|
5 |
+
# - ask the location for the sample apps
|
6 |
+
# - install any pre-requisites via package manager
|
7 |
+
# - build any pre-requisites not available via package manager (if any)
|
8 |
+
# - build the sample apps
|
9 |
+
#
|
10 |
+
# usage:
|
11 |
+
#
|
12 |
+
# build_samples.sh [ -f | --force ] [-c|--cleanup] [-i <i>|--installdir <i>] [-y|--yes]
|
13 |
+
#
|
14 |
+
# where:
|
15 |
+
# -f | --force : force rebuild or reinstall of pre-requisites
|
16 |
+
# -c | --cleanup : clean up build intermediates
|
17 |
+
# -i <i> | --installdir <i> : installation directory (default ~/mysamples)
|
18 |
+
# -y | --yes : no prompting - use default values
|
19 |
+
#
|
20 |
+
|
21 |
+
# there are exact requirements
|
22 |
+
_CUDAVER="11.8"
|
23 |
+
_TRTVER="8.6.1.6"
|
24 |
+
_CUDNNVER="8.9.1"
|
25 |
+
|
26 |
+
|
27 |
+
usage() { echo "usage: $0 [-i <dir> | --installdir <dir>] [-y|--yes] [-f|--force] [-p|--prereq]"; exit 0;}
|
28 |
+
die() { echo "$0: ERROR: $@" 1>&2; exit 1; }
|
29 |
+
progress() { echo "========== $@ =========="; }
|
30 |
+
|
31 |
+
check_exist() {
|
32 |
+
msg="$1"
|
33 |
+
shift
|
34 |
+
for i; do if [ -e "$i" ]; then return; fi; done
|
35 |
+
die "Could not find $msg: $@"
|
36 |
+
}
|
37 |
+
|
38 |
+
# usually /usr/local/ARSDK/share
|
39 |
+
SAMPDIR="$(cd ${AR_SDK_SAMPLES_DIR:-`dirname "$0"`}; pwd)"
|
40 |
+
if [ ! -e "$SAMPDIR/build_samples.sh" ]
|
41 |
+
then
|
42 |
+
die "cannot find samples directory"
|
43 |
+
fi
|
44 |
+
|
45 |
+
if [ -f /etc/os-release ]
|
46 |
+
then
|
47 |
+
. /etc/os-release
|
48 |
+
OS="$ID$VERSION_ID"
|
49 |
+
case "$OS" in
|
50 |
+
centos7 | ubuntu18.04 | ubuntu20.04 | ubuntu22.04 | rocky8.7 | rocky8.8 | debian11 );;
|
51 |
+
*) die "unsupported linux version: $OS";;
|
52 |
+
esac
|
53 |
+
else
|
54 |
+
die "cannot determine os version"
|
55 |
+
fi
|
56 |
+
|
57 |
+
# process args
|
58 |
+
TEMP=$(getopt -o 'xfdci:ypb?' --long 'force,debug,cleanup,installdir:,yes,build,prereq,help' -- "$@")
|
59 |
+
if [ $? -ne 0 ]; then usage; fi
|
60 |
+
eval set -- "$TEMP"
|
61 |
+
unset TEMP
|
62 |
+
|
63 |
+
# for
|
64 |
+
|
65 |
+
_YES="false"
|
66 |
+
_FORCE="false"
|
67 |
+
_BUILD_TYPE="Release"
|
68 |
+
_INSTALLDIR=""
|
69 |
+
_CLEANUP="false"
|
70 |
+
_BUILD="true"
|
71 |
+
_PREREQ="true"
|
72 |
+
_PREGEN="true"
|
73 |
+
while true; do
|
74 |
+
case "$1" in
|
75 |
+
'-x') set -x;; # script debug output
|
76 |
+
'-f' | '--force') _FORCE="true";; # force build
|
77 |
+
'-d' | '--debug') _BUILD_TYPE="Debug";; # debug build
|
78 |
+
'-c' | '--cleanup') _CLEANUP="true";; # clean build
|
79 |
+
'-i' | '--installdir') _INSTALLDIR="$2";shift;;
|
80 |
+
'-y' | '--yes') _YES="true";; # answer yes to questions
|
81 |
+
'-p' | '--prereq') _BUILD="false"; _PREGEN="true";; # pregenerate prerequisites
|
82 |
+
'-b' | '--build') _PREREQ="false";; # build without checking prerequisites
|
83 |
+
'--') shift;break;;
|
84 |
+
*) usage;;
|
85 |
+
esac
|
86 |
+
shift
|
87 |
+
done
|
88 |
+
|
89 |
+
|
90 |
+
if ! $_YES
|
91 |
+
then
|
92 |
+
echo ""
|
93 |
+
echo "===================================================================="
|
94 |
+
echo "This script will:"
|
95 |
+
if [ "$OS" = "centos7" ]
|
96 |
+
then
|
97 |
+
echo "- INSTALL pre-requisite packages using yum"
|
98 |
+
echo "- BUILD pre-requisite packages (opencv + ffmpeg)"
|
99 |
+
else
|
100 |
+
echo "- INSTALL pre-requisite packages using apt-get"
|
101 |
+
fi
|
102 |
+
echo "- build the sample apps to a location of your choice"
|
103 |
+
echo ""
|
104 |
+
echo "This may install many pre-requisite packages"
|
105 |
+
if [ "$OS" = "centos7" ]
|
106 |
+
then
|
107 |
+
echo "and the the build may take some time"
|
108 |
+
fi
|
109 |
+
|
110 |
+
echo ""
|
111 |
+
read -p "Ok to continue? (yes/no) " ans
|
112 |
+
case "$ans" in
|
113 |
+
[yY] | [Yy][Ee][Ss]);;
|
114 |
+
*) echo "aborted."; exit 1;;
|
115 |
+
esac
|
116 |
+
fi
|
117 |
+
|
118 |
+
if [ -z "$_INSTALLDIR" ] && ! $_YES; then
|
119 |
+
echo "Please provide an absolute path for installation directory below, or use the default. "
|
120 |
+
read -p "Install to [~/mysamples]: " _INSTALLDIR
|
121 |
+
fi
|
122 |
+
|
123 |
+
_INSTALLDIR="${_INSTALLDIR:-$HOME/mysamples}"
|
124 |
+
mkdir -p "$_INSTALLDIR/source"
|
125 |
+
|
126 |
+
progress "copy samples to $_INSTALLDIR"
|
127 |
+
|
128 |
+
echo "cp -r $SAMPDIR/* $_INSTALLDIR/source/"
|
129 |
+
cp -r $SAMPDIR/* "$_INSTALLDIR/source/"
|
130 |
+
|
131 |
+
#copy preinstalled packages if any
|
132 |
+
if [ -d "$_INSTALLDIR/pregen" ] && [ ! -d "$_INSTALLDIR/extras" ]
|
133 |
+
then
|
134 |
+
progress "copy preinstalled packages to $_INSTALLDIR"
|
135 |
+
cp -r "$_INSTALLDIR/pregen/" "$_INSTALLDIR/extras/"
|
136 |
+
fi
|
137 |
+
|
138 |
+
# containers don't require / provide sudo
|
139 |
+
if [ -x /usr/bin/sudo ]
|
140 |
+
then
|
141 |
+
SUDO="sudo"
|
142 |
+
else
|
143 |
+
SUDO=""
|
144 |
+
fi
|
145 |
+
|
146 |
+
if $_PREREQ
|
147 |
+
then
|
148 |
+
|
149 |
+
progress "check prerequisities"
|
150 |
+
|
151 |
+
case "$OS" in
|
152 |
+
|
153 |
+
centos7)
|
154 |
+
|
155 |
+
# also epel-release
|
156 |
+
PRE_REQ_LIST="
|
157 |
+
cmake3
|
158 |
+
gcc
|
159 |
+
gcc-c++
|
160 |
+
git
|
161 |
+
gtk2-devel
|
162 |
+
jasper-devel
|
163 |
+
libdc1394-devel
|
164 |
+
libjpeg-turbo-devel
|
165 |
+
libpng-devel
|
166 |
+
libtiff-devel
|
167 |
+
libv4l-devel
|
168 |
+
libwebp-devel
|
169 |
+
v4l-utils
|
170 |
+
yasm
|
171 |
+
|
172 |
+
autoconf
|
173 |
+
automake
|
174 |
+
libtool
|
175 |
+
|
176 |
+
make
|
177 |
+
wget
|
178 |
+
|
179 |
+
mesa-libGLES-devel
|
180 |
+
glfw-devel
|
181 |
+
"
|
182 |
+
|
183 |
+
if $_FORCE || ! rpm -q epel-release $PRE_REQ_LIST
|
184 |
+
then
|
185 |
+
echo "installing required packages:"
|
186 |
+
set -x
|
187 |
+
$SUDO yum -y install epel-release
|
188 |
+
$SUDO yum -y install $PRE_REQ_LIST
|
189 |
+
set +x
|
190 |
+
else
|
191 |
+
echo "Required packages are already installed"
|
192 |
+
fi
|
193 |
+
|
194 |
+
CMAKE=cmake3
|
195 |
+
|
196 |
+
;;
|
197 |
+
|
198 |
+
rocky8.7 | rocky8.8 )
|
199 |
+
PRE_REQ_LIST="
|
200 |
+
git
|
201 |
+
cmake
|
202 |
+
gcc
|
203 |
+
gcc-c++
|
204 |
+
make
|
205 |
+
python2
|
206 |
+
python3
|
207 |
+
python3-numpy
|
208 |
+
platform-python-devel
|
209 |
+
gtk2-devel
|
210 |
+
findutils
|
211 |
+
diffutils
|
212 |
+
libdc1394
|
213 |
+
libjpeg-turbo
|
214 |
+
libjpeg-turbo-devel
|
215 |
+
|
216 |
+
libv4l-devel
|
217 |
+
|
218 |
+
autoconf
|
219 |
+
automake
|
220 |
+
libtool
|
221 |
+
mesa-libGL-devel
|
222 |
+
glfw-devel
|
223 |
+
"
|
224 |
+
|
225 |
+
if $_FORCE || ! rpm -q epel-release $PRE_REQ_LIST
|
226 |
+
then
|
227 |
+
echo "installing required packages:"
|
228 |
+
set -xe
|
229 |
+
# dnf will fail with missing package
|
230 |
+
$SUDO yum -y install epel-release
|
231 |
+
$SUDO dnf config-manager --set-enabled powertools
|
232 |
+
$SUDO dnf -y install $PRE_REQ_LIST
|
233 |
+
set +x
|
234 |
+
else
|
235 |
+
echo "Required packages are already installed"
|
236 |
+
fi
|
237 |
+
|
238 |
+
CMAKE=cmake
|
239 |
+
|
240 |
+
;;
|
241 |
+
|
242 |
+
ubuntu18.04 | ubuntu20.04 | ubuntu22.04 | debian10 | debian11 )
|
243 |
+
|
244 |
+
PRE_REQ_LIST="
|
245 |
+
cmake
|
246 |
+
g++
|
247 |
+
make
|
248 |
+
ffmpeg
|
249 |
+
libopencv-dev
|
250 |
+
libgles2-mesa-dev
|
251 |
+
libglfw3-dev
|
252 |
+
"
|
253 |
+
|
254 |
+
if $_FORCE || ! dpkg --verify $PRE_REQ_LIST >/dev/null
|
255 |
+
then
|
256 |
+
echo "installing required packages:"
|
257 |
+
set -x
|
258 |
+
$SUDO apt-get update
|
259 |
+
if [ -z "$SUDO" ]
|
260 |
+
then
|
261 |
+
export DEBIAN_FRONTEND=noninteractive
|
262 |
+
apt-get install -y $PRE_REQ_LIST
|
263 |
+
else
|
264 |
+
$SUDO DEBIAN_FRONTEND=noninteractive apt-get install -y $PRE_REQ_LIST
|
265 |
+
fi
|
266 |
+
set +x
|
267 |
+
else
|
268 |
+
echo "Required packages are already installed"
|
269 |
+
fi
|
270 |
+
|
271 |
+
CMAKE=cmake
|
272 |
+
|
273 |
+
;;
|
274 |
+
|
275 |
+
*) die "unexpected OS":;
|
276 |
+
|
277 |
+
esac
|
278 |
+
|
279 |
+
|
280 |
+
cd "$_INSTALLDIR"
|
281 |
+
|
282 |
+
|
283 |
+
if [ "$OS" = "centos7" ] || [ "$OS" = "rocky8.7" ] || [ "$OS" = "rocky8.8" ]
|
284 |
+
then
|
285 |
+
progress "build any additional prerequisites"
|
286 |
+
|
287 |
+
set -e
|
288 |
+
|
289 |
+
if [ -e $_INSTALLDIR/extras/bin/nasm ] && ! $_FORCE
|
290 |
+
then
|
291 |
+
|
292 |
+
echo "nasm: already exists"
|
293 |
+
|
294 |
+
else
|
295 |
+
|
296 |
+
mkdir -p $_INSTALLDIR/build/nasm
|
297 |
+
cd $_INSTALLDIR/build/nasm
|
298 |
+
|
299 |
+
git clone https://github.com/netwide-assembler/nasm
|
300 |
+
cd nasm
|
301 |
+
git -c advice.detachedHead=false checkout tags/nasm-2.15.05
|
302 |
+
|
303 |
+
sh autogen.sh
|
304 |
+
sh configure --prefix="$_INSTALLDIR/extras"
|
305 |
+
touch nasm.1 ndisasm.1 # cheat
|
306 |
+
|
307 |
+
make -j$(nproc)
|
308 |
+
make install
|
309 |
+
|
310 |
+
cd $_INSTALLDIR/build
|
311 |
+
$_CLEANUP && rm -rf $_INSTALLDIR/build/nasm
|
312 |
+
fi
|
313 |
+
|
314 |
+
export PATH="$PATH:$_INSTALLDIR/extras/bin"
|
315 |
+
|
316 |
+
# -------------- x264 --------------
|
317 |
+
|
318 |
+
if [ -e $_INSTALLDIR/extras/lib/libx264.a ] && ! $_FORCE
|
319 |
+
then
|
320 |
+
echo "libx264: already exists"
|
321 |
+
else
|
322 |
+
mkdir -p $_INSTALLDIR/build/x264
|
323 |
+
cd $_INSTALLDIR/build/x264
|
324 |
+
|
325 |
+
git clone https://git.videolan.org/git/x264.git
|
326 |
+
cd x264
|
327 |
+
#git checkout <ver>
|
328 |
+
|
329 |
+
./configure \
|
330 |
+
--enable-static \
|
331 |
+
--enable-strip \
|
332 |
+
--enable-pic \
|
333 |
+
--disable-cli \
|
334 |
+
--disable-opencl \
|
335 |
+
\
|
336 |
+
--disable-avs \
|
337 |
+
--disable-swscale \
|
338 |
+
--disable-lavf \
|
339 |
+
--disable-ffms \
|
340 |
+
--disable-gpac \
|
341 |
+
--disable-lsmash \
|
342 |
+
\
|
343 |
+
--prefix="$_INSTALLDIR/extras"
|
344 |
+
|
345 |
+
make -j$(nproc)
|
346 |
+
make install
|
347 |
+
|
348 |
+
cd $_INSTALLDIR/build
|
349 |
+
$_CLEANUP && rm -rf $_INSTALLDIR/build/x264
|
350 |
+
fi
|
351 |
+
|
352 |
+
# -------------- ffmpeg --------------
|
353 |
+
if [ -e $_INSTALLDIR/extras/bin/ffmpeg ] && ! $_FORCE
|
354 |
+
then
|
355 |
+
echo "ffmpeg: already exists"
|
356 |
+
else
|
357 |
+
mkdir -p $_INSTALLDIR/build/ffmpeg
|
358 |
+
cd $_INSTALLDIR/build/ffmpeg
|
359 |
+
|
360 |
+
export PKG_CONFIG_PATH="$_INSTALLDIR/extras/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
|
361 |
+
|
362 |
+
echo "git clone FFmpeg"
|
363 |
+
git -c advice.detachedHead=false clone -b n4.3.2 --depth=1 https://github.com/FFmpeg/FFmpeg
|
364 |
+
|
365 |
+
cd FFmpeg
|
366 |
+
git -c advice.detachedHead=false checkout tags/n4.3.2
|
367 |
+
|
368 |
+
./configure \
|
369 |
+
--enable-pic \
|
370 |
+
--enable-shared \
|
371 |
+
--enable-ffmpeg \
|
372 |
+
--enable-ffplay \
|
373 |
+
--enable-ffprobe \
|
374 |
+
--enable-gpl \
|
375 |
+
--enable-libx264 \
|
376 |
+
--prefix="$_INSTALLDIR/extras" \
|
377 |
+
--disable-doc
|
378 |
+
|
379 |
+
make -j$(nproc)
|
380 |
+
make install
|
381 |
+
|
382 |
+
cd $_INSTALLDIR/build
|
383 |
+
$_CLEANUP && rm -rf $_INSTALLDIR/build/ffmpeg
|
384 |
+
|
385 |
+
#echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf
|
386 |
+
#ldconfig
|
387 |
+
fi
|
388 |
+
|
389 |
+
# -------------- opencv --------------
|
390 |
+
|
391 |
+
export LD_LIBRARY_PATH="$_INSTALLDIR/extras/lib:/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
|
392 |
+
|
393 |
+
if [ -e $_INSTALLDIR/extras/lib64/libopencv_core.so ] && ! $_FORCE
|
394 |
+
then
|
395 |
+
echo "opencv: already exists"
|
396 |
+
else
|
397 |
+
|
398 |
+
export PKG_CONFIG_PATH="$_INSTALLDIR/extras/lib/pkgconfig:$_INSTALLDIR/extras/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:${PKG_CONFIG_PATH:-/usr/share/pkgconfig}"
|
399 |
+
export PKG_CONFIG_LIBDIR="$_INSTALLDIR/extras/lib:$_INSTALLDIR/extras/lib64:/usr/lib64:${PKG_CONFIG_LIBDIR:-/usr/lib64}"
|
400 |
+
|
401 |
+
cd "$_INSTALLDIR/build"
|
402 |
+
|
403 |
+
echo "git clone opencv"
|
404 |
+
git -c advice.detachedHead=false clone https://github.com/opencv/opencv.git
|
405 |
+
|
406 |
+
cd opencv
|
407 |
+
git -c advice.detachedHead=false checkout tags/3.4.6
|
408 |
+
|
409 |
+
mkdir build
|
410 |
+
cd build
|
411 |
+
|
412 |
+
$CMAKE \
|
413 |
+
-D CMAKE_INSTALL_PREFIX="$_INSTALLDIR/extras" \
|
414 |
+
-D CMAKE_BUILD_TYPE=RELEASE \
|
415 |
+
-D BUILD_opencv_stitching=OFF \
|
416 |
+
-D WITH_1394=OFF \
|
417 |
+
-D WITH_FFMPEG=ON \
|
418 |
+
\
|
419 |
+
-D WITH_GSTREAMER=OFF \
|
420 |
+
-D WITH_V4L=ON \
|
421 |
+
-D WITH_LIB4VL=ON \
|
422 |
+
-D OPENCV_SKIP_PYTHON_LOADER=ON \
|
423 |
+
-D OPENCV_GENERATE_PKGCONFIG=ON \
|
424 |
+
-D ENABLE_CXX11=ON \
|
425 |
+
\
|
426 |
+
-D BUILD_opencv_apps=OFF \
|
427 |
+
-D BUILD_DOCS=OFF \
|
428 |
+
-D BUILD_PACKAGE=OFF \
|
429 |
+
-D BUILD_PERF_TESTS=OFF \
|
430 |
+
-D BUILD_TESTS=OFF \
|
431 |
+
\
|
432 |
+
-DBUILD_LIST=core,videoio,highgui,imgproc,calib3d \
|
433 |
+
..
|
434 |
+
|
435 |
+
make -j$(nproc)
|
436 |
+
make install
|
437 |
+
|
438 |
+
cd $_INSTALLDIR/build
|
439 |
+
$_CLEANUP && rm -rf $_INSTALLDIR/build/opencv
|
440 |
+
fi
|
441 |
+
|
442 |
+
if $_PREGEN
|
443 |
+
then
|
444 |
+
cp -R $_INSTALLDIR/extras/ $_INSTALLDIR/pregen/
|
445 |
+
fi
|
446 |
+
|
447 |
+
fi
|
448 |
+
|
449 |
+
progress "prerequisites for samples are complete"
|
450 |
+
fi
|
451 |
+
|
452 |
+
if $_BUILD
|
453 |
+
then
|
454 |
+
|
455 |
+
progress "verify cuda / cudnn / tensorrt"
|
456 |
+
|
457 |
+
if [ -d /usr/local/ARSDK/external/cuda ] && [ -d /usr/local/ARSDK/external/tensorrt ]
|
458 |
+
then
|
459 |
+
echo "found ARSDK tensorrt/cuda/cudnn"
|
460 |
+
# cuda/cudnn
|
461 |
+
export LD_LIBRARY_PATH="/usr/local/ARSDK/external/cuda/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
|
462 |
+
export PATH="/usr/local/ARSDK/external/cuda/bin:$PATH"
|
463 |
+
|
464 |
+
# tensorrt
|
465 |
+
export LD_LIBRARY_PATH="/usr/local/ARSDK/external/tensorrt/lib:$LD_LIBRARY_PATH"
|
466 |
+
export PATH="/usr/local/ARSDK/external/tensorrt/bin:$PATH"
|
467 |
+
else
|
468 |
+
|
469 |
+
# 7.2.2.3 -> 7.2.2.
|
470 |
+
_TRT_VER_SHORT=$(echo $_TRTVER | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\..*/\1.\2\.\3/')
|
471 |
+
|
472 |
+
check_exist "CUDA" /usr/local/cuda-$_CUDAVER
|
473 |
+
check_exist "TensorRT" /usr/local/TensorRT-$_TRTVER/lib/libnvinfer.so.$_TRT_VER_SHORT \
|
474 |
+
/usr/lib64/libnvinfer.so.$_TRT_VER_SHORT \
|
475 |
+
/usr/lib/x86_64-linux-gnu/libnvinfer.so.$_TRT_VER_SHORT
|
476 |
+
check_exist "cuDNN" /usr/local/cuda-$_CUDAVER/lib64/libcudnn.so.$_CUDNNVER \
|
477 |
+
/usr/lib64/libcudnn.so.$_CUDNNVER \
|
478 |
+
/usr/lib/x86_64-linux-gnu/libcudnn.so.$_CUDNNVER
|
479 |
+
|
480 |
+
export LD_LIBRARY_PATH="/usr/local/cuda-${_CUDAVER}/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
|
481 |
+
export PATH="/usr/local/cuda-${_CUDAVER}/bin:$PATH"
|
482 |
+
|
483 |
+
export LD_LIBRARY_PATH="/usr/local/TensorRT-${_TRTVER}/lib:${LD_LIBRARY_PATH}"
|
484 |
+
export PATH="/usr/local/TensorRT-${_TRTVER}/bin:$PATH"
|
485 |
+
fi
|
486 |
+
|
487 |
+
progress "build sample apps"
|
488 |
+
|
489 |
+
# quit on error
|
490 |
+
set -e
|
491 |
+
|
492 |
+
# build samples referencing the read-only source
|
493 |
+
cd $_INSTALLDIR
|
494 |
+
|
495 |
+
${CMAKE:-cmake} \
|
496 |
+
-DCMAKE_BUILD_TYPE=$_BUILD_TYPE \
|
497 |
+
$_INSTALLDIR/source
|
498 |
+
|
499 |
+
make -k
|
500 |
+
|
501 |
+
# copy easy-run shell scripts to cmake dir
|
502 |
+
# need one copy of setup_env.sh
|
503 |
+
cp $SAMPDIR/samples/*/run*.sh $_INSTALLDIR
|
504 |
+
cp $SAMPDIR/samples/BodyTrack/setup_env.sh $_INSTALLDIR
|
505 |
+
|
506 |
+
|
507 |
+
echo ""
|
508 |
+
echo "the sample apps have been created"
|
509 |
+
echo "If you used sudo permissions to execute this build_samples.sh script"
|
510 |
+
echo "please use sudo permissions when trying out the samples below as well"
|
511 |
+
echo "You can try the samples using:"
|
512 |
+
echo " cd $_INSTALLDIR"
|
513 |
+
/bin/ls -1 run*.sh | awk '{print " ./"$0}'
|
514 |
+
echo "or follow the instructions in the documentation found in:"
|
515 |
+
echo " $SAMPDIR/samples/doc"
|
516 |
+
echo ""
|
517 |
+
echo "you can modify the sources in $_INSTALLDIR/source and rebuild:"
|
518 |
+
echo " cd $_INSTALLDIR"
|
519 |
+
echo " $CMAKE $_INSTALLDIR/source"
|
520 |
+
echo " make"
|
521 |
+
fi
|