I'm trying to figure out how to correct the angle of a given image of a receipt (taken with a digital camera, so it's probably not straight enough) using OpenCV in Java. The plan is to (maybe) improve ABBYY FineReaders automatic text recognition results. Unfortunately I'm not making progress with the documentation - it's for C++ and I'm really having trouble with it... I don't know which functions to use, etc... Could someone with experience with OpenCV give me a few hints on how to proceed? Help would be much appreciated.
Asked
Active
Viewed 1,145 times
2
-
See [Automatic perspective correction OpenCV](http://stackoverflow.com/questions/22519545/automatic-perspective-correction-opencv/22550609#22550609) and [Perspective correction in OpenCV using python](http://stackoverflow.com/questions/22656698/perspective-correction-in-opencv-using-python/22662181#22662181)might be helpful. – Haris Apr 09 '14 at 15:38
1 Answers
0
It's pretty easy using warpaffine function in opencv. you just need to set from where the image should be rotated and then you create the rotation matrix and apply it on the image using the above function. here it is a sample code of how to make one:
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() );

PsP
- 696
- 3
- 10
- 34