개정판 e0ebfd16
issue #663: c
Change-Id: I7c3e6afc662c6f3f65c81ea32c8b5b61381faeed
DTI_PID/DTI_PID/TextDetector.py | ||
---|---|---|
228 | 228 |
for box in boxes: |
229 | 229 |
rects.append(QRect(box[0], box[1], box[4] - box[0], box[5] - box[1])) |
230 | 230 |
|
231 |
#configs = app_doc_data.getConfigs('Text Recognition', 'Merge Size')
|
|
232 |
#mergeSize = int(configs[0].value) if 1 == len(configs) else 10
|
|
231 |
configs = app_doc_data.getConfigs('Text Recognition', 'Merge Size') |
|
232 |
mergeSize = int(configs[0].value) if 1 == len(configs) else 10 |
|
233 | 233 |
#gap_size = mergeSize / 2 |
234 | 234 |
gap_size = 3 |
235 | 235 |
|
... | ... | |
257 | 257 |
if vertical1 is vertical2: |
258 | 258 |
continue |
259 | 259 |
if abs(vertical1.center().x() - vertical2.center().x()) < gap_size: |
260 |
t1, t2 = vertical1.top() + gap_size, vertical2.top() + gap_size |
|
261 |
b1, b2 = vertical1.bottom() - gap_size, vertical2.bottom() - gap_size |
|
262 |
if not (b2 < t1 or t2 < b1): |
|
260 |
t1, t2 = vertical1.top() - mergeSize, vertical2.top() - mergeSize |
|
261 |
b1, b2 = vertical1.bottom() + mergeSize, vertical2.bottom() + mergeSize |
|
262 |
l_x_y, s_x_y = [t1, b1], [t2, b2] |
|
263 |
if not (max(l_x_y) < min(s_x_y) or max(s_x_y) < min(l_x_y)): |
|
263 | 264 |
inserted = False |
264 | 265 |
for merge in v_merges: |
265 | 266 |
if vertical1 in merge and vertical2 in merge: |
... | ... | |
282 | 283 |
if horizontal1 is horizontal2: |
283 | 284 |
continue |
284 | 285 |
if abs(horizontal1.center().y() - horizontal2.center().y()) < gap_size: |
285 |
l1, l2 = horizontal1.left() - gap_size, horizontal2.left() - gap_size |
|
286 |
r1, r2 = horizontal1.right() + gap_size, horizontal2.right() + gap_size |
|
287 |
if not (l2 < r1 or r2 < l1): |
|
286 |
l1, l2 = horizontal1.left() - mergeSize, horizontal2.left() - mergeSize |
|
287 |
r1, r2 = horizontal1.right() + mergeSize, horizontal2.right() + mergeSize |
|
288 |
l_x_y, s_x_y = [l1, r1], [l2, r2] |
|
289 |
if not (max(l_x_y) < min(s_x_y) or max(s_x_y) < min(l_x_y)): |
|
288 | 290 |
inserted = False |
289 | 291 |
for merge in h_merges: |
290 | 292 |
if horizontal1 in merge and horizontal2 in merge: |
... | ... | |
315 | 317 |
min_x = rect.left() |
316 | 318 |
if rect.right() > max_x: |
317 | 319 |
max_x = rect.right() |
318 |
if rect.top() > max_y:
|
|
319 |
max_y = rect.top()
|
|
320 |
if rect.bottom() < min_y:
|
|
321 |
min_y = rect.bottom()
|
|
320 |
if rect.top() < min_y:
|
|
321 |
min_y = rect.top()
|
|
322 |
if rect.bottom() > max_y:
|
|
323 |
max_y = rect.bottom()
|
|
322 | 324 |
|
323 |
rect = QRect(min_x, max_y, max_x - min_x, max_y - min_y)
|
|
325 |
rect = QRect(min_x, min_y, max_x - min_x, max_y - min_y)
|
|
324 | 326 |
rect._vertical = True |
325 | 327 |
rects.append(rect) |
326 | 328 |
|
... | ... | |
331 | 333 |
min_x = rect.left() |
332 | 334 |
if rect.right() > max_x: |
333 | 335 |
max_x = rect.right() |
334 |
if rect.top() > max_y:
|
|
335 |
max_y = rect.top()
|
|
336 |
if rect.bottom() < min_y:
|
|
337 |
min_y = rect.bottom()
|
|
336 |
if rect.top() < min_y:
|
|
337 |
min_y = rect.top()
|
|
338 |
if rect.bottom() > max_y:
|
|
339 |
max_y = rect.bottom()
|
|
338 | 340 |
|
339 |
rect = QRect(min_x, max_y, max_x - min_x, max_y - min_y)
|
|
341 |
rect = QRect(min_x, min_y, max_x - min_x, max_y - min_y)
|
|
340 | 342 |
rect._vertical = False |
341 | 343 |
rects.append(rect) |
342 | 344 |
|
내보내기 Unified diff