cancel ebank
Showing
1 changed file
with
13 additions
and
1 deletions
1 | import os | 1 | import os |
2 | import cv2 | ||
2 | import shutil | 3 | import shutil |
3 | import fitz | 4 | import fitz |
4 | import math | 5 | import math |
... | @@ -309,7 +310,7 @@ class PDFHandler: | ... | @@ -309,7 +310,7 @@ class PDFHandler: |
309 | if isinstance(max_img_count, int) and pdf.pageCount >= max_img_count: | 310 | if isinstance(max_img_count, int) and pdf.pageCount >= max_img_count: |
310 | self.img_count = pdf.pageCount | 311 | self.img_count = pdf.pageCount |
311 | return | 312 | return |
312 | self.check_ebank(pdf) | 313 | # self.check_ebank(pdf) |
313 | for pno in range(pdf.pageCount): | 314 | for pno in range(pdf.pageCount): |
314 | il = pdf.getPageImageList(pno) # 获取页面图片对象 | 315 | il = pdf.getPageImageList(pno) # 获取页面图片对象 |
315 | # (xref, smask, width, height, bpc, colorspace, alt.colorspace, name, filter, invoker) | 316 | # (xref, smask, width, height, bpc, colorspace, alt.colorspace, name, filter, invoker) |
... | @@ -344,3 +345,14 @@ class PDFHandler: | ... | @@ -344,3 +345,14 @@ class PDFHandler: |
344 | page = pdf.loadPage(pno) | 345 | page = pdf.loadPage(pno) |
345 | self.page_to_png(page) | 346 | self.page_to_png(page) |
346 | self.img_count = len(self.img_path_list) | 347 | self.img_count = len(self.img_path_list) |
348 | |||
349 | def ebank_draw(self): | ||
350 | for img_idx, img_path in enumerate(self.img_path_list): | ||
351 | img = cv2.imread(img_path) | ||
352 | pre, suf = os.path.splitext(img_path) | ||
353 | output_path = '{0}_res{1}'.format(pre, suf) | ||
354 | for (x0, y0, x1, y0, x1, y1, x0, y1), text in self.page_text_list[img_idx].pop('rebuild_text'): | ||
355 | # print((x0, y0, x1, y0, x1, y1, x0, y1)) | ||
356 | # print(text) | ||
357 | cv2.rectangle(img, (int(x0), int(y0)), (int(x1), int(y1)), (0, 255, 0), 2) | ||
358 | cv2.imwrite(output_path, img) | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment