Object detection problem. How should I approach it?

Hi all,

I need your help to figure out how I can approach a problem of proximity/presence detection.

The objects I need to detect are placed inside a container that's installed remotely. I need to be able to know how many objects are inside at any given moment. They will be distributed on multiple shelves, and all the objects on one shelf are of different variety. I might need to stack the objects at some point and get more of them stacked on top of each other on the same shelf.

The first option, and something I already tried to implement, are weight sensor.

PROS: you can stack items on a shelf (you will be able to determine how many of them you have if you know their weight beforehand).

CONS: reliability and stability. They're prone to all sort of "analog" problems you may expect. They're especially sensitive to moisture that might form, sometimes, inside the container.

What other options do I have to obtain the same kind object-detection without using weight sensors?

Thanks!