Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16536

WSL - webcam USB : Can not open camera by index

$
0
0

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.

$lsusbBus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hubBus 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 npimport cv2cap = 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:        breakcap.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-devicesFailed 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-devicesUVC 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:

lsmodrmmod uvcvideomodprobe uvcvideo nodrop=1 timeout=5000

but its showed error

rmmod uvcvideormmod: ERROR: Module uvcvideo is builtin.

I have not find any solutions yet. Any suggestion??


Viewing all articles
Browse latest Browse all 16536

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>