Skip to content

Commit

Permalink
change text visualization color
Browse files Browse the repository at this point in the history
  • Loading branch information
MulongXie committed Jul 6, 2021
1 parent 03482ac commit 074cae3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion detect_text/Text.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def shrink_bound(self, binary_map):
*** Visualization ***
*********************
'''
def visualize_element(self, img, color=(0, 255, 0), line=1, show=False):
def visualize_element(self, img, color=(0, 0, 255), line=1, show=False):
loc = self.location
cv2.rectangle(img, (loc['left'], loc['top']), (loc['right'], loc['bottom']), color, line)
if show:
Expand Down
Binary file modified detect_text/__pycache__/Text.cpython-35.pyc
Binary file not shown.
Binary file modified detect_text/__pycache__/text_detection.cpython-35.pyc
Binary file not shown.
10 changes: 5 additions & 5 deletions detect_text/text_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ def save_detection_json(file_path, texts, img_shape):
json.dump(output, f_out, indent=4)


def visualize_texts(org_img, texts, shown_resize=None, show=False, write_path=None):
def visualize_texts(org_img, texts, shown_resize_height=None, show=False, write_path=None):
img = org_img.copy()
for text in texts:
text.visualize_element(img, line=2)

img_resize = img
if shown_resize is not None:
img_resize = cv2.resize(img, shown_resize)
if shown_resize_height is not None:
img_resize = cv2.resize(img, (int(shown_resize_height * (img.shape[1]/img.shape[0])), shown_resize_height))

if show:
cv2.imshow('img', img_resize)
cv2.imshow('texts', img_resize)
cv2.waitKey(0)
cv2.destroyAllWindows()
if write_path is not None:
Expand Down Expand Up @@ -126,7 +126,7 @@ def text_detection(input_file='../data/input/30800.jpg', output_file='../data/ou
texts = merge_intersected_texts(texts)
texts = text_filter_noise(texts)
texts = text_sentences_recognition(texts)
visualize_texts(img, texts, (600, 900), show=show, write_path=pjoin(oct_root, name+'.png'))
visualize_texts(img, texts, shown_resize_height=800, show=show, write_path=pjoin(oct_root, name+'.png'))
save_detection_json(pjoin(oct_root, name+'.json'), texts, img.shape)
print("[Text Detection Completed in %.3f s] %s" % (time.clock() - start, input_file))

Expand Down

0 comments on commit 074cae3

Please sign in to comment.