0

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.

enter image description here

This is the detected plate contour

enter image description here

And this is the warped image

enter image description here

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!

Jose Tomas
  • 107
  • 2
  • 8
  • 3
    Then, `plate_polygon` is obviously in the wrong order. Cycle the entries to achieve the corner order you have in `real_plate_polygons`. – Nico Schertler May 13 '18 at 06:51

1 Answers1

0

As nico mentioned, the problem was with the order of the points in the plate_polygon. The algorithm generating them was not consistent on the start point (in my case, starting from lower).

Jose Tomas
  • 107
  • 2
  • 8