Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Oct 15, 2024
1 parent 8a0d423 commit 4cea5c2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
Binary file added examples/official/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/official/180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/official/270.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file modified examples/official/normalizedResult_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion examples/official/orientation_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def convertNormalizedImage2Mat(normalized_image):
mat = convertNormalizedImage2Mat(image)
# Use Tesseract to determine the character orientation in the warped image
osd_data = pytesseract.image_to_osd(
mat, output_type=Output.DICT)
mat, lang='eng', output_type=Output.DICT)
print(osd_data)
rotation_angle = osd_data['rotate']

print(
Expand Down Expand Up @@ -117,6 +118,19 @@ def convertNormalizedImage2Mat(normalized_image):
cv2.imshow(
"Original Image with Detected Border and Rotation Angle", cv_image)
cv2.imshow("Normalized Image", mat)

# Rotate the image to the correct orientation
if rotation_angle == 90:
mat = cv2.rotate(
mat, cv2.ROTATE_90_CLOCKWISE)
elif rotation_angle == 180:
mat = cv2.rotate(mat, cv2.ROTATE_180)
elif rotation_angle == 270:
mat = cv2.rotate(
mat, cv2.ROTATE_90_COUNTERCLOCKWISE)

cv2.imshow("Rotated Image", mat)

cv2.waitKey(0)

errorCode, errorMsg = image_manager.save_to_file(
Expand Down

0 comments on commit 4cea5c2

Please sign in to comment.