LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid color template image

I use two bitmaps to do pattern matching using IMAQ Match Color Pattern. The error messsage says 'Invalid color template image.'
Please help, thanks.
0 Kudos
Message 1 of 4
(3,102 Views)

John123,

Before you can use a bitmap as your templete you will need to alter the bitmap so that LabVIEW recognizes it as a templete image.  This can be done in Vision Assistant or Vision Builder for Automated Inspection, by loading the image into the interface and then running the color pattern match step on the image.  You can then create a templete from the image and select the entire image.

If you want to do this from LabVIEW you will have to use the "IMAQ Learn Color Pattern" vi.

If I did not answer your question, please let me know.

Good Luck,
Lorne Hengst
Application Engineer
National Instruments

0 Kudos
Message 2 of 4
(3,089 Views)
Hi Lorne,

Thanks for the replay. Now I convert those bitmaps into Grayscale(U8) then do the pattern matching and it works. I will try
"IMAQ Learn Color Pattern" later.

The problem I have now is that I build the vi as a dll and it takes in two bitmaps and output three numbers including NumberOfMatches, XPosition and YPosition. Then I try to call the dll from my vb .net program like the following:

Declare Sub PatternMatchSrv Lib "C:\NI Machine Vision\PatternMatchingSrv.dll" _
                     (ByRef TemplateImage As Bitmap, ByRef SourceImage As Bitmap, _
                      ByRef NumberOfMatches As Integer, ByRef XPosition As Double, ByRef YPosition As double)

Dim bmpTemplate As New Bitmap("c:\NI Machine Vision\Bitmaps\Temp021406-1.bmp")
        Dim bmpSource As New Bitmap("c:\NI Machine Vision\Bitmaps\Test021406-1.bmp")
        Dim NumberOfMatches As Integer = 0
        Dim XPosition As Double = 0.0
        Dim YPosition As Double = 0.0
        Try
           'PatternMatchSrv(bmpTemplate, bmpSource, NumberOfMatches, XPosition, YPosition)
                   Catch ex As Exception
            MsgBox(ex.Message)
        End Try

The error message says 'Can not marshal parameter #2: The type definition of this type has no layout information.'

Please help to solve this problem.

Thanks.



0 Kudos
Message 3 of 4
(3,085 Views)

John,

I am not sure I can help solve this programming issue.

Are you sure you have properly imported your dll into your vb.net program?

Is there anymore information about this error? Line number? anything?

Lorne Hengst
Application Engineer
National Instruments

0 Kudos
Message 4 of 4
(3,078 Views)