The invention provides a detection device for determining position information from an object to the detection device, wherein the position information includes at least a distance from that object to the detection device. The detection device includes: a light source arranged to emit light a control device arranged to control the light source a light measuring device comprising a 2D classification of light sensitive elements and arranged to measure reflected light and to generate a corresponding measuring signal a signal processing device arranged to process the measuring signal to position information, including distance information, of the object with respect to the detection device, wherein the signal processing device includes an object recognition device is configured to recognize at least one of: an udder, a teat, a and respective parts thereof, and wherein at least one of the light measuring device has an absolute sensitivity maximum with a wavelength between 400 and 570 nm, and the light source has an absolute emission maximum with a wavelength between 400 and 570 nm.