I have some polygon (see darkblue contour):
It consists of very small segments, pixel by pixel, so angles differ although they seem to be the same. Visually we see 4 large line segments.
How can I calculate those 4 largest line segments of polygon?
I tried to use the Douglas-Peucker algorithm (red polygon) but it gave me incorrect results:
I would like that the sides of the red polygon equal the sides of the card, basically this is what the expected result must look like (yellow polygon):




As @lhf suggested in the comments I tried Hough transform on the actual contour. This gave me a number of lines per side.
Altough I tried a wide range of parameters, Hough transform was not able to fill the gaps:
I solved this by dividing the lines into groups of similar lines. The weighted average of each group gave me a pretty accurate side of the card!
I have defined similar by two conditions: