title: Displaying image from webcam using opencv in jupyter notebook
body: <p>I'm trying to display images from captured by webcam. However, the variable that stores the captured image is empty. This issue only appears when using a webcam, not when playing videos such as mp4. Is this problem caused by the version of Python? My OpenCV version is 3.4.3 and the Python version is 3.6.5.</p>
  
  <pre><code>import numpy as np
  import cv2
  from IPython import display
  import matplotlib.pyplot as py
  %matplotlib inline
  
  def showVideo():
      try:
          print('카메라를 구동합니다.')
          cap = cv2.VideoCapture(0)
      except:
          print('카메라 구동 실패')
          return
      print(cap.isOpened())
      print(cap.read())
      cap.set(3, 480)
      cap.set(4, 320)
  
      try:
          while(True):
              # Capture frame-by-frame
              ret, frame = cap.read()
              if not ret:
                  # Release the Video Device if ret is false
                  cap.release()
                  # Message to be displayed after releasing the device
                  print ("Released Video Resource")
                  break
              frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
              # Turn off the axis
              py.axis('off')
              # Title of the window
              py.title("Input Stream")
              # Display the frame
              py.imshow(frame)
              py.show()
              # Display the frame until new frame is available
              display.clear_output(wait=True)
      except KeyboardInterrupt:
          # Release the Video Device
          cap.release()
          # Message to be displayed after releasing the device
          print("Released Video Resource")
      pass
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vOQW2.jpg" rel="nofollow noreferrer">enter image description here</a></p>