# A System for Detection and Recognition of Pests in Stored-Grain Based on Video Analysis

Ying Yang, Bo Peng, Jianqin Wang

► To cite this version:

Ying Yang, Bo Peng, Jianqin Wang. A System for Detection and Recognition of Pests in Stored-Grain Based on Video Analysis. 4th Conference on Computer and Computing Technologies in Agriculture (CCTA), Oct 2010, Nanchang, China. pp.119-124, 10.1007/978-3-642-18333-1_16. hal-01559588

HAL Id: hal-01559588

https://inria.hal.science/hal-01559588

Submitted on 10 Jul 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A System for Detection and Recognition of Pests in Stored-grain based on Video Analysis

Ying Yang, Bo Peng, and Jianqin Wang

College of Information & Electrical Engineering, China Agricultural University, Beijing, P.
R. China

hbxtyy@126.com, wjqcau@126.com, pengbo_cau@126.com

**Abstract.** This paper presents a system for detection and recognition of pests in stored-grain based on video analysis. Unlike current systems which conduct analysis of static images, the proposed system uses video data captured by camera and performs video analysis to detect and recognize pests in grain. By using video data instead of static images, techniques such as motion estimation and multiple-frame verification are used to locate, count and recognize pests. Compared to systems based on image processing, the proposed system is more robust to moving pests and avoids missing and re-counting of moving pests. Furthermore, by analyzing motion of pests in video, the system can only count living pests and ignore dead ones, which are recommended by national standard of grain quality and cannot be achieved by current systems based on static image processing.

**Keywords:** video analysis, pest detection, pest recognition, store grain.

## 1 Introduction

It is well known that pests inflict great damage to stored grain. For instance, in China, pests in grain cause loss of more than one billion Yuan every year. To avoid damaging to stored grain, it is vital to detect, recognize, and count pests in stored grain, since these operations offer information such as pest species and pest density for further measurements.

In earlier research efforts, pests are detected, recognized and counted manually [1-2]. For these methods, the results depended on environments and human operation, which make the methods unreliable. Other researchers try to detect pests automatically using near infrared spectrum or X-ray scanning [3-4]. These methods can yield good results, but they are of low efficiency and require expensive devices. These days, methods based on machine vision and computer image processing become the most popular method due to their low cost, high efficiency and good performance [5-14]. These methods usually analyze images of grain taken by a camera to detect pests and use classifiers such as Neural Network or Support Vector Machine to recognize pest species. There are two major problems of these methods: first, since only one or few static images are processed, noises in images and moving pests may cause detection errors; secondly, it is impossible to decide whether the
pests detected are living in static images, while only living pest density are considered in national standard of grain quality since only living pests can cause damages.

To solve the problems of current machine-vision-based systems, this paper presents a system for detection and recognition of pests in stored-grain based on video analysis. The system uses video data captured by a camera and performs video analysis to detect and recognize pests in grain. By using video data instead of static images, techniques such as motion estimation and multiple-frame verification are used to locate, count and recognize pests. The proposed system is more robust to moving pests and avoids missing and re-counting of moving pests. Furthermore, by analyzing motion of pests in video, the system can only count living pests and ignore dead ones.

<figure><img src="image_2.png" /><figcaption>**Fig. 1.** Architecture of the proposed system.</figcaption></figure>

As shown in Fig. 1, the proposed system consists of two subsystems: video collection subsystem and video processing system. The two systems will be detailed in Section 2 and Section 3.

## 2 Video Collection Subsystem

The video collection subsystem is used to capture video of stored-grain. It is mainly a hardware subsystem similar to that proposed in [6].

As shown in Fig. 1, the video collection is composed of four major components: grain sampling device, grain conveying device, illumination device and video capture device. The grain sampling device is used to take samples of stored grain. The device works like a pump and sucks grain through pipes to the conveying device. The conveying device is a conveyer belt moving at constant speed. The grain is placed of single layer on the belt, which makes all pests in grain can appear in the video. The illumination device is a LED light which makes sure the video captured in good and constant illumination condition. The video capture device consists of a CCD camera and video capture card. The device is connected to a computer through USB port.
When the device is running, video of grain on the conveyer belt is captured and transferred into computer memory at real time.

The main difference between the proposed video collection subsystem and current image-based systems (such as the system in [6]) is that the proposed system takes video of grain instead of static images. Unlike current systems which take every image within a short interval (0.6 second in [6]), our system takes continuous video at speed of 25 frames per second. The video is transferred and stored into computer memory and disk for further processing in the video processing subsystem.

# 3 Video Processing Subsystem

The video processing subsystem is a software system running on a computer. It receives video signal captured by the video collection subsystem as input and performs video analysis to detect, count and recognize pests in the video.

Before video analysis, the continuous video signal is first segmented into video segments. The length of segment depends on moving speed of the conveyer belt. In our implementation, the segment length is set as 2 seconds.

As shown in Fig. 1, the video processing procedure includes 3 stages: pest detection, living pest counting and pest recognition, which correspond to the three major modules of the video processing subsystem.

## 3.1 Pest Detection Module

In current systems based on image processing, since only one static image is processed, detection errors may be caused by noise, and miss or re-counting may be caused by motion of pests. In the proposed system, a segment of frames in video is used instead of a single image, so verification across multiple frames can be performed to avoid missing and re-counting caused by noise or pest motion.

Before multi-frame verification, pests are segmented in each frame of the input video: First, the image is processed using image sharpen to increase the difference between pest areas and the background. Then, pest areas are segmented from background using thresholds obtained by K-means clustering of the pixels in the image. Finally, more accurate areas of pests are obtained by morphological operations.

After obtaining pest areas in each frame, multi-frame verification is performed using a neighbor-searching method. For each pest area in each frame, the image area around the pest area is divided into multiple blocks. For the prior and next frame, searching of pests is performed in the neighbor blocks. If pest areas exist, similarity is calculated between pest areas in current frame and in adjacent frames. Finally, decision is made of whether the pest area in current frame is a false detection by thresholding the similarity. An illustration is given in Fig. 2.
<figure><img src="image_3.png" /><figcaption>Fig. 2. Illustration of multi-frame verification.</figcaption></figure>

It can be seen that by using multi-frame verification, errors caused by noise or pest motion can be avoided. Therefore, better detection results can be obtained using the proposed system.

## 3.2 Living Pest Counting Module

As motioned above, in current system based on image processing, it is difficult to only count living pests and ignore dead ones since only static images are processed. In the proposed video-based system, a segment of video is processed. Therefore, living pests can be detected by analyzing their motion in the video.

Since the grain on the conveyer belt is moving, motion of living pests can not be detected simply by using difference of frames. Therefore, the aim of living pest detection based on video analysis is to detect local motion of living pests within global motion of grain in the video.

In the living pest counting module, global motion estimation is performed to obtain parameters of motion between grain and the camera. In our work, a six-parameter affine model is used: if the 2D coordinates of one point on an object in continuous frames are (x, y) and (x', y'), the affine model of six parameters is

$$x' = a_1x + a_2y + a_3, \quad y' = a_4x + a_5y + a_6 \quad (1)$$

where $a_1, a_2, \dots, a_6$ are parameters related to the camera. In our work, these parameters are estimated by global motion estimation of feature points which may be fix points marked on the conveyer belt. When global motion parameters are estimated, local motion of pest areas can be detected across multiple frames, and pests without motion are classified as dead ones.

When living pests are detected in each video segment, the count of living pest will accumulate to give total count of living pests.
## 3.3 Pests Recognition Module

The aim of pest recognition is to recognize species of pests. In current systems based on image processing, recognition errors may be caused by noise or override between grain and pest. In the pest recognition module of the proposed system based on video analysis, a multi-frame verification technique is also utilized to achieve better performance.

For each frame in the video segment, features including gray value, area, circumference, texture are extracted for pest areas recognition. These features are input into a SVM classifier to recognize the specie of the pest. The SVM classifier is trained with samples of pests using the same image features. The classification result of SVM is represented as probabilities of each species.

After getting specie-probabilities of each frame, multi-frame verification is performed by calculating the average probability value of each specie and choosing the one with maximum average probability as final recognition result.

## 4 Conclusions

This paper presents a system for detection and recognition of pests in stored-grain based on video analysis. While current systems conduct analysis of static images, the proposed system performs video analysis to achieve better performance. The system consists of video collection and video processing subsystems. In the video processing subsystem, techniques such as motion estimation and multiple-frame verification are used to locate, count and recognize pests.

As to our knowledge, the system proposed in this paper is the first system which performs video analysis for pest detection and recognition in stored grain. Compared to systems based on image processing, the proposed system is more robust to moving pests and avoids missing and re-counting of moving pests. Furthermore, the system can only count living pests and ignore dead ones, which is recommended by national standard of grain quality and cannot be achieved by current systems based on image processing.

## References

1. Smith, T.F., Waterman, M.S.: Identification of Common Molecular Subsequences. J. Mol. Biol. 147, 195--197 (1981)

2. May, P., Ehrlich, H.C., Steinke, T.: ZIB Structure Prediction Pipeline: Composing a Complex Biological Workflow through Web Services. In: Nagel, W.E., Walter, W.V., Lehner, W. (eds.) Euro-Par 2006. LNCS, vol. 4128, pp. 1148--1158. Springer, Heidelberg (2006)

3. Foster, I., Kesselman, C.: The Grid: Blueprint for a New Computing Infrastructure. Morgan Kaufmann, San Francisco (1999)

4. Czajkowski, K., Fitzgerald, S., Foster, I., Kesselman, C.: Grid Information Services for Distributed Resource Sharing. In: 10th IEEE International Symposium on High Performance Distributed Computing, pp. 181--184. IEEE Press, New York (2001)
5. Foster, I., Kesselman, C., Nick, J., Tuecke, S.: The Physiology of the Grid: an Open Grid Services Architecture for Distributed Systems Integration. Technical report, Global Grid Forum (2002)

1. Hongtao Zhang, Yuxia Hu, Daoyin Qiu: Overview of Stored-grain Pest Detection. Journal of Henan Agricultural Sciences, 2006, vol 35(3), pp.66-68(2006)

2. K W Vick, J C Webb, B A Weaver, et al: Sound detection of stored-product insects that feed inside kernels of grain. J Econ Entomol, 1988, vol.81(5), pp.1489-1493(1988)

3. J Chambers, I A Cowe, C B Van Wyk, et al: NIR analysis for the detection of insect pests in cereal grains. Proc Int Conf on Diffuse Spectroscopy. MD USA, 1992, pp.96-100(1992)

4. Keagy P M, Schatzki T E: Effect of image resolution on insect detection in wheat radiographs. Cereal Chemistry, 1991, vol.68(4), pp.339-343(1991)

5. Mao Hanping Zhang Hongtao: Research Progress and Prospect for Image Recognition of Stored-grain Pests. Transactions of the Chinese Society for Agricultural Machinery, 2008, vol.39(4), pp.175-179(2008)

6. Daoyin Qiu, Hongtao Zhang, Tiejun Chen: Hareware Design of an Intelligent Detection System for Stored-grain Pests based on Machine Vision. Transactions of the Chinese Society for Agricultural Machinery, 2003, vol.34(1), pp.86-87(2003)

7. Qiu Daoyin Zhang Hongtao, Zhang Tiejun, et al.: Software Design of an Intelligent Detection System for Stored-grain Pests based on Machine Vision. Transactions of the Chinese Society for Agricultural Machinery, 2003, vol.34(2), pp.83-85(2003)

8. Long Zhou: Application of wavelet analysis of restraining the noise and edge detection of pest image in stored grain. Journal of Huazhong University of Science and Technology (Nature Science), 2005, vol.33(5), pp.52-54(2005)

9. Long Zhou: Research on Fuzzy Detection Method of Pest's Image in Stored Grain Based on Machine Vision. Computer Applications and Software, 2005, vol.22(8), pp.24-25, (2005)

10. Hongmei Zhang, Yanfeng Fan, Geng Tian: Identification and Classification of Grain Pest Based on Digital Image Processing Technique. Journal of Henan University of Technology (Natural Science Edition), 2005, vol.26(1), pp.19-22(2005)

11. Tong Zhen, Yanfeng Fan: Research of Grain Pests Detection and Classification Based on SVM. Computer Engineering, 2006, vol.32(9), pp.167-169(2006)

12. Feiyu Lian, Yuan Zhang: Detection of Pests in Stored-grain based on Image Recognition. Journal of Henan University of Technology (Natural Science Edition), 2006, vol. 27(1), pp.21-24(2006)

13. I Y Zayas, P W Flinn: Detection of insects in bulk wheat samples with machine vision. Transactions of the ASAE, 1998, 41(3), pp.883-888(1998)

14. C Ridgway, R Davies, J Chambers: Imaging for the high-speed detection of pest insects and other contaminants in cereal grain in transit. ASAE Meeting Paper No. 01-3056, St. Joseph, ASAE (2001)