title: OpenCV contourArea() not working
body: <p>I'm pretty new to OpenCV and having a slight problem which is probably something very easy to fix.
  Basically im doing some basic image processing, I'm trying to find contours which have an contourArea() of &lt; 3000.</p>
  
  <p>The problem is, I'm getting the following error when trying to draw contours and/or call contourArea() function: </p>
  
  <p>The error is occuring on the <code>cv:contourArea()</code> line, the error message is:</p>
  
  <pre><code>OpenCV Error: Assertion failed (contour.checkVector(2) &gt;= 0 &amp;&amp; (contour.depth() == CV_32F || contour.depth() == CV_32S)) in cv::contourArea,
  file ..\..\..\..\opencv\modules\imgproc\src\contours.cpp, line 1904
  </code></pre>
  
  <p>Any help is greatly appreciated. The code is below:</p>
  
  <pre><code>using namespace cv;
  
  cv::Mat greyMat, binaryMat, newMat;
      cv::Mat image = cv::imread("image.png", 1);
  // First convert image to gray scale
  cv::cvtColor(image, greyMat, CV_BGR2GRAY);
  
  cv::adaptiveThreshold(greyMat, binaryMat, 255, cv::ADAPTIVE_THRESH_GAUSSIAN_C, cv::THRESH_BINARY_INV, 45, 0);
  
  erode(binaryMat, binaryMat, getStructuringElement(MORPH_ELLIPSE, Size(2, 2)));
  dilate(binaryMat, binaryMat, getStructuringElement(MORPH_ELLIPSE, Size(1, 1)));
  
  // Remove unclosed curves (the circled hashtag)
  cv::copyMakeBorder(binaryMat, newMat, 1, 1, 1, 1, cv::BORDER_CONSTANT, 0);
  cv::floodFill(newMat, cv::Point(0, 0), 255);
  
  newMat = 255 - newMat;
  
  cv::Mat cMat;
  newMat.copyTo(cMat);
  
  std::vector&lt;std::vector&lt;cv::Point&gt;&gt; contours;
  cv::findContours(cMat, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_NONE);
  
  std::cout &lt;&lt; "Found: " &lt;&lt; contours.size() &lt;&lt; " " &lt;&lt; contours[0][0] &lt;&lt; std::endl;
  
  for (size_t i = 0; i &lt; contours.size(); i++)
  {
      if (cv::contourArea(contours[i]) &lt; 3000)
      {
          cv::drawContours(newMat, contours, i, 255, -1);
      }
  }
  
  cv::imshow("Debug", newMat);
  cv::waitKey(0);
  return 0;
  </code></pre>