Live data from Hacker News

Open-Source Virtual Background

elder.dev

71–80 of 85 posts

Re: Open-Source Virtual Background

#71
post #64
post #60

Earlier quoted context omitted.

Has anyone got any ideas how to achieve this? Yes. Thanks for giving me a reason to write this up. 1. Download and install OBS. OBS will be your video processor; among other things it's super easy to make it capture the whole screen or individual windows. 2. Install the v4l2 loopback kernel module[1]. This makes it possible to have a virtual webcam. On Ubuntu 19.10, this was as easy as apt install v4l2loopback-dkms a…

Thanks for the info, but I already have all of this part working. The problem is that v4l2loopback only provides a virtual _webcam_ (video source), not a virtual _screen_ - the two are different and are handled differently both by browsers (webrtc) and desktop conference apps (Slack, Teams, etc). I guess the other issue is that conference apps treat webcam and screen capture differently; usually if someone is sharing…

OBS will handle the screen grabbing. At least on Ubuntu 18.04 I can select individual windows or even the whole screen.

Re: Open-Source Virtual Background

#72

Earlier quoted context omitted.

I guess I must be completely miscalibrated wrt. performance of newer technologies, because I'd imagine it's the opposite. In particular, I'd be surprised to get a Python+Node loop passing large amounts of data around like that to run 30+ FPS, unless everything Python-side is carefully written to do everything on C side. At the same time, I'd assume the inference/ML part is the fastest one, because, as far as I unders…

A modern laptop will run Bodypix at about 30 fps. There could be additional bottlenecks but the deep (and wide) NNs are usually not super fast, they're just fast for the wondrous things they do. You can usually alter performance (with Bodypix that's an accuracy/speed tradeoff) or do something silly like downscale, run, and upscale the mask. I'd like to try this.

BodyPix does downsample before masking OOTB, the article is doing 'medium' (50%) (though for this script we ought to move that over to the python side), it's still not 30fps though without egregiously sacrificing quality, at least on my (fairly powerful) machine unless I've missed something.

Amusingly I did some hacking on this and the current bottleneck is actually reading from the webcam which is capped at <10fps without doing anything else. Switching the capture to MJPG helps.

Re: Open-Source Virtual Background

#73

Fascinating write-up Ben, who would have known that you were a genius with image processing as well as running containers :-) Love the gory details and I didn't know about pyfakewebcam either. Do you have a live video recorded showing how quickly it can process a stream?

The demo at the end of the page is a video (webm), but there's not a ton of motion to reference besides the blinking. IIRC it's something like 10FPS currently which is sufficient enough for meetings so far (about 1/3 what you might get with sufficient bandwidth in most video conference tools). There's definitely room to improve it.

Amusingly the current bottleneck is actually reading from the webcam with the suboptimal ~default capture config. Without doing anything else that's ≤ 10fps. Low hanging fruit still :-)

Re: Open-Source Virtual Background

#74
post #49

This is pretty awesome work, but I just wanted to point out that Zoom doesn't actually require a green screen. If you uncheck the "I have a green screen" button, choosing your own virtual background still looks really good, although of course you're not going to get any crazy effects like this script adds.

The article links to [1] and comments on this near the beginning -- as others have mentioned this is not always the case. The Linux client does not offer this functionality, only green screen.

I'm also using this with other apps for fun though (duo, hangouts, etc.)

[1]: https://support.zoom.us/hc/en-us/articles/210707503-Virtual-...

Re: Open-Source Virtual Background

#75

I'd love to see something like this as a plugin for OBS. I've been using it lately due to all the video conferencing we're all growing to love since it's got basic color correction/manual controls for my webcam feed. It's got the option for "real" chromakey, but like the author, I don't have a green screen, Amazon isn't scheduling any deliveries for another month, and I don't feel like a trip to the fabric store woul…

You could try ordering directly from a supplier. Amazon.de gave me 4 weeks delivery time, but a company which sells theatre level fabric (Molton green) was able to send several meters within ~4 days.

Re: Open-Source Virtual Background

#76
post #64

Earlier quoted context omitted.

Thanks for the info, but I already have all of this part working. The problem is that v4l2loopback only provides a virtual _webcam_ (video source), not a virtual _screen_ - the two are different and are handled differently both by browsers (webrtc) and desktop conference apps (Slack, Teams, etc). I guess the other issue is that conference apps treat webcam and screen capture differently; usually if someone is sharing…

OBS will handle the screen grabbing. At least on Ubuntu 18.04 I can select individual windows or even the whole screen.

The parent is pointing out functionality that only pops up for explicit screensharing -- changing your camera to a screen grab won't trigger these.

In particular, one I've found very useful with Zoom is being able to zoom in to a small region and scroll around. I also suspect Zoom prioritized resolution (for content clarity) over frame rate for screen sharing, which probably doesn't apply when it's just a "webcam" in the eyes of the client. I'm guessing your window capture would get decimated in terms of quality.

Re: Open-Source Virtual Background

#77
post #59

Great read! I am curious then why the Linux client doesn't supports this, if all it takes is to send out our webcam stream data to be processed server-side? P.S. What happens when they do e2ee on the webcam stream?

I think server side processing is really not a good idea for this. Zoom is really seeing a lot of use right now. It would not be sustainable for them to not take advantage of all the computing power of the clients.

Re: Open-Source Virtual Background

#78
post #59

Great read! I am curious then why the Linux client doesn't supports this, if all it takes is to send out our webcam stream data to be processed server-side? P.S. What happens when they do e2ee on the webcam stream?

I think server side processing is really not a good idea for this. Zoom is really seeing a lot of use right now. It would not be sustainable for them to not take advantage of all the computing power of the clients.

I am thinking the same now. The OP solution requires a server to do the the processing, but I am not sure this is the case for the Zoom client.

The Zoom client also requires minimal hardware requirements from the processor iirc.

Re: Open-Source Virtual Background

#80

You mention the ~10FPS performance. It seems like moving all that data backwards and forwards between Python and Node might be a bottleneck, no?

I need to profile it more closely, I actually don't remember the exact FPS etc. but I don't expect that to be the limiting factor. The inference / ml is expensive (which I did profile initially...), and I suspect not really optimized on this backend. It appears to be faster with webGL in the browser. I sorta stopped worrying about it once it was "good enough" to show up to a few meetings with, but with all the attent…

I had success by replacing the get_mask function with:

    from keras.models import load_model


    model = load_model('models/transpose_seg/deconv_bnoptimized_munet.h5', compile=False)


    def get_mask(frame):
        # Preprocess
        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

        simg = cv2.resize(frame, (128, 128), interpolation=cv2.INTER_AREA)
        simg = simg.reshape((1, 128, 128, 3)) / 255.0

        # Predict
        out = model.predict(simg)

        # Postprocess
        msk = out.reshape((128, 128, 1))
        mask = cv2.resize(msk, (frame.shape[1], frame.shape[0]))

        return mask

The model file I got from: https://github.com/anilsathyan7/Portrait-Segmentation
Post reply on HN