I would expect that even if a can is there you will get transitions as the cans are gapped by the star wheel, how do you determine cans there.
So, you need to see a gap or how can you tell if it is working ? the problem then becomes if there is a missing can what do you do ? do you alarm & stop just because 1 can was missed, or do you wait for at least 5 or six cans in that case, there are no cans or the sensor is not detecting cans ?.
I have worked on fillers, generally the speed is quite high above a few thousand cans a minute, however, some of the larger cans may be in the hundreds, scan time can then become a problem, answer use high speed interrupts.
The ones I worked on relied on sensors on the can infeed system to check if cans are present & runout routines to bypass can in place checking, we also had to do something with glass bottles, there were sensors to detect broken bottles, if so, a wash jet was used to clear the broken glass before it was filled, this was to reduce waste product so was tracked into the filler star wheel.