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,347
  • 3
  • 16
  • 45

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

use the following code to determine the angle

import pytesseract
cv2_imshow(img)
osd = pytesseract.image_to_osd(img)
angle = re.search('(?<=Rotate: )\d+', osd).group(0)
print("angle: ", angle)
DimNsk
  • 1
  • 1