Pest control method based on agricultural Internet of things
Technical Field
The invention relates to the field of agricultural Internet of things, in particular to a pest control method based on the agricultural Internet of things.
Background
Agriculture is the basic industry of national economy in China, and the pest control effect is directly related to agricultural production benefit, agricultural product quality safety, agricultural ecological environment safety and the like. In recent years, global climate is abnormally changeable, farming systems and production modes are changed, crop multiple cropping indexes are improved, and crop insect pests are frequently and massively infected. The insect pest detection method mainly depends on the experience of growers, agricultural technicians and agricultural experts are invited to guide the plants at home or remotely in some areas, and the traditional method usually misses the best prevention and control opportunity, and has low efficiency, high cost and poor timeliness.
In recent years, with the development of machine learning and deep learning, the occurrence of agricultural insect pests can be greatly reduced by recognizing agricultural insect pests based on machine vision recognition and convolutional neural network deep learning, when the characteristics of pest bodies appear, the rapid analysis and judgment of images can be realized, the insect pest types can be accurately positioned, early warning is timely sent out, and the pests are killed in germination. Meanwhile, with the wide deployment of sensors in the real world, the internet technology gradually permeates into the physical entity world, more and more physical entities are connected to the internet through the sensors to realize information sharing, and the internet of things is applied to the background. The new wave of information development of the Internet of Things (Internet of Things) has attracted great attention from the industry and academia. The thing networking has contained 4 parts: the system comprises physical entities in the real world, sensors for sensing state information of the physical entities, a transmission network and an intelligent processing system.
Disclosure of Invention
In order to solve the problems, the invention simulates the data collected by the sensor in the noise environment, provides the pest control method based on the agricultural Internet of things, improves the stability and robustness of the Internet of things platform layer for classifying the pests, and meanwhile, the Internet of things platform layer combines various data information collected by the sensing layer to pertinently control the pests. In addition, in order to enhance the separability of farmland image data, the invention adopts an SVM classifier. To achieve the purpose, the invention provides a pest control method based on an agricultural Internet of things, which comprises the following specific steps:
step 1, building a pest control Internet of things system based on STM 32: the STM32 is used as a controller of a network layer of the Internet of things, and a WiFi communication module is used as a network layer to be in wireless communication with a perception layer and a platform layer respectively;
step 2: determining a network layer communication protocol: the communication data format comprises a frame head, an address, command codes, effective data, check bits and a frame tail, different command codes are used for sending a working instruction to the STM32, and address coding is carried out on different sensing layer sensors so as to distinguish data;
step 3, acquiring simulated noise environment data: adding salt and pepper noise to the agricultural image data acquired by the platform in the step 2, and simulating interference on an acquired signal in a noise environment by adding the salt and pepper noise;
step 4, training an SVM pest classification model: dividing the agricultural image data obtained in the step 3 into training samples and testing samples, taking the characteristics of the training samples as input, taking the labels of the training samples as output, and obtaining an SVM pest classification model;
and 5, realizing pest control based on the agricultural Internet of things: and sending a corresponding command code to an STM32 controller according to a pest classification result output by the SVM pest classification model, and killing pests in a targeted manner through an external pest control system.
Further, the pest control internet of things system based on STM32 built in the step 1 can be expressed as follows:
the system is divided into: perception layer, network layer, the data of perception layer are connected with the network layer through STM 32's wiFi module, and the perception layer includes: the temperature data that temperature sensor gathered, the humidity data that humidity transducer gathered, the PH value data that PH value sensor gathered, the light intensity data that light intensity sensor gathered, the farmland image data that CCD sensor gathered, every sensor node is independent each other. The STM32 controller passes through drive circuit, filtering amplifier circuit, AD converting circuit and gathers the all kinds of data on perception layer to utilize the WIFI module to send the data transmission who gathers to the thing networking platform, the thing networking platform layer is to the processing analysis of further step of data that detect.
Further, the acquisition of the simulated noise environment data in step 3 can be represented as:
before data are processed and analyzed on an Internet of things platform layer, a pest classification model based on the agricultural Internet of things is constructed. Thing networking platform layer distinguishes the data that the perception layer was gathered through network communication protocol's command code to obtain the farmland image of real-time collection, after STM32 detected all kinds of data, can be with data packing into data format and be: frame head, address, command code, valid data, check digit, frame tail, platform layer receive farmland image data after, establish farmland image data set, add salt and pepper noise simulation environmental noise on the basis of image data set, the salt and pepper noise model that adds is:
wherein, ImaxAnd IminIs the maximum value and the minimum value of the image pixel points, p is the probability of noise occurrence of the image, the value range of p is 20 percent to 30 percent, ixyThe actual value of the collected image pixel point (x, y) is obtained, and the f (x, y) is the image pixel point value after the salt and pepper noise is added.
Further, the process of training the SVM pest classification model in step 4 can be expressed as:
the agricultural image dataset constitutes a sample set (x) of k datai,yi)jWherein j is 1,2, the., k, i is 1,2, the., n, n is the number of training samples, y is the pest category label, and the optimal hyperplane of k classifications obtained by learning through an interval maximization learning strategy is as follows:
ω·x+b=0 (2)
where ω is the normal vector and b is the displacement, the general form of the corresponding linear classification function is:
f(x)=ω·x+b (3)
while the optimal hyperplane makes all sample points satisfy:
f(x)|≥1 (4)
the support vector of the SVM is a sample point for establishing the formula 4, and after the support vector is found, the data can be divided into two types; the SVM model adopts a Gaussian radial basis kernel function, wherein the Gaussian radial basis kernel function is as follows:
during classification, the SVM algorithm maps sample data from a low-dimensional feature space to a high-dimensional feature space in a nonlinear way through a kernel function, an optimal hyperplane with maximized interval is found in the high-dimensional feature space, and the nonlinear classification function is as follows:
the SVM algorithm is a two-classification model, a plurality of two-classification models are constructed at the same time, the multi-classification problem can be solved, when n pest categories exist, a group of SVM classifiers need to design n (n-1)/2 SVM models, and finally k SVM pest classifiers are trained.
Further, the process of implementing pest control based on the agricultural internet of things in step 5 can be expressed as:
after obtaining SVM pest classifier in step 4 training, imbed the classifier in the platform layer of thing networking, the temperature data is monitored at each monitoring point to the perception layer, humidity data, PH value data, light intensity data, behind the farmland image data, utilize the WIFI module to send to the platform layer with data packing through STM32, the platform layer distinguishes various data through the command code in the data, independently carry out the analysis, show real-time temperature data on the platform, humidity data, PH value data, light intensity data, and input farmland image data to SVM pest classifier, output farmland pest type, combine all kinds of data to have pertinence ground infrastructure, adjust planting structure, reasonable fertilization, in time water, prevention and cure measures such as chemical prevention and cure send to the platform layer, remind the grower to prevent and cure.
The pest control method based on the agricultural Internet of things has the beneficial effects that: the invention has the technical effects that:
1. the agricultural data acquisition system utilizes the sensing layer to acquire various agricultural data, and independently transmits various data to the platform layer through the driving circuit, the filtering and amplifying circuit, the A/D conversion circuit, the WIFI module and the like;
2. the method effectively simulates the interference of the agricultural image in the noise environment when the data are collected, and the data simulating the noise are used for training the SVM classification model, so that the robustness and stability of the model in the noise environment are enhanced;
drawings
FIG. 1 is a flow chart of the present invention.
Detailed Description
The invention is described in further detail below with reference to the following detailed description and accompanying drawings:
the invention provides a pest control method based on an agricultural Internet of things, and aims to improve the robustness of data decoupling of a multi-dimensional force sensor in a noise environment and improve the stability and accuracy of data decoupling. FIG. 1 is a flow chart of the present invention. The steps of the present invention will be described in detail with reference to the flow chart.
Step 1, building a pest control Internet of things system based on STM 32: the STM32 is used as a controller of a network layer of the Internet of things, and a WiFi communication module is used as a network layer to be in wireless communication with a perception layer and a platform layer respectively;
the pest control internet of things system based on STM32 built in the step 1 can be expressed as follows:
the system is divided into: perception layer, network layer, the data of perception layer are connected with the network layer through STM 32's wiFi module, and the perception layer includes: the temperature data that temperature sensor gathered, the humidity data that humidity transducer gathered, the PH value data that PH value sensor gathered, the light intensity data that light intensity sensor gathered, the farmland image data that CCD sensor gathered, every sensor node is independent each other. The STM32 controller passes through drive circuit, filtering amplifier circuit, AD converting circuit and gathers the all kinds of data on perception layer to utilize the WIFI module to send the data transmission who gathers to the thing networking platform, the thing networking platform layer is to the processing analysis of further step of data that detect.
Step 2: determining a network layer communication protocol: the communication data format comprises a frame head, an address, command codes, effective data, check bits and a frame tail, different command codes are used for sending a working instruction to the STM32, and address coding is carried out on different sensing layer sensors so as to distinguish data;
step 3, acquiring simulated noise environment data: adding salt and pepper noise to the agricultural image data acquired by the platform in the step 2, and simulating interference on an acquired signal in a noise environment by adding the salt and pepper noise;
the acquisition of the simulated noise environment data in step 3 can be represented as:
before data are processed and analyzed on an Internet of things platform layer, a pest classification model based on the agricultural Internet of things is constructed. Thing networking platform layer distinguishes the data that the perception layer was gathered through network communication protocol's command code to obtain the farmland image of real-time collection, after STM32 detected all kinds of data, can be with data packing into data format and be: frame head, address, command code, valid data, check digit, frame tail, platform layer receive farmland image data after, establish farmland image data set, add salt and pepper noise simulation environmental noise on the basis of image data set, the salt and pepper noise model that adds is:
wherein, ImaxAnd IminIs the maximum value and the minimum value of the image pixel points, p is the probability of noise occurrence of the image, the value range of p is 20 percent to 30 percent, ixyThe actual value of the collected image pixel point (x, y) is obtained, and the f (x, y) is the image pixel point value after the salt and pepper noise is added.
Step 4, training an SVM pest classification model: dividing the agricultural image data obtained in the step 3 into training samples and testing samples, taking the characteristics of the training samples as input, taking the labels of the training samples as output, and obtaining an SVM pest classification model;
the process of training the SVM pest classification model in step 4 can be expressed as:
the agricultural image dataset constitutes a sample set (x) of k datai,yi)jWhere j is 1, 2.. times, k, i is 1, 2.. times, n, n is the number of training samples, y ∈ { -1, 1} isPest category labels, and learning by an interval maximization learning strategy to obtain the optimal hyperplane of k classifications as follows:
ω·x+b=0 (2)
where ω is the normal vector and b is the displacement, the general form of the corresponding linear classification function is:
f(x)=ω·x+b (3)
while the optimal hyperplane makes all sample points satisfy:
f(x)|≥1 (4)
the support vector of the SVM is a sample point for establishing the formula 4, and after the support vector is found, the data can be divided into two types; the SVM model adopts a Gaussian radial basis kernel function, wherein the Gaussian radial basis kernel function is as follows:
during classification, the SVM algorithm maps sample data from a low-dimensional feature space to a high-dimensional feature space in a nonlinear way through a kernel function, an optimal hyperplane with maximized interval is found in the high-dimensional feature space, and the nonlinear classification function is as follows:
the SVM algorithm is a two-classification model, a plurality of two-classification models are constructed at the same time, the multi-classification problem can be solved, when n pest categories exist, a group of SVM classifiers need to design n (n-1)/2 SVM models, and finally k SVM pest classifiers are trained.
And 5, realizing pest control based on the agricultural Internet of things: and sending a corresponding command code to an STM32 controller according to a pest classification result output by the SVM pest classification model, and killing pests in a targeted manner through an external pest control system.
The process of realizing pest control based on the agricultural internet of things in the step 5 can be expressed as follows:
after obtaining SVM pest classifier in step 4 training, imbed the classifier in the platform layer of thing networking, the temperature data is monitored at each monitoring point to the perception layer, humidity data, PH value data, light intensity data, behind the farmland image data, utilize the WIFI module to send to the platform layer with data packing through STM32, the platform layer distinguishes various data through the command code in the data, independently carry out the analysis, show real-time temperature data on the platform, humidity data, PH value data, light intensity data, and input farmland image data to SVM pest classifier, output farmland pest type, combine all kinds of data to have pertinence ground infrastructure, adjust planting structure, reasonable fertilization, in time water, prevention and cure measures such as chemical prevention and cure send to the platform layer, remind the grower to prevent and cure.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, but any modifications or equivalent variations made according to the technical spirit of the present invention are within the scope of the present invention as claimed.