Skip to content

Add optional verbose parameter to hide progress bar #1389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion easyocr/easyocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def readtext(self, image, decoder = 'greedy', beamWidth= 5, batch_size = 1,\
Parameters:
image: file path or numpy-array or a byte stream object
'''
img, img_cv_grey = reformat_input(image)
img, img_cv_grey = reformat_input(image, verbose=self.verbose)

horizontal_list, free_list = self.detect(img,
min_size = min_size, text_threshold = text_threshold,\
Expand Down
8 changes: 6 additions & 2 deletions easyocr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,10 +729,14 @@ def progress_hook(count, blockSize, totalSize):

return progress_hook

def reformat_input(image):
def reformat_input(image, verbose=True):
if type(image) == str:
if image.startswith('http://') or image.startswith('https://'):
tmp, _ = urlretrieve(image , reporthook=printProgressBar(prefix = 'Progress:', suffix = 'Complete', length = 50))
reportHook = printProgressBar(prefix = 'Progress:', suffix = 'Complete', length = 50)
if not verbose:
reportHook = None

tmp, _ = urlretrieve(image , reporthook=reportHook)
img_cv_grey = cv2.imread(tmp, cv2.IMREAD_GRAYSCALE)
os.remove(tmp)
else:
Expand Down