title: Real time frame grabbing from video through webcam on google colab
body: <p>I have created a very basic image classification model using keras trained on the CIFAR-10 dataset. I extended its basic functionality to predict on user provided data. Now I want to move to real-time classification.
  This requires me to integrate my webcam with my notebook and use frame grabbing techniques to classify the images. 
  I referred a code for doing just that. But the code constantly throws this error and I am not sure what I am supposed to do</p>
  
  <pre><code>import numpy as np
  import cv2
  import random
  from google.colab.patches import cv2_imshow
  
  
  cap = cv2.VideoCapture(0)
  i=0
  while(True):
      ret, frame = cap.read()
      print(frame)
      i+=1
      cv2.imwrite('database/{index}.png'.format(index=i),frame)
      cv2_imshow(frame)
      if cv2.waitKey(1) &amp; 0xFF == ord('q'):
          break
  
  cap.release()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>AttributeError                            Traceback (most recent call
    last)  in ()
         15 
         16 
    ---> 17     cv2_imshow(frame)
         18     if cv2.waitKey(1) &amp; 0xFF == ord('q'):
         19         break</p>
    
    <p>/usr/local/lib/python3.6/dist-packages/google/colab/patches/<strong>init</strong>.py
    in cv2_imshow(a)
         20       image.
         21   """
    ---> 22   a = a.clip(0, 255).astype('uint8')
         23   # cv2 stores colors as BGR; convert to RGB
         24   if a.ndim == 3:</p>
    
    <p>AttributeError: 'NoneType' object has no attribute 'clip'</p>
  </blockquote>