LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid color template image

I try to do patttern matching using IMAQ Vision. Both source and template images are .BMP files and are generated in a VB .NET program through NI Framegrabber. IMAQ Match Color Pattern gives me the following error message:

Error-1074395384 occurred at IMAQ Match Color Pattern
Invalid color template image


Do I have to use .PNG files when doing pattern matching?

Thanks.
0 Kudos
Message 1 of 5
(4,194 Views)
Hey John123,
 
I was wondering what version of Vision that you are using? Have you tried to run any of the example programs, like the ColorPatternMatching example that can be found in the following directory: C:\Program Files\National Instruments\Vision\Examples\MSVB.NET\2. Functions\Color Pattern Matching. I was able to run this example program by using .BMP images and not PNG images. So to answer your question, you don't have to use PNG files with this function, you can use Bitmap images. You can use any kind of image that have a 32-bit RGB or HSL bit depth.
 
If you are acquiring from a Framegrabber, I would suggest that you double check and make sure that the images that you are getting from your camera are actually 32-bit, and not 16-bit. Also, you could post a couple of your images on this thread, and I could try them out with an example that uses the IMAQ Match Color Pattern function. Try some other BMP images and do you get the same error? Try the example program, and see if that gives you the error with your images. Let me know if you have any questions. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 2 of 5
(4,169 Views)
Hi DJ,

Now I am using IMAQ Find Pattern 2 to do the PatternMatching. In IMAQ Create, I set ImageType to Grayscale(U8) so it deals with B/W images instead of color images. It seems working.

The new problem is that I wish I can directly pass those two images, the source image and template image,  into the LabVIEW dll from my VB .NET program, but I cannot.  Now I  just pass in two file names and let the LabVIEW dll to get  those images. Is there any way I can pass  bitmaps directly into a LabVIEW dll?  Or is there any way to let AxCWIMAQControlsLib.AxCWIMAQ to load a bitmap image and convert the image into an array (ImageToArray) and pass the array to the LabVIEW dll? 

Thank.

0 Kudos
Message 3 of 5
(4,166 Views)

John,

You need to "Train" the image using IMAQ Learn Pattern.  What it creates is a "special" image with information encoded into the .png that aids the pattern matching.  In short, you have to use the IMAQ Learn Pattern to create reference images.  You can create reference images using NI's Vision Builder interface or use the IMAQ Learn Pattern function.

Long time vision user,

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 4 of 5
(4,158 Views)
Hey John123,
 
To answer your latest questions: "Is there any way I can pass  bitmaps directly into a LabVIEW dll?  Or is there any way to let AxCWIMAQControlsLib.AxCWIMAQ to load a bitmap image and convert the image into an array (ImageToArray) and pass the array to the LabVIEW dll?" You can pass the image as an array and also include its width and height. And then in the dll you can convert it back into the image data type. Also you can try just passing the pointer to the image. This might be the fastest way, as it is only the pointer to the image in memory and not a large amount of data. You would not want to pass the entire image if you don't have to. Try this out and let me know how things go. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 5 of 5
(4,146 Views)