ci: let tesseract binarise the normalised OCR image

In run 38711351160 the normalised image had no rings and showed the button labels, grey and dark text all dark on white, but the fixed 80% threshold turned every pixel with over 20% contrast black, so letters merged into blobs ("Be free" read as "Be tires"). With the background now uniformly white, tesseract's own threshold separates the text, so the image goes to it in grayscale.
This commit is contained in:
spacedandy-agents-simplex committed 2026-10-15 09:18:58 +00:00
1 parent 4fa605d056
commit 85747f5734
1 file changed
+1 -1
+1 -1
View File
@@ -92,7 +92,7 @@ ocr() {
convert "$png" -colorspace Gray "$o/gray.png"
convert "$o/gray.png" \( +clone -morphology Dilate Rectangle:9x1 -morphology Dilate Rectangle:1x9 -morphology Erode Rectangle:9x1 -morphology Erode Rectangle:1x9 \) -compose Difference -composite "$o/dark.png"
convert "$o/gray.png" \( +clone -morphology Erode Rectangle:9x1 -morphology Erode Rectangle:1x9 -morphology Dilate Rectangle:9x1 -morphology Dilate Rectangle:1x9 \) -compose Difference -composite "$o/light.png"
convert "$o/dark.png" "$o/light.png" -compose Lighten -composite -negate -resize 200% -threshold 80% "$o/text.png"
convert "$o/dark.png" "$o/light.png" -compose Lighten -composite -negate -resize 200% "$o/text.png"
tesseract "$o/text.png" "$o/text" --psm 11 tsv > /dev/null 2>&1
python3 "$here/screen-text.py" 2 "$@" "$o/text.tsv"
}