#!/bin/sh
#
# Shape Recognition demo macro

usage() {
    echo "megawave_sr_demo (no option)"
    echo "input:  none"
    echo "output: shape recognition demonstration"
}

if [ $# -ne 0 ]; then
    usage
    exit 1
fi

TMP=/tmp/megawave-$USERNAME
BASEDIR=$TMP/base

SHARE=/usr/share/megawave
DATA=$SHARE/data

if [ ! -d $TMP ]; then
    if mkdir $TMP; then
        echo "$TMP directory created."
    else
        echo "Could not create $TMP directory !"
        exit 1
    fi
fi

echo "Building base"
megawave_clear_base
megawave_put_to_base $DATA/shape/f?.img 
megawave_read_base

echo "Trying to recognize f2"
megawave_recognize $DATA/shape/f2.img

echo "Trying to recognize rotated f1"
megawave frot -ftype IMG -b 255 -a 30 $DATA/shape/f1.img $TMP/f1.r30.img
megawave cview -x 0 -y 0 $DATA/shape/f1.img &
megawave cview -x 150 -y 0 $TMP/f1.r30.img &
megawave_recognize $TMP/f1.r30.img
rm -f $TMP/f1.r30.img

echo "Trying to recognize noisy f9"
megawave fnoise -ftype IMG -g 50 $DATA/shape/f9.img $TMP/f9_noisy.img
megawave cview -x 0 -y 225 $DATA/shape/f9.img &
megawave cview -x 100 -y 225 $TMP/f9_noisy.img &
megawave_recognize $TMP/f9_noisy.img
rm -f $TMP/f9_noisy.img

echo "Trying to recognize noisy rotated f4"
megawave frot -ftype IMG -b 255 -a 10 $DATA/shape/f4.img $TMP/f4.r10.img
megawave fnoise -ftype IMG -g 50 $TMP/f4.r10.img $TMP/f4_noisy.r10.img
megawave cview -x 0 -y 400 $DATA/shape/f4.img &
megawave cview -x 110 -y 400 $TMP/f4_noisy.r10.img &
megawave_recognize $TMP/f4_noisy.r10.img
rm -f $TMP/f4.*.img

echo "Trying to recognize an image not in base"
megawave_recognize $DATA/shape/f10.img







