mittagessen / kraken

OCR engine for all the languages
http://kraken.re
Apache License 2.0
747 stars 131 forks source link

ketos linegen --legacy fails #307

Open bertsky opened 2 years ago

bertsky commented 2 years ago

If I use ketos linegen with the --legacy option, I currently get:

  File "kraken/ketos.py", line 933, in line_generator
    im = linegen.ocropy_degrade(im)
  File "kraken/linegen.py", line 271, in ocropy_degrade
    (sigma, ssigma, threshold, sthreshold) = degradations[np.random.choice(len(degradations))]
TypeError: cannot unpack non-iterable float object
bertsky commented 2 years ago

Thanks – that was fast!

Alas, I'm afraid there's another bug lurking here: the output in this mode looks all black. Diving in, it seems the color mode is 8 bit grayscale, but fg bg is at 1 (instead of 255). In other words, only convert 000000.png -threshold 1 -depth 1 out.png will repair it.

bertsky commented 2 years ago

Alas, I'm afraid there's another bug lurking here: the output in this mode looks all black. Diving in, it seems the color mode is 8 bit grayscale, but ~fg~ bg is at 1 (instead of 255). In other words, only convert 000000.png -threshold 1 -depth 1 out.png will repair it.

@mittagessen, reopen or new issue?

mittagessen commented 2 years ago

Sorry, I forgot about it. Let's reopen and have a look. It's probably related to the arcane image loading routines that often returned different numerical ranges than a simple np.array() call on a PIL image.