Get the vertices of card
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.
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?
I tried minAreaRect as well but it did not give good result.
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.
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
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.