Hi,
the illumination is not so important, but they should be constant (avoid interfering light).
- In a first step I would try to detect the box based on the outer contours, or place the box on a fixed position and define a mask
- Second define a roi and calculate the profile for this roi, before you can apply a e.g. median filter to eliminate noise (see images below)
- Third, for each tube, cup or empty there is a unique profile characteristics
- Fourth, compare the unique characteristics with a current one based on a distance measure
Instead of comparing the profiles you can also try to do a template matching approach.
Image with ROI including background
Image with ROI within box
Image with applied median filter before
Best