
Polygon Approximations
cv::approxPolyDP()
The routine cv::approxPolyDP() is an implementation of one of these two algorithms
5
:
void cv::approxPolyDP(
If we are drawing a contour or are engaged in shape analysis, it is common to approximate a contour
representing a polygon with another contour having fewer vertices. There are many different ways to do
this; OpenCV offers implementations of two of them.
Polygon Approximation with
cv::InputArray curve, // Array or vector of 2-dimensional points
cv::OutputArray approxCurve, // Result, type is same as ‘curve’
double epsilo // Max distance from original ‘curve’ to ‘approxCurve’ n,
bool closed // If true, assume link from last to first vertex
);
The cv::approxPolyDP() function acts on one poly at a time, which is given in the input curve.
The output of will be placed in the output array. As usual,
resented
arrays of size N-by-1 (but having two channels). Whicheve representation you choose, the input and
output arrays used for curve and approxCurve should be of the same type.
The parameter epsilon is the accuracy of approximation you require. The meaning of the epsilon
inal lygon
closed ot th
indicated by rve uld be considered a closed polygon. If set to true, the curve will be assumed to be
The Douglas-Peucker Algorithm Explained
In order to help understand how to set the epsilon parameter, as well as to better understand ...