Method and system for detecting plant leaf diseases and insect pests
By calibrating the binocular vision system and improving the YOLOv8-seg algorithm, the problems of the accuracy and efficiency of traditional pest and disease evaluation methods are solved, and efficient and accurate detection and positioning of plant leaf pests and diseases are achieved, providing technical support for smart agriculture.
Patent Information
- Application Number
- CN202411757844.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-04
AI Technical Summary
Traditional plant leaf pest and disease assessment methods have problems of low detection efficiency, poor accuracy and reliability, especially in large-scale farms, which are difficult to meet the needs of rapid response.
The calibrated binocular vision system is used to collect pest images of plant leaves, and the image segmentation is performed using the improved YOLOv8-seg algorithm. The overlapping area of the left mask and the right mask is calculated as the final area of the pest and disease, and the degree of pest and disease is then calculated. At the same time, three-dimensional correction is performed to calculate three-dimensional coordinates to locate pests and diseases.
It has achieved accurate segmentation and positioning of plant leaf pest and disease areas, improved evaluation efficiency and accuracy, reduced manpower investment, reduced costs, and provided technical support for smart agriculture.
Smart Images

Figure CN119559155A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method and system for detecting plant leaf diseases and insect pests, and relates to the fields of smart agriculture and image processing. Background Art
[0002] In the agricultural field, accurate assessment and location of plant leaf pests and diseases have become an important part of ensuring the healthy growth of crops and improving yield and quality. Traditional pest and disease assessment mainly relies on manual inspections and the rich experience of experts. However, there are many limitations to traditional pest and disease assessment. First, it is extremely dependent on human resources, resulting in low detection efficiency and failure to meet the rapid response needs of large-scale farms. Second, manual detection is easily affected by subjective factors such as light, angle, experience and fatigue of the inspector. All of the above factors will affect the accuracy and reliability of pest and disease assessment.
[0003] Given the challenges of traditional pest and disease assessment methods, the development of an efficient and accurate plant leaf pest and disease assessment method has become an urgent need in the agricultural field. Summary of the invention
[0004] The present disclosure provides a plant leaf pest detection method and system, which at least to a certain extent overcomes the problem of poor accuracy and reliability in plant leaf assessment in the related art.
[0005] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0006] According to one aspect of the present disclosure, the present disclosure provides a method for detecting plant leaf diseases and insect pests, comprising the following steps:
[0007] S1: Calibrate the binocular vision system;
[0008] S2: using the calibrated binocular vision system to collect plant leaf disease and insect pest images;
[0009] S3: Use the improved YOLOv8-seg to segment the initial area of the plant leaf pest image to obtain the left mask M L , right mask M R and whole plant leaves M all ;
[0010] S4: Calculate the left mask M L and the right mask M R The overlapping area M overlap As the final area of pests and diseases;
[0011] S5: Calculate the final area of the pests and diseases as a percentage of the total plant leaves M all The percentage of is taken as the degree of plant leaf pests and diseases;
[0012] S6: Obtain the left mask M respectively L and the right mask M R The geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R );
[0013] S7: Set the left mask M L and the right mask M R Perform stereo correction;
[0014] S8: Calculate the left mask M after stereo correction L and right mask M R The corresponding three-dimensional coordinates.
[0015] In one embodiment of the present disclosure, the calibrated binocular vision system of S1 includes:
[0016] An 8×8 rectangular chessboard calibration plate is printed on paper, where the size of each chessboard is a 14×14 mm square. The chessboard is placed within the effective measurement range of the camera of the binocular vision system, and multiple groups of clear corner point images are captured at different positions and directions. The chessboard corner points in the clear corner point images are automatically extracted using the Stereo Camera Calibrator toolbox of MATLAB, and the internal parameters of the camera are solved by calculation. The internal parameters of the camera include at least one of the focal length of the camera, the principal point offset, and the distortion parameters.
[0017] In one embodiment of the present disclosure, in S2, plant leaves are placed in the field of view of the binocular vision system, and are photographed simultaneously using the binocular camera of the binocular vision system to obtain the plant leaf disease and insect pest image, and the plant leaf disease and insect pest image is an RGB true color image.
[0018] In one embodiment of the present disclosure, in S3, the improved YOLOv8-seg includes: backbone network improvement, neck improvement and loss function improvement;
[0019] Among them, the backbone network improvements include: replacing the YOLOv8-seg backbone network with the lightweight Ghostnetv2;
[0020] The neck improvements include: introducing the CBAM module in the neck. CBAM consists of channel attention and spatial attention. The channel attention module is used to enhance the feature representation of different channels, and the spatial attention module is used to extract key information at different positions in the space.
[0021] The loss function improvements include: replacing the original YOLOv8-seg border loss function CioU with the MPDIoU loss function.
[0022] In one embodiment of the present disclosure, in S4, the left mask M is calculated using formula (3): L and the right mask M R The overlapping area M overlap The formula is:
[0023]
[0024] M overlap (x,y)=M L (i,j)×M R (i,j) (3)
[0025] Where x and y are pixel coordinates, M L (i,j) and M R (i,j) are the left mask M respectively L and right mask M R The value at (i,j).
[0026] In one embodiment of the present disclosure, in S5, the calculation of the degree of pests and diseases includes: counting the pest and disease areas M overlap The number of non-zero pixels in the table; the total area of plant leaves M all The number of non-zero pixels in the graph; the degree of plant leaf pests and diseases W is calculated as formula (4):
[0027]
[0028] Among them, H overlap The pest area M overlap The number of non-zero pixels in H all is the total leaf area of the plant M all The number of non-zero pixels in .
[0029] In one embodiment of the present disclosure, in S6, the left mask M L and right mask M R Geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R ) is calculated as in equations (5) and (6):
[0030]
[0031] Among them, m 10 is the first-order moment along the x-axis, as shown in equation (7); m01 is the first-order moment along the y-axis, as shown in equation (8); m 00 is the zero-order moment, as shown in equation (9).
[0032]
[0033] Where x and y are the coordinates of the pixel; (x,y) is the pixel value of the plant leaf pest image at the coordinate (x, y).
[0034] In one embodiment of the present disclosure, in S7, the left mask M L and right mask M R The stereo correction includes: using an undistort() function to perform an undistortion process on the left mask image and the right mask image; and using a stereoRectify() function to perform an epipolar correction on the distorted image.
[0035] In one embodiment of the present disclosure, in S8, the left mask M after stereo correction is calculated. L and right mask M R The center coordinate P L (X L ,Y L ) and P R (X R ,Y R ) to calculate the three-dimensional coordinates (X, Y, Z);
[0036] Assume that the imaging points of P on the two camera image planes are P L and P R , the distance between two imaging points is calculated as (10):
[0037]
[0038] Where T is the distance between the optical centers of the left and right cameras; x l and x r are the distances from the left and right camera image points to the left and right imaging surfaces respectively; L is the size of the imaging surface;
[0039] According to the triangle similarity theory, we get formula (11):
[0040]
[0041] The distance from the three-dimensional space point P to the projection center plane can be obtained as formula (12):
[0042]
[0043] Similarly, select P L or P RIt can be calculated that the X and Y coordinates of point P in three-dimensional space are (13) and (14) respectively:
[0044]
[0045] Finally, we get the three-dimensional world coordinates (X, Y, Z).
[0046] In another aspect of the present disclosure, a plant leaf pest detection system is provided, including a binocular vision system and a processor, wherein the calibrated binocular vision system is used to collect plant leaf pest images; the processor is used to segment the initial pest area in the plant leaf pest image using an improved YOLOv8-seg to obtain a left mask M L , right mask M R and whole plant leaves M all ; Calculate the left mask M L and the right mask M R The overlapping area M overlap As the final area of pests and diseases; Calculate the final area of pests and diseases as the proportion of the whole plant leaf M all The percentage of the left mask M is used as the degree of plant leaf pests and diseases; L and the right mask M R The geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R );The left mask M L and the right mask M R Perform stereo correction; calculate the left mask M after stereo correction L and right mask M R The corresponding three-dimensional coordinates.
[0047] Beneficial effects of the present disclosure:
[0048] (1) The plant leaf pest detection method disclosed in the present invention uses a calibrated camera to collect plant leaf pest images; then uses the improved YOLOv8-seg algorithm to perform image segmentation to obtain a left mask, a right mask and an entire plant leaf mask; calculates the overlapping area of the left mask and the right mask as the final pest area, and then calculates the degree of plant leaf pests; performs stereo correction on the left mask and the right mask, and calculates the three-dimensional coordinates after stereo correction to solve the problem of pest degree estimation and positioning.
[0049] (2) Compared with manual methods, the present invention can segment and locate the pest and disease areas of plant leaves, and use deep learning algorithms for image segmentation, which can accurately identify the pest and disease areas, avoid the subjective errors of manual judgment, and ensure the accuracy and consistency of the results; it can quickly process plant leaf images, realize real-time monitoring and rapid response to pest and disease conditions, and take corresponding prevention and control measures in time; by calculating the three-dimensional coordinates after stereo correction, it provides technical support for agricultural mechanization operations. The plant leaf pest and disease detection method has the advantages of automation, high efficiency, and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for describing the embodiments are briefly introduced below.
[0051] Figure 1 A flow chart of a method for detecting plant leaf diseases and insect pests provided by an embodiment of the present disclosure is shown.
[0052] Figure 2 A schematic diagram of the basic module structure of the GhostNetV2 network provided in an embodiment of the present disclosure is shown.
[0053] Figure 3 A schematic diagram of the structure of the CBAM attention module provided in an embodiment of the present disclosure is shown.
[0054] Figure 4 A schematic diagram of the structure of an improved YOLOv8-seg network provided in an embodiment of the present disclosure is shown.
[0055] Figure 5 A schematic diagram showing the principle of calculating three-dimensional coordinates using a left-hand mask and a right-hand mask provided by an embodiment of the present disclosure.
[0056] Figure 6 The present invention is a flowchart illustrating an example of a method for detecting plant leaf diseases and insect pests. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0058] Figure 1 A flow chart of a method for detecting plant leaf pests and diseases provided by an embodiment of the present disclosure is shown. Figure 1 As shown, the present disclosure provides a method for detecting plant leaf diseases and insect pests, which mainly includes the following steps:
[0059] S1: Calibrate the binocular vision system;
[0060] S2: Use the calibrated binocular vision system to collect plant leaf pest images;
[0061] S3: Improve YOLOv8-seg to segment the plant leaf pest image to obtain the left mask M L , right mask M R and whole plant leaves M all ;
[0062] S4: Calculate the left mask M L and right mask M R The overlapping area M overlap As the final area of pests and diseases;
[0063] S5: Calculate the final area of pests and diseases as a percentage of the entire plant leaf M all The percentage of is taken as the degree of plant leaf pests and diseases;
[0064] S6: Get the left mask M respectively L and right mask M R The geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R );
[0065] S7: Set the left mask M L and right mask M R Perform stereo correction;
[0066] S8: Calculate the left mask M after stereo correction L and right mask M R The corresponding three-dimensional coordinates.
[0067] This paper proposes a plant leaf pest detection method, which combines the advantages of modern computer vision and artificial intelligence technology, and realizes the degree assessment and precise positioning of plant leaf pest areas through accurate binocular vision system calibration and efficient image segmentation algorithm. This method can not only significantly improve the evaluation efficiency and accuracy, but also reduce manpower input and costs, and provide convenience for smart agricultural pest diagnosis and agricultural mechanization operations.
[0068] The implementation of this disclosure will effectively promote the development of smart agriculture. Through accurate assessment and positioning of pest and disease areas, agricultural producers can formulate prevention and control measures more accurately, improve crop yields and quality, reduce economic losses, and promote the sustainable development of agriculture.
[0069] The accuracy of binocular vision system calibration is crucial to the accuracy of positioning and measurement. If the calibration is inaccurate, the system will not be able to accurately calculate the location of the pest area in three-dimensional space, resulting in positioning and measurement errors.
[0070] In one embodiment, the calibration step of the above-mentioned S1 binocular vision system includes: printing an 8×8 rectangular checkerboard calibration plate on paper, where the size of each checkerboard is a 14×14 mm square. The checkerboard is placed within the effective measurement range of the camera, and multiple sets of clear corner point images are taken at different positions and directions. The checkerboard corner points in the image are automatically extracted using the Stereo Camera Calibrator toolbox of MATLAB, and the internal parameters of the camera are solved by calculation: the focal length of the camera, the principal point offset, and the distortion parameters.
[0071] The checkerboard calibration plate includes a rectangular checkerboard with 8 rows and 8 columns. The checkerboard is placed within the effective measurement range of the camera, which means that the checkerboard is located within the shooting range of the binocular camera in the binocular vision system. The binocular camera shoots different positions of the checkerboard, and shoots multiple groups of clear corner point images. The number of groups of corner point images can be determined according to actual needs, for example, 5 groups, 10 groups, 20 groups, etc., and the present disclosure does not make specific limitations on this.
[0072] The focal length of the camera determines the distance from the lens to the imaging sensor, affecting the magnification and viewing angle of the image. The principal point offset refers to the distance between the center point of the optical axis on the CCD and the center point of the camera, including the offset in the x and y directions, in pixels, which is used to correct the image distortion of the camera. The distortion parameter refers to the deviation between the pixel and the actual physical position caused by the physical reasons of the optical system during the imaging process of the camera, which needs to be corrected by distortion correction.
[0073] In some embodiments, the internal parameters of the camera may also include pixel size, aperture, etc.
[0074] In actual application, the plant leaves should be placed in the field of view of the binocular camera, and the pest and disease areas should be photographed simultaneously using the binocular camera. The higher the overlap of the image areas captured by the left and right cameras, the better the positioning accuracy.
[0075] In order to achieve lightweight deployment and high segmentation accuracy, the lightweight GhostNetV2 is used to replace the YOLOv8-seg backbone network, and CBAM attention is added to the neck to fuse features. Finally, the MPDIoU border loss function is used to speed up the convergence speed and improve the overall performance of the model. The specific improvements are as follows:
[0076] Backbone network improvement: Replace the YOLOv8-seg backbone network with the lightweight Ghostnetv2. GhostNetV2 module, such as Figure 2 By introducing asymmetric convolution in the channel dimension, the number of parameters and computation is effectively reduced, and a long-distance attention mechanism is introduced to enhance the performance of cheap operations.
[0077] Neck improvement: Introduce the CBAM module in the neck. CBAM consists of channel attention and spatial attention, such as Figure 3 As shown in Figure 1, the channel attention module helps to enhance the feature representation of different channels, and the spatial attention module helps to extract key information at different positions in the space.
[0078] Improved loss function: The original YOLOv8-seg border loss function CIoU is changed to MPDIoU loss function. MPDIoU calculates the similarity between the predicted rectangle and the real box based on the minimum point distance of the horizontal rectangle, which can more accurately reflect the matching degree between the predicted box and the real box and improve the accuracy of instance segmentation. In addition, the MPDIoU loss function takes into account the overlap between the predicted box and the real box, the center point distance, and the width and height deviation. After the above measures, the improved YOLOv8-seg network is obtained, such as Figure 4 .
[0079] The area of the final pest area after segmentation should be the left mask M L and right mask M R The intersection of , so we need to calculate the left mask M L and right mask M R The overlapping area M overlap . Left mask M L and right mask M R The formula (1) and formula (2) can be used.
[0080]
[0081] Where x and y are pixel coordinates respectively.
[0082] As shown in formula (1) and formula (2), when the pixel is diseased, the value of the mask at (x, y) is 1; in other cases (such as normal leaves or non-diseased areas), the value of the mask is 0.
[0083] Left Mask M L and right mask M R The overlapping area M overlap As shown in formula (3):
[0084] M overlap (x,y)=M L (i,j)×M R (i,j) (3)
[0085] Where x and y are pixel coordinates respectively.
[0086] As shown in formula (3), the value of the overlapping area at (x, y) is the product of the values of the left mask and the right mask at the corresponding position.
[0087] In order to characterize the degree of plant leaf pests and diseases, the percentage of the final pest and disease area to the entire plant leaf was calculated, and the pest and disease area M was counted. overlap The number of non-zero pixels in H overlap ; Count the total leaf area of plants M all The number of non-zero pixels in H all The degree of plant leaf pests and diseases W is calculated as formula (4):
[0088]
[0089] That is, the degree of plant leaf pests and diseases is the final area of pests and diseases M overlap The number of non-zero pixels in the whole plant leaf M all The ratio of the number of non-zero pixels in .
[0090] For the task of locating plant pests and diseases with binocular cameras, the traditional dense stereo matching method needs to calculate a large number of pixel disparities, which consumes a lot of computing resources, and agricultural equipment is difficult to meet the computing requirements. In the scene of plant pest and disease positioning, it is not necessary to obtain a dense disparity map of the entire scene. It is sufficient to calculate the three-dimensional coordinates of the pest and disease area by calculating the disparity of the geometric center points or several key feature points of the left mask and the right mask of the pest and disease area. L and right mask M R Geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R ) is calculated as in equations (5) and (6):
[0091]
[0092] Among them, m 10 is the first-order moment along the x-axis, as shown in formula (7); m 01 is the first-order moment along the y-axis, as shown in formula (8); m 00 is the zero-order moment, as shown in formula (9).
[0093]
[0094] In the above formula, x and y are the coordinates of the pixel; (x,y) It is the pixel value of the plant leaf pest image at the coordinate (x, y).
[0095] In one embodiment, the left mask M L and right mask MR To perform stereo rectification, use the undistort() function to undistort the left and right masked images, and then use the stereoRectify() function to perform epipolar rectification on the distorted images.
[0096] Calculate the left mask M after stereo correction L and right mask M R The center coordinate P L (X L ,Y L ) and P R (X R ,Y R ) and then calculate the three-dimensional world coordinates (X, Y, Z), such as Figure 5 Assume that the imaging points of P on the two camera image planes are P L and P R , Formula (10) is used to calculate the distance between two imaging points.
[0097]
[0098] Where T is the distance between the optical centers of the left and right cameras; x l and x r are the distances from the left and right camera image points to the left and right imaging surfaces respectively; L is the size of the imaging surface. According to the triangle similarity theory, we get formula (11):
[0099]
[0100] The distance from the three-dimensional space point P to the projection center plane can be obtained as formula (12):
[0101]
[0102] Similarly, the X and Y coordinates of point P in three-dimensional space are (13) and (14) respectively:
[0103]
[0104] Finally, the actual three-dimensional coordinates of P are obtained, and combined with the pest segmentation percentage, a method for estimating and locating the degree of plant leaf pests and diseases can be realized.
[0105] It should be noted that when calculating the 3D world coordinates of point P, you can choose the center coordinates P of the left mask. L , you can also choose the center coordinate P of the right mask R This disclosure does not make any specific limitation to this.
[0106] like Figure 6 As shown, the present disclosure provides a method for detecting plant leaf diseases and insect pests, comprising the following steps:
[0107] Binocular camera calibration;
[0108] The left camera is used to collect images, and the improved YOLOv8-seg segmentation pest and disease Mask is used to process the images collected by the left camera to obtain the left mask;
[0109] The right camera is used to collect images, and the improved YOLOv8-seg segmentation pest and disease Mask is used to process the images collected by the right camera to obtain the right mask;
[0110] Calculate the intersection of the left mask and the right mask as the final segmentation result;
[0111] Get the geometric center coordinates of two masks (i.e. left mask and right mask);
[0112] Perform stereo rectification on the left and right masks;
[0113] Calculate the three-dimensional coordinates of the corrected left mask and right mask;
[0114] The results of segmentation and positioning of plant leaf pests and diseases images are obtained based on three-dimensional coordinates. The positioning result refers to the position of the pests and diseases in the plant leaf pests and diseases images.
[0115] Example 2
[0116] The present disclosure also provides a plant leaf pest detection system, comprising: a binocular vision system and a processor, wherein the calibrated binocular vision system is used to collect plant leaf pest images; the processor is used to segment the initial pest area in the plant leaf pest image using an improved YOLOv8-seg to obtain a left mask M L , right mask M R and whole plant leaves M all ; Calculate the left mask M L and right mask M R The overlapping area M overlap As the final area of pests and diseases; calculate the final area of pests and diseases as a percentage of the total plant leaves M all The percentage of the left mask M is used as the degree of plant leaf pests and diseases; L and right mask M R The geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R ); the left mask M L and right mask M R Perform stereo correction; calculate the left mask M after stereo correction L and right mask MR The corresponding three-dimensional coordinates.
[0117] It should be noted that the specific implementation of the plant leaf pest detection system can refer to the specific implementation of the aforementioned plant leaf pest detection method, and the similarities will not be repeated here.
[0118] This paper proposes a plant leaf pest detection system, which combines the advantages of modern computer vision and artificial intelligence technology, and realizes the degree assessment and precise positioning of plant leaf pest areas through accurate binocular vision system calibration and efficient image segmentation algorithm. This method can not only significantly improve the evaluation efficiency and accuracy, but also reduce manpower input and costs, and provide convenience for smart agricultural pest diagnosis and agricultural mechanization operations.
[0119] The implementation of this disclosure will effectively promote the development of smart agriculture. Through accurate assessment and positioning of pest and disease areas, agricultural producers can formulate prevention and control measures more accurately, improve crop yields and quality, reduce economic losses, and promote the sustainable development of agriculture.
[0120] The preferred embodiments of the present disclosure disclosed above are only used to help explain the present disclosure. The preferred embodiments do not describe all the details in detail, nor do they limit the disclosure to only the specific implementation methods described.
Claims
1. A method for detecting plant leaf diseases and insect pests, characterized in that: The following steps are involved: S1: Calibrate the binocular vision system; S2: using the calibrated binocular vision system to collect plant leaf disease and insect pest images; S3: Use the improved YOLOv8-seg to segment the initial area of the plant leaf pest image to obtain the left mask M L , right mask M R and whole plant leaves M all ; S4: Calculate the left mask M L and the right mask M R The overlapping area M overlap As the final area of pests and diseases; S5: Calculate the final area of the pests and diseases as a percentage of the total plant leaves M all The percentage of is taken as the degree of plant leaf pests and diseases; S6: Obtain the left mask M respectively L and the right mask M R The geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R ); S7: Set the left mask M L and the right mask M R Perform stereo correction; S8: Calculate the left mask M after stereo correction L and right mask M R The corresponding three-dimensional coordinates.
2. The method according to claim 1, characterized in that The S1 calibrated binocular vision system comprises: An 8×8 rectangular chessboard calibration plate is printed on paper, where the size of each chessboard is a 14×14 mm square. The chessboard is placed within the effective measurement range of the camera of the binocular vision system, and multiple groups of clear corner point images are captured at different positions and directions. The chessboard corner points in the clear corner point images are automatically extracted using the Stereo Camera Calibrator toolbox of MATLAB, and the internal parameters of the camera are solved by calculation. The internal parameters of the camera include at least one of the focal length of the camera, the principal point offset, and the distortion parameters.
3. The method according to claim 1, characterized in that In S2, the plant leaves are placed in the field of view of the binocular vision system, and the binocular cameras of the binocular vision system are used to simultaneously photograph the plant leaf pests and diseases images to obtain the plant leaf pests and diseases images, and the plant leaf pests and diseases images are RGB true color images.
4. The method according to claim 1, characterized in that In S3, the improved YOLOv8-seg includes: backbone network improvement, neck improvement and loss function improvement; Among them, the backbone network improvements include: replacing the YOLOv8-seg backbone network with the lightweight Ghostnetv2; The neck improvements include: introducing the CBAM module in the neck. CBAM consists of channel attention and spatial attention. The channel attention module is used to enhance the feature representation of different channels, and the spatial attention module is used to extract key information at different positions in the space. The loss function improvements include: replacing the original YOLOv8-seg border loss function CioU with the MPDIoU loss function.
5. The method according to claim 1, characterized in that In S4, the left mask M is calculated using formula (3): L and the right mask M R The overlapping area M overlap The formula is: M overlap (x,y)=M L (i,j)×M R (i,j) (3) Where x and y are pixel coordinates, M L (i,j) and M R (i,j) are the left mask M respectively L and right mask M R The value at (i,j).
6. The method according to claim 1, characterized in that In S5, the calculation of the degree of plant leaf pests and diseases includes: counting the pest and disease areas M overlap The number of non-zero pixels in the table; the total area of plant leaves M all The number of non-zero pixels in the graph; the degree of plant leaf pests and diseases W is calculated as formula (4): Among them, H overlap The pest area M overlap The number of non-zero pixels in H all is the total leaf area of the plant M all The number of non-zero pixels in .
7. The method according to claim 1, characterized in that In S6, the left mask M L and right mask M R The geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R ) is calculated as in equations (5) and (6): Among them, m 10 is the first-order moment along the x-axis, as shown in equation (7); m01 is the first-order moment along the y-axis, as shown in equation (8); m 00 is the zero-order moment, as shown in formula (9): Where x and y are the coordinates of the pixel; (x,y) is the pixel value of the plant leaf pest image at the coordinate (x, y).
8. The method for detecting plant leaf diseases and insect pests according to claim 1, characterized in that: In S7, the left mask M L and right mask M R Stereo correction, including: Use the undistort() function to perform undistortion processing on the left mask and the right mask images; Use the stereoRectify() function to perform epipolar correction on the distorted image.
9. The method for detecting plant leaf diseases and insect pests according to claim 1, characterized in that: In S8, the left mask M after stereo correction is calculated L and right mask M R The center coordinate P L (X L ,Y L ) and P R (X R ,Y R ) to calculate the three-dimensional coordinates (X, Y, Z); Assume that the imaging points of P on the two camera image planes are P L and P R , the distance between two imaging points is calculated as (10): Where T is the distance between the optical centers of the left and right cameras; x l and x r are the distances from the left and right camera image points to the left and right imaging surfaces respectively; L is the size of the imaging surface; According to the triangle similarity theory, we get formula (11): The distance from the three-dimensional space point P to the projection center plane can be obtained as formula (12): Similarly, select P L or P R It can be calculated that the X and Y coordinates of point P in three-dimensional space are (13) and (14) respectively: Finally, we get the three-dimensional world coordinates (X, Y, Z).
10. A plant leaf pest detection system, characterized in that: It includes a binocular vision system and a processor, wherein: The calibrated binocular vision system is used to collect images of plant leaf diseases and insect pests; The processor is used to segment the initial area of the plant leaf pest image using the improved YOLOv8-seg to obtain a left mask M L , right mask M R and whole plant leaves M all ; Calculate the left mask M L and the right mask M R The overlapping area M overlap As the final area of pests and diseases; Calculate the final area of pests and diseases as the proportion of the whole plant leaf M all The percentage of the left mask M is used as the degree of plant leaf pests and diseases; L and the right mask M R The geometric center coordinates P L (X L ,Y L ) and P R (X R ,Y R );The left mask M L and the right mask M R Perform stereo correction; calculate the left mask M after stereo correction L and right mask M R The corresponding three-dimensional coordinates.
Citation Information
Cited By
Method for detecting targets in car elevator based on improved YOLOv8 algorithm
CN120375278A