#! /bin/bash # Last edited on 2008-02-04 20:32:33 by stolfi usage="${0##*/}" # Reads from the directory "IAB-2002/raw-sorted" the file # "lightballs.txt" which contains the raw centers of the bases of the # lighting calibration balls in all images. After filtering that file through # "cleanup-objcenters", writes the ball centers for each image # "{IMAGE}.jpg" listed in "lightballs.txt" to file "{IMAGE}.balls" # Also creates an image "{IMAGE}-y.jpg" showing the patch centers # and their labels. 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" ( cd ${batroot}/. ) function process_image () { imgname="$1"; shift; batname="${imgname%/*}" # echo "${imgname} ${batname}" imgfile="${batroot}/${imgname}.jpg" ctrfile="${batroot}/${imgname}.balls" if [ ! -e ${imgfile} ]; then echo "image ${imgfile} doesnt exist"; exit 1; fi; if [ -e ${ctrfile} ]; then # echo "replacing ${ctrfile}" # rm -v "${ctrfile}" rm "${ctrfile}" fi; echo "writing ${ctrfile}" while [ $# -gt 1 ]; do if [ $# -lt 6 ]; then echo "bad process_image call"; exit 1; fi bah="$1"; shift; bav="$1"; shift; bax="$1"; shift; bay="$1"; shift; baz="$1"; shift; baid="$1"; shift; printf " %6.1f %6.1f %6.1f %6.1f %6.1f %s\n" \ "${bah}" "${bav}" "${bax}" "${bay}" "${baz}" "${baid}" >> ${ctrfile} done # cat ${ctrfile} if [ "$1" != "eoi" ]; then echo "process_image - no \"eoi\""; exit 1; fi ${tools}/show-lightballs ${imgname} || exit 1 } function process_batch () { echo "--- end $1 ---" } tmpbash="/tmp/$$.bash" cd ${batroot}/. ${tools}/cleanup-objcenters \ -f ${tools}/r3x3.gawk \ < ${batroot}/lightballs.txt \ > ${tmpbash} || exit 1 source ${tmpbash} rm ${tmpbash}