I have followed this tutorial: https://github.com/dorssel/usbipd-win/wiki/WSL-support#usbip-client-tools
I successfully connect my USB camera with my WSL2, but can not open the camera.
$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
My camera USB is Logitech, Inc. Mic (Notebooks Pro) and 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()
it shows
[ WARN:0@0.009] global /io/opencv/modules/videoio/src/cap_v4l.cpp (889) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
I’ve used v4l-utils to query my container’s video devices
v4l2-ctl --list-devices
Failed to open /dev/video0: No such file or directory
I have added some config in Device Driver like @NotTheDr01ds said and now my camera show up in WSL2 with command
v4l2-ctl --list-devices
UVC Camera (046d:08c9) (usb-vhci_hcd.0-1):
/dev/video0
/dev/video1
But when I tried to run my program, its showed
[ WARN:0@10.310] global /io/opencv/modules/videoio/src/cap_v4l.cpp (1000) tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.
The light of camera is on but can not capture anything. I have tried these command below:
lsmod
rmmod uvcvideo
modprobe uvcvideo nodrop=1 timeout=5000
but its showed error
rmmod uvcvideo
rmmod: ERROR: Module uvcvideo is builtin.
I have not find any solutions yet. Any suggestion??