Class OpenCvUtil

java.lang.Object
com.itextpdf.pdfocr.onnxtr.util.OpenCvUtil

public final class OpenCvUtil extends Object
Static class with OpenCV utility functions.
  • Method Details

    • normalizeRotatedRect

      public static org.bytedeco.opencv.opencv_core.RotatedRect normalizeRotatedRect (org.bytedeco.opencv.opencv_core.RotatedRect rect)
      Normalizes RotatedRect, so that its angle is in the [-45; 45) range.

      We want our boxes to have the point order, so that it matches input image orientation. Otherwise, the orientation detection model will get a different box, which is already pre-rotated in some way. Here we will alter the rectangle, so that points would output the expected order.

      This will make box have points in the following order, relative to the page: BL, TL, TR, BR. Bottom as in bottom of the image, not the lowest Y coordinate.

      Parameters:
      rect - RotatedRect to normalize
      Returns:
      normalized RotatedRect