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\\<windows username>\\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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值