Detecting a Objects in a Box
I think, after a preparation, measuring the weight of box solves the problem. If the weights of different kinds are forcibly approximated to different primary numbers, you can distinguish the kind and quantity of them mathematically.