Real-time Monitoring Terminal Design of Orchard Pests Based on Infrared Linear Array Imaging

In order to achieve real-time monitoring of orchard pests, we propose a system which collects the infrared linear array images of the pest distribution from real-time acquisition terminals in the orchard. Based on the collected image, the system performs analysis of the pest species and quantity, and communicate with the terminals and PC through ZigBee module, 4G network and SMS modules, to provide real-time and highly accurate support to pest monitoring and therefore give early warnings.


1
Introduction Orchard pests, which often appears cyclically [1], can be suppressed in the following cycles if people can effectively eliminate them in their first occurrence. Timely detection of pests, and pest control in their first stage can reduce pollution, and help with the development of Green Orchard and Green Agriculture [2]. Based on these considerations, real-time, accurate and extensive pest monitoring of orchards is essential.
In recent years, Li [3] achieved pest recognition based on an photoelectric beam detector, but is limited by the small diameter of the insect bottle, and is only capable of counting but not differentiating the species. Qiu et al. [4] used image processing technique, which obtained the two-dimensional image of the bottom of the bottle from planar array CCD sensor, but suffered from the great computational power required for a single detection, and was not applicable for real-time monitoring. In both cases, pest monitoring fails to give predictions of pest growth in a short term and early warning.
Aiming at the above problems, we designed the real-time monitoring terminal of orchard pests based on infrared linear array imaging technology. It is features the small amount of data processing needed for a linear array of image, high precision and uninterrupted real-time collection [5], which makes the real-time orchard pests monitoring accurate and broad.   Figure 2 shows the design of infrared linear array image capture terminal, which consists of an infrared laser, a beam expander len, an IR filter, a polarizer, a linear CCD image sensor, a field programmable gate arrays and a MSP430 microcontroller. We placed some insect sex attractant at the bottom of the bottle so that when attracted by the sex attractant [6], pests would fly into the bottom, pass the shaded area and project image onto the linear array CCD sensor. The linear CCD acquire image once every 100 μs, and of all the images taken, we select the one with the largest shaded area, which enable us to calculate the size, number and species of the pest. Laser has the advantage of being coherent, directional, monochromatic and bright [7]. Compared with infrared emitting diodes, infrared laser is more suitable to be the light source in our application, since it is not likely to be scattered, therefore reduce the error caused by the scattered light entering the linear CCD image sensor.

Hardware design of infrared linear image acquisition terminal
Insects are more sensitive towards the shorter wavelengths in the electromagnetic spectrum, around 253-700nm [8]. In order to eliminate the data collection error caused by this positive and negative phototaxis, we hereby choose the infrared light with a wavelength of 980nm.
The laser beam expander can extend the diameter and reduce the divergence angle of the laser beam. The collimated laser emitted from infrared laser has a too narrow beam that it could not meet the requirements of the linear CCD. With the beam expander, the laser beam is enlarged, forming a plurality of parallel collimated beams which irradiates uniformly onto the linear CCD, thus the design requirements are satisfied.
We equipped the laser with a 980nm infrared light filter to filter out light of other wavelengths, and ensure that the light incident on the CCD sensor is monochromatic, therefore effectively reduce interference from the surroundings.
Because of the presence of near-infrared light in the surroundings, the installation of the polarizer is necessary to reduce the environmental noise. It is also important for linear CCD image sensor, which is sensitive to light so that a polarizer could help to avoid saturation.
Area array CCD camera are commonly used as the image capture device in machine vision [9]. Linear CCD, on the other hand, has the advantage of larger pixel size, higher resolution of each pixel, and smaller amount of data per capture, which makes it more suitable for rapid real-time data acquisition [10].
When pests enter the field of view of the camera, the light blocked carries the information of them and is detected by the linear CCD. We connected the output image in the order they were captured, processed them to obtain the complete high resolution pest contour image, and got the geometric dimensions the pests [9].
In this design, we used Toshiba TCD1304AP linear CCD image sensor, comprising 3648 effective pixels, each of size 8μm × 200μm. The center distance is 8 μm, the working wavelength range is 300nm ~ 1100nm, and the effective photosensitive length is 29.184mm, which meets the requirement of the measurement range and accuracy.
In this design, we use field programmable gate array (FPGA), whose parallel multi-channel processing gives higher data processing speed and efficiency, and suits the need of the continuous high-speed linear CCD image acquisition system. Together with the gate array is a MSP430 microcontroller for data transfer, which is independent of the FPGA and facilitates function expansion in future.

Software Design
We chose the C-based IAR Embedded Workbench for MSP430 program development, to acquire, process, store and transmit the image data, as shown by the flow chart in Fig. 4.
When the single-chip is powered on, the software first initializes the timers, serial ports, FPGA, etc. Then it starts to collect the image from the linear CCD based on a timed cycle, and send to the remote terminal via the wireless module.
Before the collection of images, we tested the exposure time and set it to 20 us. Then the program sends the acquisition command and start exposure. After receiving the exposure completion signal from the CCD, data is sequentially read from the 1st pixel to the 3648 pixels, each of which is divided into upper eight bits and lower eight bits and transmitted.
After the data from 3648 pixels are read out, we complete the reading a frame image. Then the program send it to the host computer for data processing and storage through the wireless module.  When the collect images are sorted in chronological order, we arrive at a three-dimensional image containing information of the pest fly path. As shown in Fig. 6, the depressed area in the middle is the pest fly path, which is due to the decreased intensity of light when it is blocked by the pest. Calculating the number of pixels depressed per frame, we can measure the width of the depression in each frame, and the maximum width is the estimation of the pest diameter, so that we may achieve pest classification and number tracking.

Fig.6 Multi frame 3D image
We now take the 15th image frame for an example to perform image processing. As shown in Fig 7, we first select the edge region, and take derivatives at the rising and falling edge to determine threshold for each frame. After finding the points with the smallest derivative at the falling edge and the largest at the rising edge, respectively, the difference between the two abscissa is the number of pixels blocked by pests.
This method, which takes derivatives at the rising edge and the falling edge, reduces the calculation amount, and avoids the error from the fixed threshold method. To select the edge of the area, we use the pixel intensity difference between the two pixels separated by 6 others. If the difference is greater than 40, the points are classified as falling (XJX), while less than -40 are classified as rising (SSX). Thereby we have the horizontal axis range of the rising and falling regions.  Since the light intensity changes fastest in the pests occlusion region, the absolute value of its derivative is largest. After we take derivative on the declined region (XJY), we found that the smallest value is at the left edge. As shown in Fig 9, when the abscissa xmin=1506, the derivative is minimized.    = , 2( ) = We have at xmax = 2111, the derivative is maximized. Fig.11 Rising edge pixel intensity and derivative

ΔX1(x)=P(x)-P(x+6) ΔX2(x)=P(x)-P(x-6)
If we let the abscissa difference of the two edges be Δx, the measured width of pests be L: Δx=xmax -xmin = Δx × d The difference between the abscissa of the two sides is the number of pixels blocked by the pest, multiplied by the pixel center distance gives the width of the measured pest.
From the equation Δx =2111-1506=605, L= 605*8um=4.840mm, that is, the pest width is 4.840mm. By examining the width, we achieve the pest classification and counting.

6
Experimental results and error analysis We performed accuracy test using three kinds of workpieces, each for five times, and the measurement results are shown in Table 1 As can be seen from the above measurement results, the measured size and the actual size have a certain deviation, the average being of 2.04%, and the maximum of 4.71%. This discrepancy is caused by the fact that, theoretically, the beam emitted by the laser beam expander should be completely parallel and uniform, but in practice it is difficult to achieve uniform parallelism due to the assembly error and the fine jitter of the voltage. In addition, the shadow edge will produce diffraction phenomena and interfere with the measurement results. In order to reduce the measurement error, we should improve the assembly accuracy of the platform and the parallelism and stability of the light source.

Conclusion
In this paper, based on the infrared linear array imaging technology and embedded technology, a real-time monitoring system of pest species and quantity was carried out. Selection of infrared parallel light source and the linear CCD sensors reduced the external interference, improves the measurement accuracy, and enables pest classification based on their sizes while counting. Threshold is determined from the derivation at the edge, which reduces the amount of calculation while eliminating the fixed threshold error. This paper provides a simple and efficient method for monitoring insect pests, which might pave way for other novel counting and classification monitoring systems.