Code Duplication    Length = 16-16 lines in 2 locations

ocrd/ocrd/workspace.py 2 locations

@@ 638-653 (lines=16) @@
635
            skew = 0
636
        segment_coords['angle'] = parent_coords['angle'] # nothing applied yet (depends on filters)
637
638
        if (orientation and
639
            not 'rotated-%d' % orientation in feature_filter.split(',')):
640
            # Transpose in affine coordinate transform:
641
            # (consistent with image transposition or AlternativeImage below)
642
            transposition = { 90: Image.ROTATE_90,
643
                              180: Image.ROTATE_180,
644
                              270: Image.ROTATE_270
645
            }.get(orientation) # no default
646
            segment_coords['transform'] = transpose_coordinates(
647
                segment_coords['transform'],
648
                transposition,
649
                np.array([0.5 * segment_xywh['w'],
650
                          0.5 * segment_xywh['h']]))
651
            segment_xywh['w'], segment_xywh['h'] = adjust_canvas_to_transposition(
652
                [segment_xywh['w'], segment_xywh['h']], transposition)
653
            segment_coords['angle'] += orientation
654
        if (skew and
655
            not 'deskewed' in feature_filter.split(',')):
656
            # Rotate around center in affine coordinate transform:
@@ 366-381 (lines=16) @@
363
        log.debug("page '%s' has orientation=%d skew=%.2f",
364
                  page_id, orientation, skew)
365
        
366
        if (orientation and
367
            not 'rotated-%d' % orientation in feature_filter.split(',')):
368
            # Transpose in affine coordinate transform:
369
            # (consistent with image transposition or AlternativeImage below)
370
            transposition = { 90: Image.ROTATE_90,
371
                              180: Image.ROTATE_180,
372
                              270: Image.ROTATE_270
373
            }.get(orientation) # no default
374
            page_coords['transform'] = transpose_coordinates(
375
                page_coords['transform'],
376
                transposition,
377
                np.array([0.5 * page_xywh['w'],
378
                          0.5 * page_xywh['h']]))
379
            page_xywh['w'], page_xywh['h'] = adjust_canvas_to_transposition(
380
                [page_xywh['w'], page_xywh['h']], transposition)
381
            page_coords['angle'] = orientation
382
        if (skew and
383
            not 'deskewed' in feature_filter.split(',')):
384
            # Rotate around center in affine coordinate transform: