Computers and electronics in agriculture
i
-
Computers and Electronics in Agriculture 12 (1995) 121-130
ptical teat inspection for automatic milking systems C. Bull *, ‘II Mottram, H. Wheeler BBSRC
Silsoe Research
Institute,
Wrest Park, Silsoe, Bedford
MK45
4HS, UK
Accepted 10 October 1994
Abstract
Automatic milking systemsrequire methods of ensuring that cows are clean before milking. This paper investigatesthe feasibility of a sensorto detect dirt on a teat basedcm the optical reflectivity of the teat. A fibre optic sensorand fast scanningmonochromator were nsed to make a series of measurements of the visible and near infrared reflectance properties of teats and the major surface contaminants.From thesedata spectral features,
which uniquely corresponded to manure and blood on a clean teat, were identified. Keywords: Milking parlour automation; Teat inspection; Dairy cattle
1. Introduction A number of authors have reported the development of robotic techniques to locate the teats and attach teat cups to cows with the aim of developing fully automatic milking (Ipema et al., 1992). However, an important element of any milking system is preparation of the teat prior to the attachment of teat cups. Yn many countries it is a legal requirement for teats to be clean before milking (for example in the European Union, EC directive 92/46). Mechanising the cleaning of teats is a major challenge in the development of complete automatic milking. Various prototype methods of automating the cleaning of cows’ udders have been demonstrated over a number of years (Kingwill, 1980). However, the rationale behind the operation of all of these systems has been to clean all the cows’ teats irrespective of their state of cleanliness. This contrasts with the current dairy practice where the teats are only washed when the visual and manual inspection of the teat by the herdsperson indicates that it is necessary. Washing and drying routinely has been shown to increase the instance of skin sores and chaps (Phillips et al., 1981). Lesions of this sort can form a major source of infection. Furthermore the washing of teats increases the risk of pathogens colonising the teat ends and * Corresponding author. 016%1699/95/$09.50 0 1995ElsevierScienceB.V. All rightsreserved. SSD?O168-1699(94)00040-9
122
C. Bull et al. /Computers
and Electronics
~in Agticulture
12 (1995)
121-130
pathogens migrating between the teats of the cow and between cows (Bramley, 1992). An automatic inspection method would enable a washing system to be controlled to wash only dirty teats and for only as long as they were dirty. In addition to dirt the milker also inspects the cow for damaged and cut teats. These need to be treated carefully as they can be exacerbated by cleaning or milking procedures. There are certain criteria that should be met by an automatic inspection system. First, the inspection and washing of the teat should be accomplished within the milk ejection reflex (let down time). Since entry into the stall will probably initiate the milk ejection reflex, it is essential that inspection and cleaning of all the teats takes no longer than about 2 min. If each teat is to be assessed in sequence the time for inspection and cleaning of each. teat should be approximately 30 sec. The second requirement is that the sensing technique should be non-contacting A method of sensing that would satisfy both of these criteria is optical sensing. Hogewerf et al. (1991) developed a system for taking electronic images of teat ends but the intention was to develop a manual system of standardising the analysis of teat lesions with the images gathered rather than to inspect teats automatically. Optical inspection for teat inspection was first attempted by Mottram et al. (1991), with a patented system which enclosed the teat in an open-topped cylinder. The power of the light signal emitted ‘by a row of LEDs inside the cylinder when reflected from the teat surface was measured. The device as demonstrated showed the mechanical feasibility but had only limited success and a better understanding of the reflectance properties of the teat was neeided. It is possible to distinguish between different substances by looking at the detail of their reflection spectra. This paper seeks to identify absorption features in the visible to NIR spectral range (380.-1100 mn) which uniquely correspond to the major contaminants on the teat and the cl.ean teats themselves, with a view to selecting specific wavelengths which1 highlight the presence or absence of dirt on the teat. This approach will give significantly better discrimination between the surface contaminants than is possib1.e by the eye or an artificial color system, such as a camera, because these systems’ are insensitive to the detail of the reflection spectra. For example, materials which rise to the same sensation of color may Ihave markedly different reflection spectra. In the absence of any rigorous study on teat contaminants it has been assumed that the major foreign materials that will be found on the udder will be soil and manure. 2. Equipment
and methods
The measurement system consisted of a tungsten halogen light source: a bifurcated light guide and a monochromator (Fig. 1). Light from the source was gui onto the teat surface along one arm of the bifurcated light guide whilst the reflected light from the teat was transmitted by the second set of fibres into the spectrum analyser. The fibre optic light guides were 500 mm long, allowing the sensor head to be held close to the teat. The geometry of the sensor head was chosen because it could be easily held up to the cow’s teat and subsequently cleaned. In these respects it was felt that this type of sensor could be used in a practical inspection system.
C. Bull et al. I Computers
and Ehctronics
in Agriculture
12 (1995)
121-130
123
Fig. 1. Schematic diagram of the measurement system. A is the light source, B the bifurcated light guide, C the teat, and D the monochromator.
A disadvantage of this sensor geometry is that it measures the specular and diffuse reflectance of the sample. The monochromator was a Monolight Instruments optical spectrum analyser (OS4 6100; Rees Instruments Ltd., Goldaming, Surrey). The system is able to take a full spectral scan in the wavelength range 300-1100 nm in 80 ms. In order to reduce the signal to noise ratio 50 consecutive scans’ were taken for each measurement. Reflectance measurements were taken over the wavelength range 380-1100 nm. This wavelength range was selected for three reasons. First, it coincides with the region of maximum light output of the source; second, the glass of the light guides attenuate strongly outside this range; and third, these wavelengths correspond to the sensitivity of silicon detectors which a.re used in the CCD arrays of video cameras. The resolution of the spectral scans was chosen to be approximately 9 nm as this is comparable to the bandwidth of interfere.nce filters (approximately 2% peak transmission wavelength) likely to replace the monochromator in the next phase of the development of the sensor system. The system was used to take two sets of experimental measurements on rhe teats of live cows selected for typical teat calloration. In the first experiment .the sensor was held in contact with a point on thie teat which was first clean, secondly coated with soil, and thirdly coated with fresh manure. The contaminants rapidly dried on the teat due to the warmth from both the cow and the fibre optic sensor. Consequently, the spectral scans were obtained from contaminants which were bfoth wet and dry and also in intermediate states. These measurements were used to identify spectral features of the clean teats and the contaminants. These data were stored as a percentage absolute reflectance by comparing the reflectance at each wavelength with that of a standard reference surface (Spectralon SRS-99-020; Oriel Scientific Ltd., Leatherhead, Surrey). The second experiment tested the effect of distance on the reflectance, the distance between the light guide and the teat surface being held at approximately 0, 5, 20, and 50 mm, respectively. The teat surface conditions were again clean, with wet soil, and contaminated with fresh manure.
124
C. Bull et al. I Computers
and Electronics
in Agriculture
12 (1995)
121-130
These data were stored as spectral scans, not as absolute reflectances, as much of the reflected light was not collected by the serrsor head. 3. Results
In the first experiment, 13 measurements were taken of the teat when it was cleaned and with each of the two contaminants. Typical absolute reflectance scans for the clean and contaminated teats, derived in experiment 1, are shown in Figs. 2a and 3a, respectively. The clean white teal: has a number of prominent spectral features which are highlighted in th.e second derivative of the scan presented in Fig. 2b. In contrast, the teat with black pigmentation shows very few spectral features
(4
300
400
500
600 700 Wavelength
800 900 (nm)
1000 1100
1
(b)
300
Fig. 2. (a) Typical reflection teat; bold line = black teat. bold line = black teat.
400
500
600 700 Wavelength
800 900 1000 1100 (nm)
spectra of clean teats obtained using a contact sensor. Fine line = white (b) The second derivative of the reflection spectra. Fine line = white teat;
C. Bull et al. /Computers
and Electronics
in Agriculture
12 (1995)
121-130
125
5 (a)
0 300
400
500
600 700 800 900 1000 1100 Wavelength (nm)
-10 c i+++++t’ (b) 300 400 500 600 700 800 900 1000 1100 Wavelength (nm) Fig. 3. (a) Typical reflection spectra of contaminated teats obtained using a contact sensor. Fine line = manure; bold line = soil. (b) The second derivative of the reflection spectra. Fine line = manure; bold line = soil.
with the reflectance varying only slightly across the spectrum. This observation is supported in the fairly featureless second derivative curve of the black teat presented in Fig. 2b. The reflectivity spectrum of manure is very different from that of the white or black teat (Fig. 3a). A second derivative spectrum of the manure scan (Fig. 3b) shows major absorption features at 680 m-n, which corresponds to the chlorophyll absorption band. By contrast, the reflection spectrum of soil (which contains some organic material) was almost identical to that of the black teat with a largely featureless curve from the visible to ,the infrared. However, there is slight evidence of a dip at 680 nm due to chlorophyll absorption. The spectral content of the light collected by the light guide as a function of distance between the sensor and a white teat is shown in Fig. 4. The features that
126
C. Bull
et al. I Computers
and Electronics
in Agrhlture
12 (1995)
121-130
0 300
400
500 600 Wavelength (nm)
700
800
Fig. 4. Spectral content of the light collected by the sensor for varying distances between the sensor and a clean white teat
appear on this scan are a superposition of the output characteristics of the light source, the transmission properties of the optical components in the system, and the reflection properties of the teat. As might be expected, the intensity of light collected decreases with increasing distance from the teat since some of the light reflected by the teat is not reflected back into the return fibre. However, the relative reflection at each wavelength appears to remain largely unchanged.
esults from experiment 1 show that a white pigmented teat is more reflective than both the black and contaminated teats over the visible spectrum (Figs. 2 and 3). Therefore, for a contact sensor white teats could be distinguished from black or contaminated teats on the basis of the magnitude of reflectance at a range of single wavelengths in the visible spectrum. Similarly one might hope to distinguish between teats with black coloration and various surface contaminants. However, this simple approach cannot be used when the sensor is not in contact with the teat surface because the reflectance signal changes markedly with distance (Fig. 4). As the distance between the tea.t and sensor increases, the reflection signal decreases. Clearly, at a given wavelength one can get the same return signal from a white teat that is some distance from the serrsor as a contaminated teat which is in close contact. It is worth looking in more detail at the effects of changing the sensor to teat distance. Fig. 5 shows the loadings, for each of the scanned wavelengths, of the first principal component of the data set presented in Fig. 4. If the effect of changing the distance is simply to affect the intensity of the reflection signal, and not the spectral content, then one would expect these loadings to be highly correlated to the individual scans. This proves to be the case. The correlation between the spectral scan taken with the sensor in contact with the teat and the first principal
C. Bull et al. i Computers
0
-0.05
and Electronics
in Agrkuiture
12 (1995’)
121-130
127
IL
iii 5 -0.1 8 -I -0.15
1.
-0.2
300 Fig. 5. Loading in Fig 4.
400
of the first principal
500 600 Wavelength component
plotted
700 (nm) against
600 wavelength
900 for the data set presented
component loadings is 0.998. Consequently one method of obtaining an index for a spectral scan that is largely invariant with sample distance is to take the ratio of the reflected signal at two wavelengths. In order to distinguish between the different scans we must consequently look for spectral features unique to each of the possible states of the teat. Examination of Fig. 3a and b shows that manure is strongly absorbing at 680 nm due to the prese’nce of the chlorophyll pigment. Chlorophyll in the cow’s diet is not fully digested and is thus present in manure throughout the year. By taking the ratio of reflectance at the chlorophyll absorption band and at a closely adjacent reference band it may be possible to distinguish
’
i
~-~-~%r-rure
Fig. 6. Ratio of the reflectance and contaminated.
Absent
at 690: 670 nm as a function
Manure Present of the two possible
teat conditions:
clean
128
C. Butt et al. /Computers
and Electronics
in Agriculture
12 (1995)
121-130
between the scans in which chlorophyll is present and those in which it is absent, For example, the ratio of reflectance at 690 : 670 nm might be suitable. This ratio has been calculated for each of the scans in the experiment where the sensor is in contact or away from the teat and the values are presented in Fig. 6 plotted against the two possible teat conditions, those with manure present and those without manure. It can be seen from this figure that it is possible to select a threshold ratio value which can be used to distinguish between the two teat conditions irrespective of whether the teat is in contact or at a variable distance from the sensor. A similar approach can be taken to determine whether the sensor is looking at a clean white teat. The scan of the white teat has a number of spectral features which are very closely related to the absorption of blood, which is illustrated in Fig, 7. Taking the ratio of reflectance at 525 : 540 nm highlights one of the spectral
I
.o (a)
300
400
500
600 700 Wavelength
800 900 1000 1100 (nm)
-20 II b) 300
400
500
600 700 Wavelength
800 900 1000 1 loo (nm) blood; (b) second derivative.
Fig. 7. (a) ‘lkansmission
spectrum
of
C. Bull et al. /Computers and Electronics in Agriculture 12 (1995) 121-130
1.6
I29
r---- --
1.4 it
1 0 -$
I I
!
0.8 0.6 0.4 0.2 0
i
! 1 -.
_..
.-
--~--.
Contaminated or Black Teat
---~~~----
White Teat
Fig. 8. Ratio of reflectance at 525 : 540 nm for clean white teats compared with all other scenarios.
features. This can be used to distinguish between white teats and some other possible conditions irrespective of the sensor to teat distance (Fig. 8). The remaining problem to distinguish between soil-covered teats and those with black pigmentation is more problematic. There are no obvious absorption features. Although in the illustrated example (Fig. 3) the soil appears to be more highly reflective than the black teat, in the near infrared this is not always the case. Consequently this feature does not give a reliable index for discriminating between black teats and those covered with solil contaminants. The main objective of future work is clearly to determine a method of unambiguously distinguishing between a clean black teat and non-chlorophyll-bearing contaminants. This may be possible by repeating the measurements with increased spectral resolution and a second sensor head geometry that only measures the diffuse component of reflection. This configuration is likely to highlight absorption features. The scans could be extended further into the NIR with a different experimental system to see if the reflection properties of soil and black teat are m,arkedly different further into the NIR. Finally, a powerful but narrow band light source might be used to monitor the absorption of 525 nm radiation by the blood underlying the pigmented skin of the teat. Once the appropriate spectral indexes have been identified it is envisaged that a practical sensor for milking system could be produced by replacing the monochromator with a system based on a number of narrow band interference filters. This might take the form of a sensor scanning the teat surface or an imaging device. In either case the system will :have to be robust and easy to clean. 5. Conclusions
With an optical inspection system it is possible to distinguish white teats from black teats or teats coated with manure or soil. It is also possible to distinguisb white
130
C. Bull et al. /Computers
and Electronics
in Agrkulture
12 (1995)
121-130
or black teats from those covered with manure. However, this method does not give a reliable index for discriminating between bl.ack teats and those covered with soil contaminants. The main objective of future work is clearly to determine a method of unambiguously distinguishing between a clean black teat and non-chlorophyllbearing contaminants and to implement the device as a practical system. Acknowledgements
The authors are pleased to acknowledge the support of MAFF funding in this project. References Bramiey, A.J. (1992) Mastitis and machine milking. In: A.J. Bramley, EH. Dodd, G.A. Mein and J.A. Bramley (Editors), Machine Milking and Lactation. insight, Newbury, pp. 343-372. Hogewerf, PH., van Heulen, SF. and Janssen, H.J.J. (1991) Equipment for taking video images of teats in dairy farming. Comput. Electron. Agric., 6: 235-242. Ipema, A.H., Lippus, A.C., Metz, J.H.M. and Rossing, W. (Editors) (1992) Proceedings of the International Symposium Prospects for Automatic Milking, Wageningen, The Netherlands, 23-25 November 1992 (EAAP Publication No. 65, 1992). Publ. Pudoc, Wageningen. Kingwill, J.C. (1980) “Teat preparation”. In: F.H. Dodd (Editor), Mechanisation and Automation of Cattle Production. BSAP Occasional Publication No. 2, British Society of Animal Production, Edinburgh. Mottram, TT, Khodabandehloo, K. and Douglas, A. (1991) A teat inspection device for automatic milking. UK Patent Application, 9109686.7. Phillips, D.S.M., Malcolm, D.B. and Copeman, P.J.A. (1981) Milking Preparation Methods - Their Effect and Implications. Proceedings of Ftuakura Farmers Conference, Ruakura Animal Research Station, Hamilton.