Skip to content

Commit

Permalink
Merge pull request JaidedAI#180 from vifly/patch
Browse files Browse the repository at this point in the history
Make readtext() can use '~' path
  • Loading branch information
rkcosmos authored Jul 26, 2020
2 parents 2489e00 + 448e8f6 commit af1fe49
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion easyocr/easyocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,14 @@ def readtext(self, image, decoder = 'greedy', beamWidth= 5, batch_size = 1,\
'''

if type(image) == str:
img = loadImage(image) # can accept URL
if image.startswith('http://') or image.startswith('https://'):
tmp, _ = urlretrieve(image)
img_cv_grey = cv2.imread(tmp, cv2.IMREAD_GRAYSCALE)
os.remove(tmp)
else:
img_cv_grey = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
image = os.path.expanduser(image)
img = loadImage(image) # can accept URL
elif type(image) == bytes:
nparr = np.frombuffer(image, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
Expand Down

0 comments on commit af1fe49

Please sign in to comment.