tesseract.js icon indicating copy to clipboard operation
tesseract.js copied to clipboard

Can I get the image Angle through OCR?

Open yewanji opened this issue 3 years ago • 2 comments

I have a requirement that the Angle of the image taken and uploaded by the user may be somewhat tilted. I hope that the Angle of the image can be corrected after the image text is obtained by OCR。thank mail [email protected] I Looking forward to your reply

yewanji avatar May 31 '21 10:05 yewanji

Take a look at worker.detect() function which returns the angle

interface DetectData {
    tesseract_script_id: number
    script: string
    script_confidence: number
    orientation_degrees: number
    orientation_confidence: number
  }

ertrzyiks avatar Jul 04 '21 18:07 ertrzyiks

Unfortunately the orientation that Tesseract reports pertains to whether the image is rotated 90/180/270 degrees, so is not of much use for determining the angle of a "somewhat tilted" image (say, 5 degrees). The exact angle may be calculated using the .hocr output, however I don't believe there is any existing way to get a single number from Tesseract with this information.

Balearica avatar Aug 06 '22 17:08 Balearica