Constrain the environment. Best is to make sure the glass is always the same (position and shape), take a picture of the glass empty and use that as reference. Otherwise, you'll need some algorithm to first detect the position of the glass (if the background is constrained, you can use that).
If the liquid is isolated, I'd recommend applying a sobelY filter and something to reduce noise. Take a vertical line out of the graph and identify each step (top glass, water level, bottom glass).