[661691]: mac / matchpoint-complete-mac.sh Maximize Restore History

Download this file

matchpoint-complete-mac.sh    161 lines (132 with data), 4.5 kB

  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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
# Time-stamp: <2005-07-24 22:05:26 oliver>
# by Pablo d'Angelo <pablo.dangelo@web.de>
# modified by Ippei UKAI <ippei_ukai@mac.com> for HuginOSX
# Oliver Beckstein 2005-07-24 <orbeckst@gmail.com>
# - dirty hack to handle filenames with spaces
# (better: reimplement in perl/python)
# Adapted for matchpoint by Harry van der Wolf (hvdwolf@gmail.com)
set -e
myexit()
{
sleep 10
exit 1
}
# dirty hack to protect whitespace in filenames
# replace temporarily with ' ' -> '__SPACE__'
# (the same trick is later used to get quotes where they are supposed to be)
_SPACE='__SPACE__';
_QUOTE='__QUOTE__';
function protect_space () {
local a="${1}"
echo "${a}" | sed -e "s| |${_SPACE}|g";
}
function unprotect_space () {
local a="${1}"
echo "${a}" | sed -e "s|${_SPACE}| |g";
}
# Set this to the directory you installed autopano-sift into, for example
#AUTOPANO_PATH="/usr/local/lib/autopano-sift/bin"
# Do not use a trailing backslash. If the executebles are within your path
# (recommended, you can leave the line below).
AUTOPANO_PATH="`dirname \"$0\"`"
usage()
{
echo "usage: matchpoint-complete.sh [options] -o panoproject.pto image1 image2 [...]"
echo
echo " -o name filename of created panorama project"
echo
echo "[options]:"
# echo " -a path specifies path to the directory where"
# echo " autopano and matchpoint are."
echo " -s number downsize images until width and height is"
echo " smaller than number, default 700"
echo " -p number number of generated control points between,"
echo " each pair, default: 10"
echo " -n no ransac detection, useful for fisheye images"
echo " -c do not reuse keypoints detected in earlier runs,"
echo " deletes old keypoint files."
myexit
}
echo `basename "$0"` "$@"
echo "AUTOPANO_PATH = \"$AUTOPANO_PATH\""
#NARG=$#
#if [ $NARG -lt 2 ]; then
# usage
# exit 1
#fi
# dirty hack to protect space in filenames
protected_args="";
for a in "$@"; do
a=`protect_space "${a}"`;
protected_args="${protected_args} ${a}";
done
set -- ${protected_args}
#args=`getopt o:a:s:p:nch $*`
args=`getopt o:s:p:nch $*`
set -- $args
if [ $? != 0 ] ; then echo "Error! (parsing arguments failed)"; echo "Terminating..." >&2 ; myexit; fi
POINTS=10;
RANSAC=1;
CLEAN=0;
SIZE=800;
while true ; do
case "$1" in
-o) PANOFILE="`unprotect_space $2`"; shift 2;;
# -a) AUTOPANO_PATH=$2; shift 2;;
-s) SIZE=$2; shift 2;;
-p) POINTS=$2; shift 2 ;;
-n) RANSAC=0; shift 1;;
-c) CLEAN=1; shift 1;;
-h) usage; shift 1;;
--) shift ; break ;;
*) echo "Command line parsing error at: $1" ; myexit ;;
esac
done
echo "Remaining arguments ($#):"
for arg do echo '--> '"\`$arg'" ; done
# Allow user to override temporary directory.
TMP=${TMPDIR:-/tmp}
if [ ! -f "$AUTOPANO_PATH/matchpoint" ]
then echo error "Cannot locate matchpoint in $AUTOPANO_PATH"; myexit; fi
if [ ! -f "$AUTOPANO_PATH/autopano" ]
then echo error "Cannot locate autopano in $AUTOPANO_PATH"; myexit; fi
# DEBUGGING: set -x
# bring back space only when filename complete
# (bash quoting sucks---rewrite in perl or whatever)
KEYFILES=""
for arg do
FILENAME="$(basename $arg).key.gz"
# keep space-protected filenames in KEYFILES
# (unprotect only when needed at end):
KEYFILES="$KEYFILES $FILENAME"
# unprotect filenames which are needed NOW:
FILENAME="`unprotect_space ${FILENAME}`"
arg="`unprotect_space ${arg}`"
if [ -f "$FILENAME" ]; then
if [ $CLEAN -ne 0 ]; then
echo "\"$AUTOPANO_PATH/matchpoint\" \"$arg\" \"$FILENAME\""
"$AUTOPANO_PATH/matchpoint" "$arg" "$FILENAME"
else
echo "Using previously generated keypoint file: $FILENAME"
fi
else
echo "\"$AUTOPANO_PATH/matchpoint\" \"$arg\" \"$FILENAME\""
"$AUTOPANO_PATH/matchpoint" "$arg" "$FILENAME"
fi
done
echo "keyfiles (space protected): $KEYFILES"
ARG="--ransac $RANSAC --maxmatches $POINTS";
echo "\"$AUTOPANO_PATH/autopano\" $ARG \"$PANOFILE\" $KEYFILES"
# splice in KEYFILES with spaces
cmd="\"$AUTOPANO_PATH/autopano\" $ARG \"$PANOFILE\""
keys=""
# use __QUOTE__ and __SPACE__ to build final commandline
for k in ${KEYFILES}; do
keys="${keys} ${_QUOTE}${k}${_QUOTE}"
done;
cmd=`echo "${cmd} ${keys}" | sed -e "s|${_QUOTE}|\"|g" -e "s|${_SPACE}| |g"`
echo "Final command: '${cmd}"
sleep 3;
eval "${cmd}"
sleep 3;