I have a set of PIL images, where some pages are correctly rotated, while others have a rotation close to 180°. This means that automatic orientation detection may fail as instead of 178° degrees recognizes a 2° degrees orientation.
Unfortunately, Tesseract sometimes cannot understand the difference between 2° orientation and 178°, so in the latter case, the output is completely wrong.
A simple im.rotate(180)
automatically fixes this, but the step is manual, and I would like tesseract to automatically understand whether the text is upside-down or not.
Looking at some approaches they require the Hough transform for understanding of the prevalent orientation in the document. In this case, however, they may fail, because of the peculiar orientation of these scanned documents.
What options for automatic rotation are available, without reyling on third party scripts, but staying within Python libraries?