|
@@ 453-484 (lines=32) @@
|
| 450 |
|
page_coords['features'] = '' |
| 451 |
|
alternative_image = None |
| 452 |
|
alternative_images = page.get_AlternativeImage() |
| 453 |
|
if alternative_images: |
| 454 |
|
# (e.g. from page-level cropping, binarization, deskewing or despeckling) |
| 455 |
|
if feature_selector or feature_filter: |
| 456 |
|
alternative_image = None |
| 457 |
|
# search from the end, because by convention we always append, |
| 458 |
|
# and among multiple satisfactory images we want the most recent: |
| 459 |
|
for alternative_image in reversed(alternative_images): |
| 460 |
|
features = alternative_image.get_comments() |
| 461 |
|
if not features: |
| 462 |
|
log.warning("AlternativeImage %d for page '%s' does not have any feature attributes", |
| 463 |
|
alternative_images.index(alternative_image) + 1, page_id) |
| 464 |
|
features = '' |
| 465 |
|
if (all(feature in features |
| 466 |
|
for feature in feature_selector.split(',') if feature) and |
| 467 |
|
not any(feature in features |
| 468 |
|
for feature in feature_filter.split(',') if feature)): |
| 469 |
|
break |
| 470 |
|
else: |
| 471 |
|
alternative_image = None |
| 472 |
|
else: |
| 473 |
|
alternative_image = alternative_images[-1] |
| 474 |
|
features = alternative_image.get_comments() |
| 475 |
|
if not features: |
| 476 |
|
log.warning("AlternativeImage %d for page '%s' does not have any feature attributes", |
| 477 |
|
alternative_images.index(alternative_image) + 1, page_id) |
| 478 |
|
features = '' |
| 479 |
|
if alternative_image: |
| 480 |
|
log.debug("Using AlternativeImage %d (%s) for page '%s'", |
| 481 |
|
alternative_images.index(alternative_image) + 1, |
| 482 |
|
features, page_id) |
| 483 |
|
page_image = self._resolve_image_as_pil(alternative_image.get_filename()) |
| 484 |
|
page_coords['features'] = features |
| 485 |
|
|
| 486 |
|
# adjust the coord transformation to the steps applied on the image, |
| 487 |
|
# and apply steps on the existing image in case it is missing there, |
|
@@ 704-735 (lines=32) @@
|
| 701 |
|
|
| 702 |
|
alternative_image = None |
| 703 |
|
alternative_images = segment.get_AlternativeImage() |
| 704 |
|
if alternative_images: |
| 705 |
|
# (e.g. from segment-level cropping, binarization, deskewing or despeckling) |
| 706 |
|
if feature_selector or feature_filter: |
| 707 |
|
alternative_image = None |
| 708 |
|
# search from the end, because by convention we always append, |
| 709 |
|
# and among multiple satisfactory images we want the most recent: |
| 710 |
|
for alternative_image in reversed(alternative_images): |
| 711 |
|
features = alternative_image.get_comments() |
| 712 |
|
if not features: |
| 713 |
|
log.warning("AlternativeImage %d for segment '%s' does not have any feature attributes", |
| 714 |
|
alternative_images.index(alternative_image) + 1, segment.id) |
| 715 |
|
features = '' |
| 716 |
|
if (all(feature in features |
| 717 |
|
for feature in feature_selector.split(',') if feature) and |
| 718 |
|
not any(feature in features |
| 719 |
|
for feature in feature_filter.split(',') if feature)): |
| 720 |
|
break |
| 721 |
|
else: |
| 722 |
|
alternative_image = None |
| 723 |
|
else: |
| 724 |
|
alternative_image = alternative_images[-1] |
| 725 |
|
features = alternative_image.get_comments() |
| 726 |
|
if not features: |
| 727 |
|
log.warning("AlternativeImage %d for segment '%s' does not have any feature attributes", |
| 728 |
|
alternative_images.index(alternative_image) + 1, segment.id) |
| 729 |
|
features = '' |
| 730 |
|
if alternative_image: |
| 731 |
|
log.debug("Using AlternativeImage %d (%s) for segment '%s'", |
| 732 |
|
alternative_images.index(alternative_image) + 1, |
| 733 |
|
features, segment.id) |
| 734 |
|
segment_image = self._resolve_image_as_pil(alternative_image.get_filename()) |
| 735 |
|
segment_coords['features'] = features |
| 736 |
|
|
| 737 |
|
alternative_image_features = segment_coords['features'].split(',') |
| 738 |
|
for duplicate_feature in set([feature for feature in alternative_image_features |