#!/bin/bash
# Test script for visualizing heading errors


# Set PYTHONPATH to project root for module imports
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
export PYTHONPATH="${PROJECT_ROOT}:${PYTHONPATH}"
echo "========================================="

echo "Heading Error Visualization Test"
echo "========================================="
echo ""

INPUT_FILE="bad_heading_cases_top50.json"
IMAGE_ROOT="/path/to/your/image/root"  # UPDATE THIS
OUTPUT_DIR="runs/heading_viz_test"

# Check if input file exists
if [ ! -f "$INPUT_FILE" ]; then
    echo "Error: Input file not found: $INPUT_FILE"
    echo "Please run extract_bad_heading_cases.py first"
    exit 1
fi

echo "Test 1: Generate all visualization types (first 10 cases)"
echo "-----------------------------------------------------"
python eval_tools/heading_analysis/visualize_heading_errors.py \
    --input "$INPUT_FILE" \
    --image-root "$IMAGE_ROOT" \
    --output "$OUTPUT_DIR/all_viz" \
    --max-cases 10 \
    --viz-types bev image angle combined

echo ""
echo ""
echo "Test 2: Generate only BEV views (first 20 cases)"
echo "-----------------------------------------------------"
python eval_tools/heading_analysis/visualize_heading_errors.py \
    --input "$INPUT_FILE" \
    --image-root "$IMAGE_ROOT" \
    --output "$OUTPUT_DIR/bev_only" \
    --max-cases 20 \
    --viz-types bev

echo ""
echo ""
echo "Test 3: Generate combined views (first 5 cases, high DPI)"
echo "-----------------------------------------------------"
python eval_tools/heading_analysis/visualize_heading_errors.py \
    --input "$INPUT_FILE" \
    --image-root "$IMAGE_ROOT" \
    --output "$OUTPUT_DIR/combined_hq" \
    --max-cases 5 \
    --viz-types combined \
    --dpi 150

echo ""
echo "========================================="
echo "All tests complete!"
echo "Output directory: $OUTPUT_DIR"
echo "========================================="
