Method for detecting pests in food grains based on near infrared machine vision, and apparatus thereof

The invention discloses an apparatus for detecting pests in food grains based on near infrared machine vision. The detection apparatus comprises a food grain sampling part, a food grain transmission part and a machine vision processing part; the food grain sampling part utilizes a grain discharge motor to drive a grain discharge wheel to rotate in order to rapidly and effectively separate a quantitative amount of food grains from a feeder; the food grain transmission part can convey a collecting box to an assigned position, and can automatically clean the food grains in the collecting box; and the machine vision processing part comprises a near infrared camera, a light source, an optical filter rotating wheel, an illumination case, a computer and corresponding software, and an identification model automatically determines the attitude of the food grains, and judges that whether the food grains are invaded by pests after the multi-wavelength near infrared image acquisition on the food grains in the collecting box. The invention also discloses a detection method corresponding to the apparatus for detecting pests in food grains based on near infrared machine vision. The apparatus and the method realize the real-time, accurate and automatic detection of the pests in the food grains.