Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

imaqFindTransformPattern incorrect return value

Hi,
 
I am using function imaqFindTransformPattern() to setup a coordinate system. This function is returning a 0, and when I use function imaqGetLastError(), I get a "No error" string. My point is that my code is working properly so I do not know why imaqFindTransformPattern() returns a 0. The help file says that on success, a non-zero value should be returned. Any ideas ? Thanks.
0 Kudos
Message 1 of 7
(4,044 Views)
Hello,
 
An error code of 0 indicates that no error has occurred.  There is an error in that documentation.  If you look at the list of error codes, linked from the documentation for imaqGetLastError(), a value of 0 indicates that no error has occurred.  Thank you for bringing this discrepancy to our attention.
 
Regards,
Scott R.
Applications Engineer
National Instruments
Scott Romine
Course Development Engineer
National Instruments
0 Kudos
Message 2 of 7
(4,038 Views)
The problem is that all functions returns 0 on failure, and they are actually doing it. In fact, the return value of the function is not the error code. Error codes are obtained via imaqGetLastError(). I think is not a problem with documentation, because so far that is the only function I have found is returning a 0 on success, instead of a non-zero. The problem is with the actual code.
0 Kudos
Message 3 of 7
(4,036 Views)

Hello,

My understanding is that your code is functioning properly, but the functions are all returning 0 values.  In the documentation, it is stated that a return value of 0 corresponds to an error.  However, attempting to determine the error type generates a message which indicates that no error has occurred. 

Is that accurate?  I will investigate those functions and determine what value should be returned.  I will let you know when I find out if the problem is with the code or with the documentation.  Have you tried to force an error in your code to determine if a non-zero value is returned in that case?

Regards,
Scott R.
Applications Engineer
National Instruments

 

Scott Romine
Course Development Engineer
National Instruments
0 Kudos
Message 4 of 7
(4,015 Views)

The only function I have found up to now returning a 0 on success, is imaqFindTransformPattern(). Then I use imaqGetLastError(), and it returns "No Error". All other functions I am using return non-zero values on success, which is what I expect.

And yes, I have forced errors in the code. As I mentioned before, only imaqFindTransformPattern() returns 0 both on success and on failure. That is weird.

0 Kudos
Message 5 of 7
(4,013 Views)
Hello,
 
How did you force the error?  Could you please attach an example of code that demonstrates the behavior that you have described? 
 
Regards,
Scott R.
Applications Engineer
National Instruments
Scott Romine
Course Development Engineer
National Instruments
0 Kudos
Message 6 of 7
(3,995 Views)

Hi,

This is an example of the code I am running. GrayscaleImage is an IMAQ_IMAGE_U8 image. CoordinateSystemPatternImage is an IMAQ_IMAGE_U8 image used as the reference for the coordinate system. AppFindTransformPatternOptions consists of the following:

   AppFindTransformPatternOptions.matchMode = IMAQ_MATCH_ROTATION_INVARIANT;  // Look for rotated images
   AppFindTransformPatternOptions.minMatchScore = MIN_SCORE; // 500
   AppFindTransformPatternOptions.subpixelAccuracy = TRUE;
   AppFindTransformPatternOptions.angleRanges = &Angles; // I set it from -45 to 45 degrees
   AppFindTransformPatternOptions.numRanges = 1;
   AppFindTransformPatternOptions.showSearchArea = FALSE;   
   AppFindTransformPatternOptions.showFeatureFound = TRUE;
   AppFindTransformPatternOptions.showResult = TRUE;

    if ((imaqFindTransformPattern(GrayscaleImage, CoordinateSystemPatternImage, &CoordSystem, IMAQ_NO_ROTATED_RECT, IMAQ_UPDATE_TRANSFORM, &AppFindTransformPatternOptions, NULL)) == 0){
     Error = imaqGetLastError();
     ErrorString = imaqGetErrorText(Error);
     if (Error)
      MessagePopup("Error", ErrorString);
     imaqDispose(ErrorString);
    }

On success, this function returns 0. That IS NOT what the documentation says. However, the function is doing what is supposed to.

0 Kudos
Message 7 of 7
(3,991 Views)