title: OpenCV 3.1 drawContours '(-215) npoints > 0'
body: <p>I'm trying to create a mask from a contour, but am getting a C++ error.</p>
  
  <p>Using OS X Yosemite, Python 2.7.10, OpenCV 3.1.0.</p>
  
  <pre><code>def create_mask(img, cnt):
      '''Create a mask of the same size as the image
         based on the interior of the contour.'''
      mask = np.zeros((img.shape[0], img.shape[1]), np.uint8)
      print("create_mask, cnt=%s" % cnt)
      cv2.drawContours(mask, [cnt], 0, (0, 255, 0), -1)
      return mask
  
  print("Creating mask from contour %s, on raw shape %s" % (page_contour, raw.shape))
  page_mask = create_mask(raw, page_contour)
  </code></pre>
  
  <p>Output (see bottom for error):</p>
  
  <pre><code>Creating mask from contour [[ 1626.   360.]
   [ 1776.  3108.]
   [  126.  3048.]
   [  330.   486.]], on raw shape (3840, 2160, 3)
  create_mask, cnt=[[ 1626.   360.]
   [ 1776.  3108.]
   [  126.  3048.]
   [  330.   486.]]
  OpenCV Error: Assertion failed (npoints &gt; 0) in drawContours, file /tmp/opencv320160309-92782-1efch74/opencv-3.1.0/modules/imgproc/src/drawing.cpp, line 2380
  Traceback (most recent call last):
    File "./books.py", line 209, in &lt;module&gt;
      page_mask = create_mask(raw, page_contour)
    File "./books.py", line 123, in create_mask
      cv2.drawContours(mask, [cnt], 0, (0, 255, 0), -1)
  cv2.error: /tmp/opencv320160309-92782-1efch74/opencv-3.1.0/modules/imgproc/src/drawing.cpp:2380: error: (-215) npoints &gt; 0 in function drawContours
  </code></pre>
  
  <p>The <a href="http://docs.opencv.org/3.1.0/d6/d6e/group__imgproc__draw.html#ga746c0625f1781f1ffc9056259103edbc&amp;gsc.tab=0" rel="noreferrer">docs</a> say it should get an array of arrays and this is seemingly what I'm giving it. So what's wrong?</p>
  
  <p>Code is ported from OpenCV 2.x.</p>