Extract the install that was applied by hand to the Jetson Nano into a single checkout that builds itself for whatever Jetson it lands on. The two nodes on the rig share no JetPack — tegra210 caps at 4, tegra234 needs 5+ — so nothing binary is portable between them. The source and the procedure are: install.sh detects the platform (L4T / JetPack / SoC), installs deps, builds the OrbbecSDK and the preview server from source locally, and generates a per-user config and systemd unit. The tested bridge.py ships verbatim; all machine-specific paths live in the generated config, so it stays unmodified — its one hardcoded path is made home-relative. The retired GStreamer/RTSP target is dropped: the direct route encodes no video. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
83 lines
2.7 KiB
Bash
Executable File
83 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Makes sure an OrbbecSDK v2 build exists for THIS platform, and prints where it
|
|
# is as OB_SDK_ROOT=... / OB_SDK_BUILD=... / OB_SDK_GENERATED=... for build_server.sh.
|
|
#
|
|
# Never ships a prebuilt binary between Jetsons: CUDA and glibc differ by
|
|
# generation, so the SDK is built from source on the machine that will run it.
|
|
# The heavy artifact stays out of git.
|
|
#
|
|
# Order of preference:
|
|
# 1. An existing build pointed to by $OB_SDK_ROOT — reused as-is. This is what
|
|
# keeps a working node (the Nano already has one) untouched.
|
|
# 2. A build at one of the known locations, likewise reused.
|
|
# 3. A fresh clone + build. On a new JetPack this is the step to watch; if it
|
|
# fails, build the SDK by hand once and re-run install.sh with OB_SDK_ROOT set.
|
|
set -euo pipefail
|
|
|
|
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
eval "$("$here/detect_platform.sh")"
|
|
|
|
# The official v2 source. Pinned loosely: a caller can override both to match a
|
|
# tag known to build on their JetPack.
|
|
SDK_REPO="${OB_SDK_REPO:-https://github.com/orbbec/OrbbecSDK_v2.git}"
|
|
SDK_REF="${OB_SDK_REF:-main}"
|
|
|
|
find_build() {
|
|
local root="$1"
|
|
[[ -f "$root/include/libobsensor/ObSensor.hpp" ]] || return 1
|
|
local b
|
|
b=$(ls -d "$root"/build/linux_* 2>/dev/null | head -1)
|
|
[[ -z "$b" ]] && b="$root/build"
|
|
[[ -f "$b/lib/libOrbbecSDK.so" ]] || return 1
|
|
echo "$b"
|
|
}
|
|
|
|
emit() {
|
|
local root="$1" build="$2"
|
|
echo "OB_SDK_ROOT=$root"
|
|
echo "OB_SDK_BUILD=$build"
|
|
echo "OB_SDK_GENERATED=$root/build/src/generated"
|
|
}
|
|
|
|
# 1 & 2: reuse whatever is already built.
|
|
for candidate in "${OB_SDK_ROOT:-}" \
|
|
"$HOME/OrbbecSDK_v2" \
|
|
"$HOME/OrbbecSDK_v2_jetson"; do
|
|
[[ -z "$candidate" ]] && continue
|
|
if b=$(find_build "$candidate" 2>/dev/null); then
|
|
echo ">> SDK deja bati, reutilise: $candidate" >&2
|
|
emit "$candidate" "$b"
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
# 3: clone + build from source.
|
|
root="${OB_SDK_ROOT:-$HOME/OrbbecSDK_v2}"
|
|
echo ">> Aucun SDK bati — clone et compilation (JetPack ${JETPACK}, ${SOC})" >&2
|
|
echo ">> ${SDK_REPO} @ ${SDK_REF} -> ${root}" >&2
|
|
|
|
if [[ ! -d "$root/.git" ]]; then
|
|
git clone --depth 1 --branch "$SDK_REF" "$SDK_REPO" "$root" >&2
|
|
fi
|
|
|
|
build="$root/build/linux_$(uname -m)"
|
|
mkdir -p "$build"
|
|
(
|
|
cd "$build"
|
|
# -DOB_BUILD_EXAMPLES=ON gives the k4a recorder sample used as recorder_bin.
|
|
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DOB_BUILD_EXAMPLES=ON >&2
|
|
make -j"$(nproc)" >&2
|
|
)
|
|
|
|
if ! b=$(find_build "$root" 2>/dev/null); then
|
|
cat >&2 <<EOF
|
|
|
|
!! La compilation du SDK ne s'est pas terminee comme attendu.
|
|
!! Bâtis-le une fois a la main, puis relance install.sh en pointant dessus :
|
|
!! OB_SDK_ROOT=<chemin> ./install.sh
|
|
EOF
|
|
exit 1
|
|
fi
|
|
echo ">> SDK bati: $b" >&2
|
|
emit "$root" "$b"
|