How to get the number of detected object

We are curently doing a bin picking project with ProM camera, Eye in Hand, mech-Vis/Viz version 2.1.2 and YASKAWA robot. We doing standard interface comand MM_START_VIZ - MM_SET_BRANCH - MM_GET_VIZDATA - MM_GET_POS. We want to get the number of detected object from mech-Viz to reduce cycle time. So the robot does not need to capture the bin after the last object was picked. How can we do that?