title: Python-OpenCV cv2 OpenCV Error: Assertion failed (scn == 3 || scn == 4) in unknown function, file ..\..\..\modules\imgproc\src\color.cpp
body: <p>I am trying to learn contours in python using cv2.</p>
  
  <p>I tried the following code given in a tutorial guide:</p>
  
  <pre><code>import cv2
  import numpy as np
  from matplotlib import pyplot as plt
  
  im = cv2.imread('C:\Users\Prashant\Desktop\test.jpg')
  imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
  ret,thresh = cv2.threshold(imgray,127,255,0)
  image, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
  img = cv2.drawContour(im, contours, -1, (0,255,0), 3)
  cv2.imshow('Image1',img)
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
  OpenCV Error: Assertion failed (scn == 3 || scn == 4) in unknown function, file ..\..\..\modules\imgproc\src\color.cpp, line 3402
  Traceback (most recent call last):
   File "&lt;stdin&gt;", line 1, in &lt;module&gt;
     execfile(filename, namespace)
   File "C:/Users/Prashant/.spyder2/.temp.py", line 15, in &lt;module&gt;
     imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
   cv2.error: ..\..\..\modules\imgproc\src\color.cpp:3402: error: (-215) scn == 3 || scn == 4
  </code></pre>