I am currently developing an ALPR system. To detect the plate first I am using the method described here.
The problem comes with certain images. After using findHomography and warpPerspective it gives me the plate image rotated.
This is the original image that gives me issues.
This is the detected plate contour
And this is the warped image
As you can see it is rotated 90 degrees. In other examples the detection works amazing.
The specific piece of code
cv::Mat warpped_plate( PLATE_HEIGHT, PLATE_WIDTH, CV_8UC3 );
vector< cv::Point> real_plate_polygons;
real_plate_polygons = {cv::Point(PLATE_WIDTH, PLATE_HEIGHT), cv::Point(0, PLATE_HEIGHT), cv::Point(0, 0), cv::Point(PLATE_WIDTH, 0)};
cv::Mat homography = cv::findHomography( plate_polygons, real_plate_polygons );
cv::warpPerspective(source_img, warpped_plate, homography, cv::Size(PLATE_WIDTH, PLATE_HEIGHT));
Where plate_polygons contains the four points of the plate (and are correct, because were used to draw the white box in the mask).
Any ideas? Thanks in advance!