#!/usr/bin/env bash
set -euo pipefail

if [ "$#" -lt 1 ]; then
  echo "usage: $0 /path/to/video.mp4 [output_dir]" >&2
  exit 2
fi

cd "$(dirname "$0")"
video_path="$1"
output_dir="${2:-output}"

if [ -z "${WATRIX_GAIT_API_KEY:-}" ]; then
  echo "请先设置 WATRIX_GAIT_API_KEY" >&2
  exit 2
fi

./build/local_video_sequence_extractor "$video_path"

video_name="$(basename "$video_path")"
video_stem="${video_name%.*}"
sequence_root="${video_stem}_gait_sequences"

mkdir -p "$output_dir"
./build/watrix_gait_sequence_api_demo "$sequence_root" "$output_dir"

echo "结果目录: $(pwd)/$output_dir"
