개정판 d98b24c3
dev issue #507 : fix ocr text
Change-Id: I95bc2a5de154c1578ac4a17067f32dd20aea1f3d
DTI_PID/DTI_PID/tesseract_ocr_module.py | ||
---|---|---|
141 | 141 |
merged_boxes.append(QRect(minx, miny, maxx - minx, maxy - miny)) |
142 | 142 |
""" |
143 | 143 |
|
144 |
# After |
|
144 | 145 |
for box in bounding_boxes: |
145 | 146 |
if merged_boxes: |
146 | 147 |
tokens = box.split(' ') |
... | ... | |
154 | 155 |
for merged_box in merged_boxes: |
155 | 156 |
bottom = merged_box.bottom() |
156 | 157 |
top = merged_box.top() |
157 |
if (abs(miny - top) <= 4 or abs(maxy - bottom) <= 4) or (miny <= top and maxy >= bottom) or \ |
|
158 |
(miny >= top and maxy <= bottom): |
|
158 |
if (abs(miny - top) <= (bottom - top) * 0.2 or abs(maxy - bottom) <= (bottom - top) * 0.2) or ( |
|
159 |
miny <= top and maxy >= bottom) or ( |
|
160 |
miny >= top and maxy <= bottom): |
|
159 | 161 |
find_box = merged_box |
160 | 162 |
|
161 | 163 |
if find_box: |
... | ... | |
174 | 176 |
maxx = int(tokens[3]) |
175 | 177 |
maxy = int(tokens[4]) |
176 | 178 |
merged_boxes.append(QRect(minx, miny, maxx - minx, maxy - miny)) |
179 |
go_loop = True |
|
180 |
while (go_loop): |
|
181 |
go_loop = False |
|
182 |
for i in range(0, len(merged_boxes) - 1): |
|
183 |
range1 = merged_boxes[i] |
|
184 |
for j in range(1, len(merged_boxes)): |
|
185 |
range2 = merged_boxes[j] |
|
186 |
if i == j: |
|
187 |
continue |
|
188 |
|
|
189 |
if range1.left() <= range2.right() and range1.right() >= range2.left() and range1.top() <= \ |
|
190 |
range2.bottom() and range1.bottom() >= range2.top(): |
|
191 |
range1.setLeft(min(range1.left(), range2.left())) |
|
192 |
range1.setTop(min(range1.top(), range2.top())) |
|
193 |
range1.setRight(max(range1.right(), range2.right())) |
|
194 |
range1.setBottom(max(range1.bottom(), range2.bottom())) |
|
195 |
merged_boxes.remove(range2) |
|
196 |
go_loop = True |
|
197 |
break |
|
198 |
|
|
199 |
if go_loop: |
|
200 |
break |
|
201 |
# After |
|
177 | 202 |
|
178 | 203 |
for rect in merged_boxes: |
179 | 204 |
if not rect.isValid() or \ |
내보내기 Unified diff