MATLAB File Help: cv.contourArea Index
cv.contourArea

Calculates a contour area

a = cv.contourArea(curve)
a = cv.contourArea(curve, 'OptionName', optionValue, ...)

Input

Output

Options

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.

Example

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));
See also