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

if [[ $# -lt 3 ]]; then
  echo "Usage: $0 <model(.trt|.onnx)> <input_image> <output_image> [detect_color] [conf] [nms]"
  exit 1
fi

MODEL_PATH="$1"
INPUT_IMAGE="$2"
OUTPUT_IMAGE="$3"
DETECT_COLOR="${4:-1}"
CONF_THRESHOLD="${5:-0.68}"
NMS_THRESHOLD="${6:-0.5}"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_ROOT="$(cd "${SCRIPT_DIR}/../../../../.." && pwd)"

cd "${WORKSPACE_ROOT}"
source ./install/setup.bash

ros2 run armor_yolo_detect trt_inference_test \
  "${MODEL_PATH}" \
  "${INPUT_IMAGE}" \
  "${OUTPUT_IMAGE}" \
  "${DETECT_COLOR}" \
  "${CONF_THRESHOLD}" \
  "${NMS_THRESHOLD}"
