- Rotate the image by 0 degrees, 22.5 degrees, 45 degrees, 67.5 degrees, and 90 degrees, and save these 5 pictures.
- Use a (lightweight) text detection model to perform text detection on these 5 pictures.
- Then select the angle with the largest long text box and the largest aspect ratio, as the approximate rotation angle judgment, and get the angle θ 1 ∈ (0, 22.5, 45, 67.5, 90) \theta1 \in (0, 22.5, 45, 67.5, 90)θ 1∈(0,22.5,45,67.5,90)。
- Using the text box obtained in the previous step, count the largest long side inclination angles of the text box to obtain the angle θ 2 \theta2θ 2。
- Through θ 1 \theta1θ 1 andθ 2 \theta2θ 2 to rotate the original image.
The original image on the left, the corrected image on the right, use 0 padding around, and the corrected image detection text box is drawn on the top.