Java图像旋转:计算的角度正确吗?

Java图像旋转:计算的角度正确吗?,java,algorithm,rotation,ocr,tesseract,Java,Algorithm,Rotation,Ocr,Tesseract,我在通过OCR处理发票的程序中发现了一个有趣的问题。 在一个步骤中,我取消了对图像的查看,现在我有了一个特定的用例 原始文件(已解密): 旋转文件(已解密): 我心里一直在想,旋转角度大约是-15度,但是程序告诉我旋转角度是-2.2度 使用的代码: private BufferedImage rotateImage(BufferedImage image, float angleDegrees, int imageType) { long start = System.current

我在通过OCR处理发票的程序中发现了一个有趣的问题。
在一个步骤中,我取消了对图像的查看,现在我有了一个特定的用例

原始文件(已解密):

旋转文件(已解密):

我心里一直在想,旋转角度大约是-15度,但是程序告诉我旋转角度是-2.2度

使用的代码:

private BufferedImage rotateImage(BufferedImage image, float angleDegrees, int imageType) {
    long start = System.currentTimeMillis();
    angleDegrees %= 360;
    BufferedImage returnImage = new BufferedImage(image.getWidth(), image.getHeight(), imageType);
    Graphics2D g2d = returnImage.createGraphics();
    g2d.rotate(Math.toRadians(angleDegrees), returnImage.getWidth() / 2, returnImage.getHeight() / 2);
    g2d.drawImage(image, 0, 0, null);
    g2d.dispose();
    long end = System.currentTimeMillis();
    float duration = 1.0f * (end - start) / 1000;
    //System.out.println("Duration: " + duration + " seconds");
    return returnImage;
}

如您所见,代码似乎运行正常,但谁是正确的?如何计算图像的实际旋转?到底发生了什么?

看看这一行:

它的尺寸是:472*20。对其应用arctan功能:

atan(20/472) = 0.042347549 radians
将其转换为度,您将拥有:

2.42633583 degrees

因此,您的程序工作正常,您对15度的估计值完全错误。

请看这一行:

它的尺寸是:472*20。对其应用arctan功能:

atan(20/472) = 0.042347549 radians
将其转换为度,您将拥有:

2.42633583 degrees

因此,您的程序工作正常,您对15度的估计值完全错误。

请看这一行:

它的尺寸是:472*20。对其应用arctan功能:

atan(20/472) = 0.042347549 radians
将其转换为度,您将拥有:

2.42633583 degrees

因此,您的程序工作正常,您对15度的估计值完全错误。

请看这一行:

它的尺寸是:472*20。对其应用arctan功能:

atan(20/472) = 0.042347549 radians
将其转换为度,您将拥有:

2.42633583 degrees
所以,你的程序运行正常,你对15度的估计完全错误