How to keep original shape size using OpenCvSharp.ApproxPolyDP

Maksym Valuiko 1 Reputation point
2020-12-27T19:43:29.25+00:00

I am using OpenCvSharp.ApproxPolyDP to reduce the number of points in a polygon. However, this algorithm changes the original shape of the shape and produces cut corners. Is it possible to optimize the number of points in a polygon and keep the original shape?

Before poly optimization:
51395-image.png

After poly optimization:
51396-image.png

Expected (red):
51397-image.png

The code that I'm using:

OpenCvSharp.Cv2.ApproxPolyDP(polyPoints, tempThreshHold, true)  
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,927 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.