Bug 59232

Summary: [NEW PORT] graphics/ocrad: OCR program implemented as filter, based on feature extraction method
Product: Ports & Packages Reporter: Ulrich Spoerlein <q>
Component: Individual Port(s)Assignee: Sergei Kolobov <sergei>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
ocrad-0.5.shar none

Description Ulrich Spoerlein 2003-11-12 22:10:11 UTC
GNU Ocrad is an OCR (Optical Character Recognition) program implemented
as a filter and based on a feature extraction method. It reads a bitmap
image in pbm format and outputs text in ISO-8859-1 (Latin-1) charset.
Also includes a layout analyser able to separate the columns or blocks
of text normally found on printed pages.
It can be used as a stand-alone console application, or as a backend to
other programs.

WWW: http://www.gnu.org/software/ocrad/ocrad.html

Generated with FreeBSD Port Tools 0.50
Comment 1 Sergei Kolobov freebsd_committer freebsd_triage 2003-11-15 23:18:22 UTC
Responsible Changed
From-To: freebsd-ports-bugs->sergei

I'll take it.
Comment 2 Sergei Kolobov freebsd_committer freebsd_triage 2003-11-15 23:27:53 UTC
The port fails to compile under 4.x:

g++ -Wall -W -O2 -c iso_8859_1.cc
In file included from iso_8859_1.cc:20:
iso_8859_1.h:103: syntax error before `!'
iso_8859_1.h:104: syntax error before `!'
iso_8859_1.h:105: syntax error before `!'
iso_8859_1.cc:129: syntax error before `('
*** Error code 1

Please investigate and provide a fix if possible.
In addition to that, please try to make the port respect
${CXX} and ${CXXFLAGS}.

Sergei
Comment 3 Sergei Kolobov freebsd_committer freebsd_triage 2003-11-15 23:31:24 UTC
State Changed
From-To: open->feedback

Asked submitter for feedback re: build problems on -STABLE.
Comment 4 Ulrich Spoerlein 2003-11-16 18:49:15 UTC
Sorry for not testing this port on 4-STABLE. Here is a new shar that
works on -STABLE and 5.1-RELEASE. However, I don't know much about
2.95's C++ vs. 3.2's C++. So if someone with more C++ knowledge could
look into the patches, thank you.

Ulrich Sp=F6rlein

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	ocrad
#	ocrad/Makefile
#	ocrad/distinfo
#	ocrad/files
#	ocrad/files/patch-configure
#	ocrad/files/patch-main.cc
#	ocrad/files/patch-Makefile.in
#	ocrad/files/patch-bitmap.cc
#	ocrad/files/patch-character.h
#	ocrad/files/patch-iso_8859_1.h
#	ocrad/files/patch-textline.cc
#	ocrad/pkg-descr
#	ocrad/pkg-plist
#
echo c - ocrad
mkdir -p ocrad > /dev/null 2>&1
echo x - ocrad/Makefile
sed 's/^X//' >ocrad/Makefile << 'END-of-ocrad/Makefile'
X# New ports collection makefile for:	graphics/ocrad
X# Date created:				12.11.2003
X# Whom:					Ulrich Spoerlein <q@uni.de>
X#
X# $FreeBSD$
X#
X
XPORTNAME=3D	ocrad
XPORTVERSION=3D	0.5
XCATEGORIES=3D	graphics
XMASTER_SITES=3D	${MASTER_SITE_GNU}
XMASTER_SITE_SUBDIR=3D	${PORTNAME}
X
XMAINTAINER=3D	q@uni.de
XCOMMENT=3D	OCR program implemented as filter, based on feature extractio=
n method
X
XUSE_BZIP2=3D	yes
XHAS_CONFIGURE=3D	yes
XUSE_GETOPT_LONG=3Dyes
X
XCONFIGURE_ARGS=3D	--prefix=3D${PREFIX}
XMAKE_ENV+=3D	CPPFLAGS=3D"${CPPFLAGS}" \
X		LDFLAGS=3D"${LDFLAGS}"
X
XINFO=3D	ocrad
X
X.include <bsd.port.mk>
END-of-ocrad/Makefile
echo x - ocrad/distinfo
sed 's/^X//' >ocrad/distinfo << 'END-of-ocrad/distinfo'
XMD5 (ocrad-0.5.tar.bz2) =3D 75bdfda680ddeede5dafa523a16c7191
END-of-ocrad/distinfo
echo c - ocrad/files
mkdir -p ocrad/files > /dev/null 2>&1
echo x - ocrad/files/patch-configure
sed 's/^X//' >ocrad/files/patch-configure << 'END-of-ocrad/files/patch-co=
nfigure'
X--- configure.orig	Mon Aug 25 00:07:09 2003
X+++ configure	Wed Nov 12 22:50:24 2003
X@@ -13,7 +13,7 @@
X while true ; do
X=20
X 	# Break out if there are no more args
X-	if [ $# =3D=3D 0 ]; then break ; fi
X+	if [ $# =3D 0 ]; then break ; fi
X=20
X 	# Get the first arg, and shuffle
X 	option=3D$1
X@@ -48,7 +48,7 @@
X=20
X # Find the source files, if location was not specified.
X srcdirtext=3D
X-if [ x${srcdir} =3D=3D x ]; then
X+if [ x${srcdir} =3D x ]; then
X 	srcdirtext=3D"or . or .." ; srcdir=3D.
X 	if [ ! -r ${srcdir}/${srctrigger} ] ; then srcdir=3D.. ; fi
X 	if [ ! -r ${srcdir}/${srctrigger} ] ; then
X@@ -65,7 +65,7 @@
X fi
X=20
X # Set srcdir to . if that's what it is.
X-if [ $(pwd) =3D=3D $(cd ${srcdir} ; pwd) ] ; then srcdir=3D. ; fi
X+if [ $(pwd) =3D $(cd ${srcdir} ; pwd) ] ; then srcdir=3D. ; fi
X=20
X # write variables to config file.
X rm -f Makefile
END-of-ocrad/files/patch-configure
echo x - ocrad/files/patch-main.cc
sed 's/^X//' >ocrad/files/patch-main.cc << 'END-of-ocrad/files/patch-main=
.cc'
X--- main.cc.orig	Sat Oct 18 01:27:29 2003
X+++ main.cc	Sun Nov 16 18:16:41 2003
X@@ -28,6 +28,7 @@
X #include <cstring>
X #include <vector>
X #include <getopt.h>
X+#include <libgen.h>
X #include "common.h"
X #include "rectangle.h"
X #include "bitmap.h"
X@@ -289,8 +290,8 @@
X     {
X     if( infile =3D=3D stdin )
X       {
X-      std::ungetc( std::getc( infile ), infile );
X-      if( std::feof( infile ) || std::ferror( infile ) ) infile =3D 0;
X+      ungetc( getc( infile ), infile );
X+      if( feof( infile ) || ferror( infile ) ) infile =3D 0;
X       }
X     while( infile !=3D stdin )
X       {
END-of-ocrad/files/patch-main.cc
echo x - ocrad/files/patch-Makefile.in
sed 's/^X//' >ocrad/files/patch-Makefile.in << 'END-of-ocrad/files/patch-=
Makefile.in'
X--- Makefile.in.orig	Sat Oct 18 01:29:16 2003
X+++ Makefile.in	Sun Nov 16 18:18:58 2003
X@@ -4,13 +4,14 @@
X=20
X DISTNAME =3D ocrad-0.5
X=20
X-CXX =3D g++
X-INSTALL =3D install
X-INSTALL_PROGRAM =3D $(INSTALL)
X-INSTALL_DATA =3D $(INSTALL) -m 644
X-SHELL =3D /bin/sh
X-CXXFLAGS =3D -Wall -W -O2
X-LDFLAGS =3D
X+CXX?=3D g++
X+INSTALL?=3D install
X+INSTALL_PROGRAM?=3D $(INSTALL)
X+INSTALL_DATA?=3D $(INSTALL) -m 644
X+SHELL?=3D /bin/sh
X+CXXFLAGS?=3D -Wall -W -O2
X+CPPFLAGS?=3D
X+LDFLAGS?=3D
X=20
X objs =3D common.o rectangle.o iso_8859_1.o bitmap.o block.o blockmap.o =
\
X        profile.o feats.o character.o recognize1.o \
X@@ -22,10 +23,10 @@
X all : ocrad
X=20
X ocrad : $(objs)
X-	$(CXX) $(LDFLAGS) $(CXXFLAGS) -o ocrad $(objs)
X+	$(CXX) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) -o ocrad $(objs)
X=20
X ocradp : $(objs)
X-	$(CXX) $(LDFLAGS) $(CXXFLAGS) -pg -o ocradp $(objs)
X+	$(CXX) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) -pg -o ocradp $(objs)
X=20
X %.o : %.cc
X 	$(CXX) $(CXXFLAGS) -c -o $@ $<
X@@ -42,6 +43,7 @@
X textline.o   : block.h character.h iso_8859_1.h textline.h
X textblock.o  : block.h character.h textline.h textblock.h
X main.o       : block.h blockmap.h bitmap.h character.h textline.h textb=
lock.h
X+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c main.cc
X=20
X=20
X install : all install-info
END-of-ocrad/files/patch-Makefile.in
echo x - ocrad/files/patch-bitmap.cc
sed 's/^X//' >ocrad/files/patch-bitmap.cc << 'END-of-ocrad/files/patch-bi=
tmap.cc'
X--- bitmap.cc.orig	Sun Nov 16 17:28:14 2003
X+++ bitmap.cc	Sun Nov 16 17:33:30 2003
X@@ -24,12 +24,11 @@
X #include "rectangle.h"
X #include "bitmap.h"
X=20
X-
X namespace {
X=20
X char pbm_getrawbyte( FILE * f ) throw( Bitmap::Error )
X   {
X-  int ch =3D std::getc( f );
X+  int ch =3D getc( f );
X=20
X   if( ch =3D=3D EOF )
X     throw Bitmap::Error( "end-of-file reading pbm file.\n" );
X@@ -58,7 +57,7 @@
X   char ch;
X   int i =3D 0;
X=20
X-  do ch =3D pbm_getc( f ); while( std::isspace( ch ) );
X+  do ch =3D pbm_getc( f ); while( isspace( ch ) );
X   if( !std::isdigit( ch ) )
X     throw Bitmap::Error( "junk in pbm file where an integer should be.\=
n" );
X   do { i =3D (i * 10) + (ch - '0'); ch =3D pbm_getc( f ); }
X@@ -71,7 +70,7 @@
X   {
X   char ch;
X=20
X-  do ch =3D pbm_getc( f ); while( std::isspace( ch ) );
X+  do ch =3D pbm_getc( f ); while( isspace( ch ) );
X=20
X   if( ch =3D=3D '0' ) return false;
X   if( ch =3D=3D '1' ) return true;
END-of-ocrad/files/patch-bitmap.cc
echo x - ocrad/files/patch-character.h
sed 's/^X//' >ocrad/files/patch-character.h << 'END-of-ocrad/files/patch-=
character.h'
X--- character.h.orig	Sun Nov 16 17:40:28 2003
X+++ character.h	Sun Nov 16 17:40:44 2003
X@@ -64,6 +64,7 @@
X   void swap_guesses( int i, int j ) throw();
X   const Guess & guess( int i ) const throw();
X   int guesses() const throw() { return _guess.size(); }
X+#undef isalnum
X   bool isalnum() const throw();
X=20
X   void join( Character & c ) throw();
END-of-ocrad/files/patch-character.h
echo x - ocrad/files/patch-iso_8859_1.h
sed 's/^X//' >ocrad/files/patch-iso_8859_1.h << 'END-of-ocrad/files/patch=
-iso_8859_1.h'
X--- iso_8859_1.h.orig	Sun Nov 16 17:14:19 2003
X+++ iso_8859_1.h	Sun Nov 16 17:33:51 2003
X@@ -100,6 +100,11 @@
X   static unsigned char base_letter( unsigned char ch ) throw();
X   static unsigned char compose( unsigned char base_letter,
X                                 unsigned char accent ) throw();
X+#undef isalnum
X+#undef isalpha
X+#undef isupper
X+#undef isvowel
X+#undef toupper
X   static bool isalnum( unsigned char ch ) throw();
X   static bool isalpha( unsigned char ch ) throw();
X   static bool isupper( unsigned char ch ) throw();
END-of-ocrad/files/patch-iso_8859_1.h
echo x - ocrad/files/patch-textline.cc
sed 's/^X//' >ocrad/files/patch-textline.cc << 'END-of-ocrad/files/patch-=
textline.cc'
X--- textline.cc.orig	Sun Nov 16 17:39:59 2003
X+++ textline.cc	Sun Nov 16 17:44:01 2003
X@@ -33,7 +33,7 @@
X   for( ; end < characters(); ++end )
X     {
X     Character & c =3D character( end );
X-    if( c.guesses() && std::isspace( c.guess(0).ch ) ) break;
X+    if( c.guesses() && isspace( c.guess(0).ch ) ) break;
X     }
X   return end;
X   }
X@@ -264,11 +264,11 @@
X     if( c1.guesses() =3D=3D 1 )
X       {
X       unsigned char ch =3D c1.guess( 0 ).ch;
X-      if( std::isspace( ch ) ) { begin =3D i + 1 ; continue; }
X+      if( isspace( ch ) ) { begin =3D i + 1 ; continue; }
X       if( ch !=3D 'c' && ch !=3D 'o' && ch !=3D 's' && ch !=3D 'u' && c=
h !=3D 'v' &&
X           ch !=3D 'w' && ch !=3D 'x' && ch !=3D 'z' ) continue;
X       if( 4 * c1.height() > 5 * mean_height() )
X-        { c1.only_guess( std::toupper( ch ), 0 ); continue; }
X+        { c1.only_guess( toupper( ch ), 0 ); continue; }
X       if( 5 * c1.height() < 4 * mean_height() ) continue;
X       for( int j =3D begin; j < characters(); ++j ) if( j !=3D i )
X         {
X@@ -276,12 +276,12 @@
X         if( c2.guesses() >=3D 1 )
X           {
X           unsigned char ch2 =3D c2.guess( 0 ).ch;
X-          if( std::isspace( ch2 ) ) break;
X-          if( ( std::isalpha( ch2 ) && 4 * c1.height() > 5 * c2.height(=
) ) ||
X-              ( ( std::isupper( ch2 ) || ch2 =3D=3D 'l' ) && ch2 !=3D '=
B' &&
X+          if( isspace( ch2 ) ) break;
X+          if( ( isalpha( ch2 ) && 4 * c1.height() > 5 * c2.height() ) |=
|
X+              ( ( isupper( ch2 ) || ch2 =3D=3D 'l' ) && ch2 !=3D 'B' &&
X                 ( c1.height() >=3D c2.height() ||
X                   Ocrad::similar( c1.height(), c2.height(), 10 ) ) ) )
X-            { c1.insert_guess( 0, std::toupper( ch ), 1 ); break; }
X+            { c1.insert_guess( 0, toupper( ch ), 1 ); break; }
X           }
X         }
X       }
X@@ -310,7 +310,7 @@
X     if( c1.guesses() >=3D 1 )
X       {
X       unsigned char ch =3D c1.guess( 0 ).ch;
X-      if( std::isspace( ch ) ) { begin =3D i + 1 ; continue; }
X+      if( isspace( ch ) ) { begin =3D i + 1 ; continue; }
X       if( ch <=3D 127 || c1.block_vector().size() < 2 ) continue;
X       int chb =3D ISO_8859_1::base_letter( ch );
X       if( chb !=3D 'o' && chb !=3D 'u' ) continue;
X@@ -323,11 +323,11 @@
X           unsigned char ch2 =3D c2.guess( 0 ).ch;
X           int ch2b =3D ISO_8859_1::base_letter( ch2 );
X           if( !ch2b && ch2 > 127 ) continue;
X-          if( std::isspace( ch2 ) ) break;
X-          if( ( std::isalpha( ch2 ) && 4 * b1.height() > 5 * c2.height(=
) ) ||
X-              ( std::isupper( ch2 ) && Ocrad::similar( b1.height(), c2.=
height(), 10 ) ) ||
X-              ( std::isalpha( ch2b ) && 4 * c1.height() > 5 * c2.height=
() ) ||
X-              ( std::isupper( ch2b ) && Ocrad::similar( c1.height(), c2=
.height(), 10 ) ) )
X+          if( isspace( ch2 ) ) break;
X+          if( ( isalpha( ch2 ) && 4 * b1.height() > 5 * c2.height() ) |=
|
X+              ( isupper( ch2 ) && Ocrad::similar( b1.height(), c2.heigh=
t(), 10 ) ) ||
X+              ( isalpha( ch2b ) && 4 * c1.height() > 5 * c2.height() ) =
||
X+              ( isupper( ch2b ) && Ocrad::similar( c1.height(), c2.heig=
ht(), 10 ) ) )
X             { c1.insert_guess( 0, ISO_8859_1::toupper( ch ), 1 ); break=
; }
X           }
X         }
X@@ -341,7 +341,7 @@
X     if( c1.guesses() >=3D 1 )
X       {
X       unsigned char ch =3D c1.guess( 0 ).ch;
X-      if( std::isspace( ch ) ) { begin =3D i + 1 ; continue; }
X+      if( isspace( ch ) ) { begin =3D i + 1 ; continue; }
X       if( ch !=3D 'o' && ch !=3D 'O' && ch !=3D 'l' ) continue;
X       for( int j =3D begin; j < characters(); ++j ) if( j !=3D i )
X         {
X@@ -349,8 +349,8 @@
X         if( c2.guesses() >=3D 1 )
X           {
X           unsigned char ch2 =3D c2.guess( 0 ).ch;
X-          if( std::isspace( ch2 ) ) break;
X-          if( std::isdigit( ch2 ) )
X+          if( isspace( ch2 ) ) break;
X+          if( isdigit( ch2 ) )
X             {
X             if( Ocrad::similar( c1.height(), c2.height(), 10 ) )
X               c1.insert_guess( 0, (ch =3D=3D 'l') ? '1' : '0', c1.guess=
(0).value + 1 );
X@@ -372,7 +372,7 @@
X       Character & c2 =3D character( i );
X       if( !c2.guesses() ) continue;
X       unsigned char ch =3D c2.guess( 0 ).ch;
X-      if( !std::isalnum( ch ) && ch !=3D '.' && ch !=3D '|' ) continue;
X+      if( !isalnum( ch ) && ch !=3D '.' && ch !=3D '|' ) continue;
X       switch( ch )
X         {
X         case 'g': case 'j': case 'p': case 'q': case 'y':
X@@ -426,14 +426,14 @@
X       if( i < characters() - 1 && character( i + 1 ).guesses() )
X         rch =3D character( i + 1 ).guess( 0 ).ch;
X       if( ISO_8859_1::isupper( rch ) &&
X-          ( !lch || ISO_8859_1::isupper( lch ) || std::isspace( lch ) )=
 )
X+          ( !lch || ISO_8859_1::isupper( lch ) || isspace( lch ) ) )
X         { c.insert_guess( 0, 'I', 1 ); continue; }
X       if( ch =3D=3D 'l' ) continue;
X       if( ISO_8859_1::isalpha( lch ) || ISO_8859_1::isalpha( rch ) )
X         { c.insert_guess( 0, 'l', 1 ); continue; }
X-      if( rch =3D=3D '|' && ( !lch || std::isspace( lch ) ) &&
X+      if( rch =3D=3D '|' && ( !lch || isspace( lch ) ) &&
X           i < characters() - 2 && character( i + 2 ).guesses() &&
X-          std::isalpha( character( i + 2 ).guess( 0 ).ch ) )
X+          isalpha( character( i + 2 ).guess( 0 ).ch ) )
X         { c.insert_guess( 0, 'l', 1 ); continue; }
X       }
X     }
X@@ -475,7 +475,7 @@
X     if( c.guesses() )
X       {
X       unsigned char ch =3D c.guess( 0 ).ch;
X-      if( std::isspace( ch ) ) { begin =3D i + 1 ; continue; }
X+      if( isspace( ch ) ) { begin =3D i + 1 ; continue; }
X       if( i =3D=3D begin && ch =3D=3D 'a' && c.guesses() =3D=3D 2 &&
X           c.guess( 1 ).ch =3D=3D 'Q' && 4 * c.height() > 5 * mean_heigh=
t() )
X         c.swap_guesses( 0, 1 );
X@@ -501,7 +501,7 @@
X     if( c1.guesses() )
X       {
X       unsigned char ch =3D c1.guess(0).ch;
X-      if( std::isspace( ch ) ) { begin =3D i + 1 ; continue; }
X+      if( isspace( ch ) ) { begin =3D i + 1 ; continue; }
X       if( c1.guesses() !=3D 2 || ch !=3D 'B' || c1.guess(1).ch !=3D 'a'=
 ) continue;
X       if( 4 * c1.height() > 5 * mean_height() ) continue;
X       for( int j =3D begin; j < characters(); ++j ) if( j !=3D i )
X@@ -510,9 +510,9 @@
X         if( c2.guesses() >=3D 1 )
X           {
X           unsigned char ch2 =3D c2.guess(0).ch;
X-          if( std::isspace( ch2 ) ) break;
X-          if( ( std::isalpha( ch2 ) && 5 * c1.height() < 4 * c2.height(=
) ) ||
X-              ( std::islower( ch2 ) &&
X+          if( isspace( ch2 ) ) break;
X+          if( ( isalpha( ch2 ) && 5 * c1.height() < 4 * c2.height() ) |=
|
X+              ( islower( ch2 ) &&
X                 ( c1.height() <=3D c2.height() ||
X                   Ocrad::similar( c1.height(), c2.height(), 10 ) ) ) )
X             { c1.swap_guesses( 0, 1 ); break; }
END-of-ocrad/files/patch-textline.cc
echo x - ocrad/pkg-descr
sed 's/^X//' >ocrad/pkg-descr << 'END-of-ocrad/pkg-descr'
XGNU Ocrad is an OCR (Optical Character Recognition) program implemented
Xas a filter and based on a feature extraction method. It reads a bitmap
Ximage in pbm format and outputs text in ISO-8859-1 (Latin-1) charset.
XAlso includes a layout analyser able to separate the columns or blocks
Xof text normally found on printed pages.
XIt can be used as a stand-alone console application, or as a backend to
Xother programs.
X
XWWW: http://www.gnu.org/software/ocrad/ocrad.html
END-of-ocrad/pkg-descr
echo x - ocrad/pkg-plist
sed 's/^X//' >ocrad/pkg-plist << 'END-of-ocrad/pkg-plist'
Xbin/ocrad
END-of-ocrad/pkg-plist
exit
Comment 5 Sergei Kolobov freebsd_committer freebsd_triage 2003-11-20 21:46:39 UTC
State Changed
From-To: feedback->closed

New port added, thanks!