-
Notifications
You must be signed in to change notification settings - Fork 0
/
dem_corr_eval.sh
executable file
·132 lines (106 loc) · 3.38 KB
/
dem_corr_eval.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/bash
# help
Help()
{
# Display Help
echo "Syntax: dem_corr_eval.sh -n pair_list "
echo "options:"
echo "n input file: list of pairs"
echo "h Print this Help."
echo "Carefull: asp_parameters.txt file must be in this directory"
echo
}
while getopts ":hvfn:" option; do
case $option in
h) # display Help
Help
exit;;
n) PAIRS=$OPTARG;;
\?) echo "Error: "$OPTARG "is an invalid option"
exit;;
esac
done
# Initial checkings
if [ -z $PAIRS ]; then { Help; exit 1; } fi
if [ ! -f "asp_parameters.txt" ]; then
echo "missing parameter file: asp_parameters.txt"
echo ; exit
fi
. ./asp_parameters.txt
# set home directory
ROOT=$PWD
TRISTEREO=FALSE
# check if stereo or tri-stereo
cols=`awk '{print NF}' $PAIRS | tail -n 1`
if [[ $cols -eq '6' ]]; then
TRISTEREO=TRUE
elif [[ $cols -eq '4' ]]; then
TRISTEREO=FALSE
else
echo "Invalid number of columns in input pair list file. Must be 4 (stereo) or 6 (tri-stereo)"
echo ; exit
fi
cat < $PAIRS | while true
do
read ligne
echo
echo "Processing...."
echo $ligne
if [ "$ligne" = "" ]; then break; fi
if [[ $TRISTEREO = 'TRUE' ]]; then
set -- $ligne ; DATE1=$1 ; NAME1=$2 ; DATE2=$3 ; NAME2=$4 ; DATE3=$5 ; NAME3=$6 ;
else
set -- $ligne ; DATE1=$1 ; NAME1=$2 ; DATE2=$3 ; NAME2=$4 ;
fi
cd $ROOT
# set output dir
OUTPUT_DIR=$ROOT/$NAME1"-"$NAME2
#############
# CORR EVAL #
#############
cd $OUTPUT_DIR
# set prefilter mode depending of stereo-algorithm
if [[ $ST_ALG == "asp_bm" ]]; then
PREF_MODE_EVAL="2"
else
PREF_MODE_EVAL="0"
fi
if [[ $TRISTEREO = 'TRUE' ]]; then
# compute corr_eval for each dem-pair in demPleiades
if [[ ! -f $OUTPUT_DIR"/demPleiades/dem-pair1/dem-ncc.tif" ]]; then
echo $OUTPUT_DIR/demPleiades/dem-pair1
cd $OUTPUT_DIR/demPleiades/dem-pair1
corr_eval --prefilter-mode $PREF_MODE_EVAL --kernel-size $CORR_KERNEL --metric ncc "1-L.tif" "1-R.tif" "1-F.tif" dem
fi
if [[ ! -f $OUTPUT_DIR"/demPleiades/dem-pair2/dem-ncc.tif" ]]; then
echo $OUTPUT_DIR/demPleiades/dem-pair2
cd $OUTPUT_DIR/demPleiades/dem-pair2
corr_eval --prefilter-mode $PREF_MODE_EVAL --kernel-size $CORR_KERNEL --metric ncc "2-L.tif" "2-R.tif" "2-F.tif" dem
fi
# compute corr_eval for each dem-pair in demPleiades-filt
if [[ ! -f $OUTPUT_DIR"/demPleiades-filt/dem-pair1/dem-ncc.tif" ]]; then
echo $OUTPUT_DIR/demPleiades-filt/dem-pair1
cd $OUTPUT_DIR/demPleiades-filt/dem-pair1
corr_eval --prefilter-mode $PREF_MODE_EVAL --kernel-size $CORR_KERNEL --metric ncc "1-L.tif" "1-R.tif" "1-F.tif" dem
fi
if [[ ! -f $OUTPUT_DIR"/demPleiades-filt/dem-pair2/dem-ncc.tif" ]]; then
echo $OUTPUT_DIR/demPleiades-filt/dem-pair2
cd $OUTPUT_DIR/demPleiades-filt/dem-pair2
corr_eval --prefilter-mode $PREF_MODE_EVAL --kernel-size $CORR_KERNEL --metric ncc "2-L.tif" "2-R.tif" "2-F.tif" dem
fi
else
# compute corr_eval in demPleiades
if [[ ! -f $OUTPUT_DIR"/demPleiades/dem-ncc.tif" ]]; then
echo $OUTPUT_DIR/demPleiades
cd $OUTPUT_DIR/demPleiades
corr_eval --prefilter-mode $PREF_MODE_EVAL --kernel-size $CORR_KERNEL --metric ncc "dem-L.tif" "dem-R.tif" "dem-F.tif" dem
fi
# compute corr_eval in demPleiades-filt
if [[ ! -f $OUTPUT_DIR"/demPleiades-filt/dem-ncc.tif" ]]; then
echo $OUTPUT_DIR/demPleiades-filt
cd $OUTPUT_DIR/demPleiades-filt
corr_eval --prefilter-mode $PREF_MODE_EVAL --kernel-size $CORR_KERNEL --metric ncc "dem-L.tif" "dem-R.tif" "dem-F.tif" dem
fi
fi
exit
done