0

I am trying to connect a usb webcam to my chrome browser.I Am able to connect the device on chrome and able to get the name and configurations as well ,but how to get the images from the web cam

I am using below code to access the usb device ,but how to proceed further ? .Any link or suggestions are welcome. Thanks

button.addEventListener('click', async () => {
  navigator.usb.requestDevice({ filters: [{ vendorId: 6403}] })
            .then(device => {
    
                console.log(device);
                const constraints = {
                    video: true,
                };
    
                device.getUserMedia(constraints) // this is not working it works only for webcams
                    .then((stream) => {
                      player.srcObject = stream;
                    })
            .catch(error => { console.log(error); });
    
            })
    
    
    
    
    
    });

I figured out by isochronousTransferIn(), we can stream video and audio ,but still it doesn't work

button.addEventListener('click', async () => {
        navigator.usb.requestDevice({ filters: [{ vendorId: 6403 }] })
            .then(selectedDevice => {
                device = selectedDevice;
                return device.open(); // Begin a session.
            })
            .then(() => device.isochronousTransferIn(1, 64)) // Select configuration #1 for the device.
            .then((result) => console.log(result)) // Select configuration #1 for the device.
            .catch(error => { console.log(error); });




    });
gANDALF
  • 360
  • 4
  • 21
  • You do know how USB device classes work, right? Implementing the host end of the UVC is non-trivial, so WebUSB is probably not the right API to use to get media from a webcam, why not use the WebRTC or `MediaDevices` API instead? – Dai Sep 07 '20 at 12:39
  • Yeah but the problem is ,mediadevices are detecting the inbuilt cameras and not the usb cameras ? @Dai how to solve that? – gANDALF Sep 07 '20 at 12:42
  • If the cameras aren't showing up in the Media Devices API then that is a driver issue you'll need to resolve. If the issue is that the internal camera is being selected by default use the navigator.mediaDevices.enumerateDevices() method to see if there are other cameras available. – Reilly Grant Sep 09 '20 at 01:07
  • @ReillyGrant can you look at this https://stackoverflow.com/questions/64059658/web-usb-transfer-data-from-device-to-browser-not-working – gANDALF Sep 25 '20 at 07:31

0 Answers0