Run Inspection Only Once on a Folder of Images in Vision Builder AI

Updated Sep 21, 2020

Environment

Software

  • Vision Builder for Automated Inspection

Vision Builder AI is application software that helps you rapidly develop and deploy machine vision inspection systems. In Vision Builder AI, when using the step "Read Image File", there is the option to cycle through the images in a folder. By default, Vision Builder cycles back to the first image after the inspection has gone through all the images in the folder and starts over. This article goes through how to get the inspection to run on a folder or batch of images just once, in both the Configuration Interface, as well as the Inspection Interface.

There are two ways to achieve this, each of which has its advantages and disadvantages, as shown below:

Method 1: Run Inspection Multiple Times:
  1. Identify the number of images in the folder to be inspected
  2. Add a "Read Image File" step to the main state, and make sure to select the checkbox to "Cycle through Folder Images"
  3. Navigate to the "Operate" tab, and then select: "Run Inspection Multiple Times..."
  4. Then specify the "Number of runs", which will be equal to the number of images in the folder
  5. You can also specify whether you want the inspection to start from the current image, or whichever other image you specify using the "Image #" input:


Note: The advantage of using this method is that it gives the desired result right away with no required programming. The disadvantage, however, is that this method only works in the Configuration Interface, as this option is not available in the Inspection Interface. Also, this requires a manual input from the user for the number of images in the folder as the "Number of runs".


Method 2: Using a State Transition Diagram with Variables:
  1. Add a "Read Image File" step to the main state, and make sure to select the checkbox to "Cycle through Folder Images"
  2. Navigate to the "Tools" tab, and then select the "Variable Manager"
  3. Add a numeric variable called "Image Counter" 
  4. Then, using a "Set Variable" step, set this variable to be equal to the index # of the current image in the folder, as shown below:
  5. Then, in another "Set Variable" step, increment the "Image Counter" variable. This is because the index of the first image in the folder will be 0, and we will need the incremented value for the last step of this method to work.
  6. Then set the inspection steps, and inspection status based on the application
  7. Next, you will need to create a state diagram as shown in the image below:
  8. The "Batch Complete Notification" state is only reached when the the index of the image being inspected (also the Image Counter variable) is equal to the number of images in the folder. The next step is to add this as the condition for the "Batch Complete" transition to occur: 
  9. Finally, you would want to add a notification once the inspection of all the images in the folder is complete. This is also what will allow the inspection to run through the images in the folder just once before starting over again, especially in the Inspection Interface. (where this usually runs continuously be default)
  10. This can be done by adding a "User Input" step in the "Batch Complete" state, configured as follows:  
  11. Now you can run the inspection through all the images in a given folder just once, in either the Configuration Interface, or the Inspection Interface

Note: The advantage of using this method is that it does not require manual input from the user for the number of images in the folder, and instead this is automated. In addition, this will work in both, the Configuration Interface, as well as the Inspection Interface. The only disadvantage is that this method takes more time to set up. However, you will only need to set this up once. Also, you can use the attached example: "VBAILoopImages Example.vbai" as a template or starting point.

 

In the Inspection Interface, the result will look similar to the one shown below: