Vision Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Bob_Schor

Enumerate Cameras (à la MAX)

Status: New

MAX will list all of the Cameras that are attached to the PC, along with attached DAQmx Devices, VISA Devices, and other Devices.  There is a very useful DAQmx System property node that returns an I/O reference to all the DAQmx Devices, allowing the user (me) to "find the USB-6002 with serial number 12345 that I so carefully calibrated and am using in my Test".  I'd like to be able to do the same thing for Cameras -- I have multiple cameras visible in MAX, but I want my code to use a particular Camera and would like to programmatically "discover" it by enumerating the Cameras and getting relevant properties (Name, Serial Number, other ID information, potentially IMAQdx parameters) to find the Camera I want to use.

 

Bob Schor

8 Comments
TomOrr0W
Member

I have done something similar to find cameras using the Measurement and I/O -> System Configuration Palette.  It is slower than the DAQmx system property you mention however.

 

Get Cameras.png

 

(google drive link, as you can't attach files)
https://drive.google.com/file/d/13VFiBijCpmE2eRksND8xFkqONqdo8XNG/view?usp=sharing

Bob_Schor
Knight of NI

OK, another corner of LabVIEW I haven't investigated in a decade of LabVIEW Development ...  With this as a hint, I'm able to pull out (some of) the data that I was trying to get ...

 

I'd give you a Kudo or Solution for the comment (as it essentially allows me to "solve" the situation I was trying to understand), but I don't think those are options here ...

 

Bob Schor

Bob_Schor
Knight of NI

Second comment on TomOrr0w's very informative comment:  In MAX, I can find my Cameras, and can give them "Friendly" names (by right-clicking and choosing "Rename").  First, I get the Devices & Chassis "Product Name", which returns the name MAX displays as the "unchangable" Camera Name.  I also get the Expert Info:Alias property, which gives me the "Friendly" name, the one MAX lets you change.  However, I can't figure out how to (programmatically) change it -- as a Property Node, it is Read-Only, and there are no Methods available for the System Hardware reference.  So we have some of the functionality that MAX can exploit, but not all of it.  I suspect that this may involve manipulating the Camera's .iid file and setting the "interface name" Property.  Do-able, but it would be "nice" if such details could be wrapped up into an NI-supplied function ...

 

Bob Schor

Brad
Active Participant

Maybe I’m missing but why don’t use the IMAQdx enumerate VI to list all the cameras since this returns array of clusters with serial number, manufacture, model, etc. There is also a VI in vi.lib/vision/driver/IMAQdx.llb that lets you save the current settings as a user defined interface name and then you can use that user defined name to open sessions later. (I believe this is the case, but I’m not at my computer to verify). 

 

Hope this helps

Brad

TomOrr0W
Member

Now that you mention it, I remember trying the IMAQdx enumerate vi.

 

It does run faster, but I believe it still listed my USB frame grabbers (Epiphan DVI2USB3.0 devices) as connected even when they are unplugged.  Unfortunately, there is a test running on the computer where I tried this, so I can't double-check this at the moment.

In case my memory on this is correct and this is a bug rather than a feature, the software versions I was running were LabVIEW 2015 SP1 f10, IMAQdx 17.5, and Vision Development Module 2017 SP1.  The devices are connected over a USB hub.

This vi may be better for Bob's use case, however.

TomOrr0W
Member

I got someone to pause the test and unplug one of the frame grabbers.  My code still gave the same output as the IMAQdx enumerate vi.

 

I noticed that the frame grabber disappeared from MAX when unplugged rather than just going to red X (device missing/disconnected) mode.  I think red X mode is where you get a difference in behavior between the two.  Maybe I was using an older driver version when I put the code I shared together which shows red X's on missing devices in MAX.

Bob_Schor
Knight of NI

IMAQdx Enumerate Cameras "cheats".  All it does is to interrogate the .icd and .iid files that MAX creates, mines them for information (the hard work already having been done somehow by MAX) and packages it as an array of Clusters.

 

Here's how to prove this (I just did it):

  1. Run Enumerate Cameras to make sure it works.
  2. Unplug your cameras.  [This step, and Step 3, might not be necessary, but this is what I did].
  3. Delete or otherwise "hide" the .icd and .iid files that MAX has created.
  4. Plug the cameras back in.
  5. Run Enumerate Cameras again.  It will fail with Error -1074360290, Unable to read/write to file.

Well, the above is not 100% true -- if you wait a minute and run Enumerate Cameras one more time, it will work and find the Cameras!  Something is running in the background (the Device Monitor?) and making files, presumably "somewhere else", that this function can use.  Well, it wasn't getting the data from a .iid file (I looked, and it wasn't sitting anywhere on the C: drive).

 

Bob Schor

 

TomOrr0W
Member

The System Configuration API does support changing Aliases (System Configuration -> Hardware -> Rename).  However that functionality appears to not be supported in IMAQdx.

Rename Not Allowed.png