Paddy field farming behavior identification and alarm method

By adding a small target detection layer and a global attention mechanism to the YOLOv8 network, combined with structural similarity and peak signal-to-noise ratio algorithms, the problem of high computing power or low accuracy in rice field farming behavior recognition is solved, and high accuracy is achieved Highly efficient and low-cost detection of farming behavior in rice fields.

CN118609013APending Publication Date: 2024-09-06NINGBO INST OF TECH ZHEJIANG UNIV ZHEJIANG
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410643951.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing rice field farming behavior recognition methods are difficult to balance between high computing power input or low accuracy. Especially during the rice planting process, agricultural machinery occlusion and large-area rice field operations lead to the loss of feature information, affecting the recognition accuracy.

Method used

An improved version of the YOLOv8 deep learning target detection network is used to add a small target detection layer and a global attention mechanism, and combine structural similarity and peak signal-to-noise ratio algorithms for data preprocessing to improve small-size target detection capabilities and identification of similar farming behaviors.

Benefits of technology

It achieves high-accuracy detection in rice field farming behavior recognition and alarm, reduces costs, and improves recognition accuracy by enhancing small-size target detection capabilities and similar behavior recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118609013A
    Figure CN118609013A
Patent Text Reader

Abstract

The invention relates to the field of farming behavior detection, in particular to a paddy field farming behavior identification and alarm method. The method comprises the following steps: S1, collecting rice field behavior data; s2, carrying out behavior data labeling, S3, carrying out improvement on YOLOv8, adding a small target detection layer, and adding an attention mechanism; s4, training a target detection network to obtain a trained model; s5, loading a video stream, carrying out target detection, directly recording when an agricultural machine is detected, and then skipping to S7; if the person is detected, skipping to the next step; s6, judging whether the maximum enclosing rectangles where the person and the farm implement are located are overlapped or not, if yes, recording the farm behavior, and skipping to the next step; if not, returning to the step S5 to continue the detection; and S7, comparing the recorded behavior with a preset behavior, and if the recorded behavior is overlapped with the preset behavior, giving an alarm. By adopting the method, the detection accuracy is high, and the investment cost is low.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of agricultural behavior detection, and in particular to a method for identifying and warning agricultural behavior in a paddy field. Background Art

[0002] There are currently two main types of agricultural behavior recognition. One is to use time series, space, skeleton and other information for behavior recognition. This method has high accuracy, but has high requirements for computing power and feature information. In agricultural production, large computing power investment will increase farmers' production costs. In the process of rice planting, agricultural machinery operations will block the driver. As the rice grows, agricultural personnel will be seriously blocked. The loss of these feature information will affect the accuracy of recognition. The other is to classify agricultural behaviors based on image feature information using target detection technology. This method has low computing power investment, but poor accuracy. In the process of rice planting, similar agricultural behaviors such as manual backpack fertilization and pesticide application, manual land preparation and weeding have a great impact on the accuracy of image feature detection. In addition, the rice field operation area is large, and it is impossible to set up a large number of cameras, which results in smaller targets in the acquired image data and serious loss of feature information. Therefore, small target detection is a challenge faced by both methods. Summary of the invention

[0003] The technical problem to be solved by the present invention is: a method for identifying and warning paddy field farming behaviors, which has high detection accuracy and low investment cost.

[0004] The technical solution adopted by the present invention is: a method for identifying and warning paddy field farming behaviors, which comprises the following steps:

[0005] S1, collect rice field behavior data;

[0006] S2. Use annotation software to annotate behavioral data, including:

[0007] S2.1. Label the agricultural machinery with its largest circumscribed rectangle, and the label information is the agricultural activity corresponding to the agricultural machinery;

[0008] S2.2, labeling with the largest circumscribed rectangle of a person, with label information of person;

[0009] S2.3, label the largest circumscribed rectangle of the agricultural tools used in manual farming activities, and the label information is the name of the corresponding agricultural tool;

[0010] S3, based on the original deep learning target detection network of YOLOv8, it improves on this by adding a small target detection layer and an attention mechanism;

[0011] S4, target detection network training, obtaining the trained model;

[0012] S5, loading the video stream of the rice field, using the model trained in step S4 to perform target detection, and when agricultural machinery is detected, directly record the agricultural behavior, and then jump to step S7; if a person is detected, jump to the next step;

[0013] S6, determining whether the maximum circumscribed rectangle of the person and the farm implement overlaps, if so, determining that the person is operating the corresponding farm implement to perform farming activities, then recording the farming activities and jumping to the next step; if not, returning to step S5 to continue detection;

[0014] S7. Compare the recorded farming behavior with the preset farming correction behavior. Both the recorded farming behavior and the preset farming correction behavior include time, address and specific behavior. If all three overlap, an alarm is issued.

[0015] Preferably, adding a small target detection layer in step S3 specifically includes adding a feature image layer with a resolution of 160×160 that is not used by the original target detection network, and adding an upsampling operation to effectively splice the feature information with the deep feature information.

[0016] Preferably, adding the attention mechanism in step 3 specifically includes adding a global attention mechanism before the pooling layer, and the workflow of the global attention mechanism includes the following steps:

[0017] S3.1. Input and feature extraction: Input feature image, with N channels, L length and W width, can be regarded as a two-dimensional feature matrix on N channels after feature extraction;

[0018] S3.2, global average pooling: perform global average pooling on the feature map, average pooling the features on each channel according to the spatial dimension, so as to obtain a scalar value on each channel as the feature of the entire channel;

[0019] S3.3, Scaling and Activation: The result of global average pooling is scaled and operated with a nonlinear activation function;

[0020] S3.4, weight calculation: weight calculation is performed on the scaled and activated features to obtain the weight vectors on N channels, which are used to indicate the global importance of each channel;

[0021] S3.5, feature weighting: perform a channel-by-channel point multiplication operation on the original feature map and the calculated weight to obtain a weighted feature map;

[0022] S3.6. Finally, the weighted feature map is reshaped and fused to restore it to the same dimension as the input image.

[0023] Preferably, step S6 specifically includes the following steps:

[0024] S6.1. Calculate the coordinates (x1, y1) and (x2, y2) of the intersections of the rectangular frame of the person and the rectangular frame of the farm implement on the x-axis and y-axis;

[0025] S6.2. Calculate the intersection area between the rectangular frame of the person and the rectangular frame of the farm implement. If the intersection does not exist, the intersection area is 0.

[0026] S6.3. Calculate the area of ​​the rectangular frame of the person and the rectangular frame of the farm implement;

[0027] S6.4. Calculate the intersection over union (IoU), that is, the ratio of the intersection area to the union area. If it is greater than 0, it is determined that the person and the farm tool overlap, and then the farming behavior is recorded.

[0028] Preferably, after collecting the paddy field behavior data in step S1, a structural similarity algorithm is required to be processed. The calculation formula of the structural similarity algorithm is as follows:

[0029]

[0030] Where: SSIM(x,y) refers to the similarity between images x and y, μ x The average pixel value of the real image x, μ y refers to the pixel average of image y, σ x refers to the pixel standard deviation of image x, σ y refers to the pixel standard deviation of image y, σ xy It refers to the pixel covariance of images x and y, and C1 and C2 are arbitrary constants.

[0031] Preferably, after the structural similarity algorithm is processed, a peak signal-to-noise ratio algorithm is also required to be processed. The calculation formula of the peak signal-to-noise ratio algorithm is as follows:

[0032]

[0033]

[0034] Where: MSE refers to the mean square error, mn refers to the original image of size m×n, K refers to the image after adding noise, I(i,j) refers to the real image, K(i,j) refers to the image to be evaluated, MAX I Refers to the maximum pixel value of the image.

[0035] Compared with the prior art, the present invention has the following advantages: the present invention adds a global attention mechanism to the YOLOv8 deep learning target detection network structure, enhances the network's attention to small-scale feature information, adds a small-scale target detection layer, improves the network's ability to extract small-scale feature information, and comprehensively improves the small-scale target detection capability of the target detection model. In addition, the present invention proposes a secondary determination network for position feature relationships based on the IoU threshold, which improves the network's ability to identify similar agricultural behaviors.

[0036] The structural similarity algorithm and the peak signal-to-noise ratio algorithm are used to preprocess the image. In this way, the structural similarity algorithm can simulate the subjective judgment of the human eye, and then the objective quantification of the peak signal-to-noise ratio algorithm can be combined to evaluate the similarity, while removing low-quality image data. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 It is a flowchart of a method for identifying and warning paddy field farming behaviors according to the present invention.

[0038] Figure 2 This is the original YOLOv8 network structure diagram.

[0039] Figure 3 This is the improved YOLOv8 network structure diagram.

[0040] Figure 4 Schematic diagram with agricultural machinery labeled.

[0041] Figure 5 It is a schematic diagram of the symbols of people and farm tools.

[0042] Figure 6 It is a schematic diagram of agricultural machinery identification.

[0043] Figure 7 This is a schematic diagram of the identification of people and farm tools. DETAILED DESCRIPTION

[0044] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.

[0045] Embodiment 1:

[0046] A method for identifying and warning rice field farming behaviors, such as Figure 1 As shown, it includes the following steps:

[0047] S1, collect rice field behavior data;

[0048] Since the camera is fixed in position, the valid behavior data only appears in the video for a short time. In order to ensure that key information is not lost, the video data containing the target behavior is first screened out, and then processed through video editing software (VideoStudio X10). Only the video clips containing the target behavior are retained. Using video segmentation technology, a total of 84,524 image data are obtained by taking an image at 25 frames. Due to the large amount of initial data, automatic data processing is achieved by defining python code. The initial data is not reduced by spacing more frames because the camera is fixed and the valid data does not stay in the picture for a long time. If the number of frame intervals is large, a lot of key information will be lost. The automated processing first simulates the subjective judgment of the human eye through the structural similarity (SSIM) algorithm, and then combines the objective quantification of the peak signal-to-noise ratio (PSNR) algorithm to evaluate the similarity and remove low-quality image data.

[0049] Structural Similarity (SSIM) algorithm, the calculation formula is:

[0050]

[0051] Where: SSIM(x,y)——Similarity index between images x and y, μ x ——The average pixel value of image x, μ y ——The average pixel value of image y, σ x ——Pixel standard deviation of image x, σ y ——Pixel standard deviation of image y, σ xy ——pixel covariance of images x and y, C1, C2——arbitrary constants;

[0052] Peak Signal-to-Noise Ratio (PSNR) algorithm, the calculation formula is:

[0053]

[0054]

[0055] Where: MSE - mean square error, mn - the original image of size m×n, K - the image after adding noise, I(i,j) - the real image, K(i,j) - the image to be evaluated, MAX I ——The maximum pixel value of the image;

[0056] The specific method includes the following steps:

[0057] S1.1, Image reading: Use OpenCV library to read image files;

[0058] S1.2, Image preprocessing: Ensure that the two compared images have the same size and number of channels;

[0059] S1.3. Similarity evaluation: Use the structural similarity function in the skimage.metrics library to calculate;

[0060] S1.4, structural similarity algorithm: calculates the structural information and local contrast of the image to measure the visual similarity between two images;

[0061] S1.5, Peak signal-to-noise ratio algorithm: Use the pcak signal noise ratio function in the skimage.mctrics library to calculate and evaluate the quality difference between the reconstructed image and the original image, and quantify it by calculating the root mean square of the pixel error;

[0062] S1.6, threshold judgment: judge the image similarity and image quality according to the values ​​of SSIM and PSNR;

[0063] S1.7, Exception handling: Add some error handling, such as when the file does not exist or the image size does not match;

[0064] S1.8, file migration: migrate the eliminated images to the backup folder according to the results;

[0065] S1.9. User interaction: Use cv2.waitKcy to visualize the comparison results and decide whether to continue.

[0066] S2. Use annotation software to annotate behavioral data, such as Figure 4 and Figure 5 As shown, it includes:

[0067] S2.1. Label the agricultural machinery with its largest circumscribed rectangle, and the label information is the agricultural activity corresponding to the agricultural machinery;

[0068] S2.2, labeling with the largest circumscribed rectangle of a person, with label information of person;

[0069] S2.3, label the largest circumscribed rectangle of the agricultural tools used in manual farming activities, and the label information is the name of the corresponding agricultural tool;

[0070] S3, based on the original deep learning target detection network of YOLOv8, it improves on this by adding a small target detection layer and an attention mechanism;

[0071] like Figure 2This is the original YOLOv8 network structure diagram. YOLOv8 is a lightweight target detection algorithm that can simultaneously take into account recognition accuracy and detection speed for multi-scale target detection. The network structure of YOLOv8 is mainly composed of the following four parts:

[0072] 1) Input: It consists of mosaic data enhancement, adaptive anchor box calculation, and adaptive grayscale filling;

[0073] 2) Backbone network: It consists of Conv, C2f and SPPF structures. The C2f module refers to the design ideas of the C3 module of YOLOv5 and the ELAN

[15] module of YOLOv7. It adds more branches to obtain richer gradient flow information.

[0074] 3) Neck network: It adopts the PAN (Path Aggregation Network) structure

[16] . The main advantage of the PAN structure is that it can effectively utilize feature information of different scales to achieve efficient feature fusion, thereby improving the performance of target detection tasks;

[0075] 4) Head network: The decoupled head structure is adopted to reduce the number of parameters and computational complexity, while enhancing the generalization ability and robustness of the model. The loss function is calculated using the Task-AlignedAssigner positive sample assignment strategy

[17] , the bounding box regression loss uses the CIOU (Complete Intersection Over Union) loss function and DistributionFocal Loss

[18] , and the category classification loss uses BCE Loss;

[0076] Since the actual working scene in the field is large, and due to the limitations of actual application costs and application environment, network cameras are not deployed in large numbers in farmland. As a result, in actual applications, most of the data obtained by network cameras are small-sized targets. In order to enhance the model's small target detection capabilities, the existing YOLOv8 network structure is improved to make the model more in line with actual application needs.

[0077] Therefore, in order to increase the detection layer, the YOLOv8 network downsampling multiple is large, and two 3×3 convolution kernels are used continuously for convolution operations. Although higher-level semantic features can be extracted, it also makes it difficult to effectively represent the features of smaller targets during the downsampling process. In order to improve the detection performance of the established YOLOv8 model on small-sized targets, on the basis of the original network structure, the network's receptive field is increased by adding a detection layer, and the network's attention to the feature information of small-sized targets is enhanced, thereby improving the detection ability of small-sized targets.

[0078] The improved network adds a 160×160 detection layer that was not fused in the original feature extraction process. In the feature fusion process, the upsampling is increased once to splice the shallower feature information with the deeper feature information, and more feature information of small-sized targets is retained. The improved network structure is as follows: Figure 3 As shown;

[0079] Attention Mechanism plays an important role in deep learning. It can help the model pay weighted attention to the key information of the input data, thereby improving the performance and effect of the model. By applying attention weights to different image areas, the model can better understand the contextual information of the image.

[0080] The Global Attention Mechanism (GAM) is a commonly used attention mechanism in target detection models. It helps the model understand global contextual information by paying weighted attention to the input feature pixel area. Adding a GAM module in the feature fusion stage can weightedly fuse features of different levels, allowing the model to pay attention to both low-level and high-level features, thereby improving the model's ability to detect targets of different scales. By adding a GAM module before the pooling layer (SPPF), the resolution of the region of interest can be improved;

[0081] GAM adds weight to the input feature map through the following process:

[0082] 1) Input and feature extraction: Input feature image, with N channels, L length and W width, can be regarded as a two-dimensional feature matrix on N channels after feature extraction;

[0083] 2) Global average pooling: Perform global average pooling on the feature map, and average pool the features on each channel according to the spatial dimension (L, W), so as to obtain a scalar value on each channel as the feature of the entire channel;

[0084] 3) Scaling and activation: The result of global average pooling is scaled and operated with nonlinear activation function;

[0085] 4) Weight calculation: The scaled and activated features are weighted to obtain the weight vectors on N channels, which are used to indicate the global importance of each channel.

[0086] 5) Feature weighting: Perform a channel-by-channel point multiplication operation on the original feature map and the calculated weight to obtain a weighted feature map;

[0087] 6) Finally, the weighted feature map is reshaped and fused to restore it to the same dimension as the input image;

[0088] By introducing the global attention mechanism on the basis of adding the target detection layer to the network structure, the new network structure is more adaptable to the needs of the research task in this paper. The network with the added target detection layer and the global attention mechanism is named YOLOV8-GS, and its network structure is as follows:

[0089] (1) Input: Mosaic data enhancement, which enriches the diversity of training data by splicing four pictures, helps model generalization; adaptive anchor box calculation, which can automatically adjust the size and proportion of the anchor box according to the characteristics of the data set to improve detection accuracy; adaptive grayscale filling, which can avoid edge information loss caused by image size changes;

[0090] (2) Backbone network: GAM_Attention enables the model to focus on the more important parts of the input. Conv and C2f, convolution and feature fusion operations, are used to extract and integrate features; SPPF (Spatial Pyramid Pooling-Fast) performs spatial pyramid pooling operations on feature maps to capture feature information of different scales;

[0091] (3) Neck network: PAN structure, multi-scale feature fusion through feature pyramid network;

[0092] (4) Head network: decouples the head structure to decouple the prediction of different tasks (such as positioning, classification, etc.);

[0093] (5) Loss function: Task-AlignedAssigner positive sample assignment strategy, bounding box regression loss uses CIOU loss function and Distribution Focal Loss, and category classification loss uses BCE Loss;

[0094] S4, target detection network training, obtaining the trained model;

[0095] S5, loading the video stream of the rice field, using the model trained in step S4 to perform target detection, and when agricultural machinery is detected, directly record the agricultural behavior, and then jump to step S7; if a person is detected, jump to the next step;

[0096] S6, determining whether the maximum circumscribed rectangle of the person and the farm implement overlaps, if so, determining that the person is operating the corresponding farm implement to perform farming activities, then recording the farming activities and jumping to the next step; if not, returning to step S5 to continue detection;

[0097] Determining whether the maximum bounding rectangles overlap includes the following steps, the first of which is:

[0098] S6.1: The coordinates of the bounding box are in the format of x1, y1, x2, y2 (boxes = frame_result.boxes.xyxy) frame_result.boxes is an object containing the bounding boxes of all detected target objects. The xyxy attribute represents the coordinates of these bounding boxes. Each bounding box consists of four values: (x1, y1, x2, y2), where (x1, y1) is the coordinate of the upper left corner of the bounding box, and (x2, y2) is the coordinate of the lower right corner of the bounding box.

[0099] S6.2: Get the class label list through classes = frame_result.boxes.cls. frame_result.boxes.cls is a list of integers, where each integer corresponds to the class label of a bounding box. These labels are usually assigned according to the class index of the training data set. For example, if a value in classes is 0, it may represent the category of "person"; if it is 1, it may represent "pesticide application tool"; if it is 2, it may represent "fertilizer application tool", etc., which is done by manually assigning labels to 0, 1, 2, 3, 4.

[0100] S6.3: By using NumPy's Boolean indexing function, the code filters out bounding boxes of specific categories according to the values ​​in the classes list. For example, boxes[classes==0] returns the coordinates of all bounding boxes with a label of 0 (i.e., the "person" category), which is represented by person_boxes=boxes[classes==0]; returns all bounding boxes with a label of 1 (i.e., the "patools" category), where patools represents a pesticide application tool, which is represented by pa_tools_boxes=boxes[classes==1]; if all bounding boxes with a label of 2 (i.e., the "fa tools" category) are returned, fa tools represents a fertilizer application tool, which is represented by fa_tools_boxes=boxes[classes==2];

[0101] S6.4: Input the bounding box coordinate information of “person” and “farm tool” into the position feature judgment network respectively;

[0102] S6.5: Determine whether the IoU is greater than 0. If it is not greater than 0, no operation is performed, that is, the ratio of the intersection and union of the target frames of "person" and "farm tool" is greater than 0, that is, the position feature relationship of the two target frames has interacted;

[0103] S6.6: If IoU>0, the preset farming behavior is output and recorded, and the result is saved in the form of picture (.jpg) plus text (.txt);

[0104] For example, if the bounding box IoU of "person" and "fertilizer spreading tool" is greater than 0, output "fertilization behavior" and record it, save the image where the behavior is detected, and record the behavior type and the location and time of occurrence in text form with the same name.

[0105] Among them, the calculation of IoU is mainly as follows:

[0106] By defining a function box_overlap, the overlap between two bounding boxes is calculated, namely the Intersection over Union (IoU). IoU is a commonly used indicator in computer vision tasks such as target detection and image segmentation, which is used to evaluate the overlap between the predicted bounding box and the real bounding box.

[0107] The overlapping area of ​​the two target frames is the intersection of target frame A and target frame B, and its calculation formula is:

[0108] IoU = (A∩B) / (A∪B)

[0109] The calculation formula for the union of target box A and target box B is:

[0110] A∪B=A+BA∩B

[0111] The function parameters box1 and box2 are both lists or tuples containing four elements, representing the coordinates of the rectangular box. These four elements are arranged in the order of [xmin, ymin, xmax, ymax], where (xmin, ymin) is the coordinate of the upper left corner of the rectangular box, and (xmax, ymax) is the coordinate of the lower right corner. Therefore, the upper left corner coordinates and lower right corner coordinates of target box A and target box B can be defined as [(xmin_A, ymin_A), (xmax_A, ymax_A)], [(xmin_B, ymin_B), (xmax_B, ymax_B)], then the calculation formula for the rectangle of the intersection of target box A and target box B is:

[0112] xmin_AB=max(xmin_A, xmin_B)

[0113] ymin_AB=max(ymin_A, ymin_B)

[0114] xmax_AB=min(xmax_A, xmax_B)

[0115] ymax_AB=min(ymax_A, ymax_B)

[0116] The calculation formulas for the intersection and union of target box A and target box B are:

[0117] A∩B=(xmax_AB-xmin_AB)×(ymax_AB-ymin_AB)

[0118] XW_A=xmax_A-xmin_A

[0119] XH_A=ymax_A-ymin_A

[0120] XW_B=xmax_B-xmin_B

[0121] XH_B=xmax_B-xmin_B

[0122] A∪B=W_A×H_A+W_B×H_B-A∩B

[0123] Where W_A and H_A represent the width and height of target box A, W_B and H_B represent the width and height of target box B. The corresponding calculation process inside the Python function is as follows:

[0124] (1) Calculate the coordinates of the intersection of the two rectangular boxes on the x-axis and y-axis (x1, y1) and (x2, y2). Use the max and min functions to ensure the validity of the intersection coordinates;

[0125] (2) Calculate the area of ​​the intersection of the two rectangular boxes (intersection_area). If the intersection does not exist (i.e., x2≤x1 or y2≤y1), the intersection area is 0;

[0126] (3) Calculate the area of ​​each of the two rectangular boxes (box1_area and box2_area);

[0127] (4) Calculate IoU, which is the ratio of the intersection area to the union area;

[0128] (5) The function calculates the IoU value and returns a Boolean value, indicating whether the IoU is greater than 0. This Boolean value can be adjusted according to the task requirements. ;

[0129] (6) If the IoU is greater than 0, it is determined that the person and the tool used overlap, and the behavior that occurred is output and recorded.

[0130] S7. Compare the recorded agricultural activities with the preset agricultural correction activities. Both the recorded agricultural activities and the preset agricultural correction activities include time, address and specific activities. If all three overlap, an alarm will be issued. For example, the preset pesticide rest period for rice field A is from T1 to T2. If the recorded rice pesticide application behavior occurs in rice field A, in the interval of T1-T2, an alarm for illegal rice field pesticide application will be issued.

[0131] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

[0132] Various changes and modifications will undoubtedly be apparent to those skilled in the art after reading the above description. Therefore, the appended claims should be regarded as covering all changes and modifications to the true intent and scope of the present invention. Any and all equivalent ranges and contents within the scope of the claims should be considered to still be within the intent and scope of the present invention.

Claims

1. A method for identifying and warning paddy field farming behaviors, characterized in that: It includes the following steps: S1, collect rice field behavior data; S2. Use annotation software to annotate behavioral data, including: S2.

1. Label the agricultural machinery with its largest circumscribed rectangle, and the label information is the agricultural activity corresponding to the agricultural machinery; S2.2, labeling with the largest circumscribed rectangle of a person, with label information of person; S2.3, label the largest circumscribed rectangle of the agricultural tools used in manual farming activities, and the label information is the name of the corresponding agricultural tool; S3, based on the original deep learning target detection network of YOLOv8, it improves on this by adding a small target detection layer and an attention mechanism; S4, target detection network training, obtaining the trained model; S5, loading the video stream of the rice field, using the model trained in step S4 to perform target detection, and when agricultural machinery is detected, directly record the agricultural behavior, and then jump to step S7; if a person is detected, jump to the next step; S6, determining whether the maximum circumscribed rectangle of the person and the farm implement overlaps, if so, determining that the person is operating the corresponding farm implement to perform farming activities, then recording the farming activities and jumping to the next step; if not, returning to step S5 to continue detection; S7. Compare the recorded farming behavior with the preset farming correction behavior. Both the recorded farming behavior and the preset farming correction behavior include time, address and specific behavior. If all three overlap, an alarm is issued.

2. A method for identifying and warning paddy field farming behaviors according to claim 1, characterized in that: Adding a small target detection layer in step S3 specifically includes adding a feature image layer with a resolution of 160×160 that is not used by the original target detection network, and adding an upsampling operation to effectively splice the feature information with the deep feature information.

3. The method for identifying and warning paddy field farming behaviors according to claim 1, characterized in that: Adding the attention mechanism in step 3 specifically includes adding a global attention mechanism before the pooling layer, and the workflow of the global attention mechanism includes the following steps: S3.

1. Input and feature extraction: Input feature image, with N channels, L length and W width, can be regarded as a two-dimensional feature matrix on N channels after feature extraction; S3.2, global average pooling: perform global average pooling on the feature map, average pooling the features on each channel according to the spatial dimension, so as to obtain a scalar value on each channel as the feature of the entire channel; S3.3, Scaling and Activation: The result of global average pooling is scaled and operated with a nonlinear activation function; S3.4, weight calculation: weight calculation is performed on the scaled and activated features to obtain the weight vectors on N channels, which are used to indicate the global importance of each channel; S3.5, feature weighting: perform a channel-by-channel point multiplication operation on the original feature map and the calculated weight to obtain a weighted feature map; S3.

6. Finally, the weighted feature map is reshaped and fused to restore it to the same dimension as the input image.

4. The method for identifying and warning paddy field farming behaviors according to claim 1, characterized in that: Step S6 specifically includes the following steps: S6.

1. Calculate the coordinates (x1, y1) and (x2, y2) of the intersections of the rectangular frame of the person and the rectangular frame of the farm implement on the x-axis and y-axis; S6.

2. Calculate the intersection area between the rectangular frame of the person and the rectangular frame of the farm implement. If the intersection does not exist, the intersection area is 0. S6.

3. Calculate the area of ​​the rectangular frame of the person and the rectangular frame of the farm implement; S6.

4. Calculate the intersection over union (IoU), that is, the ratio of the intersection area to the union area. If it is greater than 0, it is determined that the person and the farm tool overlap, and then the farming behavior is recorded.

5. The method for identifying and warning paddy field farming behaviors according to claim 1, characterized in that: After the paddy field behavior data is collected in step S1, it is necessary to perform structural similarity algorithm processing. The calculation formula of the structural similarity algorithm is as follows: Where: SSIM(x,y) refers to the similarity between images x and y, μ x The average pixel value of the real image x, μ y refers to the pixel average of image y, σ x refers to the pixel standard deviation of image x, σ y refers to the pixel standard deviation of image y, σ xy It refers to the pixel covariance of images x and y, and C1 and C2 are arbitrary constants.

6. A method for identifying and warning paddy field farming behaviors according to claim 5, characterized in that: After the structural similarity algorithm is processed, the peak signal-to-noise ratio algorithm needs to be processed. The calculation formula of the peak signal-to-noise ratio algorithm PSNR is as follows: Where: MSE refers to the mean square error, mn refers to the original image of size m×n, K refers to the image after adding noise, I(i,j) refers to the real image, K(i,j) refers to the image to be evaluated, MAX I Refers to the maximum pixel value of the image.

Citation Information

Patent Citations

  • Farming behavior supervision method

    CN111242007A

  • System for automatically identifying illegal ladder use behaviors in construction

    CN112131951A

  • Method for automatic identification and intelligent matching of tillage and soil preparation agricultural implements in unmanned farm

    CN114037846A

  • Farming scene-based behavior analysis method and server

    CN115294651A

  • Farming behavior detection method and device, electronic equipment and storage medium

    CN115880558A