I am trying to get the text from rotated letters from images by using the Python cv2 and tesseract ocr library but am unable to do that.
Input Image:

My first approach to split into multiple letters and fix the rotate letter's and then extract the text which didn't works.
import cv2
from imutils import contours
image = cv2.imread('input_0.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
thresh = cv2.threshold(gray,0,255,cv2.THRESH_OTSU + cv2.THRESH_BINARY)[1]
cnts = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
cnts, _ = contours.sort_contours(cnts, method="left-to-right")
ROI_number = 0
for c in cnts:
area = cv2.contourArea(c)
if area > 10:
x,y,w,h = cv2.boundingRect(c)
ROI = 255 - image[y:y+h, x:x+w]
cv2.imwrite('ROI_{}.png'.format(ROI_number), ROI)
cv2.rectangle(image, (x, y), (x + w, y + h), (36,255,12), 1)
ROI_number += 1
cv2.imshow('thresh', thresh)
cv2.imshow('image', image)
cv2.waitKey(0)
Output Getting:

Now
I want to reduce the space between the letters and fix the rotated letters in the image but I am not getting any solution for the same.
UPDATE
Tried to rotate the letter by using below code but am unable
cnts = cv2.findContours(thresh, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
rect = cv2.minAreaRect(cnts[0])
box = np.int0(cv2.boxPoints(rect))
cv2.drawContours(image, [box], 0, (36,255,12), 3) # OR
# cv2.polylines(image, [box], True, (36,255,12), 3)
cv2.imshow('image', image)
cv2.waitKey()
Expected Output
784FIK
Please suggest how to reduce the space between the letters and fix the rotated letters? then may be tesseract ocr works.
