OCR-D / ocrd_calamari

Recognize text using Calamari OCR and the OCR-D framework
Apache License 2.0
13 stars 6 forks source link

Fix word coordinates when using textequiv_level = "word" #60

Closed sven-nm closed 3 years ago

sven-nm commented 3 years ago

Hi all,

When using ocrd-calamary-recognize with textequiv_level word, pc:Word-spans appear to have wrong y-coordinates in the Coords-spans. It looks like all words are lowered to the bottom of the text region they belong to.

For instance : When drawing the line polygons, the coords are right :

Capture d’écran 2021-02-24 à 16 03 32

But when drawing the word polygons, the coords are wrong :

Capture d’écran 2021-02-24 à 16 03 06

I am using cv2 to draw the polygons, but I double-checked in the PAGE xml file, and words of a text-region (sometimes the entire page) all have the same y-coordinates.

Here is the entire code used to generate the OCR :

docker run --rm -u $(id -u) -v $PWD:/data -w /data -- ocrd/all:maximum ocrd process \
  "cis-ocropy-binarize -I OCR-D-IMG -O OCR-D-BIN" \
  "anybaseocr-crop -I OCR-D-BIN -O OCR-D-CROP" \
  "skimage-binarize -I OCR-D-CROP -O OCR-D-BIN2 -P method li" \
  "skimage-denoise -I OCR-D-BIN2 -O OCR-D-BIN-DENOISE -P level-of-operation page" \
  "tesserocr-deskew -I OCR-D-BIN-DENOISE -O OCR-D-BIN-DENOISE-DESKEW -P operation_level page" \
  "cis-ocropy-segment -I OCR-D-BIN-DENOISE-DESKEW -O OCR-D-SEG -P level-of-operation page" \
  "cis-ocropy-dewarp -I OCR-D-SEG -O OCR-D-SEG-LINE-RESEG-DEWARP" \
  "calamari-recognize -I OCR-D-SEG-LINE-RESEG-DEWARP -O OCR-D-OCR -P checkpoint /data/calamari_model/\*.ckpt.json -P textequiv_level word"
kba commented 3 years ago

Looks like a duplicate of https://github.com/OCR-D/ocrd_calamari/issues/57, fixed in v1.0.2 https://github.com/OCR-D/ocrd_calamari/commit/0869386ec4191e7f2b2c96163d5e002eb70c6d35. This is not yet in ocrd_all, though, I'll make a new ocrd_all release this week.

mikegerber commented 3 years ago

This is fixed in v1.0.2, and the update is also in ocrd_call since last week, as @kba announced here!

@sven-nm I'll close this, please re-open if you still have the issue after updating!

mikegerber commented 3 years ago

@sven-nm Please note that glyph support in ocrd_calamari is not super useful for image based use cases¹, you might want to explore what ocrd_tesserocr has to offer in this regard.

¹ I implemented it to produce glyph alternatives, but the CTC based coordinates are not suitable for e.g. image extraction