@echo off
REM 3_pipeline_multiview.bat
REM Multi-camera ArUco detection and pose estimation pipeline

REM Example: 3 camera views
REM Usage: run_pipeline_multiview.bat

cd /d "%~dp0"

set ROBOT_JSON=..\robot.json
set OUT_DIR=.

REM Camera 1
set IMG_1=render_1a.png
set NPZ_1=render.npz
set CAM_ID_1=cam1

REM Camera 2 (example - you need actual second camera image)
set IMG_2=render_1b.png
set NPZ_2=render.npz
set CAM_ID_2=cam2

REM Camera 3 (example)
set IMG_3=render_1c.png
set NPZ_3=render.npz
set CAM_ID_3=cam3



echo [STEP 1] Detect ArUco markers from all cameras
python 1_detect_aruco_observations.py -i %IMG_1% -npz %NPZ_1% -robot %ROBOT_JSON% -cameraId %CAM_ID_1% -outDir %OUT_DIR%
python 1_detect_aruco_observations.py -i %IMG_2% -npz %NPZ_2% -robot %ROBOT_JSON% -cameraId %CAM_ID_2% -outDir %OUT_DIR%
python 1_detect_aruco_observations.py -i %IMG_3% -npz %NPZ_3% -robot %ROBOT_JSON% -cameraId %CAM_ID_3% -outDir %OUT_DIR%

echo.
echo [STEP 2] Estimate camera poses from detections
python 2_estimate_camera_from_observations.py -i render_3a_aruco_detection.json -robot %ROBOT_JSON% -outDir %OUT_DIR%
python 2_estimate_camera_from_observations.py -i render_3b_aruco_detection.json -robot %ROBOT_JSON% -outDir %OUT_DIR%
python 2_estimate_camera_from_observations.py -i render_3c_aruco_detection.json -robot %ROBOT_JSON% -outDir %OUT_DIR%

echo.
echo [STEP 3] Triangulate marker positions from multi-view observations
python 3_multiview_bundle_adjustment_v6.py ^
  -det render_3a_aruco_detection.json ^
  -det render_3b_aruco_detection.json ^
  -det render_3c_aruco_detection.json ^
  -pose render_3a_camera_pose.json ^
  -pose render_3b_camera_pose.json ^
  -pose render_3c_camera_pose.json ^
  -robot %ROBOT_JSON%  -lambdaWeight 100.0

echo.
echo [DONE] Pipeline complete
