I have some images containing plates and each image has a file that contains a list of points around the plate. The points were chosen manually by some persons, so there is no rule (like chose the four corners or something like that). I want to extract the plates from the images, but I have met some problems in choosing the best approach for finding the closer quadrilateral that describes the plate.
I have tried to do a minAreaRect
on the contour, but his is often returning a very different quadrilateral that has a lot of background and/or the plate is inclined (like italic) in some direction.
I have tried to do approxPolyDP
and it seems that it returns a much more close contour (that is expected to be so), but here the problem is about the approximation error (epsilon): if it is too small, I get a contour that has more than 4 corners; if it is too large, I may receive a contour that has 3 corners, or that has cut a part of the plate. [I have tried to apply here the minAreaRect
on those cases, but it seems that I arrive in the same situation as in the first try]
I am willing to apply the approxPolyDP
in a recursive mode: if the approximation has not 4 corners I will increase the error and apply once more the function. But is this the way to go? Isn't there a function that may approximate the contour with the closest quadrilateral? Or is there another suggestion in achieving this?