Jit.dx.grab - multiple webcams - picking a device & setting its output format

we_are_theBorg's icon

Hello all,

I'm a total n00b, and I have a rather massive project that I'm trying to figure out:

I've got 32 webcams connected to a single PC, and I'm trying to create a patch that will randomly switch from one camera to another, and record the output for an extended period of time.
I know this doesn't sound that complicated, and the fact that I've managed to get some part of the way through it suggests that it's really not, but there are a few things that are catching me up:

First off, there's a delay and a freeze in the grab as a camera is initialized. I've solved this by having two separate jit.dx.grab objects, and having them open separately and output their contents in to a primary matrix, and only switch the contents of their matrix in to the output matrix after a 5 second initialization period. That seems to work ok.

My much larger problem is that I have about 7 different flavors of webcam that are used in different places in the installation based on size, sensitivity, field of view, etc. I'll list them here for reference:

Logitech QuickCam c260

Logitech QuickCam c310

Logitech HD Pro Webcam c920

Logitech Webcam Pro 9000

Microsoft LifeCam HD-3000

Microsoft LifeCam Studio

StarTech SVID2USB2 (an analog to digital adapter for composite video cameras)

All of these devices do function excellently when accessed individually and configured to their ideal settings from the getformatlist dropdown provided in the jit.dx.grab reference patch.

The thing is, all of these different cameras have different optimal modes and maximum resolutions. Not only are the options different for each one, but the same setting is enumerated to a different place on the list for each type of camera, so I can't just do an operation something like: "IF vdevice == $1 THEN format == $23", I have to evaluate the individual items on the list, and evaluate if the best quality option is available on that list, like "MJPG [1920 x 1080]", and if that's not available then go for "MJPG [1280 x 720], and if that mode isn't available go for "YUY2 [640 x 480] which seems to be the lowest common denominator amongst all the devices I have.

I'd like some way of evaluating those strings, and basically having the patch choose the optimal mode based on the devices capabilities each time a device is chosen from the list. In my browsings it's looking like I may have to use JavaScript to do this, which is daunting the heck out of me, as my JavaScript chops are utterly abysmal.

Am I making sense? Any of you gurus have any brilliant ideas? I'm basically just creating a couple of iterations of the reference jit.dx.grab patch, and routing them, so opening that patch will show you where the vdevice and format lists are created and populated. That's what I'm working with.

My output matrix goes to a full screen 1080p window, and also is written to an h.263 .MOV file, which seem to be working ok as of now.

MANY THANKS FOR ANY THOUGHTS, SUGGESTIONS OR PATCH IMPROVEMENTS!

diablodale's icon

I recommend that you manually test and choose what settings you want for a given camera. Then when you know them, to use some storage methodology to persist that information and then look it up when you need to configure a given camera.

I read that pattr can do most any kinda of preset type data storage/retrieval. I'm no expert on that object myself. However, a quick look at it get me to thinking you could use it. Something like:
- make umenus for all the settings you want to store/retrieve
- hook them into a pattr storage system
- use a pattrstorage to store coordinate the settings. check out the help patcher for it on the "interface" tab.
- store a slotname for the presets. make the slotname the name of the camera
- make a umenu to recall a camera's presets using this slotname like on "interface" tab
- then hook this back into your random camera selection system so that when a new camera is selected, its name is sent to the umenu that drives the pattrstorage retrieval.
- note that you can save these presets using pattr into a JSON file so you can reload it every time you open your patcher

I'm more a javascript guy myself.

Somewhat amazed u have 32 webcams functioning on the same PC...congrats!

MJ's icon

Why not use 7 jit.qt.grab objects ?

For an operaplay i created a patch which combined 8 fire-wire cams to one image . Using 8 jt.qt.grab objects .
-mj

we_are_theBorg's icon

Diablodale,

Thanks very much for the suggestion. I think I understand what you're suggesting, and I'm going to take a look now. I'll report my findings or (more likely) what I've stumbled over soon :-)

MJ,

The goal of this project is to display the output of one camera at a time, and have that output change from one camera to another. The output matrix has been optimistically set to 1080p, as is the recorded movie. The goal is to project the output on to a gallery wall, and to record it at the highest quality possible for future purposes.

The webcams range from NTSC A/D capture for some tiny wireless spycams, to the rather excellent 1080p Logitech HD Pro Webcam c920, which provides a direct hardware pre-compressed stream of H.264 video(neat!).

I'm running this project on a custom PC that I built with 12x USB 3.0 ports to provide adequate upstream bandwidth for whatever might get thrown at it, each of those USB 3.0 root ports has a 4 port USB 3.0 hub connected to it, for serious connectivity (up to 48 devices and 6GB/s (theoretical). As it's a PC, using the jit.dx.grab object seemed like a better bet. Incidentally, when I try using the jit.qt.grab object it only recognizes one webcam, no matter how many are connected, and calls it the built-in iSight. This isn't much use, and all the firewire cameras I could find are far more expensive, not to mention that I'd have to get firewire expansion cards and hubs, which are all more expensive, and offer lower bandwidth.

I'm not bringing this up to poopoo your ideas. I started off thinking I'd use the jit.qt.grab object, but since you mentioned it I thought I'd address your comment because hopefully others attempting this crazy number of webcams can take something from my experience.

On that note, I want to put something out there that might be good to know for someone: As of right now, and based on my research it's been true for some time, though not well documented or commented on, at least many, if not all Microsoft webcams, certainly the Microsoft LifeCam HD-3000 and the Microsoft LifeCam Studio (which I've personally tested) DO NOT ENJOY PLAYING WELL WITH OTHERS, especially other Microsoft webcams. Initially I tried to have 30 jit.dx.grab objects all open at once, and do things like motion detection on several streams so I could configure the randomizer to make an "informed decision" about which camera might be interesting to switch to, but I found that I could not have more than two Microsoft webcams on (opened) at any given time or they would start interfering with each other and prevent a new Microsoft webcam from initializing. I even crashed Max a couple of times and once even got a BSOD on my machine!! This has not happened with any of the Logitech webcams, nor with the NTSC to USB converters I'm using, so it seems to be part of the Microsoft driver. Also, the Microsoft cams have a driver included in Windows 7 x64 SP1, but they automatically try to install an updated driver with a bunch of crapware in a utility that automatically pops up any time the camera is initialized. These factors combine to make the Microsoft cams very poorly suited for this application and despite good video quality and good prices, as well as good form factors and build quality I can't recommend them for anything requiring more than two webcams.