workspace._rotate: avoid unnecessary image ops for 'recropped' (with false warning)
@@ -1066,9 +1066,13 @@ def _rotate(log, name, skew, segment, segment_image, segment_coords, segment_xyw
(not isinstance(segment, BorderType) or # always crop below page level
'cropped' in segment_coords['features'])):
# only shift coordinates as if re-cropping
- _, segment_coords, segment_xywh = _crop(
- log, name, segment, segment_image, segment_coords,
- op='recropped', **kwargs)
+ segment_polygon = coordinates_of_segment(segment, segment_image, segment_coords)
+ segment_bbox = bbox_from_polygon(segment_polygon)
+ segment_xywh = xywh_from_bbox(*segment_bbox)
+ segment_coords['transform'] = shift_coordinates(
+ segment_coords['transform'],
+ np.array([-segment_bbox[0],
+ -segment_bbox[1]]))
return segment_image, segment_coords, segment_xywh
def _scale(log, name, factor, segment_image, segment_coords, segment_xywh, **kwargs):
