Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

imaqMatchPattern2 Division by zero

Im using the next code:

 pmArray = imaqMatchPattern2 (baseimage, ImPatternMatch, &matchPatternSet, NULL, ROIBox, &PMNumber);

ImPatternMatch is a valid png template loaded from file and baseimage is a valid image loaded from file or acquired with a camera.

With some kind of templates it just gives me an Division by Zero errror. To avoid this error I start making the ROIBox bigger (e.g. +5 and -5 pixels) and then it start working.

As added information, when Division by Zero is thrown, I cant dispose the image with the next code:

imaqDispose (ImPatternMatch);

It blocks the computer.

No error is returned using imaqGetLastError.

To avoid this error, Im making a duplicate of the template image before testing and if the imaqMatchPattern2 fails, it "destroys" the copy and I can erase the original one, but leaving a memory leak each time it fails.

Some help requiered.

Thanks
0 Kudos
Message 1 of 4
(3,230 Views)

Hello GARCIA_CHIH,

It seems you are encountering an error when calling the imaqMatchPattern2 function that may or may not be an issue with the IMAQ driver.  In order for us to identify the error and its source the quickest, it would be very helpful if you could post some code onto this forum that we could run on our end and easily demonstrate the issue.  What development environment are you using (LabWindows/CVI, MSVC, VB, C++, etc.)?  Please post any necessary files and instructions for us to run them and observe the error.

Regards,
Luke H

0 Kudos
Message 2 of 4
(3,215 Views)
I have found some issues here:
 
I was using
 
matchPatternSet.numMatchesRequested = 1  
 
and it fails.
 
I increased to:
 
matchPatternSet.numMatchesRequested = 3;  
 
and now it works. The function returns 2 matches found. But when I was requesting just 1, it fails at the point of not allow to erase the images.
 
Im attaching the images (bmp and png). Just search the png on the bmp extracting the green plane.
Note: Change extension to bmp erasing .txt section. It's changed so I can upload it.
 
 
Download All
0 Kudos
Message 3 of 4
(3,204 Views)
GARCIA_CHIH,

Could you please post your code so that I can run it on this image and see the behavior you are seeing?

Thanks,
Luke H
0 Kudos
Message 4 of 4
(3,176 Views)