title: Opencv Error: Assertion failed (scn == 3 || scn == 4) in ipp_cvtColor
body: <p>I recorded a video to test out the cascade classifier. I wrote a script as follow to record how many times the cascade classifier recognize my face in the short video.</p>
  
  <pre><code>import cv2
  import numpy as np
  
  face_cascade = cv2.CascadeClassifier('./data/cascade.xml')
  cap = cv2.VideoCapture('/home/jianyepa/opencv-learning/output.avi')
  count = 0
  
  print cap.isOpened()
  while 1:
          ret, frame = cap.read()
          gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
          faces = face_cascade.detectMultiScale(gray, 1.3,5)
  
          for (x,y,w,h) in faces:
                  cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)
                  roi_gray = gray[y:y+h,x:x+w]
                  roi_color = frame[y:y+h,x:x+w]
                  count += 1
                  print 'face detected'
  
          cv2.imshow('frame',frame)
          if cv2.waitKey(10) &amp; 0xFF == ord('q'):
                  break
  
  print count
  cap.release()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>Somehow, if I play the video to end, it will show the following output</p>
  
  <blockquote>
    <p>True </p>
    
    <p>face detected </p>
    
    <p>face detected </p>
    
    <p>face detected</p>
    
    <p>OpenCV Error: Assertion failed (scn == 3 || scn == 4) in ipp_cvtColor,
    file /home/jianyepa/opencv-3.1.0/modules/imgproc/src/color.cpp, line
    7456 Traceback (most recent call last):   File "cascade.py", line 11,
    in 
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.error: /home/jianyepa/opencv-3.1.0/modules/imgproc/src/color.cpp:7456: error:
    (-215) scn == 3 || scn == 4 in function ipp_cvtColor</p>
  </blockquote>
  
  <p>However, if I terminate the video before it end, the output is like expected</p>
  
  <blockquote>
    <p>True</p>
    
    <p>face detected</p>
    
    <p>face detected</p>
    
    <p>2</p>
  </blockquote>
  
  <p>Can someone give some idea on what is happening?
  Thanks.</p>