Diff for scripts/shell/sms/sms.markiza.sk/aocr.sh between version 1.1 and 1.2
| version 1.1, 2002/05/26 17:24:13 |
version 1.2, 2002/09/10 23:24:11 |
|
|
| #!/bin/bash |
#!/bin/sh |
| #-------------------------------------------------------#----------------------# |
#-------------------------------------------------------#----------------------# |
| # Author : Maros RAJNOCH # GNU LINUX # |
# Author : Maros RAJNOCH # GNU LINUX # |
| # Email : rajnoch@sophia.dtp.fmph.uniba.sk # .~. # |
# Email : rajnoch@sophia.dtp.fmph.uniba.sk # .~. # |
|
|
| # Examples : aocr img.png # ^`~'^ # |
# Examples : aocr img.png # ^`~'^ # |
| # Version : ${version} # B E F R E E # |
# Version : ${version} # B E F R E E # |
| #=======================================================#======================# |
#=======================================================#======================# |
| VERSION='0.002' |
|
| USAGE=`cat <<EOU |
# |
| AOCR - Version ${VERSION}^G |
# Heavily patched by Ondrej Jombik <nepto@pobox.sk> at 11th September 2002 |
| |
# Copyright (c) 2002 Platon SDG, http://www.platon.sk/ |
| Usage: aocr <picture> |
# Note, that `perl' is needed, but it should work fine anyway. |
| aocr <picture> -d |
# |
| aocr <picture> -d -v |
|
| |
VERSION='0.002.platon' |
| where: -d DEBUGE MOD |
|
| -v VERBOSE MOD |
# |
| EOU |
# Help printing |
| ` |
# |
| PICTURE="${1?$USAGE}" |
|
| |
if [ "X$1" = "X" ]; then |
| |
echo " |
| |
AOCR - Version ${VERSION} |
| |
|
| |
Usage: aocr <picture> |
| |
aocr <picture> -d |
| |
aocr <picture> -d -v |
| |
|
| |
where: -d DEBUGE MOD |
| |
-v VERBOSE MOD |
| |
" |
| |
exit; |
| |
fi |
| |
|
| |
# |
| |
# Input parameters parsing |
| |
# |
| |
|
| |
PICTURE="$1"; |
| |
DEBUG="0"; |
| |
VERBOSE="0"; |
| |
if [ "X$2" == "X-d" ]; then DEBUG="1"; fi |
| |
if [ "X$2" == "X-v" ]; then VERBOSE="1"; fi |
| |
|
| |
# |
| |
# Color tables |
| |
# |
| |
|
| FA0='4,6,4,4,4,4,6,4' ; FA1='2,3,10,10,1,1' ; FA2='2,4,5,4,4,5,5,3' |
FA0='4,6,4,4,4,4,6,4' ; FA1='2,3,10,10,1,1' ; FA2='2,4,5,4,4,5,5,3' |
| FA3='2,4,2,3,3,7,7,3' ; FA4='2,3,3,3,3,10,10,1' ; FA5='6,7,4,3,3,5,6,3' |
FA3='2,4,2,3,3,7,7,3' ; FA4='2,3,3,3,3,10,10,1' ; FA5='6,7,4,3,3,5,6,3' |
| FA6='6,8,5,3,3,6,6,2' ; FA7='3,4,3,3,3,3,4,3' ; FA8='3,7,7,3,3,7,7,3' |
FA6='6,8,5,3,3,6,6,2' ; FA7='3,4,3,3,3,3,4,3' ; FA8='3,7,7,3,3,7,7,3' |
| FA9='2,6,6,3,3,5,8,6' |
FA9='2,6,6,3,3,5,8,6' |
| |
|
| ############## F R E K V E N C N A A N A L Y Z A F A R B Y ############### |
# |
| |
# Frequency color analyse |
| |
# |
| |
|
| FACLR=$( convert ${PICTURE} txt:- |\ |
FACLR=$( convert ${PICTURE} txt:- |\ |
| cut -d'#' -f2 |\ |
cut -d'#' -f2 |\ |
| sort |\ |
sort |\ |
| uniq -c |\ |
uniq -c |\ |
| sort -rn |\ |
sort -rn |\ |
| sed -n '2p' |\ |
sed -n '2p' |\ |
| cut -d' ' -f2 |
sed 's/^ *//g' |\ |
| |
cut -f2 |\ |
| |
sed 's/...$//g' |
| ) |
) |
| |
|
| ############## F R E K V E N C N A A N A L Y Z A F O N T U ############### |
if [ "X$DEBUG" = "X1" ]; then |
| |
echo "FACLR = $FACLR"; |
| |
fi |
| |
|
| |
# |
| |
# Frequency font analyse |
| |
# |
| |
|
| FAFNT=$( convert "${PICTURE}" txt:- |\ |
FAFNT=$( convert "${PICTURE}" txt:- |\ |
| egrep "${FACLR}" |\ |
egrep "${FACLR}" |\ |
| cut -d: -f1 |\ |
cut -d: -f1 |\ |
| cut -d, -f1 |\ |
cut -d, -f1 |\ |
| sort -n |\ |
sort -n |\ |
| uniq -c |\ |
uniq -c |\ |
| cut -d' ' -f1 |\ |
perl -a -e'while(<>){split;$__.=",".$_[0];}print"$__\n"' |\ |
| sed -e 's/ */,/g' |\ |
sed -e 's/^,*//' |
| tr -d '\n' |\ |
|
| sed -e 's/^,//' |
|
| ) |
) |
| |
|
| |
if [ "X$DEBUG" = "X1" ]; then |
| |
echo "FAFNT = $FAFNT"; |
| |
fi |
| |
|
| |
# |
| |
# Comparing analysed data with color table |
| |
# |
| |
|
| indexa=10 |
indexa=10 |
| while [ "$((indexa-=1))" -ge "0" ]; do |
while [ "$((indexa-=1))" -ge "0" ]; do |
| maska="FA${indexa}" ; eval maska=\$$maska |
maska="FA${indexa}" ; eval maska=\$$maska |
| Line 68 while [ "$((indexc-=1))" -ge "0" ]; do |
|
| Line 113 while [ "$((indexc-=1))" -ge "0" ]; do |
|
| echo "${FAFNT}" | egrep "${maska:4}$" &> /dev/null && break |
echo "${FAFNT}" | egrep "${maska:4}$" &> /dev/null && break |
| done |
done |
| |
|
| # D E B U G E R E Z I M |
# |
| if [ "$2" == "-d" ]; then |
# Additional debug info |
| |
# |
| |
|
| |
if [ "X$DEBUG" = "X1" ]; then |
| foo=foo.$$ |
foo=foo.$$ |
| |
|
| convert "${PICTURE}" txt:- |\ |
convert "${PICTURE}" txt:- |\ |
| Line 85 if [ "$2" == "-d" ]; then |
|
| Line 133 if [ "$2" == "-d" ]; then |
|
| rm -rf "${foo}" |
rm -rf "${foo}" |
| fi |
fi |
| |
|
| # V E R B O S E R E Z I M |
# |
| if [ "$3" == "-v" ]; then |
# Additional verbose info |
| |
# |
| |
|
| |
if [ "X$VERBOSE" = "X1" ]; then |
| echo "${FAFNT}" |
echo "${FAFNT}" |
| for index in "${indexa}" "${indexb}" "${indexc}" |
for index in "${indexa}" "${indexb}" "${indexc}" |
| do |
do |
| Line 95 if [ "$3" == "-v" ]; then |
|
| Line 146 if [ "$3" == "-v" ]; then |
|
| done |
done |
| fi |
fi |
| |
|
| |
# |
| |
# Output printing |
| |
# |
| |
|
| echo "$indexa$indexb$indexc" |
echo "$indexa$indexb$indexc" |
| exit 0 |
exit 0 |
| |
|
Platon Group <platon@platon.org> http://platon.org/
|
|