reconstruct_png.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! /bin/bash
  2. if [ -z "$1" ]
  3. then
  4. echo "No argument supplied"
  5. echo "Need data folder"
  6. exit 1
  7. fi
  8. if [ -z "$2" ]
  9. then
  10. echo "No argument supplied"
  11. echo "Need output folder"
  12. exit 1
  13. fi
  14. if [ -z "$3" ]
  15. then
  16. echo "No argument supplied"
  17. echo "Need step output images expected (step of samples)"
  18. exit 1
  19. fi
  20. prefix="p3d_"
  21. build_folder="build"
  22. data_folder=$1
  23. output_folder=$2
  24. step=$3
  25. for folder_path in $(ls -d ${data_folder}*/)
  26. do
  27. nb_elements=$(ls -l ${folder_path} | grep ${prefix} | wc -l)
  28. IFS='/' read -ra ADDR <<< "${folder_path}"
  29. folder=${ADDR[-1]}
  30. # get output expected path
  31. output_scene_path=$output_folder/$folder
  32. output_scene_path_fixed=${output_scene_path//\/\//\/}
  33. if [ ! -d "$output_scene_path_fixed" ]; then
  34. # Control will enter here if $DIRECTORY doesn't exist.
  35. mkdir -p $output_scene_path_fixed
  36. samples=$step
  37. while [ $samples -le ${nb_elements} ]
  38. do
  39. suffix=$samples
  40. while [ ${#suffix} -le 5 ]
  41. do
  42. suffix="0"${suffix}
  43. done
  44. # need to create `outfile` name
  45. outfile="${folder}_${suffix}.png"
  46. echo "$folder: [merge of ${samples} samples] into ${outfile}"
  47. ./${build_folder}/main/rawls_merge --folder ${folder_path} --samples ${samples} --random 0 --outfile ${output_scene_path_fixed}/${outfile}
  48. samples=$(( $samples + $step ))
  49. done
  50. fi
  51. done