OS: ubuntu 18.04
class VideoThread(QThread):
change_pixmap_signal = pyqtSignal(np.ndarray)
def __init__(self) -> None:
super().__init__()
self._run_flag = True
def run(self) -> None:
# capture from web cam
cap = cv2.VideoCapture(0)
while self._run_flag:
ret, cv_img = cap.read()
if ret:
self.change_pixmap_signal.emit(cv_img)
# shut down capture system
cap.release()
I used the above code to capture images using a webcam, but I got some errors like below mentioned
i tried cap = cv2.VideoCapture(1)
& cap = cv2.VideoCapture(-1)
both methods also failed
Now how to resolve this issue?
[ WARN:0] global /io/opencv/modules/videoio/src/cap_v4l.cpp (887) open VIDEOIO(V4L2:/dev/video0): can't open camera by index