# 在一行坚排文字的左边画一条红线
Browse files
main.py
CHANGED
|
@@ -38,7 +38,10 @@ def imread(imgpath, read_type=cv2.IMREAD_COLOR, max_retry_limit=5, retry_interva
|
|
| 38 |
|
| 39 |
return img
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
if __name__ == '__main__':
|
| 44 |
|
|
@@ -108,17 +111,25 @@ if __name__ == '__main__':
|
|
| 108 |
chunk_size = 16
|
| 109 |
|
| 110 |
regions, textblk_lst_indices = collect_textblock_regions(img, blk_list, model_text_height, model_maxwidth, split_textblk, seg_func)
|
| 111 |
-
# return self.model(blk_list, regions, textblk_lst_indices, chunk_size=self.chunk_size)
|
| 112 |
|
| 113 |
|
| 114 |
ocr_model(blk_list, regions, textblk_lst_indices, chunk_size=chunk_size)
|
| 115 |
|
|
|
|
|
|
|
|
|
|
| 116 |
# ui\mainwindow.py
|
| 117 |
for blk in blk_list:
|
| 118 |
text = blk.get_text()
|
|
|
|
|
|
|
| 119 |
pass
|
| 120 |
# blk.text = self.ocrSubWidget.sub_text(text)
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
pass
|
| 123 |
|
| 124 |
|
|
|
|
| 38 |
|
| 39 |
return img
|
| 40 |
|
| 41 |
+
def chunks(lst, n):
|
| 42 |
+
"""Yield successive n-sized chunks from lst."""
|
| 43 |
+
for i in range(0, len(lst), n):
|
| 44 |
+
yield lst[i:i + n]
|
| 45 |
|
| 46 |
if __name__ == '__main__':
|
| 47 |
|
|
|
|
| 111 |
chunk_size = 16
|
| 112 |
|
| 113 |
regions, textblk_lst_indices = collect_textblock_regions(img, blk_list, model_text_height, model_maxwidth, split_textblk, seg_func)
|
|
|
|
| 114 |
|
| 115 |
|
| 116 |
ocr_model(blk_list, regions, textblk_lst_indices, chunk_size=chunk_size)
|
| 117 |
|
| 118 |
+
|
| 119 |
+
img_draw = img.copy()
|
| 120 |
+
|
| 121 |
# ui\mainwindow.py
|
| 122 |
for blk in blk_list:
|
| 123 |
text = blk.get_text()
|
| 124 |
+
for line in blk.lines:
|
| 125 |
+
img_draw = cv2.rectangle(img_draw, line[0], line[3], (0, 0, 255), 2) # 在一行坚排文字的左边画一条红线
|
| 126 |
pass
|
| 127 |
# blk.text = self.ocrSubWidget.sub_text(text)
|
| 128 |
|
| 129 |
+
|
| 130 |
+
cv2.imwrite("E:/xxxxxxxxxxxxxxxx.jpg", img_draw)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
pass
|
| 134 |
|
| 135 |
|