Skip to content

Commit

Permalink
feat: Only visualize without output to file
Browse files Browse the repository at this point in the history
  • Loading branch information
shahrukhqasim committed Oct 14, 2017
1 parent 26e5fa5 commit 796e8c2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions python/tools/unlv_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import json
import shutil

show = False
show = True
show_ocr = False
dont_output = True


class UnlvConverter:
Expand Down Expand Up @@ -41,8 +42,9 @@ def see_table(self, table, increment):
table_json['table']['y2'] = y2

sorted_path_full = self.sorted_path + "-%d" % increment
assert(not os.path.exists(sorted_path_full))
os.mkdir(sorted_path_full)
if not dont_output:
assert(not os.path.exists(sorted_path_full))
os.mkdir(sorted_path_full)

image = np.copy(self.image)
rows, cols, _ = np.shape(image)
Expand All @@ -65,13 +67,15 @@ def see_table(self, table, increment):
cells.append(cell)
json_out = dict()
json_out['cells'] = cells
with open(os.path.join(sorted_path_full, 'cells.json'), 'w') as f:
json.dump(json_out, f)
with open(os.path.join(sorted_path_full, 'ocr.json'), 'w') as f:
json.dump(self.words_json, f)
with open(os.path.join(sorted_path_full, 'table.json'), 'w') as f:
json.dump(table_json, f)
shutil.copy(self.png_path, os.path.join(sorted_path_full, 'image.png'))

if not dont_output:
with open(os.path.join(sorted_path_full, 'cells.json'), 'w') as f:
json.dump(json_out, f)
with open(os.path.join(sorted_path_full, 'ocr.json'), 'w') as f:
json.dump(self.words_json, f)
with open(os.path.join(sorted_path_full, 'table.json'), 'w') as f:
json.dump(table_json, f)
shutil.copy(self.png_path, os.path.join(sorted_path_full, 'image.png'))

if show:
image = cv2.resize(image, None, fx=0.25, fy=0.25)
Expand Down

0 comments on commit 796e8c2

Please sign in to comment.