0

I am doing a tutorial in opencv about VideoCapture(), I use a usb camera and it works fine, here is the code, I also use jupyter notebook for this.

import cv2
import numpy as np

cap = cv2.VideoCapture(0)

width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)

while True:
    ret,frame = cap.read()
    if ret:
    
        cv2.imshow("frame",frame)
    
    if cv2.waitKey(1) & 0xFF == ord("q"):
        break
cap.release()
cv2.destroyAllWindows()

the success variable comes out as "False" and frame is 'none' and on the VideoCapture(0), I changed the numbers to 1, to 2 to 0.

Sans
  • 1
  • what is the problem here? The code works and looks fine – Junaid Nov 14 '21 at 19:06
  • 1
    Does this answer your question? [Is it possible to display an OpenCV video inside the IPython /JuPyter Notebook?](https://stackoverflow.com/questions/27882255/is-it-possible-to-display-an-opencv-video-inside-the-ipython-jupyter-notebook) – isydmr Nov 14 '21 at 19:40
  • 2
    *where* does the jupyter notebook run? is any other program currently using the webcam? – Christoph Rackwitz Nov 14 '21 at 20:29

0 Answers0