Ask Your Question
3

What is the best way to approximate a contour with a warped rectange?

asked 2015-04-08 06:18:57 -0600

thdrksdfthmn gravatar image

updated 2015-09-18 07:34:45 -0600

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?


After many requests, I finally add the images.

Supposing I have an image like this image description or like this one image description. Do a simple binarization to find some plates contour. It should have many points, and especially on the corners there are more than one point. If you do something interesting, please let me know :)

edit retag flag offensive close merge delete

Comments

would you add some images describe the problem

essamzaky gravatar imageessamzaky ( 2015-04-08 08:43:03 -0600 )edit

@thdrksdfthmn did you solve your problem?

sturkmen gravatar imagesturkmen ( 2015-09-08 06:26:25 -0600 )edit

:( no... I have used he approxPolyDP, because my in case the contour has 4 main corners and the others may be approximated by the function... I think another approach should be by grouping the contour's corners, if they are "in agglomerations". And then, maybe by using lines... I don't know. Do you have a similar problem? You can post a new question and link this one too.

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-09-08 08:26:22 -0600 )edit

i am willing to try to find a solution. could you provide a sample image?

sturkmen gravatar imagesturkmen ( 2015-09-17 14:42:03 -0600 )edit

Have you solve your problem ? with this image (I have supposed that license is isolated) I can rotate this image ( using plate major axis) and after with local translation I have got this. Black line in result are due to method but they can be filled after.

LBerger gravatar imageLBerger ( 2015-09-26 15:06:58 -0600 )edit

Interesting approach! How did you do the local translations?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-09-28 02:51:57 -0600 )edit

I look for nearest neighbour between rect and contour plate. After I have got translation value for each plate contour

LBerger gravatar imageLBerger ( 2015-09-28 04:04:02 -0600 )edit

I am not really sure that I understood :)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-09-28 09:11:17 -0600 )edit

@thdrksdfthmn My problem with my code is: first it works for my own image. If you want to change orignal image you have to check contour index (of plate) manually. Second I don't know method name I have to read some papers. Third there is a bug somewhere in algorithm... I can give you source code by email. You can use this to find my email

LBerger gravatar imageLBerger ( 2015-09-28 09:59:23 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-09-20 04:06:13 -0600

updated 2015-09-20 04:17:40 -0600

this is not a complate answer. just initial work to understand desired result.

i have made a small change to squares.cpp like here

result :

image description

image description

edit flag offensive delete link more

Comments

Nice approach, I shall test it when I have the time... Have you tried to display the area (applying perspective transform)? Is it deformed a lot?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-09-21 02:25:43 -0600 )edit

openalpr , i found it newly. i should try it!

sturkmen gravatar imagesturkmen ( 2016-01-02 17:25:11 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-04-08 06:18:57 -0600

Seen: 1,551 times

Last updated: Sep 20 '15