12.141 emacspeak-ocr

This module defines Emacspeak front-end to OCR. This module assumes that sane is installed and working for image acquisition, and that there is an OCR engine that can take acquired images and produce text.

12.141.1 Emacspeak-Ocr Commands

12.141.1.1 emacspeak-ocr

Command: emacspeak-ocr
C-e C-o
An OCR front-end for the Emacspeak desktop.  

Page image is acquired using tools from the SANE package.
The acquired image is run through the OCR engine if one is
available, and the results placed in a buffer that is
suitable for browsing the results.

For detailed help, invoke command emacspeak-ocr bound to
C-e C-o to launch emacspeak-ocr-mode, and press
‘?’ to display mode-specific help for emacspeak-ocr-mode.

12.141.1.2 emacspeak-ocr-backward-page

Command: emacspeak-ocr-backward-page (&optional count-ignored)
Like backward page, but tracks page number of current document.

(fn &optional COUNT-IGNORED)

12.141.1.3 emacspeak-ocr-customize

Command: emacspeak-ocr-customize
Customize OCR settings.

12.141.1.4 emacspeak-ocr-flipflop-and-recognize-image

Command: emacspeak-ocr-flipflop-and-recognize-image
Run OCR engine on current image after flip-flopping it.
Useful if you’ve scanned a page upside down and are using an
engine that does not automatically flip the image for you.  You
need the imagemagik family of tools — we use mogrify to
transform the image.  Prompts for image file if file
corresponding to the expected ‘current page’ is not found.

12.141.1.5 emacspeak-ocr-forward-page

Command: emacspeak-ocr-forward-page (&optional count-ignored)
Like forward page, but tracks page number of current document.

(fn &optional COUNT-IGNORED)

12.141.1.6 emacspeak-ocr-mode

Command: emacspeak-ocr-mode
 An OCR front-end for the Emacspeak desktop.

Pre-requisites:

1) A working scanner back-end like SANE on Linux.

2) An OCR engine.

1: Make sure your scanner back-end works, and that you have
the utilities to scan a document and acquire an image as a
tiff file.  Then set variable
emacspeak-ocr-scan-image-program to point at this utility.
By default, this is set to ‘scanimage’ which is the image
scanning utility provided by SANE.

By default, this front-end attempts to compress the acquired
tiff image; make sure you have a utility like tiffcp.
Variable emacspeak-ocr-compress-image is set to ‘tiffcp’ by
default; if you use something else, you should customize
this variable.

2: Next, make sure you have an OCR engine installed and
working.  By default this front-end assumes that OCR is
available as /usr/bin/ocr.

Once you have ensured that acquiring an image and applying
OCR to it work independently of Emacs, you can use this
Emacspeak front-end to enable easy OCR access from within
Emacspeak.

The Emacspeak OCR front-end is launched by command
emacspeak-ocr bound to C-e C-o.  

This command switches to a special buffer that has OCR
commands bounds to single keystrokes– see the key-binding
list at the end of this description.  Use Emacs online help
facility to look up help on these commands.

emacspeak-ocr-mode provides the necessary functionality to
scan, OCR, read and save documents.  By default, scanned
images and the resulting text are saved under directory
~/ocr; see variable emacspeak-ocr-working-directory.
Invoking command emacspeak-ocr-open-working-directory bound
to M-x emacspeak-ocr-open-working-directory will open this directory.

By default, the document being scanned is named ‘untitled’.
You can name the document by using command
emacspeak-ocr-name-document bound to
M-x emacspeak-ocr-name-document.  The document name is used
in constructing the name of the image and text files.

Key Bindings: 

See 
Key             Binding
——————————————————————————-
RET             emacspeak-ocr-scan-and-recognize
SPC             emacspeak-ocr-read-current-page
1 .. 9          emacspeak-ocr-page
?               describe-mode
C               emacspeak-ocr-set-compress-image-options
I               emacspeak-ocr-set-scan-image-options
[               emacspeak-ocr-backward-page
]               emacspeak-ocr-forward-page
c               emacspeak-ocr-customize
d               emacspeak-ocr-open-working-directory
f               emacspeak-ocr-flipflop-and-recognize-image
i               emacspeak-ocr-scan-image
j               emacspeak-ocr-scan-photo
n               emacspeak-ocr-name-document
o               emacspeak-ocr-recognize-image
p               emacspeak-ocr-page
q               bury-buffer
s               emacspeak-ocr-save-current-page
w               emacspeak-ocr-write-document
.

In addition to any hooks its parent mode ‘text-mode’ might have run,
this mode runs the hook ‘emacspeak-ocr-mode-hook’, as the final or
penultimate step during initialization.

12.141.1.7 emacspeak-ocr-name-document

Command: emacspeak-ocr-name-document (name)
Name document being scanned in the current OCR buffer.
Pick a short but meaningful name.

(fn NAME)

12.141.1.8 emacspeak-ocr-open-working-directory

Command: emacspeak-ocr-open-working-directory
Launch dired on OCR working directory.

12.141.1.9 emacspeak-ocr-page

Command: emacspeak-ocr-page
Move to specified page.

12.141.1.10 emacspeak-ocr-read-current-page

Command: emacspeak-ocr-read-current-page
Speaks current page.

12.141.1.11 emacspeak-ocr-recognize-image

Command: emacspeak-ocr-recognize-image
Run OCR engine on current image.
Prompts for image file if file corresponding to the expected
‘current page’ is not found.

12.141.1.12 emacspeak-ocr-save-current-page

Command: emacspeak-ocr-save-current-page
Writes out recognized text from current page
to an appropriately named file.

12.141.1.13 emacspeak-ocr-scan-and-recognize

Command: emacspeak-ocr-scan-and-recognize
Scan in a page and run OCR engine on it.
Use this command once you’ve verified that the separate
steps of acquiring an image and running the OCR engine work
correctly by themselves.

12.141.1.14 emacspeak-ocr-scan-image

Command: emacspeak-ocr-scan-image
Acquire page image.

12.141.1.15 emacspeak-ocr-scan-photo

Command: emacspeak-ocr-scan-photo (&optional metadata)
Scan in a photograph.
The scanned image is converted to JPEG.

(fn &optional METADATA)

12.141.1.16 emacspeak-ocr-set-compress-image-options

Command: emacspeak-ocr-set-compress-image-options (setting)
Interactively update  image compression options.
Prompts with current setting in the minibuffer.
Setting persists for current Emacs session.

(fn SETTING)

12.141.1.17 emacspeak-ocr-set-scan-image-options

Command: emacspeak-ocr-set-scan-image-options (setting)
Interactively update scan image options.
Prompts with current setting in the minibuffer.
Setting persists for current Emacs session.

(fn SETTING)

12.141.1.18 emacspeak-ocr-write-document

Command: emacspeak-ocr-write-document
Writes out recognized text from all pages in current document.

12.141.2 emacspeak-ocr Options

Variable: User Option emacspeak-ocr-compress-image
Command used to compress the scanned tiff file.

Default Value:

nil

Variable: User Option emacspeak-ocr-compress-image-options
Options used for compressing tiff image.

Default Value:

"-c g3 "

Variable: User Option emacspeak-ocr-compress-photo-options
Options used when created JPEG from  scanned photographs.

Default Value:

"-optimize -progressive"

Variable: User Option emacspeak-ocr-engine
OCR engine to process acquired image.

Default Value:

"/home/raman/emacs/lisp/emacspeak/etc/tesseract.pl"

Variable: User Option emacspeak-ocr-engine-options
Command line options to pass to OCR engine.

Default Value:

nil

Variable: User Option emacspeak-ocr-image-extension
Filename extension used for acquired image.

Default Value:

".tif"

Variable: User Option emacspeak-ocr-jpeg-metadata-writer
Program to add metadata to JPEG files.

Default Value:

"wrjpgcom"

Variable: User Option emacspeak-ocr-keep-uncompressed-image
If set to T, uncompressed image is not removed.

Default Value:

nil

Variable: User Option emacspeak-ocr-photo-compress
Program to create JPEG compressed images.

Default Value:

"cjpeg"

Variable: User Option emacspeak-ocr-scan-image-options
Command line options to pass to image acquisition program.

Default Value:

"--resolution 300 --mode lineart --format=tiff"

Variable: User Option emacspeak-ocr-scan-photo-options
Options  used when scanning in photographs.

Default Value:

"--mode color --format=pnm"

Variable: User Option emacspeak-ocr-working-directory
Directory where images and OCR results
will be placed.

Default Value:

"/home/raman/.emacspeak/ocr/"