#!/bin/bash

# Input variables.
GT_LMDB=/mnt/flashblade/vision_lidar_transfer_metrics/data/20161114T232354-kitt_01-2016_10_20-2016_11_14-1479166875.0-1479166890.0-0.3/20161114T232354-kitt_01-2016_10_20-2016_11_14-1479166875.0-1479166890.0-0.3.lmdb
PERC_LMDB=/mnt/flashblade/vision_lidar_transfer_metrics/metrics_datasets_v2/20161114T232354-kitt_01-2016_10_20-2016_11_14-1479166875.0-1479166890.0-0.3/VL2_min_coverage.detection.lmdb
DET_METRICS_LMDB=/mnt/flashblade/vision_lidar_transfer_metrics/metrics_datasets_v2/20161114T232354-kitt_01-2016_10_20-2016_11_14-1479166875.0-1479166890.0-0.3/VL2_min_coverage.metrics.lmdb

# HTML reports will be written to this path.
BASE_DIR=/home/praveen/data/det_report/
CATEGORY=car
BASE_CATEGORY_PATH=$BASE_DIR/$CATEGORY/
GT_IMAGES_DIR=$BASE_CATEGORY_PATH/gt_images/
DET_IMAGES_DIR=$BASE_CATEGORY_PATH/det_images/

mkdir -p $GT_IMAGES_DIR
bazel run //lidar/metrics:detection_viewer -- --ground_truth_lmdb=$GT_LMDB --perception_lmdb=$PERC_LMDB --detection_metrics_lmdb=$DET_METRICS_LMDB --object_class_name=$CATEGORY  --initial_layer_type=ground_truth --logtostderr=1 --image_output_directory $GT_IMAGES_DIR --iteration_mode per_object

mkdir -p $DET_IMAGES_DIR
bazel run //lidar/metrics:detection_viewer -- --ground_truth_lmdb=$GT_LMDB --perception_lmdb=$PERC_LMDB --detection_metrics_lmdb=$DET_METRICS_LMDB --object_class_name=$CATEGORY  --initial_layer_type=detections --logtostderr=1 --image_output_directory $DET_IMAGES_DIR --iteration_mode per_object

bazel run //experimental/praveen/detection_metrics_report:detection_metrics_report_generator -- --class_name=$CATEGORY --detection_files_path=$BASE_DIR/$CATEGORY --output_directory $BASE_CATEGORY_PATH

for f in $(ls $BASE_CATEGORY_PATH/*.proto); do
  html_file=$(echo $f | sed 's/proto/html/g')
  echo $html_file
  bazel run //base/report:report_generator -- --input $f --output $html_file
done
