tesseract icon indicating copy to clipboard operation
tesseract copied to clipboard

Orientation Angle is Incorrect (180 instead of 0)

Open wvanrensburg opened this issue 1 year ago • 4 comments

Current Behavior

Trying to get the orientation of an image using psm 0, and it's reporting an incorrect orientation angle.

Commands Tried:

tesseract /path/to/image.png /pah/to/reportout --psm 0
tesseract /path/to/image.png /pah/to/reportout --psm 0 --oem 0
tesseract /path/to/image.png /pah/to/reportout --psm 0 --oem 1
tesseract /path/to/image.png /pah/to/reportout --psm 0 --oem 3

Output of the osd result:

Page number: 0
Orientation in degrees: 180
Rotate: 180
Orientation confidence: 1.45
Script: Greek
Script confidence: 0.59

Image being used: download

Expected Behavior

The result should spit out a rotation of zero..

Page number: 0
Orientation in degrees: 0
Rotate: 0
...

Suggested Fix

N/A

tesseract -v

tesseract 5.3.3
 leptonica-1.83.1
  libgif 5.2.1 : libjpeg 8d (libjpeg-turbo 3.0.0) : libpng 1.6.40 : libtiff 4.6.0 : zlib 1.2.11 : libwebp 1.3.2 : libopenjp2 2.5.0
 Found SSE4.1
 Found libarchive 3.7.2 zlib/1.2.11 liblzma/5.4.4 bz2lib/1.0.8 liblz4/1.9.4 libzstd/1.5.5
 Found libcurl/7.85.0 SecureTransport (LibreSSL/3.3.6) zlib/1.2.11 nghttp2/1.47.0

Operating System

macOS 13 Ventura

Other Operating System

No response

uname -a

No response

Compiler

No response

CPU

No response

Virtualization / Containers

No response

Other Information

No response

wvanrensburg avatar Dec 21 '23 00:12 wvanrensburg

I figured a work around, which means Im suspecting the tesseract orientation code isn't using enough characters to determine the correct orientation. Adding -c min_characters_to_try=200 produces the correct results..

tesseract /path/to/image.png /pah/to/reportout --psm 0 --oem 0 -c min_characters_to_try=200

Page number: 0
Orientation in degrees: 0
Rotate: 0
Orientation confidence: 3.59
Script: Latin
Script confidence: 0.57

wvanrensburg avatar Dec 21 '23 00:12 wvanrensburg

If you know in advance that the text is written in a specific language, like English in this case, another thing you can try is to add the parameter -l eng.

I didn't test this on the attached image.

amitdo avatar Dec 25 '23 08:12 amitdo

tesseract i4172.png - --psm 0
Page number: 0
Orientation in degrees: 180
Rotate: 180
Orientation confidence: 1.45
Script: Greek
Script confidence: 0.59

and with specifying lang:

tesseract i4172.png - --psm 0 -l eng
Warning, detects only orientation with -l eng
Page number: 0
Orientation in degrees: 0
Rotate: 0
Orientation confidence: 25.67
Script: Latin
Script confidence: 5.48
tesseract i4172.png - --psm 0 -l osd
Page number: 0
Orientation in degrees: 180
Rotate: 180
Orientation confidence: 1.45
Script: Greek
Script confidence: 0.59
tesseract i4172.png - --psm 0 -l osd+eng
Warning, detects only orientation with -l osd+eng
Page number: 0
Orientation in degrees: 180
Rotate: 180
Orientation confidence: 1.45
Script: Greek
Script confidence: 0.59
tesseract i4172.png - --psm 0 -l eng+osd
Warning, detects only orientation with -l eng+osd
Page number: 0
Orientation in degrees: 0
Rotate: 0
Orientation confidence: 25.67
Script: Latin
Script confidence: 5.48

zdenop avatar Jan 13 '24 10:01 zdenop