#!/bin/bash
# parses the lens ".ini" files generated by hugin
# and appends the info to "lenses.txt" file used by "calibrate.py"

for file in *.ini
do
  grep '^\(a\|b\|c\|FocalLength\)=[0-9.-]' "$file" \
    | tr '\n' ' ' \
    | sed 's/a=\([0-9.-]*\) b=\([0-9.-]*\) c=\([0-9.-]*\) FocalLength=\([0-9.-]*\) */distortion(\4mm) = \1, \2, \3\n/' \
    >>lenses.txt
done


