A machine vision-based online monitoring system and method for real-time water consumption of vegetable crops

Through detailed processing of vegetable crop leaf images, combined with leaf area, saturation and environmental factors, the real-time water consumption of vegetable crops is calculated, which solves the problem that existing technology fails to fully consider multiple factors and improves the accuracy of monitoring. and cost-effectiveness.

CN118397030BActive Publication Date: 2024-10-22AI SHANGTIAN INTERNATIONAL AGRICULTURAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410562845.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-08
Publication Date
2024-10-22
Estimated Expiration
2044-05-08

AI Technical Summary

Technical Problem

The existing real-time water consumption monitoring method of vegetable crops based on machine vision fails to fully consider the various factors that affect the water demand of vegetable crops. It relies on the judgment of the fitting curve of daily coverage and crop coefficient, and its accuracy is limited.

Method used

Using image acquisition module, image segmentation module, edge extraction module, contour recognition module, color acquisition module and environment acquisition and processing module, the leaf area, average leaf saturation and environmental impact index of vegetable crops are obtained through image processing technology, and combined with crop coefficient calculation Real-time water consumption.

Benefits of technology

By processing leaf images of vegetable crops in detail to accurately monitor their water consumption, the vegetable crops themselves and environmental factors are taken into consideration, improving the accuracy and cost-effectiveness of monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118397030B_ABST
    Figure CN118397030B_ABST
Patent Text Reader

Abstract

The present invention provides a real-time online monitoring system and method for water consumption of vegetable crops based on machine vision, which relates to the technical field of plant growth monitoring. The system adopts image processing technology to calculate the surface area of ​​vegetable crop leaves in grayscale images, calculates the leaf saturation in HSV color space, calculates the water consumption of a single leaf through the leaf surface area and color saturation, and combines the ambient temperature, ambient humidity and light intensity collected by sensors, monitors and calculates the leaves of the entire plant, and generates the water consumption of the entire plant. The present invention uses the leaf water consumption to approximately replace the water consumption of the entire plant, reduces the monitoring cost while maintaining a high monitoring accuracy, and achieves the purpose of real-time regulation of the irrigation water volume of vegetable crops.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of plant growth monitoring, and in particular to a machine vision-based online monitoring system and method for real-time water consumption of vegetable crops. Background Art

[0002] Real-time monitoring of the water consumption of vegetable crops is of great significance to agricultural management and agricultural production. On the one hand, it can help agricultural managers manage the irrigation system more effectively, irrigate according to the actual water demand of vegetable crops, and avoid excessive irrigation and waste of water resources. On the other hand, it can keep vegetable crops growing under suitable water conditions, detect water stress of vegetable crops in time, and take measures to adjust and deal with them, so as to improve the yield and quality of vegetable crops.

[0003] In the prior art, publication number CN109712110B discloses a real-time crop water consumption monitoring method based on machine vision, including: acquiring crop images, performing background segmentation on the images using an adaptive step-size fruit fly algorithm, calculating crop coverage based on the segmented grayscale image, acquiring actual crop evapotranspiration based on a lysimeter, and calculating the crop coefficient value at any time based on the daily coverage obtained from the image data, and obtaining the real-time evapotranspiration of the crop in combination with the reference evapotranspiration at the corresponding time, thereby obtaining the corresponding amount of water required for irrigation.

[0004] The main problems with the above method are: the water demand of vegetable crops is affected by many factors, including climatic conditions, soil moisture, vegetable crop varieties, photosynthesis intensity, etc. This method fails to fully consider other factors; it relies on the fitting curve of crop daily coverage and crop coefficient for judgment, and the accuracy of the fitting curve will affect the final judgment result. Summary of the invention

[0005] The purpose of the present invention is to provide a system and method for online monitoring of real-time water consumption of vegetable crops based on machine vision to solve the problems raised in the above background technology.

[0006] To achieve the above object, the present invention provides the following technical solutions:

[0007] A real-time water consumption online monitoring system for vegetable crops based on machine vision, specifically comprising:

[0008] An image acquisition module is used to acquire images of vegetable crop leaves, scale the images, adjust the size to a uniform size of 224*224, and then copy the images into two identical groups of images, one group of which is grayscaled to generate a first recognition image, and the other group of which is converted from an RGB color space to an HSV color space to generate a second recognition image, establish a coordinate system for the first recognition image, and map the pixel positions of the second recognition image one by one in the coordinate system;

[0009] An image segmentation module is used to filter the first recognition image using a bilateral filter, count the grayscale histogram formed by the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, perform threshold segmentation on the first recognition image after filtering using the best segmentation threshold, identify the foreground part and the background part, and extract the foreground part to form a third recognition image;

[0010] An edge extraction module is used to set an edge threshold, use the Sobel operator to calculate the horizontal and vertical gradient values ​​of the third recognition image, and calculate the gradient amplitude of all pixels through the horizontal and vertical gradient values. If the pixel gradient amplitude is greater than the edge threshold, the pixel is retained, otherwise the pixel is set to black to generate edge points of the third recognition image;

[0011] A contour recognition module is used to generate the gradient size and gradient direction of each pixel point through the Canny algorithm, connect all edge pixels of the third recognition image to form a contour, and generate the contour area of ​​the third recognition image;

[0012] The color acquisition module is used to acquire the saturation corresponding to each pixel in the second recognition image and generate the average saturation of the leaves. The saturation value is [0, 255]. The closer the saturation is to 0, the lighter the color is, and the closer it is to 255, the darker the color is. The environment acquisition and processing module is used to acquire the temperature, humidity, and light intensity of the environment in which the vegetable crops are located, and generate an environmental impact index according to the inverse relationship between temperature, humidity, light intensity and water consumption.

[0013] The comprehensive calculation module is used to generate the water consumption of the corresponding leaves according to the generated leaf area, average leaf saturation value, environmental impact index and crop coefficient, and generate the total water consumption of vegetable crops according to the water consumption of each leaf of vegetable crops.

[0014] Furthermore, the principle for converting the image from the RGB color space to the HSV color space to generate the second recognition image is as follows: for any pixel in the image, its RGB color space is represented as (R, G, B), and its HSV color space is represented as (H, S, V). First, the value of the RGB space is converted to between [0, 1], and the formula is as follows:

[0015]

[0016]

[0017]

[0018] H0, S0, and V0 between [0,1] are calculated through R0, G0, and B0. The specific formula is:

[0019] V0 = max(R0, G0, B0);

[0020]

[0021]

[0022]

[0023] S = S0*255;

[0024] V = V0*255;

[0025] Among them, R represents the red channel value, G represents the green channel value, B represents the blue channel value, H represents the hue channel value, S represents the saturation channel value, and V represents the brightness channel value.

[0026] Furthermore, a coordinate system is established for the first recognition image, and the pixel positions of the second recognition image are mapped one by one in the coordinate system based on the principle of: taking the bottom pixel of the first recognition image as the horizontal axis and the leftmost pixel as the vertical axis to establish a coordinate system, and mapping the pixel positions of the second recognition image and the first recognition image one by one through the coordinate points, so that each pixel has a unique coordinate value.

[0027] Furthermore, the formula for calculating the maximum inter-class variance is:

[0028] g(i) 2 =ω i0 ω i1 (μ i0 -μ i1 ) 2 ;

[0029] Among them, g(i) represents the inter-class variance when the threshold is i, ω i0 Indicates the proportion of the target (foreground) part to the total image when the threshold is i, μ i0 represents the gray value of the target part when the threshold is i, ω i1 Indicates the proportion of the background part to the total image when the threshold is i, μ i1 Indicates the gray value of the background part when the threshold is i;

[0030] When g(i) reaches its maximum value, the corresponding threshold i is the optimal segmentation threshold.

[0031] Furthermore, the principle for calculating the gradient amplitude of all pixels by the horizontal gradient value and the vertical gradient value is as follows: multiply the gray value of each pixel and the gray values ​​of its eight adjacent pixels by the horizontal template of the Sobel operator, and add all the products to obtain the horizontal gradient value of the pixel; multiply the gray value of each pixel and the gray value of its eight adjacent pixels by the vertical template of the Sobel operator, and add all the products to obtain the vertical gradient value of the pixel; the horizontal gradient value calculation formula is:

[0032]

[0033] The vertical gradient value calculation formula is:

[0034]

[0035] Wherein, Gx(i, j) represents the horizontal gradient value of the pixel with abscissa i and ordinate j, Gy(i, j) represents the vertical gradient value of the pixel with abscissa i and ordinate j, and X(i, j) represents the grayscale value of the pixel with abscissa i and ordinate j.

[0036] The formula for generating the gradient magnitude is:

[0037]

[0038] Wherein, G(i, j) represents the gradient amplitude of the pixel point with abscissa i and ordinate j.

[0039] Furthermore, the principle for generating the contour area of ​​the third recognition image is: generating the gradient direction of the pixel point according to the horizontal gradient value and the vertical gradient value, and the specific calculation formula is:

[0040]

[0041] Wherein, θ(i, j) represents the gradient direction of the pixel with abscissa i and ordinate j, Gx(i, j) represents the horizontal gradient value of the pixel with abscissa i and ordinate j, and Gy(i, j) represents the vertical gradient value of the pixel with abscissa i and ordinate j.

[0042] The direction in which the gradient of the pixel changes the most is the gradient direction;

[0043] In order to leave only one maximum pixel on the edge, a non-maximum suppression algorithm is used to retain the target pixel. The principle of the non-maximum suppression algorithm is as follows: for a pixel m, in the gradient direction of m, if the pixel m satisfies: Gm>G around ;

[0044] Among them, Gm represents the gradient amplitude of pixel m, G around Represents the pixel amplitudes of the same gradient direction adjacent to the pixel m. If the pixel m has the largest gradient amplitude compared with its surrounding pixels with the same gradient direction, the pixel m is retained. Otherwise, the pixel m is suppressed.

[0045] After non-maximum suppression, a binary image is generated. The grayscale values ​​of non-edge points in this binary image are all 0, and there are false edges. The number of false edges can be reduced by double threshold detection. The principle of double threshold detection is: set two high and low thresholds, compare the gradient amplitude of the pixel point with the numerical values ​​of the high threshold and the low threshold, and determine whether to connect the pixel point based on the judgment result. The judgment is based on the formula:

[0046]

[0047] Among them, V max Indicates the high threshold, V min Indicates the low threshold, G n Represents the gradient amplitude of the target pixel n. According to the comparison results, it can be divided into three cases. If it is case ①, the pixel n is marked as a strong edge pixel; if it is case ②, the pixel n is marked as a weak edge pixel; if it is case ③, the pixel n is suppressed; the pixel marked as a strong edge can be directly identified as the real edge. For the weak edge pixel, check the eight adjacent pixels of the weak edge pixel. As long as there is a strong edge pixel among these eight pixels, the weak edge pixel can be identified as the real edge; in this way, all edge pixels are determined to generate an image with closed contours, and the area of ​​the closed area is generated by the contourArea function in OpenCV.

[0048] Furthermore, the formula for generating the average saturation of the leaves is:

[0049]

[0050] in, represents the average saturation of the leaves, s represents the number of pixels contained in the leaves, and H i Indicates the saturation of the i-th pixel of the leaf.

[0051] Furthermore, the formula for generating the environmental impact index K is:

[0052]

[0053] Among them, T represents ambient temperature, W represents ambient humidity, and G represents ambient light intensity; the higher the temperature, the stronger the transpiration, and the greater the water consumption of the leaves, so the temperature is directly proportional to the water consumption and directly proportional to the environmental impact index; the lower the humidity, the stronger the transpiration, and the greater the water consumption of the leaves, so the humidity is inversely proportional to the water consumption and inversely proportional to the environmental impact index; the stronger the light, the more active the photosynthesis, and the greater the water consumption of the leaves, so the light is directly proportional to the water consumption and directly proportional to the environmental impact index.

[0054] Furthermore, according to the generated leaf area, leaf average saturation value, environmental impact index and crop coefficient, the formula for calculating the water consumption of the corresponding leaf is:

[0055]

[0056] Among them, E represents the water consumption of the leaves, K represents the environmental impact index, S represents the surface area of ​​the leaves, represents the average saturation of leaves, K c It represents the crop coefficient. The environmental impact index is jointly determined by the ambient temperature, ambient humidity and ambient light intensity, so the water consumption is proportional to the environmental impact index. The larger the leaf surface area, the stronger the transpiration of the leaf, so the water consumption is proportional to the leaf surface area. The greater the average saturation of the leaf, the darker the color of the leaf and the stronger the photosynthesis, so the water consumption is proportional to the average saturation of the leaf. The crop coefficient is a constant determined according to the different types of vegetable crops and the early, middle and late stages of the growth cycle of vegetable crops. It is proportional to the water consumption of the leaf. The water consumption of each leaf is calculated according to the method described, and the water consumption of each leaf is added to generate the total water consumption of the vegetable crop plant.

[0057] The present invention further provides a method for online monitoring of real-time water consumption of vegetable crops based on machine vision. The method is performed by the above-mentioned online monitoring system for real-time water consumption of vegetable crops, and the specific steps include:

[0058] Step 1: Collect images of vegetable crop leaves, scale and transform the leaf images, adjust the size to 224*224, and then copy the images into two identical groups of images. One group is grayscaled and reconstructed to generate a first recognition image. The other group is converted from RGB color space to HSV color space and reconstructed to generate a second recognition image. A coordinate system is established for the first recognition image, and the pixel positions of the second recognition image are mapped one by one in the coordinate system.

[0059] Step 2: Filter the first recognition image using a bilateral filter, count the grayscale histogram consisting of the frequency of occurrence of pixels at each level in the 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, use the best segmentation threshold to perform threshold segmentation on the first recognition image after filtering, identify the foreground part and the background part, and extract the foreground part to form the third recognition image;

[0060] Step 3: Set the edge threshold, use the Sobel operator to calculate the horizontal and vertical gradient values ​​of the third recognition image, and calculate the gradient amplitude of all pixels through the horizontal and vertical gradient values. If the pixel gradient amplitude is greater than the edge threshold, the pixel is retained, otherwise the pixel is set to black to generate the edge point of the third recognition image;

[0061] Step 4: Generate the gradient size and gradient direction of each pixel point through the Canny algorithm, connect all edge pixels of the third recognition image to form a contour, and generate the contour area of ​​the third recognition image;

[0062] Step 5: Collect the saturation corresponding to each pixel in the second recognition image to generate the average saturation of the leaves. The saturation value is [0, 255]. The closer the saturation is to 0, the lighter the color is, and the closer it is to 255, the darker the color is.

[0063] Step 6: Collect the temperature, humidity, and light intensity of the environment in which the vegetable crops are located, and generate an environmental impact index based on the positive and negative relationship between temperature, humidity, light intensity and water consumption;

[0064] Step 7: Generate the water consumption of the corresponding leaves based on the generated leaf area, average leaf saturation value, environmental impact index and crop coefficient. Generate the total water consumption of the vegetable crops based on the water consumption of each leaf of the vegetable crops.

[0065] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention divides the factors affecting the water consumption of vegetable crops into: vegetable crop factors, including leaf surface area and leaf color saturation; environmental factors, including temperature, humidity, light intensity, and generates an environmental impact index to quantify the impact of the environment. Edge points of leaf images are extracted, the leaf surface area is calculated by OpenCV, the leaf image is converted to the HSV color space to generate the leaf saturation, and the real-time water consumption of the leaf can be obtained by combining the environmental impact index. Compared with the common vegetable crop water consumption monitoring method, this method uses an image processing method to specifically monitor the leaf part that has the greatest impact on transpiration, maps the grayscale image and the HSV color space image one by one in the coordinate system, monitors the surface area and saturation of each leaf of the vegetable crop one by one to generate the water consumption of the leaf, and adds up the water consumption of all leaves to approximately replace the water consumption of the entire plant, saving monitoring costs while ensuring accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 This is a system module diagram for online monitoring of real-time water consumption of vegetable crops according to an embodiment of the present invention;

[0067] Figure 2 This is a flow chart of a method for online monitoring of real-time water consumption of vegetable crops according to an embodiment of the present invention. DETAILED DESCRIPTION

[0068] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments.

[0069] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the present invention should be understood by people with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0070] Example:

[0071] See also Figure 1 The present invention is a real-time water consumption online monitoring system for vegetable crops based on machine vision, comprising:

[0072] An image acquisition module is used to acquire images of vegetable crop leaves, scale the images, adjust the size to a uniform size of 224*224, and then copy the images into two identical groups of images, one group of which is grayscaled to generate a first recognition image, and the other group of which is converted from an RGB color space to an HSV color space to generate a second recognition image, establish a coordinate system for the first recognition image, and map the pixel positions of the second recognition image one by one in the coordinate system;

[0073] In this embodiment, the image size is adjusted to 224*224, which can retain the main features and structural information of the image and avoid excessive distortion. At the same size, data can be more easily compared, reducing the computational complexity. The purpose of copying the image into two groups of images and graying one of the groups to generate the first recognition image is:

[0074] The grayscale image retains the brightness information of the image, reduces the interference of image color, enhances the image contrast, and makes the structural features of the image easier to identify. Subsequently, it is necessary to find the optimal segmentation threshold for the first recognition image after grayscale processing to retrieve the number of pixels. The formula for grayscale processing is:

[0075] Y=0.299*R+0.587*G+0.114*B;

[0076] Wherein, Y is the gray value of the first recognition image, R represents the brightness value of the red channel of the initial image, G represents the brightness value of the green channel of the initial image, and B represents the brightness value of the blue channel of the initial image.

[0077] In this embodiment, the purpose of converting the image from the RGB color space to the HSV color space to generate the second recognition image is: the HSV color space uses a method that is more in line with human perception to describe color, and it divides the attributes of color into: hue (Hue), saturation (Saturation) and brightness (Value); wherein, hue represents the type of color, which is an angle value from 0 to 360°, corresponding to the position on the color spectrum, 0° and 360° correspond to red, 120° corresponds to green, and 240° corresponds to blue; saturation represents the degree of lightness of the color, when the saturation is 0, it represents grayscale color, the lightest color, the higher the saturation, the brighter the color; brightness represents the degree of lightness of the color, ranging from 0-100%, when the brightness is 0, it represents black, and when the brightness is 100%, it represents white. The principle of converting the image from the RGB color space to the HSV color space is: for any pixel m in the image, its RGB color space is represented as m(R, G, B), first convert the value of the RGB space to between [0,1], and the formula based on it is:

[0078]

[0079]

[0080]

[0081] H0, S0, and V0 between [0,1] are calculated through R0, G0, and B0. The specific formula is:

[0082] V0=max(R0、G0、B0);

[0083]

[0084]

[0085]

[0086] S = S0*255;

[0087] V = V0*255;

[0088] Among them, R represents the red channel value, G represents the green channel value, B represents the blue channel value, H represents the hue channel value, S represents the saturation channel value, and V represents the brightness channel value.

[0089] An image segmentation module is used to filter the first recognition image using a bilateral filter, count the grayscale histogram formed by the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, perform threshold segmentation on the first recognition image after filtering using the best segmentation threshold, identify the foreground part and the background part, and extract the foreground part to form a third recognition image;

[0090] In this embodiment, the calculation formula of the inter-class variance is: g(i) 2 =ω i0 ω i1 (μ i0 -μ i1 ) 2 ;

[0091] Among them, the calculation formula of the inter-class variance is the formula of OTSU method, g(i) represents the inter-class variance when the threshold is i, ω i0 Indicates the proportion of the target (foreground) part to the total image, μ i0 represents the gray value of the target part when the threshold is i, ω i1 Indicates the proportion of the background part to the total image when the threshold is i, μ i1It represents the gray value of the background part when the threshold is i. When g(i) is larger, it means that the difference between the two parts of the image is greater and the segmentation effect is better. When g(i) takes the maximum value, the corresponding i is the optimal segmentation threshold.

[0092] An edge extraction module is used to set an edge threshold, use the Sobel operator to calculate the horizontal and vertical gradient values ​​of the third recognition image, and calculate the gradient amplitude of all pixels through the horizontal and vertical gradient values. If the pixel gradient amplitude is greater than the edge threshold, the pixel is retained, otherwise the pixel is set to black to generate edge points of the third recognition image;

[0093] In this embodiment, the principle for calculating the gradient amplitude of all pixels by the horizontal gradient value and the vertical gradient value is as follows: the gray value of each pixel and the gray values ​​of its eight adjacent pixels are multiplied by the horizontal template of the Sobel operator, and all the products are added to obtain the horizontal gradient value of the pixel; the gray value of each pixel and the gray values ​​of its eight adjacent pixels are multiplied by the vertical template of the Sobel operator, and all the products are added to obtain the vertical gradient value of the pixel; the horizontal gradient value calculation formula is:

[0094]

[0095] The vertical gradient value calculation formula is:

[0096]

[0097] Wherein, Gx(i, j) represents the horizontal gradient value of the pixel with abscissa i and ordinate j, Gy(i, j) represents the vertical gradient value of the pixel with abscissa i and ordinate j, and X(i, j) represents the grayscale value of the pixel with abscissa i and ordinate j.

[0098] The formula for generating the gradient magnitude is:

[0099]

[0100] Wherein, G(i, j) represents the gradient amplitude of the pixel point with abscissa i and ordinate j.

[0101] A contour recognition module is used to generate the gradient size and gradient direction of each pixel point through the Canny algorithm, connect all edge pixels of the third recognition image to form a contour, and generate the contour area of ​​the third recognition image;

[0102] In this embodiment, the gradient direction of the pixel point is generated according to the horizontal gradient value and the vertical gradient value. The specific calculation formula is:

[0103]

[0104] Wherein, θ(i, j) represents the gradient direction of the pixel with abscissa i and ordinate j, Gx(i, j) represents the horizontal gradient value of the pixel with abscissa i and ordinate j, and Gu(i, j) represents the vertical gradient value of the pixel with abscissa i and ordinate j.

[0105] The direction in which the gradient of the pixel changes the most is the gradient direction;

[0106] In order to leave only one maximum pixel on the edge, a non-maximum suppression algorithm is used to retain the target pixel. The principle of the non-maximum suppression algorithm is as follows: for a pixel m, in the gradient direction of m, if the pixel m satisfies: Gm>G around ;

[0107] Among them, Gm represents the gradient amplitude of pixel m, G around Represents the pixel amplitudes of the same gradient direction adjacent to the pixel m. If the pixel m has the largest gradient amplitude compared with its surrounding pixels with the same gradient direction, the pixel m is retained. Otherwise, the pixel m is suppressed.

[0108] After non-maximum suppression, a binary image is generated. The grayscale values ​​of non-edge points in this binary image are all 0, and there are false edges. The number of false edges can be reduced by double threshold detection. The principle of double threshold detection is: set two high and low thresholds, compare the gradient amplitude of the pixel point with the numerical values ​​of the high threshold and the low threshold, and determine whether to connect the pixel point based on the judgment result. The judgment is based on the formula:

[0109]

[0110] Among them, V max Indicates the high threshold, V min Indicates the low threshold, G nRepresents the gradient amplitude of the target pixel n. According to the comparison results, it can be divided into three cases. If it is case ①, the pixel n is marked as a strong edge pixel; if it is case ②, the pixel n is marked as a weak edge pixel; if it is case ③, the pixel n is suppressed; the pixel marked as a strong edge can be directly identified as the real edge. For the weak edge pixel, check the eight adjacent pixels of the weak edge pixel. As long as there is a strong edge pixel among these eight pixels, the weak edge pixel can be identified as the real edge; in this way, all edge pixels are determined to generate an image with closed contours, and the area of ​​the closed area is generated by the contourArea function in OpenCV. The specific steps are: findContours detects the contour of the image part, stores the detection results in the contours list, then uses contours[i] to take out the contour of the i-th image in the contours list, and calculates the area surrounded by the contour--S through the contourArea function.

[0111] A color acquisition module is used to acquire the saturation corresponding to each pixel in the second recognition image and generate an average saturation of the leaves. The saturation value is [0, 255]. The closer the saturation is to 0, the lighter the color is, and the closer it is to 255, the darker the color is.

[0112] In this embodiment, the formula for calculating the average saturation of the blade is:

[0113]

[0114] in, represents the average saturation of the leaves, s represents the number of pixels contained in the leaves, and H i Indicates the saturation of the i-th pixel on the leaf.

[0115] The environment collection and processing module is used to collect the temperature, humidity and light intensity of the environment in which the vegetable crops are located, and generate an environmental impact index based on the positive and negative relationship between temperature, humidity, light intensity and water consumption;

[0116] In this embodiment, the formula for generating the environmental impact index K is:

[0117]

[0118] Among them, T represents ambient temperature, W represents ambient humidity, and G represents ambient light intensity; the higher the temperature, the stronger the transpiration, and the greater the water consumption of the leaves, so the temperature is directly proportional to the water consumption and directly proportional to the environmental impact index; the lower the humidity, the stronger the transpiration, and the greater the water consumption of the leaves, so the humidity is inversely proportional to the water consumption and inversely proportional to the environmental impact index; the stronger the light, the more active the photosynthesis, and the greater the water consumption of the leaves, so the light is directly proportional to the water consumption and directly proportional to the environmental impact index.

[0119] The comprehensive calculation module is used to generate the water consumption of the corresponding leaves according to the generated leaf area, average leaf saturation value, environmental impact index and crop coefficient, and generate the total water consumption of vegetable crops according to the water consumption of each leaf of vegetable crops.

[0120] In this embodiment, the formula for calculating the water consumption of the corresponding leaf according to the generated leaf area, leaf average saturation value, environmental impact index and crop coefficient is:

[0121]

[0122] Among them, E represents the water consumption of the leaves, K represents the environmental impact index, S represents the surface area of ​​the leaves, represents the average saturation of leaves, K c It represents the crop coefficient. The environmental impact index is jointly determined by the ambient temperature, ambient humidity and ambient light intensity, so the water consumption is proportional to the environmental impact index. The larger the leaf surface area, the stronger the transpiration of the leaf, so the water consumption is proportional to the leaf surface area. The greater the average saturation of the leaf, the darker the color of the leaf and the stronger the photosynthesis, so the water consumption is proportional to the average saturation of the leaf. The crop coefficient is a constant determined according to the different types of vegetable crops and the early, middle and late stages of the growth cycle of vegetable crops. It is proportional to the water consumption of the leaf. The water consumption of each leaf can be calculated according to the method described. The water consumption of all leaves can be added to generate the total water consumption of the vegetable crop plant.

[0123] See also Figure 2 The present invention also provides a method for online monitoring of real-time water consumption of vegetable crops based on machine vision. The method is executed by the above-mentioned online monitoring system for real-time water consumption of vegetable crops, and the specific steps include:

[0124] Step 1: Collect images of vegetable crop leaves, scale and transform the leaf images, adjust the size to 224*224, and then copy the images into two identical groups of images. One group is grayscaled and reconstructed to generate a first recognition image. The other group is converted from RGB color space to HSV color space and reconstructed to generate a second recognition image. A coordinate system is established for the first recognition image, and the pixel positions of the second recognition image are mapped one by one in the coordinate system.

[0125] Step 2: Filter the first recognition image using a bilateral filter, count the grayscale histogram consisting of the frequency of occurrence of pixels at each level in the 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, use the best segmentation threshold to perform threshold segmentation on the first recognition image after filtering, identify the foreground part and the background part, and extract the foreground part to form the third recognition image;

[0126] Step 3: Set the edge threshold, use the Sobel operator to calculate the horizontal and vertical gradient values ​​of the third recognition image, and calculate the gradient amplitude of all pixels through the horizontal and vertical gradient values. If the pixel gradient amplitude is greater than the edge threshold, the pixel is retained, otherwise the pixel is set to black to generate the edge point of the third recognition image;

[0127] Step 4: Generate the gradient size and gradient direction of each pixel point through the Canny algorithm, connect all edge pixels of the third recognition image to form a contour, and generate the contour area of ​​the third recognition image;

[0128] Step 5: Collect the saturation corresponding to each pixel in the second recognition image to generate the average saturation of the leaves. The saturation value is [0, 255]. The closer the saturation is to 0, the lighter the color is, and the closer it is to 255, the darker the color is.

[0129] Step 6: Collect the temperature, humidity, and light intensity of the environment in which the vegetable crops are located, and generate an environmental impact index based on the positive and negative relationship between temperature, humidity, light intensity and water consumption;

[0130] Step 7: Generate the water consumption of the corresponding leaves based on the generated leaf area, average leaf saturation value, environmental impact index and crop coefficient. Generate the total water consumption of the vegetable crops based on the water consumption of each leaf of the vegetable crops.

[0131] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.

[0132] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented by software, the above embodiments may be implemented in whole or in part in the form of a computer program product. Those skilled in the art may appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein may be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed by hardware or software methods depends on the specific application and design constraints of the technical solution.

[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, and may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0134] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A real-time online monitoring system for water consumption of vegetable crops based on machine vision, It is characterized in that include: The image acquisition module is used to acquire images of vegetable crop leaves, scale and convert the leaf images, adjust the size to 224*224, and then copy the images into two identical groups of images. One group is gray-scaled and reconstructed to generate a first recognition image. The other group is converted from RGB color space to HSV color space and reconstructed to generate a second recognition image. A coordinate system is established for the first recognition image, and the pixel positions of the second recognition image are mapped one by one in the coordinate system. An image segmentation module is used to filter the first recognition image using a bilateral filter, count the grayscale histogram formed by the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, perform threshold segmentation on the first recognition image after filtering using the best segmentation threshold, identify the foreground part and the background part, extract the foreground part and reconstruct it to generate a third recognition image; An edge extraction module is used to set an edge threshold, use the Sobel operator to calculate the horizontal and vertical gradient values ​​of the third recognition image, and calculate the gradient amplitude of all pixels through the horizontal and vertical gradient values. If the pixel gradient amplitude is greater than the edge threshold, the pixel is retained, otherwise the pixel is set to black to generate edge points of the third recognition image; A contour recognition module is used to generate the gradient size and gradient direction of each pixel point through the Canny algorithm, connect all edge pixels of the third recognition image to form a contour, and generate the contour area of ​​the third recognition image; A color acquisition module is used to acquire the saturation corresponding to each pixel in the second recognition image and generate an average saturation of the leaves. The saturation value is [0, 255]. The closer the saturation is to 0, the lighter the color is, and the closer it is to 255, the darker the color is. The environment collection and processing module is used to collect the temperature, humidity and light intensity of the environment in which the vegetable crops are located, and generate an environmental impact index based on the positive and negative relationship between temperature, humidity, light intensity and water consumption; A comprehensive calculation module is used to generate the water consumption of the corresponding leaves according to the generated leaf area, average leaf saturation value, environmental impact index and crop coefficient, and to generate the total water consumption of the vegetable crops according to the water consumption of each leaf of the vegetable crops; The principle for generating the contour area of ​​the third recognition image is: generating the gradient direction of the pixel point according to the horizontal gradient value and the vertical gradient value. The specific calculation formula is: Wherein, θ(i, j) represents the gradient direction of the pixel with abscissa i and ordinate j, Gx(i, j) represents the horizontal gradient value of the pixel with abscissa i and ordinate j, and Gy(i, j) represents the vertical gradient value of the pixel with abscissa i and ordinate j. The direction in which the gradient of the pixel changes the most is the gradient direction; In order to leave only one maximum pixel on the edge, a non-maximum suppression algorithm is used to retain the target pixel. The principle of the non-maximum suppression algorithm is as follows: for a pixel m, in the gradient direction of m, if the pixel m satisfies: Gm>G around Among them, Gm represents the gradient amplitude of pixel m, G around Represents the pixel amplitudes of the same gradient direction adjacent to the pixel m. If the pixel m has the largest gradient amplitude compared with its surrounding pixels with the same gradient direction, the pixel m is retained. Otherwise, the pixel m is suppressed. After non-maximum suppression, a binary image is generated. The grayscale values ​​of non-edge points in this binary image are all 0, and there are false edges. The number of false edges can be reduced by double threshold detection. The principle of double threshold detection is: set two high and low thresholds, compare the gradient amplitude of the pixel point with the numerical values ​​of the high threshold and the low threshold, and determine whether to connect the pixel point based on the judgment result. The judgment is based on the formula: Among them, V max Indicates the high threshold, V min Indicates the low threshold, G n Indicates the gradient amplitude of the target pixel n. According to the comparison results, it can be divided into three cases. If it is case ①, the pixel n is marked as a strong edge pixel; if it is case ②, the pixel n is marked as a weak edge pixel; if it is case ③, the pixel n is suppressed; the pixel marked as a strong edge can be directly identified as the real edge. For the weak edge pixel, check the eight adjacent pixels of the weak edge pixel. As long as there is a strong edge pixel among these eight pixels, the weak edge pixel can be identified as the real edge; in this way, all contour recognition is completed, all edge pixels are determined, and the contours are connected to generate a closed contour image. The area of ​​the closed area is generated by the contourArea function in OpenCV; The formula for generating the environmental impact index K is: Among them, T represents the ambient temperature, W represents the ambient humidity, and G represents the ambient light intensity; the higher the temperature, the stronger the transpiration, and the greater the water consumption of the leaves, so the temperature is proportional to the water consumption and proportional to the environmental impact index; the lower the humidity, the stronger the transpiration, and the greater the water consumption of the leaves, so the humidity is inversely proportional to the water consumption and inversely proportional to the environmental impact index; the stronger the light, the more active the photosynthesis, and the greater the water consumption of the leaves, so the light is proportional to the water consumption and proportional to the environmental impact index; According to the generated leaf area, leaf average saturation value, environmental impact index and crop coefficient, the formula for calculating the water consumption of the corresponding leaf is: Among them, E represents the water consumption of the leaves, K represents the environmental impact index, S represents the surface area of ​​the leaves, represents the average saturation of leaves, K c It represents the crop coefficient. The environmental impact index is jointly determined by the ambient temperature, ambient humidity and ambient light intensity, so the water consumption is proportional to the environmental impact index; the larger the leaf surface area, the stronger the transpiration of the leaf, so the water consumption is proportional to the leaf surface area; the greater the average saturation of the leaf, the darker the color of the leaf, and the more intense the photosynthesis, so the water consumption is proportional to the average saturation of the leaf; the crop coefficient is a constant determined according to the different types of vegetable crops and the early, middle and late stages of the growth cycle of vegetable crops. It is proportional to the water consumption of the leaf. The water consumption of each leaf is calculated according to the formula, and the water consumption of each leaf is added to generate the total water consumption of the vegetable crop plant.

2. According to claim 1, a real-time online monitoring system for water consumption of vegetable crops based on machine vision, Features: The principle for converting the image from the RGB color space to the HSV color space to generate the second recognition image in the image acquisition module is: for any pixel in the image, its RGB color space is represented as (R, G, B), and its HSV color space is represented as (H, S, V). First, the value of the RGB space is converted to between [0, 1], and the formula based on it is: By R 0 , G 0 , B 0 Calculate the value of H between [0,1] 0 , S 0 、V 0 , the specific formula is: V 0 =max(R 0 ,G 0 ,B 0 ) S=S 0 *255 V=V 0 *255 Among them, R represents the red channel value, G represents the green channel value, B represents the blue channel value, H represents the hue channel value, S represents the saturation channel value, and V represents the brightness channel value.

3. According to claim 1, a machine vision-based online monitoring system for real-time water consumption of vegetable crops, Features: The image acquisition module establishes a coordinate system for the first recognition image and maps the pixel positions of the second recognition image one by one in the coordinate system. The principle is as follows: take the bottom pixel of the first recognition image as the horizontal axis and the leftmost pixel as the vertical axis to establish a coordinate system, and map the pixel positions of the second recognition image and the first recognition image one by one through the coordinate points so that each pixel has a unique coordinate value.

4. According to claim 1, a real-time online monitoring system for water consumption of vegetable crops based on machine vision, Features: The formula for calculating the maximum inter-class variance in the image segmentation module is: g(i) 2 =ω i0 oh i1 (m i0 -m i1 ) 2 Among them, g(i) represents the inter-class variance when the threshold is i, ω i0 Indicates the proportion of the foreground part to the total image when the threshold is i, μ i0 represents the gray value of the foreground part when the threshold is i, ω i1 Indicates the proportion of the background part to the total image when the threshold is i, μ i1 Indicates the gray value of the background part when the threshold is i; When g(i) reaches its maximum value, the corresponding threshold i is the optimal segmentation threshold.

5. According to claim 1, a machine vision-based online monitoring system for real-time water consumption of vegetable crops, Features: The principle for calculating the gradient amplitude of all pixels by the horizontal gradient value and the vertical gradient value in the edge extraction module is as follows: multiply the gray value of each pixel and the gray values ​​of its eight adjacent pixels by the horizontal template of the Sobel operator, and add all the products to obtain the horizontal gradient value of the pixel; multiply the gray value of each pixel and the gray values ​​of its eight adjacent pixels by the vertical template of the Sobel operator, and add all the products to obtain the vertical gradient value of the pixel; the horizontal gradient value calculation formula is: The vertical gradient value calculation formula is: Wherein, Gx(i, j) represents the horizontal gradient value of the pixel with abscissa i and ordinate j, Gy(i, j) represents the vertical gradient value of the pixel with abscissa i and ordinate j, and X(i, j) represents the grayscale value of the pixel with abscissa i and ordinate j. The formula for generating the gradient magnitude is: Wherein, G(i, j) represents the gradient amplitude of the pixel point with abscissa i and ordinate j.

6. According to claim 1, a real-time online monitoring system for water consumption of vegetable crops based on machine vision, Features: The formula for generating the average saturation of leaves in the color acquisition module is: in, represents the average saturation of the leaves, s represents the number of pixels contained in the leaves, and H i Indicates the saturation of the i-th pixel of the leaf.

7. A real-time online monitoring method for water consumption of vegetable crops based on machine vision. It is characterized in that The monitoring method is performed by the online monitoring system for real-time water consumption of vegetable crops according to any one of claims 1 to 6, and the specific steps include: Step 1: Collect images of vegetable crop leaves, scale and transform the leaf images, adjust the size to 224*224, and then copy the images into two identical groups of images. One group is grayscaled and reconstructed to generate a first recognition image. The other group is converted from RGB color space to HSV color space and reconstructed to generate a second recognition image. A coordinate system is established for the first recognition image, and the pixel positions of the second recognition image are mapped one by one in the coordinate system. Step 2: Filter the first recognition image using a bilateral filter, count the grayscale histogram consisting of the frequency of occurrence of pixels at each level in the 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, use the best segmentation threshold to perform threshold segmentation on the first recognition image after filtering, identify the foreground part and the background part, and extract the foreground part to form the third recognition image; Step 3: Set the edge threshold, use the Sobel operator to calculate the horizontal and vertical gradient values ​​of the third recognition image, and calculate the gradient amplitude of all pixels through the horizontal and vertical gradient values. If the pixel gradient amplitude is greater than the edge threshold, the pixel is retained, otherwise the pixel is set to black to generate the edge point of the third recognition image; Step 4: Generate the gradient size and gradient direction of each pixel point through the Canny algorithm, connect all edge pixels of the third recognition image to form a contour, and generate the contour area of ​​the third recognition image; Step 5: Collect the saturation corresponding to each pixel in the second recognition image to generate the average saturation of the leaves. The saturation value is [0, 255]. The closer the saturation is to 0, the lighter the color is, and the closer it is to 255, the darker the color is. Step 6: Collect the temperature, humidity, and light intensity of the environment in which the vegetable crops are located, and generate an environmental impact index based on the positive and negative relationship between temperature, humidity, light intensity and water consumption; Step 7: Generate the water consumption of the corresponding leaves based on the generated leaf area, average leaf saturation value, environmental impact index and crop coefficient. Generate the total water consumption of the vegetable crops based on the water consumption of each leaf of the vegetable crops.