wsl使用usb摄像头

wsl config

# wsl linux kernel compiling for uvcvideo 
wget https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-5.15.74.2.zip
unzip linux-msft-wsl-5.15.74.2.zip
make KCONFIG_CONFIG=Microsoft/config-wsl menuconfig # modify kernel config according to #Ref
make KCONFIG_CONFIG=Microsoft/config-wsl -j$(nproc)
make modules_install -j$(nproc)
make install -j$(nproc)

# install kernel
cp arch/x86/boot/bzImage /mnt/c/Users/<windows username>/
cat << 'EOT' > /mnt/c/Users/<windows username>/.wslconfig
[wsl2]
kernel=C:\\Users\\\\bzImage 
EOT

# reboot wsl for kernel to taking effect 
win10 => wsl --shutdown

# USB/IP client tools
sudo apt install linux-tools-virtual hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20

# modprobe
modprobe uvcvideo

win10 config

# win10 install usbip
winget install --interactive --exact dorssel.usbipd-win

# win10 start usbip
usbipd list
usbipd bind --busid 1-1 -f
usbipd wsl attach --busid 1-1
usbipd wsl detach --busid 1-1

Test camera using guvcview in wsl

sudo rmmod uvcvideo
sudo modprobe uvcvideo nodrop=1 timeout=60   # parameter is for some bug
sudo chmod 777 /dev/video*
ll /dev/video*
guvcview -a none

summary

Some camera do not take effective in right way.

Ref

https://learn.microsoft.com/en-us/windows/wsl/connect-usb
https://stackoverflow.com/questions/72255353/wsl-webcam-usb-can-not-open-camera-by-index
https://github.com/PINTO0309/wsl2_linux_kernel_usbcam_enable_conf
https://github.com/dorssel/usbipd-win/wiki/WSL-support

你可能感兴趣的:(linux,windows)