I have the following contour:
https://drive.google.com/file/d/0B45BJEUVEkjseFd3X3RITzM5S3c/edit?usp=sharing
containing the following points (printed in order):
https://drive.google.com/file/d/0B45BJEUVEkjsN3NIRU5lOFBDb00/edit?usp=sharing
However, when I calculate the area of this contour (using the function contourArea), I get 157, which is too low for the size of that contour. I expect it to be in the thousands. Why is the contour area being calculated incorrectly, and how may I fix it?
The following is the code I'm using to calculate the areas of all contours of the image. The contour of interest is the last one. The original image I'm using is here:
https://drive.google.com/file/d/0B45BJEUVEkjsbGhXM3E3UW1lZWs/edit?usp=sharing
int main(int argc, char* argv[])
{
Mat imgOriginal = imread(argv[1], 0);
if(imgOriginal.empty())
return -1;
Mat img;
resize(imgOriginal, img, Size(640, 480));
medianBlur(img, img, 11);
Canny(img, img, 25, 100);
vector< vector<Point> > contours;
findContours(img, contours, RETR_EXTERNAL, CHAIN_APPROX_NONE);
for (int i = 0; i < contours.size(); i++)
cout << "Area " << i << ": " << contourArea(contours[i]) << endl;
return 0;
}
Also, I noticed that several points in the contour are duplicates (I'm not sure why), which may be causing the area to be calculated incorrectly.