Browse Source

Automation of reconstruction using script added

Jérôme BUISINE 4 months ago
parent
commit
444e932810
1 changed files with 66 additions and 0 deletions
  1. 66 0
      reconstruct_png.sh

+ 66 - 0
reconstruct_png.sh

@@ -0,0 +1,66 @@
+#! /bin/bash
+
+if [ -z "$1" ]
+  then
+    echo "No argument supplied"
+    echo "Need data folder"
+    exit 1
+fi
+
+if [ -z "$2" ]
+  then
+    echo "No argument supplied"
+    echo "Need output folder"
+    exit 1
+fi
+
+if [ -z "$3" ]
+  then
+    echo "No argument supplied"
+    echo "Need step output images expected (step of samples)"
+    exit 1
+fi
+
+prefix="p3d_"
+build_folder="build"
+
+data_folder=$1
+output_folder=$2
+step=$3
+
+for folder_path in $(ls -d ${data_folder}*/)
+do
+  nb_elements=$(ls -l ${folder_path} | grep ${prefix} | wc -l)
+
+  IFS='/' read -ra ADDR <<< "${folder_path}"
+  folder=${ADDR[-1]}
+
+  # get output expected path
+  output_scene_path=$output_folder/$folder
+  output_scene_path_fixed=${output_scene_path//\/\//\/}
+
+  if [ ! -d "$output_scene_path_fixed" ]; then
+    # Control will enter here if $DIRECTORY doesn't exist.
+    
+    mkdir -p $output_scene_path_fixed
+
+    samples=$step
+
+    while [ $samples -le ${nb_elements} ]
+    do
+      suffix=$samples
+
+      while [ ${#suffix} -le 5 ]
+      do
+        suffix="0"${suffix}
+      done
+
+      # need to create `outfile` name
+      outfile="${folder}_${suffix}.png"
+      echo "$folder: [merge of ${samples} samples] into ${outfile}"
+
+      ./${build_folder}/main/rawls_merge --folder ${folder_path} --samples ${samples} --random 0 --outfile ${output_scene_path_fixed}/${outfile}
+      samples=$(( $samples + $step ))
+    done
+  fi
+done