I 'm trying to connect my webcam USB with WSL2. I can get it showed up on WSL2 with command
$lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 046d:08cb Logitech, Inc. Mic (Notebooks Pro)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
or
$ v4l2-ctl --list-devices
UVC Camera (046d:08c9) (usb-vhci_hcd.0-1):
/dev/video0
/dev/video1
When I tried to run my program
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
if ret:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
The webcam light is on, its mean activating but can not capture any frame.
[ WARN:0@10.310] global /io/opencv/modules/videoio/src/cap_v4l.cpp (1000) tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.
I tried these command below but seems doesn’t help
lsmod
rmmod uvcvideo
modprobe uvcvideo nodrop=1 timeout=5000
its showed error
rmmod uvcvideo
rmmod: ERROR: Module uvcvideo is builtin.
Any solutions?