Skip to content

Commit 8ba0ce9

Browse files
committed
Update README with new usage instructions
1 parent b4af403 commit 8ba0ce9

File tree

1 file changed

+56
-55
lines changed

1 file changed

+56
-55
lines changed

README.md

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,48 @@
1111

1212
_Hough_ finds skew angles in scanned document pages, using the Hough transform.
1313

14-
It is oriented to batch processing, and can make use of multiple cores. (You'll
15-
want this - analysis and image processing is very CPU intensive!)
14+
It is oriented to batch processing, and can make use of multiple cores or an
15+
optional CUDA backend. (It can be very compute intensive!)
1616

1717
# Installation and usage
1818

1919
## Installation
2020

2121
```
22-
pip install -U pip
23-
pip install hough
22+
pipx install hough
2423
```
2524

26-
The first line is required to update `pip` to a new enough version to be
27-
compatible with `manylinux` wheel packaging, required for PyMuPDF.
25+
Or, if you have a supported GPU and have [installed CUDA](https://developer.nvidia.com/cuda-toolkit) (currently 12.x supported):
2826

29-
Older versions of `pip` are fine, but you'll have to install MuPDF, its
30-
headers, and a compiler first, so PyMuPDF can be compiled locally.
27+
```
28+
pipx install "hough[cuda]"
29+
```
30+
31+
If you don't use `pipx`, other methods such as `pip` should work fine, just create a virtual environment first.
3132

3233
## Usage
3334

3435
To get started right away, here's some examples.
3536

36-
Generate angles (in CSV form) for a bunch of TIFF page images, one page per file:
37+
Generate angles (in CSV form) for a bunch of TIFF images:
3738

3839
```
39-
hough --csv in/*.tif
40+
hough analyse in/*.tif
4041
```
4142

4243
The same, but for a PDF file, and display a histogram at the end:
4344

4445
```
45-
hough --histogram Able_Attach_Sep83.pdf
46+
hough analyse --histogram Able_Attach_Sep83.pdf
4647
```
4748

48-
The same, but show progress while running:
49+
The same, but show more information while running:
4950

5051
```
51-
hough -v --histogram Able_Attach_Sep83.pdf
52+
hough --verbose --histogram Able_Attach_Sep83.pdf
5253
```
5354

54-
55-
The deskewing results are placed in the `results.csv` file. Example:
55+
The deskewing results are placed in a `results.csv` file created under the `out/<timestamp>` directory, which is created at invocation time. Here's an example:
5656

5757
```csv
5858
"Input File","Page Number","Computed angle","Variance of computed angles","Image width (px)","Image height (px)"
@@ -101,41 +101,43 @@ Samples: 195
101101
You can list them by running `hough --help`:
102102

103103
```
104-
hough - straighten scanned pages using the Hough transform.
105-
106-
Usage:
107-
hough (-h | --help)
108-
hough [options] [FILE] ...
109-
hough [options] [--results=<file>] [FILE] ...
110-
hough (-r | --rotate) [options] [--results=<file>]
111-
hough (-r | --rotate) [options] [--results=<file>] [FILE] ...
112-
113-
Arguments:
114-
FILE input files to analyze/rotate
115-
116-
Options:
117-
-h --help display this help and exit
118-
--version display the version number and exit
119-
-v --verbose print status messages
120-
-d --debug retain debug image output in debug/ dir
121-
(also enables --verbose)
122-
--histogram display rotation angle histogram summary
123-
-o DIR, --out=DIR store output results/images in named
124-
directory. Directory is created if it
125-
does not exist [default: out/TIMESTAMP]
126-
--results=<file> save results in FILE under output path,
127-
or specify path to results file for
128-
rotation [default: results.csv]
129-
-w <workers> --workers=<#> specify the number of workers to run
130-
simultaneously. Default: total # of CPUs
131-
-r --rotate rotates the files passed on the command
132-
line, or if none given, those listed
133-
in the results file.
104+
Usage: hough COMMAND
105+
106+
╭─ Commands ─────────────────────────────────────────────────────────────────────────────╮
107+
│ analyse Analyse one or more files for deskewing. │
108+
│ histogram Show a histogram of rotation angles from a previous analysis. │
109+
│ process Fully analyse and rotate one or more files. │
110+
│ rotate Rotate one or more files that have previously been analysed. │
111+
│ --help -h Display this message and exit. │
112+
│ --version Display application version. │
113+
╰────────────────────────────────────────────────────────────────────────────────────────╯
114+
```
115+
116+
Or ask for help for a specific command, *e.g.* `hough analyse --help`:
117+
118+
```
119+
Usage: hough analyse [ARGS] [OPTIONS]
120+
121+
Analyse one or more files for deskewing.
122+
123+
╭─ Parameters ───────────────────────────────────────────────────────────────────────────╮
124+
│ * FILES --files One or more files to analyse for deskewing. [required] │
125+
│ DEBUG --debug Save intermediate results in debug/ under out folder. │
126+
│ [default: False] │
127+
│ VERBOSE --verbose Print status messages instead of progress bar. [default: │
128+
│ False] │
129+
│ OUT --out Use the specified path for results and post-rotated files. │
130+
│ [default: out/TIMESTAMP] │
131+
│ WORKERS --workers Number of workers to run simultaneously. [default: 4] │
132+
│ HISTOGRAM --histogram Display result summary as histogram after processing. │
133+
│ [default: False] │
134+
╰────────────────────────────────────────────────────────────────────────────────────────╯
134135
```
135136

137+
136138
# Examples
137139

138-
Just about all of [these files](http://docs.telegraphics.com.au/) have been
140+
Just about all of [these files](https://web.archive.org/web/20231024133854/http://docs.telegraphics.com.au/) have been
139141
deskewed this way.
140142

141143
# Getting the best results
@@ -147,7 +149,7 @@ from your document scans:
147149

148150
1. Bilevel (black-and-white) bitmaps will produce lower quality results.
149151
For best results, scan to greyscale or RGB first, deskew with _Hough_, then
150-
reduce the colour depth to bilevel.
152+
reduce the colour depth to bilevel if desired.
151153
1. Hough deskewing is an inexact process, with many heuristics discovered
152154
by trial and error. _Hough_ may not work well on your material without tuning
153155
and further modification. (We'd love your pull requests!)
@@ -156,7 +158,7 @@ from your document scans:
156158

157159
You can spy on _Hough_'s attempts to perform deskewing by passing the `--debug`
158160
flag on the command line. The generated images, and any detected lines in them,
159-
are placed in the `debug/<datetime>/` directory.
161+
are placed in the `out/<timestamp>/debug/` directory.
160162

161163
Note that _Hough_ cannot always determine a skew for a page (e.g. blank pages
162164
in particular), and will very occasionally get the skew wrong (depending on
@@ -189,24 +191,23 @@ You'll need to install [Poetry](https://python-poetry.org/docs/#installation),
189191
then run:
190192

191193
```
192-
poetry run pip install -U pip setuptools
193-
poetry install
194-
poetry shell
194+
poetry sync --with dev # or --with dev,cuda if you have CUDA installed
195+
poetry self add 'poethepoet[poetry_plugin]' poetry-plugin-shell
195196
```
196197

197-
Do some work, then run the tests with
198+
Do some work, then run the pre-commit checks and tests with:
198199

199200
```
200-
pytest
201-
pre-commit run
201+
poetry run pre-commit
202+
poetry poe test
202203
```
203204

204205
# License notice
205206

206207
```
207208
This file is part of "hough", which detects skew angles in scanned images
208209
Copyright (C) 2016-2020 Toby Thain <toby@telegraphics.com.au>
209-
Copyright (C) 2020 Joan Touzet <wohali@apache.org>
210+
Copyright (C) 2020-2025 Joan Touzet <wohali@apache.org>
210211
211212
This program is free software; you can redistribute it and/or modify
212213
it under the terms of the GNU General Public License as published by

0 commit comments

Comments
 (0)