# contourArea

Calculates a contour area.

``````double contourArea(InputArray contour, bool oriented=false )
``````

Parameters:
contour – Input vector of 2D points (contour vertices), stored in std::vector or Mat.
oriented – Oriented area flag. If it is true, the function returns a signed area value, depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can determine orientation of a contour by taking the sign of an area. By default, the parameter is false, which means that the absolute value is returned.会有方向的话，就会返回有正负，否则就是绝对值。

``````vector contour;
contour.push_back(Point2f(0, 0));
contour.push_back(Point2f(10, 0));
contour.push_back(Point2f(10, 10));
contour.push_back(Point2f(5, 4));

double area0 = contourArea(contour);
vector approx;
approxPolyDP(contour, approx, 5, true);
double area1 = contourArea(approx);

cout << "area0 =" << area0 << endl <<
"area1 =" << area1 << endl <<
"approx poly vertices" << approx.size() << endl;
``````

``````void approxPolyDP(InputArray curve, OutputArray approxCurve, double epsilon, bool closed)
``````