Clara OCR Developer's Guide

[Main] [FAQ] [Glossary] [Tutorial] [User's Manual] [Developer's Guide]

Welcome. Clara OCR is a free OCR, written for systems supporting the C library and the X Windows System. Clara OCR is intended for the cooperative OCR of books. There are some screenshots available at http://www.claraocr.org/. symbols depending on their geometry.

Build words and lines

Start building the words and lines. These heuristics will be applied on the current page or on all pages, depending on the state of the "Work on current page only" item of the Options menu.

Generate spelling hints

Obs. this is not implemented yet.

Start filtering through ispell to generate transliterations for unknow symbols or alternative transliterations for known symbols. Clara will use the dictionaries available for the languages selected on the Languages menu. Filtering will be performed on the current page or on all pages, depending on the state of the "Work on current page only" item of the Options menu.

Generate output

The OCR output is generated to be displayed on the "PAGE (output)" window. The output is also saved to the file page.html.

Generate web doubts

Files containing symbols to be revised through the web interface are created on the "doubts" subdirectory of the work directory. This step is performed only when Clara OCR is started with the -W command-line switch.

6. Reference of command-line switches
A number of internal variables now can be defined on the command-line. Variable names can be optionally preceded by '-'. If a value is absent, the default is 1. Examples:


    clara -pp_deskew
    clara pp_deskew
    clara pp_deskew=1
    clara -pp_deskew=1

    (apply deskewer)

    clara bin_method=3

    (use the classification-based, local thresholder)
To known about the variables that can be defined on the command line, see the source code, file clara.c, function checkvar().

-a bf_auto,st_auto,st_auto_global,classifier

Bookfont handling options

-b

Run in batch mode.

The application window will not be created, and the OCR will automatically execute a full OCR run on all pages (or on the page specified through -f).

-c N|c|black,gray,white,darkgray,vdgray

Choose the number of gray levels or the colors to be used by the GUI. To choose the number the colors AND the colors, this option must be used twice.

The Clara OCR GUI uses by default only five colors, internally called "white", "black", "gray", "darkgray" and "vdgray" ("very dark gray"). There are two predefined schemes to map these internal colors into RGB values: "c" (color) and the default (grayscale). Alternatively, the mapping may be explicited, informing the RGB values separated by commas. The notation #RRGGBB is not supported; RGB values must be specified through color names known by the xserver (e.g. "brown", "pink", "navyblue", etc, see the file /etc/X11R6/lib/X11/rgb.txt). The following example specify the default mapping:


    -c black,gray80,white,gray60,gray40
To simulate reverse video try:


    -c white,gray40,black,gray60,gray80
However, when displaying graymaps, the GUI may use more colors. On truecolor displays, the GUI uses by default 32 or 256 graylevels when displaying graymaps. On pseudocolor displays, 4 graylevels are used (in fact, the colors "black", "vdgray", "gray" and "white" are used, so the "graylevels" are not necessarily "gray"). To force only 4 graylevels on truecolor displays, use


    -c 4
To force black-and-white, use


    -c 2
(by now, '-c N' is useful mainly as a workaround for bad behaviour of the GUI on some display).

-D or -display

X Display to connect (by default read the environment variable DISPLAY).

-d

Run in debug mode. Debug messages will be sent to stderr. Debug messages are generated when an acceptable but not reasonable event is detected.

-e reviewer,type

Reviewer and reviewer type.

All revision data is assigned by Clara to its originator. By default the reviewer name is "nobody" and its type is "A".

The reviewer generally will be an email address or a nickname, The type may be T (trusted), A (arbiter) or N (anonymous). Example:


    -e ueda@ime.usp.br,T

-F fontname

The X font to use (must be a font with fixed column size, e.g. "fixed" or "9x15").

-f path

Scanned page or page directory. Defaults to the current directory.

The argument must be a pbm file (with absolute or relative path) or the path (absolute or relative) of the directory where the pbm file(s) was (were) placed.

-g wxh(+|-)x(+|-)y

X geometry.

-h

Display short help and exit.

-i

Emulate dead keys functionality.

-k list

Parameters SA,RR,MA,MP,ML,MB,RX,BT used to compute skeletons.

BUG: these parameters are ignored when a "patterns" already exists. In this case, Clara will read the parameters from the "patterns" file.

-N list

Switch off optimizations. Generally useful only for debug purposes. Non-supported displays depths (if any) may require '-N d'. The argument is the list of the (one or more) optimizations to switch off (s, a, j, q, c, x or d). Examples:


    -N s
    -N aq
    -N jq

-o t|h

Select output format (t=text, h=html). The default is HTML.

-P PNT1,PNT2,MD

Parameters for filtering symbol comparison.

PNT1 and PNT2 are the pixel number thresholds. These thresholds are used to filter out bad candidates when classifying symbols. The first threshold is for strong similarity and the second for weak similarity. The comparison algorithm performs two passes. The first pass uses PNT1 to filter. The second pass uses PNT2. So on the first pass only patterns "quite similar" to the symbol to classify are tried. On the second pass, we relax and permit more patterns to be tried. This method helps to achieve a good performance. As PNT1 becomes larger, less patterns will be tried on the first pass. As PNT2 becomes smaller, more patterns will be tried on the second pass.

MD is the maximum clearance to try a skeleton. The clearance must be an integer in the range 4..30 (default 6). The shape recognition algorithm will refuse to try to fit an skeleton into a symbol if the difference of the widths or heights of them is larger than twice the clearance.

Examples:


    -P 50,5,8
    -P 40,3,6

-R doubts

Maximum number of doubts per run. The argument must be an integer (default 30).

-T

Avoid loading and creation of session files. Also reports bookfont size on stdout before exiting. This option is intended to be used by the selthresh.pl script.

-t

Switch on trace messages. Trace messages depict the execution flow, and are useful for developers. Trace messages are written to stderr.

-v

Verbose mode. Without this option, Clara runs quietly (default). Otherwise, informative warnings about potentially relevant events are sent to stderr.

-V

Print version and compilation options and exit.

-W

Web mode. Will read from the doubts subdir the input collected from web, and will dump on that same directory the doubts to be reviewed.

-w path

Work directory. Defaults to the page directory (see -f).

The path of the directory where the OCR will write the output, the acts, the book font and the session files. The doubts directory (web operation) is assumed to be a subdirectory of the work directory.

-X 0|1

Switch off (0) or on (1) index checking. Index checking is performed in some critical points in order to detect memory leaks. Index checking is unavailable when Clara is compiled with the symbol MEMCHECK undefined.

-y resolution

Inform the resolution of the scanned image in dots per inch (default 600). This resolution applies for all pages to be processed until the program exits.

-z

Write (and read) compressed session files (*.session, acts and patters will be compressed using GNU zip).

Be careful: if -z is used, any existing uncompressed file (*.session, acts or patterns) will be ignored. So if you start using uncompressed files and suddenly decides to begin using compressed files, then compress manually all existing files before starting Clara with the -z switch.

Clara OCR support for reading and writing compressed files depends on the platform, and requires gzip and gunzip to be installed in some directory of binaries included in the PATH.

-Z ZPS

ZPS, that is, the size of the bitmap pixels measured in display pixels, when in fat bit mode. Must be a small odd integer (1, 3, 5, 7 or 9).

7. AVAILABILITY

Clara OCR is free software. Its source code is distributed under the terms of the GNU GPL (General Public License), and is available at http://www.claraocr.org/. If you don't know what is the GPL, please read it and check the GPL FAQ at http://www.gnu.org/copyleft/gpl-faq.html. You should have received a copy of the GNU General Public License along with this software; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The Free Software Foundation can be found at http://www.fsf.org.

8. CREDITS

Clara OCR was written by Ricardo Ueda Karpischek. Giulio Lunati wrote the internal preprocessor. Clara OCR includes bugfixes produced by other developers. The Changelog (http://www.claraocr.org/CHANGELOG) acknowledges all them (see below). Imre Simon contributed high-volume tests, discussions with experts, selection of bibliographic resources, propaganda and many ideas on how to make the software more useful.

Ricardo authored various free materials, some included (at least) in Conectiva, Debian, FreeBSD and SuSE (the verb conjugator "conjugue", the ispell dictionary br.ispell and the proxy axw3). He recently ported the EiC interpreter to the Psion 5 handheld and patched the Xt-based vncviewer to scale framebuffers and compute image diffs. Ricardo works as an independent developer and instructor. He received no financial aid to develop Clara OCR. He's not an employee of any company or organization.

Imre Simon promotes the usage and development of free technologies and informat