0

Question - is it possible to get a raw buffer image from a usb camera without any processing done to it. It seems no matter what format the camera output internally is when you grab it with getUserMedia it converts it to RGB.

Problem - I have a YUV 4:2:0 camera output that i'm pushing out over usb from a microcontroller. What i was planning to do is embedded some data information in the image on the Y channel for say the last 2 lines. But the problem i'm running into is that when you grab the image from the camera with getUserMedia and stick it into the video frame and then use the video frame data as you're buffer it's in RGB. I could try to convert the RGB back into YUV, but i think that in some edge cases the data is lossy as in there's rounding errors or the color spaces don't perfectly match up. So basically I'm just looking for a way to keep my buffer from the camera unedited.

  • So i had a thought that i could create a way to make it easy to convert from RGB back to YUV. I was going to make the last two lines black and white basically. So the UV channels have 128 in them and the Y channel have my data. Then i wouldn't have to worry about the conversion because the data should just be the Y channel. But it seems that chrome has a algorithm like this where the Y is subtracted and then re added as a multiple https://stackoverflow.com/questions/17892346/how-to-convert-rgb-yuv-rgb-both-ways – used_up_user Apr 12 '22 at 20:42
  • I haven't figured out a way to get the raw video in the web, so i opted to kind of go around the problem with a different api. I'm trying know to use the Opencv javascript api and then feed the video up to a canvas image. [opencv4nodejs](https://github.com/UrielCh/opencv4nodejs). But to use this i'm using electron – used_up_user Apr 15 '22 at 19:16
  • You're correct that everything video in gUM is RGBA. – O. Jones Apr 22 '22 at 10:48

1 Answers1

0

From what i'm reading when a browser grabs a video stream it will convert it to a RGBA format. There doesn't really seam like a way around this.

So what i'm doing is using a electron app and grabbing the image at a os level and passing the image up.

I'm thinking of using either opencv or this library https://github.com/node-ffi-libraries/node-ffi-library-libuvc-v0.0.6 . which is a lower level usb camera interface.