A machine that uses artificial vision and UV rays to scan through citrus fruits and get rid of rotten ones has been developed in Spain.
Usually the inspection is done manually in dark rooms, also using UV light.
But this type of light can harm workers' eyes and skin, so they must wear protective clothing and goggles.
The team from the Valencian Institute of Agrarian Research said that their technology could eliminate these risks.
The researchers describe the study in the journal Food and Bioprocess Technology.
Detecting rotten citrus fruit is tricky, as interior decay is not visible to the naked eye.
That is why traditionally, workers use ultraviolet light - and when the essential oils of the decayed citrus rind react with UV rays, the fruits emit fluorescence.
But although there is usually a good chance that the oranges and mandarins that present spots of fluorescence turn out to be rotten, it is not always the case.
Fluorescence can be produced by defects other than decay, and thus workers often need to examine the fruit manually as well.
They must wear gloves and special goggles, and should not stay in the dark room too long.
"The biological effect of UV rays is very bad for the health," said Gregory Varennes of Roda Iberica, the company responsible for introducing the technology into the market.
"According to the tolerable radiation limits of the UV light lamps, operators must not remain in the dark room for more than one hour - but often they stay in there for longer periods.
And this labour also represents a considerable cost for the company, added Mr Varennes.
So to avoid workers' UV exposure, Professor Jose Blasco of the Valencian Institute of Agrarian Research and his colleagues decided to let a machine do the job.
"Our system captures the images of the fruits inside an inspection chamber illuminated only with black light," he said.
"If the fruit is infected, it will show a spot of fluorescence, which is like a small right circle in the middle of the dark.
"The machine then uses image analysis techniques that are combined with UV to confirm the detection."
He added that fruit decay was one of the main causes of lost profits in the industry - meaning that detecting infected fruits as soon as possible and removing them from the rest of the pack was crucial.
The team has also developed another, similar mechanism that classifies citrus fruits on the production line according to their quality, colouring and the type of damage that the skin presents - at a speed of 15 to 20 pieces of fruit per second.
Thus, first class fruits that are destined for more demanding markets are separated from second class fruits that are perfectly edible despite having some small defects such as visible scratches.