2.195 emacsvox-ocr

This module defines the Emacsvox front end to OCR. PaddleOCR PP-StructureV3 is the default engine and accepts images and PDFs. SANE remains available as an optional image-acquisition route.

2.195.1 Emacsvox-Ocr Commands

2.195.1.1 emacsvox-ocr

Command: emacsvox-ocr
C-e C-o
Open the Emacsvox front end for image and PDF OCR.

The selected file is run through ‘emacsvox-ocr-engine’ and the result is
placed in a buffer suitable for reading and saving.  Optional image
acquisition commands use tools from the SANE package.

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

2.195.1.2 emacsvox-ocr-backward-page

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

(fn &optional COUNT-IGNORED)

2.195.1.3 emacsvox-ocr-customize

Command: emacsvox-ocr-customize
Customize OCR settings.

2.195.1.4 emacsvox-ocr-flipflop-and-recognize-image

Command: emacsvox-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.

2.195.1.5 emacsvox-ocr-forward-page

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

(fn &optional COUNT-IGNORED)

2.195.1.6 emacsvox-ocr-mode

Command: emacsvox-ocr-mode
An OCR front end for the Emacsvox desktop.

The default engine is PaddleOCR PP-StructureV3.  It recognizes images and
PDFs, preserves reading order, and represents detected tables in Markdown.
Install it as described in the Emacsvox user manual, then use ‘o’ to choose a
file.  OCR runs asynchronously; engine diagnostics go to the buffer named by
‘emacsvox-ocr-error-buffer’.

The optional scanner commands require a working scanner back end such as SANE
on Linux.  ‘emacsvox-ocr-scan-image’ uses ‘scanimage’ to acquire a TIFF file;
customize ‘emacsvox-ocr-scan-image’ and its related options if necessary.

Launch this front end with ‘emacsvox-ocr’, bound to C-e C-o.  The
result buffer uses single-keystroke commands; see the key-binding list below.
Recognized text and optional acquired images are saved under
‘emacsvox-ocr-working-directory’.  Command
‘emacsvox-ocr-open-working-directory’, bound to
M-x emacsvox-ocr-open-working-directory, opens that directory.

By default, the document is named from the current date.
You can name the document by using command
emacsvox-ocr-name-document bound to
M-x emacsvox-ocr-name-document.  The document name is used
in constructing the name of the image and text files.

Key Bindings:

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

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

2.195.1.7 emacsvox-ocr-name-document

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

(fn NAME)

2.195.1.8 emacsvox-ocr-open-working-directory

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

2.195.1.9 emacsvox-ocr-page

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

2.195.1.10 emacsvox-ocr-read-current-page

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

2.195.1.11 emacsvox-ocr-recognize-file

Command: emacsvox-ocr-recognize-file (input-file)
Run the OCR engine asynchronously on image or PDF INPUT-FILE.

(fn INPUT-FILE)

2.195.1.12 emacsvox-ocr-recognize-image

Command: emacsvox-ocr-recognize-image
Compatibility command that recognizes an image or PDF.

2.195.1.13 emacsvox-ocr-save-current-page

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

2.195.1.14 emacsvox-ocr-scan-and-recognize

Command: emacsvox-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.

2.195.1.15 emacsvox-ocr-scan-image

Command: emacsvox-ocr-scan-image
Acquire a page image, publishing it only after successful processing.
With compression and ‘emacsvox-ocr-keep-uncompressed-image’, retain the
original with -uncompressed before its extension.  On processing failure,
report the recovery path and leave the page number unchanged.

2.195.1.16 emacsvox-ocr-scan-photo

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

(fn &optional METADATA)

2.195.1.17 emacsvox-ocr-set-compress-image-options

Command: emacsvox-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)

2.195.1.18 emacsvox-ocr-set-scan-image-options

Command: emacsvox-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)

2.195.1.19 emacsvox-ocr-write-document

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

2.195.2 emacsvox-ocr Options

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

Default Value:

nil

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

Default Value:

"-c g3 "

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

Default Value:

"-optimize -progressive"

Variable: User Option emacsvox-ocr-engine
OCR engine used to process an image or PDF.

Default Value:

"<emacsvox-root>/bin/emacsvox-paddleocr"

Variable: User Option emacsvox-ocr-engine-options
Additional command-line arguments passed literally to the OCR engine.
For the bundled PaddleOCR adapter, these follow the typed customization
options and can override them.

Default Value:

nil

Variable: User Option emacsvox-ocr-error-buffer
Buffer that receives diagnostics from the OCR engine.

Default Value:

"*Emacsvox OCR Errors*"

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

Default Value:

".tif"

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

Default Value:

"wrjpgcom"

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

Default Value:

nil

Variable: User Option emacsvox-ocr-paddleocr-device
Paddle device used by the bundled adapter.
Examples include ‘cpu’, ‘gpu’, and ‘gpu:0’.

Default Value:

"cpu"

Variable: User Option emacsvox-ocr-paddleocr-enable-mkldnn
Whether to enable oneDNN/MKL-DNN acceleration for PaddleOCR.
Keep this disabled for the tested PaddlePaddle 3.3.0 CPU setup on WSL.

Default Value:

nil

Variable: User Option emacsvox-ocr-paddleocr-language
Language used by the bundled PaddleOCR adapter.

Default Value:

"en"

Variable: User Option emacsvox-ocr-paddleocr-python
Python executable used by the bundled PaddleOCR adapter.
When nil, the launcher uses its default isolated environment.  This option has
no effect when ‘emacsvox-ocr-engine’ selects another OCR engine.

Default Value:

nil

Variable: User Option emacsvox-ocr-paddleocr-use-document-orientation
Whether PaddleOCR should classify document orientation.

Default Value:

t

Variable: User Option emacsvox-ocr-paddleocr-use-document-unwarping
Whether PaddleOCR should correct warped document images.

Default Value:

t

Variable: User Option emacsvox-ocr-paddleocr-use-formula-recognition
Whether PaddleOCR should recognize mathematical formulas.

Default Value:

t

Variable: User Option emacsvox-ocr-paddleocr-use-table-recognition
Whether PaddleOCR should recognize and preserve tables.

Default Value:

t

Variable: User Option emacsvox-ocr-paddleocr-use-text-line-orientation
Whether PaddleOCR should classify individual text-line orientation.

Default Value:

t

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

Default Value:

"cjpeg"

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

Default Value:

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

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

Default Value:

"--mode color --format=pnm"

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

Default Value:

"~/.emacsvox/ocr/"