A teat location system for automated milking systems comprises a lightprojectionsource and a camera having a two dimensional array of pixels, each of which iscapable of returning time of flight information as well as intensity. Depth offieldlimitations and the problem of overlapping teat images are thereby overcome orminimized.