#! /bin/bash # Last edited on 2008-02-04 20:32:24 by stolfi usage="${0##*/}" # Reads from the directory "IAB-2002/raw-sorted" the file # "gridpoints.txt" which contains the raw refpoint data for all images. # After filtering that file through "cleanup-gridpoints", writes the # reference points for each image "{IMAGE}.jpg" listed in # "gridpoints.txt" to the file "{IMAGE}.grpts" under that same # directory. Also creates an image "{IMAGE}-g.jpg" showing the # reference points and the interpolated grid. # # The size of the grid is assumed to be stored in the file # "{IMAGE}.grsz" or "batch.grsz" in the same directory as the image # file. # if [ $# -ne 0 ]; then echo "usage: ${usage}"; exit 1; fi batroot="${STOLFIHOME}/projects/fragments/IAB-2002/raw-sorted" tools="${STOLFIHOME}/projects/fragments/IAB-2002/tools" # Set the following option to refine the points refine=0 ( cd ${batroot}/. ) function process_image () { imgname="$1"; shift; batname="${imgname%/*}" # echo "${imgname} ${batname}" imgfile="${batroot}/${imgname}.jpg" rawfile="${batroot}/${imgname}.grraw" ptsfile="${batroot}/${imgname}.grpts" mapfile="${batroot}/${imgname}.grmap" bszfile="${batroot}/${batname}/batch.grsz" iszfile="${batroot}/${imgname}.grsz" if [ ! -e ${imgfile} ]; then echo "image ${imgfile} doesnt exist"; exit 1; fi; if [ -e ${rawfile} ]; then # echo "replacing ${rawfile}" # rm -v "${rawfile}" rm "${rawfile}" fi; echo "writing ${rawfile}" while [ $# -gt 1 ]; do if [ $# -lt 6 ]; then echo "bad process_image call"; exit 1; fi pth="$1"; shift; ptv="$1"; shift; ptx="$1"; shift; pty="$1"; shift; ptz="$1"; shift; ptid="$1"; shift; printf " %6.1f %6.1f %6.1f %6.1f %6.1f %s\n" \ "${pth}" "${ptv}" "${ptx}" "${pty}" "${ptz}" "${ptid}" >> ${rawfile} done if [ ${refine} ]; then ${tools}/refine-refpoints ${imgfile} ${rawfile} ${ptsfile} else cp -p ${rawfile} ${ptsfile} fi # cat ${ptsfile} if [ "$1" != "eoi" ]; then echo "process_image - no \"eoi\""; exit 1; fi if [ -e ${mapfile} ]; then # echo "removing ${mapfile}" # rm -v "${mapfile}" rm "${mapfile}" fi; if [ -r ${iszfile} ]; then gridsize=`cat ${iszfile}`; elif [ -r ${bszfile} ]; then gridsize=`cat ${bszfile}`; else gridsize="10 10"; fi ${tools}/show-gridpoints ${imgname} ${gridsize} || exit 1 } function process_batch () { echo "--- end $1 ---" } tmpbash="/tmp/$$.bash" cd ${batroot} ${tools}/cleanup-gridpoints \ < ${batroot}/gridpoints.txt \ > ${tmpbash} || exit 1 source ${tmpbash} rm ${tmpbash}