I designed a circuit similar to this
one a long time ago to help a beekeeper count the number of bees going into or out
of a hive. The low power circuit uses a slotted opto-sensor to detect the passing
bees. The circuit advances an electronic counting module whenever a honeybee
passes through the sensor. The device only counts the number of bees going through
the sensor. A different circuit would be needed to count the number of bees only
going out or only coming into the hive.
Click on Drawing Below to view PDF version of Schematic