Get the vertices of card

asked 2018-03-25 22:18:04 -0600

JustMyName gravatar image

I am trying to detect a card and do warpperspective on the image. I have successfully get the contour of the card. But I am facing difficulties on how to get the vertices point (show as blue point in image) as the input of getPerspectiveTransform function.

image description

Actually I have done it with simple algorithm on a static image. However, it does not work well for live frame especially when the card rotate. Is there any simple yet robust method that can get the four vertices point of card regardless of the orientation of card?

image description

I tried minAreaRect as well but it did not give good result.

image description

edit retag flag offensive close merge delete

Comments

1

You can try the Harris corner filter to get the corners. This is probably the simplest method.

Another, more robust method is to detect the contour lines using the linear Hough transform, then get the corners, which are the intersections of the lines.

kbarni gravatar imagekbarni ( 2018-03-26 05:43:00 -0600 )edit

Actually I have tried this method too. But as u see in the last image the card edge is not only consists of one straight line. Thus multiple lines are detected for a single edge which make things complicated

JustMyName gravatar imageJustMyName ( 2018-03-26 05:56:33 -0600 )edit

To get a more robust estimation, try to modify the parameters, for example srn=2.

Then, try to detect the correct edges from the vector of lines: normally these are the first four detections. However, if two lines are too close, you can eliminate the second one and get a new line from the vector.

kbarni gravatar imagekbarni ( 2018-03-26 07:54:44 -0600 )edit