Loading rpc/methods.py +1 −20 Original line number Diff line number Diff line Loading @@ -70,19 +70,6 @@ def _deskew(image_path: str, max_skew: int = 10) -> float: x1, y1, x2, y2 = line[0] angles.append(numpy.arctan2(y2 - y1, x2 - x1)) # If the majority of our lines are vertical, this is probably a landscape image landscape = ( numpy.sum([abs(angle) > numpy.pi / 4 for angle in angles]) > len(angles) / 2 ) # Filter the angles to remove outliers based on max_skew if landscape: angles = [ angle for angle in angles if numpy.deg2rad(90 - max_skew) < abs(angle) < numpy.deg2rad(90 + max_skew) ] else: angles = [angle for angle in angles if abs(angle) < numpy.deg2rad(max_skew)] if len(angles) < 5: Loading @@ -92,12 +79,6 @@ def _deskew(image_path: str, max_skew: int = 10) -> float: # Average the angles to a degree offset angle_deg = numpy.rad2deg(numpy.median(angles)) # If this is landscape image, rotate the entire canvas appropriately if landscape: if angle_deg < 0: angle_deg += 90 elif angle_deg > 0: angle_deg -= 90 return angle_deg * -1 Loading Loading
rpc/methods.py +1 −20 Original line number Diff line number Diff line Loading @@ -70,19 +70,6 @@ def _deskew(image_path: str, max_skew: int = 10) -> float: x1, y1, x2, y2 = line[0] angles.append(numpy.arctan2(y2 - y1, x2 - x1)) # If the majority of our lines are vertical, this is probably a landscape image landscape = ( numpy.sum([abs(angle) > numpy.pi / 4 for angle in angles]) > len(angles) / 2 ) # Filter the angles to remove outliers based on max_skew if landscape: angles = [ angle for angle in angles if numpy.deg2rad(90 - max_skew) < abs(angle) < numpy.deg2rad(90 + max_skew) ] else: angles = [angle for angle in angles if abs(angle) < numpy.deg2rad(max_skew)] if len(angles) < 5: Loading @@ -92,12 +79,6 @@ def _deskew(image_path: str, max_skew: int = 10) -> float: # Average the angles to a degree offset angle_deg = numpy.rad2deg(numpy.median(angles)) # If this is landscape image, rotate the entire canvas appropriately if landscape: if angle_deg < 0: angle_deg += 90 elif angle_deg > 0: angle_deg -= 90 return angle_deg * -1 Loading