Hi kapium,
Thank you for posting on the National Instruments discussion forums.
In VBAI, the Detect Objects step allows you to specify the order of the detected objects. This does not modify the order in which the objects are scanned. This is set by the algorithm used by the step; it always detects the object from top left to bottom right, line by line. When you specify the order, VBAI will take the detected objects, then rearrange them so that, instead of being ordered by their scan order, they will be ordered by the criteria that you specify (size, X position, etc.).
This is important to note because it explains how something similar to this would be done in LabVIEW. Basically, you would need to take the cluster returned by the IMAQ Count Objects 2 VI and rearrange the objects in the cluster based on the property of your choice. By migrating a VBAI inspection to LabVIEW, you can see the LabVIEW code that VBAI generates to do this. Here is a screenshot of this code:
To reproduce this, you will need to create a VBAI inspection that uses the Detect Objects step and is set to sort the objects by something other than the scan order. Next, in VBAI, select Tools -> Migrate Inspection to LabVIEW... This will generate the LabVIEW code, but the sorting code that you want is buried a little bit. First, you will need to open Inspect State Exec 1.vi which is located in the Inspect case inside of the while loop. Next, open IVB Detect Objects Code.vi, then IVB Detect Objects Exec.vi in the Exec case, then IVB Detect Objects Algorithm.vi in stack #1 of the stacked sequence structure. The code you want will then be located in the stack #9 of the stacked sequence structure in this VI.
I hope this helps. Please reply if you have any questions about implementing this. Thanks.
Rishee B.
Applications Engineer
National Instruments
Message Edited by risheeb on
12-27-2007 09:07 AM