Select random video input device from dynamic enum

So, the question is pretty much as in the title, but here’s some more info:

My final project is going to be a cloud of objects, just simple quads with video textures.

For some of these objects, I want to use live video input. That isn’t hard, in itself, but I want to use multiple webcams, and select which webcam is being used randomly for each new object.

The solution I was thinking of was to randomly select a video device from the automatically generated list of devices from the VL.Video.MediaFoundation nuget, but the whole dynamic enum thing is confusing me. How can I go about selecting a random element from this dynamic enum?

If I could only do that, everything else would fall into place.

I think I could make a static solution to this, just hard-coding the specific devices, generating the video textures, and then selecting from these textures for the final object, but I’d prefer to just dynamically pick from the enum of devices, so I can plug-and-play. I’m not sure how many webcams I’ll use, and it seems like a poor solution to just rely on manually configuring it all.

Any ideas on how I could make this work? Hopefully without having to dive into the non VL code 😚

Thank you for reading, and for any help you have! I can provide the patch if y’all want it, but I didn’t think it would really clarify the issue much. Please lemme know if there are any questions I can answer for you :)

It is indeed easier if you make a Spread of all textures of the video inputs with a Cons node and then use GetSlice with a random index for every quad.

For nodes that generally work with dynamic enums have a look at the data types starting with IDynamcEnum, there you’ll find things like SelectIndex and so on. But note that changing the device on a VideoInput will most likely freeze the application for a few frames, so it isn’t recommended to do that during a show.

1 Like

Ah! I found what you’re talking about! I think I’ve got what I need to fix it now :) Thank you so much for the speedy response!

Now that I can work with the enum better, I’ll generate the texture spread at startup and work from there. I’ll post something up when I’ve got something nice to show :)

1 Like