1

I just found the solution to Detect and fix text skew and related article OpenCV - Rotation (Deskewing). But the solution is not work for some text rotated 90 degree.

I want to fix text rotated 90 degree like images below, Detect and fix text skew solution works for second image but first image is not work.

tomfriwel
  • 2,575
  • 3
  • 20
  • 47

2 Answers2

1

You can use the Python OCR (pytesseract) to read the text from image, once you extracted the string, then search for some specific keywords/Stopwords in the text. If they not exist rotate for 90 degree and run OCR again. If they exist stop rotation.

This can rotate 90,270,180 degree shifted images.

Note: This is only applicable for text images.

0

this code rotates by multiples of 90 degrees angles

import pytesseract
orientation = pytesseract.image_to_osd(tempname, output_type='dict')['orientation']  
if orientation in [90, 180, 270]:
   image = image.rotate(int(orientation), expand=True)
DimNsk
  • 21
  • 1
  • 2