Skip to content

Commit 4cea5c2

Browse files
committed
Update
1 parent 8a0d423 commit 4cea5c2

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

examples/official/0.png

1.04 MB
Loading

examples/official/180.png

1.02 MB
Loading

examples/official/270.png

1.05 MB
Loading
File renamed without changes.
-1.53 KB
Loading

examples/official/orientation_detection.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def convertNormalizedImage2Mat(normalized_image):
8989
mat = convertNormalizedImage2Mat(image)
9090
# Use Tesseract to determine the character orientation in the warped image
9191
osd_data = pytesseract.image_to_osd(
92-
mat, output_type=Output.DICT)
92+
mat, lang='eng', output_type=Output.DICT)
93+
print(osd_data)
9394
rotation_angle = osd_data['rotate']
9495

9596
print(
@@ -117,6 +118,19 @@ def convertNormalizedImage2Mat(normalized_image):
117118
cv2.imshow(
118119
"Original Image with Detected Border and Rotation Angle", cv_image)
119120
cv2.imshow("Normalized Image", mat)
121+
122+
# Rotate the image to the correct orientation
123+
if rotation_angle == 90:
124+
mat = cv2.rotate(
125+
mat, cv2.ROTATE_90_CLOCKWISE)
126+
elif rotation_angle == 180:
127+
mat = cv2.rotate(mat, cv2.ROTATE_180)
128+
elif rotation_angle == 270:
129+
mat = cv2.rotate(
130+
mat, cv2.ROTATE_90_COUNTERCLOCKWISE)
131+
132+
cv2.imshow("Rotated Image", mat)
133+
120134
cv2.waitKey(0)
121135

122136
errorCode, errorMsg = image_manager.save_to_file(

0 commit comments

Comments
 (0)