From 347d237638a2e2adcdf450dc9b8f5cb4d56ed579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rostislav=20L=C3=A1n?= Date: Mon, 6 Mar 2023 16:55:56 +0100 Subject: [PATCH] Added script to automate fingerprint filtration and stl generation. --- test.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 test.sh diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..e99e23f --- /dev/null +++ b/test.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# test script to apply filters to all files in a directory +# author: Rostislav Lán + +# activate virtual environment +source .venv/bin/activate + +#----------------------------Settings------------------------------# + +# place all image files to one folder +input_path=res/test/ZK10R/p* +exec_path=src/main.py + +# this is very important, run this on directories containing files with the same dpi!!!!!!!!!!!!!!!!!! +dpi=500 + +# reccomend png, it's supported by opencv +format=png + +# name of configuration file +config_file=config/config-test.json + +# name of preset in conf. file +#presets=("strong" "test-weak" "test-repeat" "test-strong") +presets=("test-very-strong") + +generate_stl=false + +#----------------------------Application---------------------------# + +# function to apply filter to all files in directory +apply_filter() { + for file in ${file_arr[@]} + do + if test -f "$file" + then + in=$file + out="${in%%${match1}*}_$preset${match1}$format" + + # check if file already has one of the filter names in it + #if [[ " ${presets[*]} " =~ " ${preset} " ]]; then + # ((j++)) + # continue + #fi + ((i++)) + echo "File no. $i: $in" + if [[ "$generate_stl" = true ]]; then + echo "Generating STL" + echo $in + python3 $exec_path $in $out $dpi -c $config_file $1 --stl "${in%%${match1}*}_$preset${match1}stl" 3 10 -p || break + else + python3 $exec_path $in $out $dpi -c $config_file $1 || break + fi + else + echo "File $file does not exist" + fi + + done +} + +# for pattern matching in filenames +match1=. +match2=/ +i=0 +j=0 +file_arr=() + +# get all filenames in all directories +for file in $input_path/* +do + file_arr=("${file_arr[@]}" "$file") +done + +# apply all given presets to all the files +for preset in ${presets[@]} +do + echo -e "\n|-----------------------Filter "$preset"------------------------------|\n" + j=0 + apply_filter $preset $j + if [ ! "$j" -eq "0" ]; then + echo -e "Skipped $j files" + fi +done +echo "Processed $i files" \ No newline at end of file