The recorder does not load the stock libk4a/libk4arecord. It dlopens a single custom libk4arecord_v2.so: the wrapper's MKV-writing sources linked to a pure-data shim (k4a_shim.cpp) instead of libk4a, so recording has no OrbbecSDK dependency. That target is FTF's own (wrapper/recordv2/), absent from the stock wrapper the Orin carried — so ship it and inject+build it, the same pattern as the recorder in the SDK examples tree. Idempotent; only added when missing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
99 lines
3.7 KiB
Bash
Executable File
99 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Makes sure the Orbbec K4A wrapper is built for THIS platform, INCLUDING FTF's
|
|
# libk4arecord_v2.so, and prints K4A_WRAPPER_DIR=... for build_sdk.sh (the recorder
|
|
# example needs the headers) and for the recorder's runtime rpath.
|
|
#
|
|
# This is the libk4a provider — Orbbec's own, NOT Microsoft's Azure Kinect SDK. It
|
|
# bundles its own OrbbecSDK, so it builds standalone.
|
|
#
|
|
# The recorder does not dlopen the stock libk4a/libk4arecord. It dlopens a single
|
|
# custom library, libk4arecord_v2.so: the wrapper's own MKV-writing sources linked
|
|
# to a pure-data shim (k4a_shim.cpp) instead of libk4a — K4A-compatible recording
|
|
# with no OrbbecSDK dependency. That target is FTF's (wrapper/recordv2/ in this
|
|
# repo), not part of the stock wrapper, so it is injected and built here.
|
|
#
|
|
# Reuses an existing build; only adds the v2 target if it is missing.
|
|
set -euo pipefail
|
|
|
|
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
repo=$(cd "$here/.." && pwd)
|
|
eval "$("$here/detect_platform.sh")"
|
|
|
|
REPO_URL="${OB_K4A_REPO:-https://github.com/orbbec/OrbbecSDK-K4A-Wrapper}"
|
|
REF="${OB_K4A_REF:-v1.10.4}"
|
|
|
|
# A usable wrapper base: headers and the stock libk4a. The v2 target is ensured
|
|
# separately, so a wrapper built before this repo existed still qualifies.
|
|
find_wrapper() {
|
|
local d="$1"
|
|
[[ -f "$d/include/k4a/k4a.h" ]] || return 1
|
|
[[ -f "$d/build/lib/libk4a.so" ]] || return 1
|
|
echo "$d"
|
|
}
|
|
|
|
# Injects FTF's recordv2 sources and builds libk4arecord_v2.so if it is not there.
|
|
# Idempotent: the add_subdirectory line and the copy are guarded.
|
|
ensure_recordv2() {
|
|
local d="$1"
|
|
[[ -f "$d/build/lib/libk4arecord_v2.so" ]] && return 0
|
|
|
|
echo ">> libk4arecord_v2.so absent — injection de recordv2 et compilation…" >&2
|
|
local dst="$d/src/orbbec/recordv2"
|
|
mkdir -p "$dst"
|
|
cp "$repo/wrapper/recordv2/CMakeLists.txt" "$dst/"
|
|
cp "$repo/wrapper/recordv2/k4a_shim.cpp" "$dst/"
|
|
|
|
local ob_cmake="$d/src/orbbec/CMakeLists.txt"
|
|
if [[ -f "$ob_cmake" ]] && ! grep -q "add_subdirectory(recordv2)" "$ob_cmake"; then
|
|
echo "add_subdirectory(recordv2)" >> "$ob_cmake"
|
|
fi
|
|
|
|
( cd "$d/build"
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release >&2
|
|
make -j"$(nproc)" k4arecord_v2 >&2 )
|
|
|
|
[[ -f "$d/build/lib/libk4arecord_v2.so" ]]
|
|
}
|
|
|
|
# 1 & 2: reuse a wrapper base, then make sure the v2 target is present.
|
|
for candidate in "${K4A_WRAPPER_DIR:-}" \
|
|
"$HOME/OrbbecSDK-K4A-Wrapper" \
|
|
"$HOME/Downloads/OrbbecSDK-K4A-Wrapper"; do
|
|
[[ -z "$candidate" ]] && continue
|
|
if find_wrapper "$candidate" >/dev/null 2>&1; then
|
|
echo ">> Wrapper K4A trouve: $candidate" >&2
|
|
if ensure_recordv2 "$candidate"; then
|
|
echo "K4A_WRAPPER_DIR=$candidate"
|
|
exit 0
|
|
fi
|
|
echo "!! libk4arecord_v2.so n'a pas pu etre bati dans $candidate" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# 3: clone + build the wrapper base, then the v2 target.
|
|
dir="${K4A_WRAPPER_DIR:-$HOME/OrbbecSDK-K4A-Wrapper}"
|
|
echo ">> Wrapper K4A absent — clone et compilation (JetPack ${JETPACK}, ${SOC})" >&2
|
|
echo ">> ${REPO_URL} @ ${REF} -> ${dir}" >&2
|
|
|
|
if [[ ! -d "$dir/.git" ]]; then
|
|
git clone --recursive --depth 1 --branch "$REF" "$REPO_URL" "$dir" >&2
|
|
fi
|
|
|
|
mkdir -p "$dir/build"
|
|
( cd "$dir/build"
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release >&2
|
|
make -j"$(nproc)" k4a k4arecord >&2 )
|
|
|
|
if ! find_wrapper "$dir" >/dev/null 2>&1 || ! ensure_recordv2 "$dir"; then
|
|
cat >&2 <<EOF
|
|
|
|
!! La compilation du wrapper K4A (ou de libk4arecord_v2.so) a echoue dans $dir.
|
|
!! Bâtis-le une fois a la main, puis relance install.sh avec :
|
|
!! K4A_WRAPPER_DIR=$dir ./install.sh
|
|
EOF
|
|
exit 1
|
|
fi
|
|
echo ">> Wrapper K4A + libk4arecord_v2.so batis: $dir" >&2
|
|
echo "K4A_WRAPPER_DIR=$dir"
|