File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,12 @@ def _get_box(box):
101
101
]
102
102
return box
103
103
104
+ def _normal_box (box ):
105
+ # Ensure the height and width of bbox are greater than zero
106
+ if box [3 ] - box [1 ] < 0 or box [2 ] - box [0 ] < 0 :
107
+ return False
108
+ return True
109
+
104
110
def _is_ch (s ):
105
111
for ch in s :
106
112
if "\u4e00 " <= ch <= "\u9fff " :
@@ -120,6 +126,8 @@ def _is_ch(s):
120
126
for segment in ocr_result :
121
127
box = segment [0 ]
122
128
box = _get_box (box )
129
+ if not _normal_box (box ):
130
+ continue
123
131
text = segment [1 ][0 ]
124
132
layout .append ((box , text ))
125
133
else :
@@ -130,6 +138,8 @@ def _is_ch(s):
130
138
for segment in ocr_result :
131
139
box = segment ["text_region" ]
132
140
box = _get_box (box )
141
+ if not _normal_box (box ):
142
+ continue
133
143
text = segment ["text" ]
134
144
layout .append ((box , text , region ["type" ]))
135
145
else :
@@ -156,6 +166,8 @@ def _is_ch(s):
156
166
bbox [0 ] + cell_box [2 ],
157
167
bbox [1 ] + cell_box [3 ],
158
168
]
169
+ if not _normal_box (box ):
170
+ continue
159
171
if _is_ch (text ):
160
172
text = text .replace (" " , "" )
161
173
layout .append ((box , text , region ["type" ]))
You can’t perform that action at this time.
0 commit comments