341 Commits

Author SHA1 Message Date
Erik Auerswald 443b100ab9 bump version number to 2.25.1 v2.25.1 2025-10-31 19:44:16 +01:00
Erik Auerswald 63495ef4a8 suppress debug output without -P, --debug-output
Again, a debug message was not properly guarded with a check
for the debug-flag.
2025-10-30 00:04:42 +01:00
Erik Auerswald 9d9b2253e1 bump version number to 2.25.0 v2.25.0 2025-03-23 19:06:24 +01:00
Erik Auerswald e914669079 add option -F, --adapt-after-crop
When this option is used, the threshold is adapted to the cropped
image, i.e., after the "crop" command, but not directly before.
This allows to avoid adjusting the threshold to the full image,
and thus potentially reduce the time needed for recognition.
2025-03-23 19:03:48 +01:00
Erik Auerswald 94ce321060 lazily adapt threshold to image
Instead of adapting the threshold to the image before executing
commands, adapt the threshold just before it is needed.

This allows to avoid theshold adaptation when -p, --process-only
is used with only the "grayscale" and/or "mirror" commands.

This also prepares the code to allow introduction of a new option
to avoid adapting the threshold to the original image before the
"crop" command is applied.
2025-03-23 18:54:13 +01:00
Erik Auerswald 7cae796188 ssocr.c: code maintenance
Fix two minor issues with crop command execution:

 * correct two variable names in a comment, and
 * remove a useless imlib_context_set_image() call.
2025-03-23 14:27:52 +01:00
Erik Auerswald 7f2a9f3f22 warn when options -a and -T are used together 2025-03-22 18:45:15 +01:00
Erik Auerswald 00312ee70e man page: describe interaction of -a and -T
Option -a, --absolute-threshold inhibts the effect of option
-T, --iter-threshold.
2025-03-22 18:38:04 +01:00
Erik Auerswald e309861f24 man page: suggest -a when using gray_stretch 2025-03-20 21:23:33 +01:00
Erik Auerswald 4b5c6ea770 NEWS: mention speed up of -g with gray_stretch
Commit 67abe0fba8 improved the
speed for determining both minimum and maximum luminance (gray)
values for the image.  This speeds up some debugging output,
and also using the gray_stretch command together with option -g.
(I did not notice that initially.)
2025-03-20 21:15:01 +01:00
Erik Auerswald 56d1b22118 simplify some command execution code paths
Commands with optional argument had two code paths leading
to the respective function application, one of those with
hard-coded argument "1".  Instead, ensure the variable for
the optional argument is always set, and have just one
function call, always using this variable, per command.
2025-03-20 21:12:00 +01:00
Erik Auerswald eaf0f32850 NEWS: mention performance improvement 2025-03-18 21:45:00 +01:00
Erik Auerswald fa30f473e7 simplify adapt_threshold() and iterative_threshold()
Both functions are always called with the same arguments.
Only the get_threshold() function is also called with
different x, y, w, h arguments (when used during dynamic
thresholding).
2025-03-18 21:31:19 +01:00
Erik Auerswald 67abe0fba8 combine get_minval() and get_maxval()
This simplifies the code a bit, and slightly speeds up using
option "-P, --debug-output".
2025-03-18 20:42:38 +01:00
Erik Auerswald ac060de96b speed up reading from standard input
Instead of reading one byte at a time, read data in chunks
of BUFSIZ bytes.

For one example, this improves recognition time for image
data read via standard input from 281ms to 53ms.  YMMV.
2025-03-18 20:10:51 +01:00
Erik Auerswald 74aeb44f94 rename draw_pixel() to draw_fg_bg_pixel() 2025-02-02 20:42:52 +01:00
Erik Auerswald f012c14d93 refactoring and type consistency fixes
* The draw_pixel() function was called with an "image" parameter
  of type "Imlib_Image" instead of "Imlib_Image *".  This type
  error did not result in a compilation error, and thus stayed
  undetected in the code.

* Introduce a new function draw_color_pixel() similar to draw_pixel(),
  and use it instead of repeatedly open-coding this operation.
2025-02-02 20:32:48 +01:00
Erik Auerswald b44a4ad72a update copyright years 2025-02-01 19:33:29 +01:00
Erik Auerswald 13a5ec3802 imgproc.c: remove some useless code
The removed code was intended to clear the image to allow
only drawing foreground pixels in the following loop.  But
it only drew the outline of a rectangle and thus did not
clear the image as intended.

Since the image is not cleared, the following loop already
draws every pixel, overwriting any previously drawn rectangle
anyway.
2025-02-01 19:26:09 +01:00
Erik Auerswald 2824d0aea7 ensure M_PI is defined
Some image manipulation functions use trigonometric functions.
This includes using the number Pi.  Pi is often available as
M_PI via including <math.h>.  This constant is part of the Unix98
standard, not the C standard itself.  According to the GCC
documentation[1], M_PI is only defined when the feature selection
macro _XOPEN_SOURCE=500 is used.  This seems to be default in
many versions of GNU/Linux, since ssocr could always use M_PI
without explicitly setting _XOPEN_SOURCE=500.

An MPlayer bug report[2] reported a build failure because M_PI
was not defined.  This lead to a patch[3] to work around this
problem.

I want to avoid running into this specific problem in the future,
without introducing significant changes to ssocr.  Thus I check
if M_PI is defined after inlcuding <math.h>, and define it myself
if it is missing.  I use the value found in /usr/include/math.h
from GNU Libc on my current system (Ubuntu GNU/Linux 20.04.6 LTS).

[1] https://www.gnu.org/software/libc/manual/html_node/Mathematical-Constants.html
[2] https://trac.mplayerhq.hu/ticket/2423
[3] https://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2024-December/074244.html

Also add '+' to the version number to indicate changes after the
latest release.
2024-12-14 14:56:13 +01:00
Erik Auerswald 5439679c83 bump version number to 2.24.1 v2.24.1 2024-12-11 15:43:49 +01:00
Erik Auerswald e7a20fbb2d man page: fix two typos 2024-12-11 15:38:10 +01:00
Erik Auerswald 88a627050a print warning when ignoring unknown luminance formula 2024-11-18 17:55:02 +01:00
Erik Auerswald 6e8c8361fd improve wording of unknown charset warning 2024-11-18 17:43:55 +01:00
Erik Auerswald ad5b6da118 NEWS: mention recent changes 2024-11-17 19:44:57 +01:00
Erik Auerswald 7485ba3ffc man page: option argument separation description 2024-11-17 19:33:35 +01:00
Erik Auerswald acdf26c6bf print warning when ignoring unknown charset 2024-11-17 19:25:33 +01:00
Erik Auerswald 4ab3869eea add '+' to version to indicate unreleased changes 2024-11-17 19:13:33 +01:00
Erik Auerswald 70692aa5c4 suppress debug output without -P, --debug-output 2024-11-17 19:10:34 +01:00
Erik Auerswald 9964c8ce85 fix copy & paste error in a comment 2024-11-17 19:09:00 +01:00
Erik Auerswald 895b0cb2b5 bump version number to 2.24.0 v2.24.0 2024-06-22 20:05:30 +02:00
Erik Auerswald 894f3035fd fix a special case for decimal point recognition
When the widest digit found in the image is a one, it is likely
that a decimal separator is nearly as wide as this digit.  Thus
it cannot be recognized, because the decimal separator needs to
be at most half as wide as the widest digit (before this commit).

Thus add an additional pass over the digits for this special case.
This pass comes after the existing recognition passes for the
digit one, decimal separator, and minus sign.  In the new pass,
the width of the digit is ignored.

This addresses GitHub issue #26.
2024-06-22 20:04:08 +02:00
Erik Auerswald 40c34ad6d7 tweak --help and --version output 2024-05-19 01:05:22 +02:00
Erik Auerswald bae7381e34 add lower case r to character set "full" 2024-05-18 23:51:13 +02:00
Erik Auerswald d6be469e14 add lower case h to character set "full" 2024-05-18 23:49:07 +02:00
Erik Auerswald af6c53c3f3 add lower case n for consistency with lower case c
Neither lower case c nor lower case n can happen with correct
image segmentation.  Lower case c was already used in the code,
but lower case n was only found as a comment.

I am not sure if I want to keep this or rather remove both lower
case variants.  I do want to have this consistent, though.
2024-05-18 21:44:42 +02:00
Erik Auerswald b05410efae man page: fix "white_border" description
The command name stems from the time when ssocr always considered
"white" as background and "black" as foreground.  The intention
has always been to ensure some background border around the seven
segment displays, and the implementation always followed this.  The
output of --help correctly uses "background" for the "white_border"
description.  Now, the man page description is correct, too.
2024-05-09 16:19:36 +02:00
Erik Auerswald 6569ca9f6b update copyright years 2024-02-23 19:03:58 +01:00
Erik Auerswald 48da4ee8c1 help: align equal signs in Defaults section 2024-02-23 18:58:58 +01:00
Erik Auerswald 1a8c4d7701 help: mention that rotate is clockwise 2024-02-23 18:57:04 +01:00
Erik Auerswald 624e998efb NEWS: mention message improvements 2023-09-10 14:54:27 +02:00
Erik Auerswald 81c5472b69 add program name to warning messages 2023-09-10 14:49:12 +02:00
Erik Auerswald 6fc62729e9 improve error message for wrong number of digits
* Use different messages for single digit and digit ranges.
* Use singular when looking for one digit, plural otherwise.
2023-09-10 14:35:49 +02:00
Erik Auerswald 19f93dcb58 fix debug output regarding flag DEBUG_OUTPUT 2023-07-26 19:50:15 +02:00
Erik Auerswald 5ca3455873 add ssocr version to debug output 2023-07-26 19:47:01 +02:00
Erik Auerswald 2026f39ee7 INSTALL: tweak prerequisites list 2023-05-21 18:45:08 +02:00
Erik Auerswald 73e7a69b4c INSTALL: mention (GNU) make as prerequisite 2023-05-20 19:37:29 +02:00
Erik Auerswald f25047745d INSTALL: mention gcc and man under prerequisites 2023-05-20 16:58:38 +02:00
Erik Auerswald 658230679a bump version number to 2.23.1 v2.23.1 2023-05-18 16:13:18 +02:00
Erik Auerswald 1fe392c772 use latest release date as man page date
The latest release date is extracted from the NEWS file,
i.e., it depends only on the sources, not the build date.
This is intended to help in creating reproducible builds
by avoiding timestamps.  It is also closer to the date of
the contents of the man page than using just the latest
copyright year.

I do not have a perfect solution that works for both a git
clone and a downloaded tar ball.  This solution works well
for released tar balls of the ssocr sources.
2023-05-14 17:37:48 +02:00