我正在尝试弄清楚如何使用 Java 中的 OpenCV 校正给定收据图像的角度(用数码相机拍摄,因此它可能不够直)。该计划是(可能)改进 ABBYY FineReaders 自动文本识别结果。 不幸的是,我没有在文档方面取得进展——它是针对 C++ 的,我真的遇到了麻烦……我不知道要使用哪些函数,等等…… 有 OpenCV 经验的人可以给我一些关于如何进行的提示吗? 非常感谢您的帮助。
最佳答案
使用 warpaffine 非常简单opencv中的函数您只需要设置图像应该旋转的位置,然后创建旋转矩阵并使用上述函数将其应用于图像。这是如何制作的示例代码:
cv::Point Rotation_anchor = cv::Point( Desired_X_Position, Desired_Y_Position );
double angle = Angle_Val;
double scale = 1;
/// Get the rotation matrix with the specifications above
cv::Mat rotation_matrix = cv::getRotationMatrix2D( Rotation_anchor, angle, scale );
/// Rotate the warped image
cv::warpAffine( Input_Image, Output_Image, rotation_matrix, Input_Image.size() );
关于java - 使用 OpenCV - Java 在收据上查找边缘并校正角度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22966109/