Machine Vision

Showing results for 
Search instead for 
Did you mean: 

Handling variable number of detected ojects in VBAI calculator

Go to solution

I have an inspection that searches for bright objects (holes) in a product, and typically it does not find any (good), but when it does I need to know the locations of each hole, to determine xy-boundaries of the region of holes, i.e., the mins and maxes of the xy-coordinates of each hole. To do this, I'd like to use a caclulator step and interate through all the holes found.....but I don't believe the calculator can handle a variable number of holes..or can it?




0 Kudos
Message 1 of 4
Accepted by eberg

Hi Eric,


The calculator step does not support arrays. We got numerous requests about better array support in VBAI and we're going to address it.

In the meantime, you can iterate through the results of a step that produces arrays by building a slightly more complex state diagram. Index Measurements Example.vbai and Classify Objects Example.vbai for examples on how to do that.


Hope this helps.


Best regards,



0 Kudos
Message 2 of 4

It can if you put it in a loop with the index step indexing through each detected object and getting the center X, Y for hole[i], passing these results to caluclator, incrementing i, and using index step to get coordinates for next hole, and leave this state when no holes left.


Hope that  helps,


0 Kudos
Message 3 of 4


Thanks, that did the trick.


0 Kudos
Message 4 of 4