B=0
TOT=0
TITLE="$(basename $PWD) - CAPTCHA test"
HEADER="<html><head><title>$TITLE</title><style>img.ans { border:red solid thin}</style><body>"
RESULTS=''
for i in *.png
	do
	ANSWER=`sed -e 's/image_\([a-z]*\)_.*$/\1/' <<<$i`
	A=`tesseract $i stdout -psm 8 -c tessedit_char_whitelist=abcdefghijklmnopqrstuvwxyz`
	RESULTS="$RESULTS <img src='$i' title='Answer: $ANSWER; OCR: ${A// /}' "
	if [ "${A// /}" == "$ANSWER" ]
		then RESULTS="$RESULTS class='ans' "
		B=$(($B+1))
	fi
	RESULTS="$RESULTS >"
	TOT=$(($TOT+1))
done

RESULTS="$RESULTS </body></html>"
echo $HEADER
echo "<h1>$TITLE</h1>"
echo "<p>$1</p>"
echo "<p>Note, this uses the DejaVuSans font, instead of the <i>FreeMonoBoldOblique.ttf</i> that Wikipedia currently uses</p>"
echo "<p><small>View other captcha tests: <a href="../setB">Current captcha</a> | <a href="../tim">Tim's proposal</a> | <a href="../img">Tim's captcha without gradiant</a> | <a href="../ocr">Current captcha with OCR rejection</a> | <a href="../setG/"> Using negative kerning and less harriness [Bawolff's proposal]</a> | <a href="../setF">Negative kerning and harriness</a></small></p>" 
echo "<p>Tesseract (off the shelf. No special training. Version 3.03 -psm 8. Later versions and -psm 13 may have slightly better results) success on this set is $B (out of $TOT) or <b>"
bc <<< "scale=1;$B*100/$TOT"
echo "%</b></p><hr>"
echo $RESULTS
