-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added configuration options for tesseract
- Loading branch information
1 parent
1469cbf
commit 01775c3
Showing
3 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
IDE: PyCharm | ||
Project: ocr-api | ||
Author: Robin | ||
Filename: preprocessing.py | ||
Date: 21.01.2020 | ||
""" | ||
import cv2 | ||
|
||
|
||
def preprocess_image(image_path): | ||
# load the example image and convert it to grayscale | ||
image = cv2.imread(image_path) | ||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) | ||
gray = cv2.threshold(gray, 0, 255, | ||
cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1] | ||
cv2.imwrite(image_path, gray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters