Machine Vision

Showing results for 
Search instead for 
Did you mean: 

Looking for a good explanation of how to use IMAQ Find CoordSys (Rect) 2


I'm struggling to make this work. Here's my understanding of how to use it. Maybe someone can explain what I'm missing or guide me to some helpful reference material.


I'm trying to set up a coordinate system to position a mask in a series of images. The region I want to mask moves slightly between images because I have some variation in how parts are presented to the camera.


In principle, I first need to define a coordinate system based on the intersection of two edges in a master image. For this I use Find CoordSys in 'Find Reference' mode. I only run this once, when my program first runs or initializes.


For each image that I load subsequently, I use Find CoordSys in 'Update CoordSys' mode to find the intersection of the two edges in that image. I am assuming that I use the same Line Options, ROI and Search region options that I used when running my master image. I'm using Local Variables to do this.


I also assume that Find CoordSys in 'Update CoordSys' mode effectively generates an offset from the master image. Now do I put this in to IMAQ Transform ROI to generate a modified mask ROI? 


And last, when I run this, why on some images do I get, "Unable to fit a line for the primary axis?" 

Obviously I've misunderstood something, but I can't see what. Any suggestions will be gratefully received.


0 Kudos
Message 1 of 4

Hi there!


I found this link helpful in describing when to use coordinate systems as well as the general process you should follow when looking at images of parts that may be in slightly different positions:


NI Vision Concepts Help: Coordinate System


When you use the IMAQ Find CoordSys (Rect) 2 VI, it performs an edge detection search in two directions within the search ROI you define. It first searches for the main (or primary) axis in one direction and then searches for the secondary axis in the direction perpendicular to the primary axis. The "Unable to fit a line for the primary axis" error is saying that the edge detection did not locate any edge based on the parameters you used. This could happen if the feature you are trying to detect is outside of the ROI, or lighting/contrast is insufficient to highlight the feature. You could try messing around with the Edge Options parameter to get a more consistent outcome.


This VI returns the Coordinate System Out with two parts: the Reference System and the Measurement System. The Reference System is defined when you use the "Find Reference" mode. When you call the VI again in "Update CoordSys" mode, it updates the Measurement System to reflect the new coordinate system based on the new image. This coordinate system can then be used with various search and measurement VIs, such as the clamp VIs. The search area for these VIs will automatically reposition based on the new coordinate system. This method 


I don't think that the mask VIs accept the same coordinate system, so you would want to extract the measurement system part of the Coordinate System Out and use it to reposition your mask. IMAQ Transform ROI should work great for this! If you have more question, it would be helpful for us to see your code and sample images if possible!



Jordan C.

0 Kudos
Message 2 of 4

Thanks for the suggestions and explanation Jordan. It will take me some time to dig in, so I'll let you know how I'm getting on next week.

0 Kudos
Message 3 of 4

It's been a long time since last message but still hard to find detailed information about this topic.  This is the procedure I use for the find coordinate system VI, it's for the pattern method but for rect should be similar:


1 - In your reference image take the template for the origin of the coordinate system. Here we'll set the mode to "find reference". This will update the 'Reference system' field of the coordinate system.


2 - Do the same with the new image(displaced or rotated), so use the same template in the "find coordinate system' this time setting the mode to 'update coordsys'.  This will update the 'Measurement system' field.


3 - The ouput of the previous step will be the input of the Transform ROI VI. The input ROI would be the area where looking for the pattern in the original image and the ouput would be the ROI transformed that will be wired to the input of the match pattern VI.


This way the match pattern VI will look for the pattern in the new ROI, based on new position of the template reference in the new image.


A bit tricky but hope I managed to explain myself. 

0 Kudos
Message 4 of 4