MATLAB File Help: cv.contourArea | Index |
Calculates a contour area
a = cv.contourArea(curve)
a = cv.contourArea(curve, 'OptionName', optionValue, ...)
{[x,y], ...}
).The function computes a contour area. Similarly to cv.moments, the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using cv.drawContours or cv.fillPoly, can be different. Also, the function will most certainly give a wrong results for contours with self-intersections.
contour = {[0 0], [10 0], [10 10], [5 4]};
area0 = cv.contourArea(contour);
approx = cv.approxPolyDP(contour, 'Epsilon',5, 'Closed',true);
area1 = cv.contourArea(approx);
fprintf('area0 = %.2f\narea1 = %.2f\napprox poly vertices = %d\n', ...
area0, area1, numel(approx));