File size: 1,880 Bytes
9ad187e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# verify_all.sh [PxCy ...] -- run verify_alignment.py --expect 0 over captures, sequentially.
#
# Passes a real capture DIRECTORY, which is what verify_alignment.py needs. Passing a bare
# capture name used to fail as `FileNotFoundError: <name>/cameras.json`, which reads like a
# misalignment but is just a bad argument; the script now resolves bare names too, and this
# wrapper passes the resolved path explicitly.
#
# Writes one log per capture plus a summary table.
#     setsid nohup ./scripts/verify_all.sh > logs/verify.log 2>&1 < /dev/null &
set -uo pipefail

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BASE="$(dirname "$HERE")"
STAGING="${STAGING:-$BASE/staging}"
PY="${PY:-/home/szj/miniconda3/envs/omni_pose/bin/python}"
LOGDIR="$BASE/logs"; mkdir -p "$LOGDIR"

CAPTURES=("$@")
if [ ${#CAPTURES[@]} -eq 0 ]; then
  CAPTURES=(P1C1 P1C2 P2C1 P2C2 P3C1 P3C2 P4C1 P4C2 P5C2 P6C2)
fi

STAMP="$(date +%Y%m%d_%H%M%S)"
SUM="$LOGDIR/verify_summary_${STAMP}.txt"
: > "$SUM"

for c in "${CAPTURES[@]}"; do
  log="$LOGDIR/verify_${c}_${STAMP}.log"
  d="$STAGING/data/$c"
  if [ ! -f "$d/cameras.json" ]; then
    printf '%-6s NOT_STAGED\n' "$c" | tee -a "$SUM"; continue
  fi
  timeout 3600 "$PY" "$HERE/verify_alignment.py" "$d" --cams 6 12 --expect 0 > "$log" 2>&1
  rc=$?
  best=$(grep -o 'MEASURED: video_frame = fit_frame + ([+-][0-9]*)' "$log" | tail -1 \
         | grep -o '[+-][0-9]*' | tail -1)
  marg=$(grep -o 'margin over d=[+-][0-9]*: [0-9.]*' "$log" | tail -1 | awk '{print $NF}')
  case $rc in
    0) verdict="PASS d=${best:-?}" ;;
    1) verdict="FAIL d=${best:-?} (expected +0)" ;;
    2) verdict="INCONCLUSIVE d=${best:-?}" ;;
    124) verdict="TIMEOUT" ;;
    *) verdict="ERROR rc=$rc" ;;
  esac
  printf '%-6s %-28s margin=%-7s %s\n' "$c" "$verdict" "${marg:-n/a}" "$log" | tee -a "$SUM"
done

echo "VERIFY DONE" | tee -a "$SUM"