MATLAB Image-Processing Toolbox: asking for a roadmap!
If the distinct contents/ingredients really have different colors than you just have to take a picture, always in the same location/distance, and then count the amount of pixels for each color.

You can transform your RGB image to the HSV color space to make it easy to identify specific colors. 

Some pseudocode: 

image_hsv = rgb2hsv(image_rgb)
greenmax = 120+10
greenmin = 120-10
num_green_pixels = sum( and( image_hsv[H]&gt;greenmin, image_hsv[H]&lt;greenmax ) )