Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Error with IMAQ ImageToArray and USB camera

I'm working with some pre-existing code that uses a USB camera and the IMAQ for USB drivers (utilizing DirectShow).  The code works fine - I just needed to add additional functionality.  However, when I tried to use the IMAQ ImageToArray function, I got the error message "-1074396080, Invalid image type."  I've stripped it down to basic functionality in the code snippet below.  As I said before, it grabs an image without a hitch - the only error occurs at that one function.  Furthermore, I've tried changing the image type to both signed and unsigned 16-bit: no luck.  Any ideas?
 
Simplified USB IMAQ.png 
 
 
 
-------------------
Greg
Certifed LabVIEW Developer
0 Kudos
Message 1 of 7
(4,052 Views)

Hi Greg,

 

You have a datalow issue. Your image deletion can run in parallel with the ImageToArray in your code because its only dependencies are the Grab Image VI. This is going to be a problem if the image you are converting is getting deleted at the same time. You probably want to move the error wire so that the deletion happens after the conversion to the array...

 

Eric 

0 Kudos
Message 2 of 7
(4,044 Views)
Nope, it's not as simple as a dataflow issue.  I originally had the error wired directly as you suggested.  I wired it like that in the snippet so that I could see if any other subVI was having issues after that one.  Furthermore, in the full-blown code (of which the snippet is the stripped down version), the image reference is not even deleted until the program is closed by the user.
-------------------
Greg
Certifed LabVIEW Developer
0 Kudos
Message 3 of 7
(4,038 Views)

Greg,

 

If I recall, the old USB driver would always return RGB images. I'm no expert on ImageToArray, but my hunch would be that it doesn't work with RGB images since the outputs are all grayscale-looking. You likely want to convert the image to grayscale first before converting it to an array.

 

Eric 

0 Kudos
Message 4 of 7
(4,035 Views)

You said the "old USB" driver.  Is there something more recent that I can use with a USB camera?  I'm certainly not wedded to those drivers. 

 

Also, would the driver still return an RGB even if the memory location I've created for it is unsigned 8-bit grayscale?  That seems odd to me.  But I can certainly try using IMAQ Cast before the array function to "force the issue."

-------------------
Greg
Certifed LabVIEW Developer
0 Kudos
Message 5 of 7
(4,032 Views)

Yes, IMAQ for USB cameras was never released as a product and was mostly for experimental use by customers. Similar functionality has since been included in the IMAQdx driver (part of Vision Acquisition) and improved quite a bit. It is now has first-class support in all applications that use our drivers (MAX, Vision Builder AI, etc).

 

All of our drivers will change the source image into a type that matches what the camera is returning, so the type you create it with will not necessarily be what you get out of the driver when you retrieve an image. With IMAQdx, if the driver for your camera supports it, IMAQdx can get monochrome images from the camera rather than RGB. Otherwise you will still have to convert afterwards.

 

Eric 

 

 

0 Kudos
Message 6 of 7
(4,030 Views)
Well, I have LV developer, but the Vision software is not installed on that computer - I believe that costs extra.  I checked earlier, and the IMAQ Type function seems to be part of the vision software.  Is the IMAQdx driver set separate from the vision software?   MAX says I have IMAQdx v3.2, but I don't see any IMAQdx Vis on the palette...
-------------------
Greg
Certifed LabVIEW Developer
0 Kudos
Message 7 of 7
(4,018 Views)