A water pollution judgment method and system based on image recognition

Through the water pollution judgment method based on image recognition, the image shooting device and ResNet network structure are used to solve the problems of long inspection time, high cost and high risk coefficient of water pollution detection, and fast and accurate monitoring of water pollution is achieved, reducing the Inspection of risks and support 24/7 monitoring.

CN114792402BActive Publication Date: 2024-11-29重庆知行数联智能科技有限责任公司
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202111655387.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2024-11-29
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

In the prior art, water pollution inspection and inspection time are long, costly and high risk factors, especially in remote lakes or ponds and inclement weather conditions, it is difficult to effectively monitor the phosphorus content and pollution of water bodies.

Method used

Using the water pollution judgment method based on image recognition, the video stream is obtained through the image shooting device, frame the images, grayscale processing and area cropping are performed, and image recognition is performed in combination with the ResNet network structure to determine whether there is water pollution in the water area, and the entry is analyzed. Outbound and upstream and downstream pollution.

Benefits of technology

It achieves rapid and accurate judgment of water pollution, reduces the risk of inspection, reduces the frequency of manual inspection, can monitor all-weather, and improves the efficiency and safety of water pollution monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114792402B_ABST
    Figure CN114792402B_ABST
Patent Text Reader

Abstract

The present invention provides a water pollution judgment method and system based on image recognition, including: extracting a video stream, dividing the video stream into frames, and using the single-frame image after framing as a target image; graying the target image to obtain the gray value corresponding to each pixel; and screening out the pixel points whose gray value is greater than or equal to the preset gray value, and recording them as target pixels; obtaining the image coordinates of the target pixel points, and mapping the corresponding image area according to the image coordinates, calculating the area of ​​the image area, and when it is greater than or equal to the preset area value, cutting out the image area as an image to be identified; using an image recognition model to perform image recognition on the image to be identified, and determining whether the target water area has water pollution. The present invention can determine whether the target water area has water pollution by only obtaining a video stream shot at the target water area position, not only does it not require manual actual inspection of the target water area, but the present invention can also maintain all-day inspections.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of water pollution detection, and in particular to a water pollution judgment method and system based on image recognition. Background Art

[0002] Water pollution is caused by harmful chemicals that reduce or lose the use value of water, thereby polluting water resources in the environment. Acids, alkalis, oxidants, compounds such as copper, cadmium, mercury, arsenic, and organic toxins such as benzene, ethylene dichloride, and ethylene glycol in sewage can poison aquatic organisms and affect drinking water sources and scenic spots. When organic matter in sewage is decomposed by microorganisms, it consumes oxygen in the water, affecting the life of aquatic organisms. After the dissolved oxygen in the water is exhausted, the organic matter undergoes anaerobic decomposition, producing unpleasant gases such as hydrogen sulfide and mercaptans, which further deteriorates the water quality.

[0003] At present, for some lakes or ponds near chemical plants, the wastewater discharged by some chemical plants may contain a large amount of phosphorus, resulting in excessive phosphorus content in the water body, which causes eutrophication of the water body and causes rapid reproduction of algae and other plankton. For example, excessive phosphorus content in the water body will cause the water hyacinth or duckweed in the lake or pond to reproduce in large quantities, causing the dissolved oxygen content in the water body to decrease, deteriorating the water quality, and causing a large number of fish and other organisms to die. Therefore, in order to avoid the deterioration of water quality, the current solution is for inspectors to actually go to the lake or pond for on-site inspection, observe the area of ​​water hyacinth or duckweed in the lake or pond, and then judge whether the water body has excessive phosphorus content. However, since some lakes or ponds are relatively remote, the time spent by inspectors on a single inspection is long, and the inspection cost is also high; and in bad weather (such as heavy rain), the inspectors are also at high risk when conducting on-site inspections in places such as lakes and ponds. Summary of the invention

[0004] In view of the above-mentioned shortcomings of the prior art, the purpose of the present invention is to provide a water pollution judgment method and system based on image recognition, which is used to solve the problems of long inspection time, high inspection cost and high risk factor in the prior art for detecting water pollution.

[0005] To achieve the above-mentioned object and other related objects, the present invention provides a water pollution judgment method based on image recognition, the method comprising the following steps:

[0006] Extracting a video stream within a target time period from an image capture device; the image capture device is pre-set close to a target water area, and the image capture device is used to capture the target water area and form a corresponding video stream;

[0007] Divide the extracted video stream into frames, and use each single frame image after framing as the target image;

[0008] Performing grayscale processing on the target image and obtaining the grayscale value corresponding to each pixel in the target image;

[0009] Compare the grayscale value corresponding to each pixel with a preset grayscale value, and select pixel points whose grayscale values ​​are greater than or equal to the preset grayscale value as target pixel points;

[0010] Obtaining the image coordinates of each target pixel in the target image, and mapping a corresponding image area on the target image according to the obtained image coordinates;

[0011] Calculating the area of ​​the image region, comparing the calculated area result with a preset area value, and when the area of ​​the image region is greater than or equal to the preset area value, cutting out the image region from the target image as an image to be recognized;

[0012] The image to be identified is input into a trained image recognition model, the image recognition model is used to perform image recognition on the image to be identified, and whether the target water area is polluted is determined according to the image recognition result.

[0013] Optionally, the training process of the image recognition model includes:

[0014] Acquire multiple images containing water pollution and multiple images not containing water pollution as training images;

[0015] Label each water pollution training image with the pollutant category according to the preset pollutant category, and label each non-water pollution training image with the non-pollutant category. After labeling, all labeled training images are simultaneously input into the ResNet network structure for classification training;

[0016] The true positive rate and false positive rate in the ResNet network structure at the current moment are calculated, and when the true positive rate is greater than the first target value and the false positive rate is less than the second target value, the ResNext network structure and the corresponding network parameters at the current moment are combined and output to generate an image recognition model for identifying whether water pollution exists in the image to be identified.

[0017] Optionally, the process of performing image recognition on the image to be recognized by using the image recognition model, and determining whether the target water area has water pollution according to the image recognition result includes:

[0018] Using the image recognition model to classify the image to be recognized into pollutant categories, and obtaining the classification probability of the image to be recognized being classified into each preset pollutant category;

[0019] All classification probabilities are normalized, and the normalized probability values ​​are compared with the preset probability values ​​to determine whether there is a normalized probability value greater than or equal to the preset probability value; if so, the pollutant category corresponding to the maximum value in the normalized probability value is used as the pollutant category of the image to be identified, and it is determined that water pollution exists in the target water area; if not, it is determined that there is no water pollution in the image to be identified and the target water area.

[0020] Optionally, the method further comprises:

[0021] When water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an entry section and an exit section;

[0022] If there is an entry section and an exit section, the pollution concentration data value in the water area of ​​the entry section is obtained and recorded as the entry section value concentration value; and the pollution concentration data value in the water area of ​​the exit section is obtained and recorded as the exit section value concentration value

[0023] The difference between the inbound section concentration value and the outbound section concentration value is calculated. If the difference is greater than zero, it is determined that the inbound pollution of the target water area is greater than the outbound pollution; if the difference is less than zero, it is determined that the outbound pollution of the target water area is greater than the inbound pollution; if the difference is equal to zero, it is determined that the outbound pollution of the target water area is the same as the inbound pollution.

[0024] Optionally, the method further comprises:

[0025] When water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an upstream section and a downstream section;

[0026] If there is an upstream section and a downstream section, the pollution concentration data value in the water area of ​​the upstream section is obtained, which is recorded as the upstream section value concentration value; and the pollution concentration data value in the water area of ​​the downstream section is obtained, which is recorded as the downstream section value concentration value

[0027] The difference between the concentration value of the upstream section value and the concentration value of the downstream section value is calculated. If the difference is greater than zero, it is determined that the upstream pollution of the target water area is greater than the downstream pollution; if the difference is less than zero, it is determined that the downstream pollution of the target water area is greater than the upstream pollution; if the difference is equal to zero, it is determined that the downstream pollution of the target water area is the same as the upstream pollution.

[0028] Optionally, the process of graying the target image and obtaining the gray value corresponding to each pixel in the target image includes:

[0029] Get the grayscale value of each pixel in the red channel, green channel and blue channel respectively;

[0030] Perform weighted calculation on the grayscale values ​​of the red channel, green channel, and blue channel of each pixel to obtain the grayscale value of each pixel:

[0031] Gray(x,y)=0.30*R(x,y)+0.59*G(x,y)+0.11*B(x,y);

[0032] In the formula, Gray(x, y) represents the gray value of the pixel with image coordinates (x, y);

[0033] R(x, y) represents the gray value of the pixel with image coordinates (x, y) under the red channel;

[0034] G(x, y) represents the gray value of the pixel with image coordinates (x, y) under the green channel;

[0035] B(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the blue channel.

[0036] Optionally, when water pollution exists in the target water area, the method further comprises:

[0037] Using a light source to generate an incident light;

[0038] Utilizing the incident light to illuminate a target water sample and generate corresponding projection light; wherein the target water sample is a water sample of a certain volume randomly obtained in advance from the target water area;

[0039] The optical path of the incident light in the target water sample and the light source intensity of the projected light are obtained, and the turbidity of the target water sample is calculated in combination with the light source intensity of the incident light, as follows:

[0040]

[0041] Wherein, d is the turbidity of the target water sample;

[0042] I0 is the light source intensity of the incident light;

[0043] I is the light source intensity of the projection light;

[0044] l is the optical path length of the incident light in the target water sample;

[0045] K is a constant.

[0046] The present invention also provides a water pollution judgment system based on image recognition, the system comprising:

[0047] A video stream acquisition module, used to extract a video stream within a target time period from an image capture device; the image capture device is pre-set close to a target water area, and the image capture device is used to capture the target water area and form a corresponding video stream;

[0048] A framing module is used to frame the extracted video stream and use each single frame image after framing as a target image;

[0049] A grayscale processing module, used to perform grayscale processing on the target image and obtain the grayscale value corresponding to each pixel in the target image;

[0050] A grayscale comparison module is used to compare the grayscale value corresponding to each pixel with a preset grayscale value, and filter out the pixel points whose grayscale value is greater than or equal to the preset grayscale value and record them as target pixel points;

[0051] An image mapping module, used to obtain the image coordinates of each target pixel point in the target image, and map a corresponding image area on the target image according to the obtained image coordinates;

[0052] An image cropping module, used to calculate the area of ​​the image region, compare the calculated area result with a preset area value, and when the area of ​​the image region is greater than or equal to the preset area value, crop the image region from the target image as an image to be recognized;

[0053] The water pollution identification module is used to input the image to be identified into the trained image recognition model, use the image recognition model to perform image recognition on the image to be identified, and determine whether the target water area has water pollution according to the image recognition result.

[0054] Optionally, the training process of the image recognition model in the water pollution recognition module includes:

[0055] Acquire multiple images containing water pollution and multiple images not containing water pollution as training images;

[0056] Label each water pollution training image with the pollutant category according to the preset pollutant category, and label each non-water pollution training image with the non-pollutant category. After labeling, all labeled training images are simultaneously input into the ResNet network structure for classification training;

[0057] The true positive rate and false positive rate in the ResNet network structure at the current moment are calculated, and when the true positive rate is greater than the first target value and the false positive rate is less than the second target value, the ResNext network structure and the corresponding network parameters at the current moment are combined and output to generate an image recognition model for identifying whether water pollution exists in the image to be identified.

[0058] Optionally, the water pollution identification module uses the image recognition model to perform image recognition on the image to be identified, and determines whether the target water area is water polluted according to the image recognition result, including:

[0059] Using the image recognition model to classify the image to be recognized into pollutant categories, and obtaining the classification probability of the image to be recognized being classified into each preset pollutant category;

[0060] All classification probabilities are normalized, and the normalized probability values ​​are compared with the preset probability values ​​to determine whether there is a normalized probability value greater than or equal to the preset probability value; if so, the pollutant category corresponding to the maximum value in the normalized probability value is used as the pollutant category of the image to be identified, and it is determined that water pollution exists in the target water area; if not, it is determined that there is no water pollution in the image to be identified and the target water area.

[0061] As described above, the present invention provides a method and system for judging water pollution based on image recognition, which has the following beneficial effects:

[0062] The present invention first extracts a video stream within a target time period from an image capture device; then divides the extracted video stream into frames, and uses each single-frame image after the division as a target image; then grayscales the target image, and obtains the grayscale value corresponding to each pixel in the target image; compares the grayscale value corresponding to each pixel with a preset grayscale value, and filters out pixels whose grayscale values ​​are greater than or equal to the preset grayscale value, and records them as target pixels; then obtains the image coordinates of each target pixel in the target image, and maps the corresponding image area on the target image according to the obtained image coordinates; calculates the area of ​​the image area, and compares the calculated area result with the preset area value, and when the area of ​​the image area is greater than or equal to the preset area value, cuts out the image area from the target image as an image to be identified; finally, inputs the image to be identified into a trained image recognition model, uses the image recognition model to perform image recognition on the image to be identified, and determines whether there is water pollution in the target water area according to the image recognition result. It can be seen from this that the present invention can first obtain the video stream in the image shooting device set at the target water area position, and then divide the video stream into frames to obtain multiple single-frame images, and then perform image recognition on each single-frame image, so as to determine whether there is water pollution in the target water area. Therefore, the present invention only needs to obtain the video stream shot at the target water area position to determine whether there is water pollution in the target water area. Not only does it not require manual actual inspection of the target water area, but the present invention can maintain all-day inspections, so that the water pollution judgment of the target water area can be realized by low-risk monitoring means. Therefore, the present invention can not only reduce the degree of danger of water pollution inspection, but also accurately determine whether there is water pollution in the target water area. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 A schematic diagram of a flow chart of a water pollution determination method based on image recognition provided by an embodiment;

[0064] Figure 2 A schematic diagram of a ResNet network structure provided by an embodiment;

[0065] Figure 3 A schematic diagram of incident light irradiating a certain water area provided by an embodiment;

[0066] Figure 4 A schematic diagram of the hardware structure of a water pollution judgment system based on image recognition provided by an embodiment. DETAILED DESCRIPTION

[0067] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0068] It should be noted that the illustrations provided in this embodiment are only used to illustrate the basic concept of the present invention in a schematic manner. Therefore, the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0069] See also Figure 1 As shown, this embodiment provides a water pollution judgment method based on image recognition, and the method includes the following steps:

[0070] S100, extracting a video stream within a target time period from an image capture device; the image capture device is pre-set near a target water area, and the image capture device is used to capture the target water area and form a corresponding video stream. As an example, the image capture device in this embodiment may be a network camera, the target water area may be a lake or pond that needs to be tested for water pollution, and the target time period may be pre-customized, such as defining 0:00 to 6:00, 8:00 to 12:00, 14:00 to 18:00, 20:00 to 24:00, etc. every day; or directly defining 0:00 to 24:00 every day.

[0071] S200, dividing the extracted video stream into frames, and taking each single frame image after the division as the target image. As an example, this embodiment can use OpenCV to divide the extracted video stream into frames, and then obtain multiple single frame images.

[0072] S300, performing grayscale processing on the target image, and obtaining the grayscale value corresponding to each pixel in the target image. As an example, the present embodiment performs grayscale processing on the target image, and the process of obtaining the grayscale value corresponding to each pixel in the target image includes: obtaining the grayscale value of each pixel under the red channel, green channel and blue channel respectively; performing weighted calculation on the grayscale values ​​of the red channel, green channel and blue channel of each pixel to obtain the grayscale value of each pixel, and Gray(x, y)=0.30*R(x, y)+0.59*G(x, y)+0.11*B(x, y); wherein Gray(x, y) represents the grayscale value of the pixel with image coordinates (x, y); R(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the red channel; G(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the green channel; B(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the blue channel.

[0073] S400, compare the grayscale value corresponding to each pixel with the preset grayscale value, and select the pixel whose grayscale value is greater than or equal to the preset grayscale value, and record it as the target pixel. The preset grayscale value in this embodiment can be set according to actual conditions, and this embodiment does not limit the specific value.

[0074] S500, acquiring the image coordinates of each target pixel in the target image, and mapping a corresponding image area on the target image according to the acquired image coordinates;

[0075] S600, calculating the area of ​​the image region, comparing the calculated area result with the preset area value, and when the area of ​​the image region is greater than or equal to the preset area value, cutting out the image region from the target image as the image to be identified. The preset area value in this embodiment can be set according to actual conditions, and this embodiment does not limit the specific value. For example, for a lake, the preset area value can be 10% of the area value of the lake.

[0076] S700: Input the image to be recognized into a trained image recognition model, use the image recognition model to perform image recognition on the image to be recognized, and determine whether there is water pollution in the target water area according to the image recognition result.

[0077] According to the above records, in an exemplary embodiment, the training process of the image recognition model includes: obtaining multiple images containing water pollution and multiple images not containing water pollution as training images; labeling each water pollution training image with a pollutant category according to a preset pollutant category, and labeling each non-water pollution training image with a non-pollutant category, and after the labeling is completed, inputting all labeled training images into the ResNet network structure for classification training at the same time; calculating the true positive rate and false positive rate in the ResNet network structure at the current moment, and when the true positive rate is greater than the first target value, and the false positive rate is less than the second target value, the ResNext network structure and the corresponding network parameters at the current moment are combined and output to generate an image recognition model for identifying whether there is water pollution in the image to be identified. Figure 2 As shown, this embodiment provides a 34-layer ResNext network structure. Figure 2 In the figure, the solid connection part indicates that the channels are the same. For example, for the 2nd and 4th network structures, each network structure is a 3x3x64 feature map. Since the channels of these two network structures are the same, the calculation method used is H(x)=F(x)+x. The dotted connection part indicates that the channels are different. For example, for the 8th and 10th network structures, the 8th network structure represents a 3x3x64 feature map, and the 10th network structure represents a 3x3x128 feature map. Since the channels of these two network structures are different, the calculation method used is H(x)=F(x)+Wx, where W is a convolution operation used to adjust the x dimension.

[0078] As an example, when training an image recognition model, this embodiment can record a training image with water pollution as a positive example and a training image without water pollution as a negative example; if during the training process, the ResNext network structure classifies a training image with water pollution as a positive example, the classification result is recorded as a true positive example TP; if the ResNext network structure classifies a training image without water pollution as a positive example, the classification result is recorded as a false positive example FP; if the ResNext network structure classifies a training image without water pollution as a negative example, the classification result is recorded as a true negative example TN; if the ResNext network structure classifies a training image with water pollution as a negative example, the classification result is recorded as a false negative example FN. Calculate the false positive rate FPR value and the true positive rate TPR value at the current moment, and you have: TPR = TP / (TP+FN); FPR = FP / (TN+FP). When the FPR value is less than 0.00945 and the TPR value is greater than 0.9364, the ResNext network structure and the corresponding parameters at the current moment are combined and output to generate an image recognition model for identifying whether there is water pollution in the image to be identified. If the FPR value is greater than or equal to 0.00932, and / or the TPR value is less than 0.9467, then after adjusting the network parameters of the ResNext network structure, continue to use the original training image or re-enter a new training image for classification training. Among them, the network parameters of the ResNext network structure include the number of topological structure stacks and the size of the convolution kernel in each topological structure. That is, the first target value in this embodiment is 0.9467, and the second target value is 0.00932.

[0079] According to the above records, in an exemplary embodiment, the process of using the image recognition model to perform image recognition on the image to be recognized, and determining whether the target water area has water pollution according to the image recognition result includes: using the image recognition model to classify the pollutant category of the image to be recognized, and obtaining the classification probability of the image to be recognized being classified into each preset pollutant category; normalizing all classification probabilities, comparing the normalized probability value with the preset probability value, and judging whether there is a normalized probability value greater than or equal to the preset probability value; if there is, the pollutant category corresponding to the maximum value in the normalized probability value is used as the pollutant category of the image to be recognized, and judging whether the target water area has water pollution; if not, judging whether the image to be recognized and the target water area do not have water pollution. As an example, the preset pollutant category can be: water hyacinth pollution, duckweed pollution, etc. The specific pollutant category can be set according to the actual situation, and this embodiment does not make specific restrictions. Specifically, if the image A to be identified is classified and identified using the image recognition model, the probability value of the image A to be identified being classified as water hyacinth pollution is 0.86, and the probability value of the image A to be identified being classified as duckweed pollution is 0.24, then all classification probabilities are normalized; the normalized probability value of the image A to be identified being classified as water hyacinth pollution is 0.86÷(0.86+0.24)=0.782; the normalized probability value of the image A to be identified being classified as duckweed pollution is 0.24÷(0.86+0.24)=0.218. The pre-set probability value of 0.7 is obtained, from which it can be seen that the normalized probability value of the image A to be identified being classified as water hyacinth pollution is greater than or equal to the pre-set probability value of 0.7, indicating that the image A to be identified has water hyacinth pollution. Since the image A to be identified is cropped from the original image, and the original image is framed from the video stream shooting the target water area, it is equivalent to that the water hyacinth present in the target water area exceeds the preset area, indicating that the corresponding target water area may have too high phosphorus content.

[0080] In an exemplary embodiment, the method further includes: when water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an entry section and an exit section; if there is an entry section and an exit section, obtaining the pollution concentration data value in the water area of ​​the entry section, recorded as the entry section value concentration value; and obtaining the pollution concentration data value in the water area of ​​the exit section, recorded as the exit section value concentration value; calculating the difference between the entry section value concentration value and the exit section value concentration value, if the difference is greater than zero, determining that the entry pollution of the target water area is greater than the exit pollution; if the difference is less than zero, determining that the exit pollution of the target water area is greater than the entry pollution; if the difference is equal to zero, determining that the exit pollution of the target water area is the same as the entry pollution. Specifically, in this embodiment, for a river basin, if it has an entry section and an exit section, the river basin is regarded as a whole, and the monitoring concentration difference of the entry and exit sections is used to reflect the proportion of internal and external sources in the river basin. If the difference is a positive number, it indicates that the pollution generated inside the basin is greater than the water environment capacity of the basin, and the pollution situation in the basin is relatively poor; if the difference is a negative number, it indicates that the pollution generated inside the basin is less than the water environment capacity of the basin, and the pollution situation in the basin is relatively good. Therefore, this embodiment can be used to analyze the internal and external pollution of the target water area.

[0081] In another exemplary embodiment, the method further includes: when water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an upstream section and a downstream section; if there is an upstream section and a downstream section, obtaining the pollution concentration data value in the water area of ​​the upstream section, recorded as the upstream section value concentration value; and obtaining the pollution concentration data value in the water area of ​​the downstream section, recorded as the downstream section value concentration value; calculating the difference between the upstream section value concentration value and the downstream section value concentration value, if the difference is greater than zero, determining that the upstream pollution of the target water area is greater than the downstream pollution; if the difference is less than zero, determining that the downstream pollution of the target water area is greater than the upstream pollution; if the difference is equal to zero, determining that the downstream pollution of the target water area is the same as the upstream pollution. Specifically, in this embodiment, for a river basin, if it has an upstream section and a downstream section, the river basin is regarded as a whole, and the monitoring concentration difference of the upstream and downstream sections is used to reflect the proportion of internal and external sources in the river basin. If the difference is a positive number, it indicates that the pollution generated by the upstream river section is greater than the water environment capacity of the river section, and the pollution situation of the river section is worse; if the difference is a negative number, it indicates that the pollution generated by the upstream river section is less than the water environment capacity of the river section, and the pollution situation of the river section is better. Therefore, this embodiment can perform upstream and downstream pollution analysis on the target water area.

[0082] According to the above records, in an exemplary embodiment, when there is water pollution in the target water area, the method further includes: randomly obtaining a certain volume of water from the target water area as a target water sample; using a light source to generate an incident light; using the incident light to illuminate the target water sample and generate corresponding projection light; obtaining the optical path of the incident light in the target water sample and the light source intensity of the projection light, and calculating the turbidity of the target water sample in combination with the light source intensity of the incident light, where: Wherein, d is the turbidity of the target water sample; I0 is the light source intensity of the incident light; I is the light source intensity of the projected light; l is the optical path length of the incident light in the target water sample; and K is a constant. When water pollution occurs in the target water area, this embodiment obtains a certain volume of water from the target water area as the target water sample, and then detects the turbidity in the target water sample by a transmission method, and then determines the current pollution level of the target water area based on the turbidity detection result, thereby facilitating management personnel to degrade the corresponding impurity pollution concentration based on the pollution level of the target water area in the later stage. Among them, the schematic diagram of detecting the turbidity in the target water sample by the transmission method is shown in the figure. Figure 3 shown.

[0083] In summary, the present invention provides a water pollution judgment method based on image recognition, which first extracts a video stream within a target time period from an image capture device; then divides the extracted video stream into frames, and uses each single frame image after the frame division as a target image; then grayscales the target image, and obtains the grayscale value corresponding to each pixel in the target image; compares the grayscale value corresponding to each pixel with a preset grayscale value, and filters out pixels with grayscale values ​​greater than or equal to the preset grayscale value, which are recorded as target pixels; then obtains the image coordinates of each target pixel in the target image, and maps the corresponding image area on the target image according to the obtained image coordinates; calculates the area of ​​the image area, and compares the calculated area result with the preset area value, and when the area of ​​the image area is greater than or equal to the preset area value, cuts out the image area from the target image as an image to be recognized; finally, inputs the image to be recognized into a trained image recognition model, uses the image recognition model to perform image recognition on the image to be recognized, and determines whether there is water pollution in the target water area according to the image recognition result. It can be seen that the method can first obtain the video stream in the image shooting device set at the target water area, and then divide the video stream into frames to obtain multiple single-frame images, and then perform image recognition on each single-frame image, so as to determine whether there is water pollution in the target water area. Therefore, the method can determine whether there is water pollution in the target water area only by obtaining the video stream shot at the target water area. Not only does it not require manual inspection to actually check the target water area, but the method can also maintain all-day inspections, so that the water pollution judgment of the target water area can be realized by low-risk monitoring means. Therefore, the method can not only reduce the danger level of water pollution inspection, but also accurately determine whether there is water pollution in the target water area.

[0084] like Figure 4 As shown, the present invention also provides a water pollution judgment system based on image recognition, the system comprising:

[0085] The video stream acquisition module M10 is used to extract the video stream within the target time period from the image capture device; the image capture device is pre-set close to the target water area, and the image capture device is used to capture the target water area and form a corresponding video stream. As an example, the image capture device in this embodiment can be a network camera, the target water area can be a lake, pond, etc. that needs to be tested for water pollution, and the target time period can be customized in advance, such as defining 0:00 to 6:00, 8:00 to 12:00, 14:00 to 18:00, 20:00 to 24:00, etc. every day; 0:00 to 24:00 every day can also be directly defined.

[0086] The framing module M20 is used to frame the extracted video stream and use each single frame image after framing as the target image. As an example, this embodiment can use OpenCV to frame the extracted video stream and then obtain multiple single frame images.

[0087] The grayscale processing module M30 is used to perform grayscale processing on the target image and obtain the grayscale value corresponding to each pixel in the target image. As an example, the present embodiment performs grayscale processing on the target image, and the process of obtaining the grayscale value corresponding to each pixel in the target image includes: obtaining the grayscale value of each pixel under the red channel, green channel and blue channel respectively; performing weighted calculation on the grayscale values ​​of the red channel, green channel and blue channel of each pixel to obtain the grayscale value of each pixel, and Gray(x, y)=0.30*R(x, y)+0.59*G(x, y)+0.11*B(x, y); wherein Gray(x, y) represents the grayscale value of the pixel with image coordinates (x, y); R(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the red channel; G(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the green channel; B(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the blue channel.

[0088] The grayscale comparison module M40 is used to compare the grayscale value corresponding to each pixel with the preset grayscale value, and screen out the pixel whose grayscale value is greater than or equal to the preset grayscale value, and record it as the target pixel. Among them, the preset grayscale value in this embodiment can be set according to actual conditions, and this embodiment does not limit the specific value.

[0089] An image mapping module M50 is used to obtain the image coordinates of each target pixel point in the target image, and map a corresponding image area on the target image according to the obtained image coordinates;

[0090] The image cropping module M60 is used to calculate the area of ​​the image region, compare the calculated area result with the preset area value, and when the area of ​​the image region is greater than or equal to the preset area value, crop the image region from the target image as the image to be identified. The preset area value in this embodiment can be set according to actual conditions, and this embodiment does not limit the specific value. For example, for a lake, the preset area value can be 10% of the area value of the lake.

[0091] The water pollution identification module M70 is used to input the image to be identified into the trained image recognition model, use the image recognition model to perform image recognition on the image to be identified, and determine whether the target water area has water pollution according to the image recognition result.

[0092] According to the above records, in an exemplary embodiment, the training process of the image recognition model in the water pollution identification module M70 includes: obtaining multiple images containing water pollution and multiple images not containing water pollution as training images; labeling each water pollution training image with a pollutant category according to a preset pollutant category, and labeling each non-water pollution training image with a non-pollutant category, and after the labeling is completed, inputting all labeled training images into the ResNet network structure for classification training at the same time; calculating the true positive rate and false positive rate in the ResNet network structure at the current moment, and when the true positive rate is greater than the first target value and the false positive rate is less than the second target value, combining the ResNext network structure and the corresponding network parameters at the current moment for output, and generating an image recognition model for identifying whether there is water pollution in the image to be identified. Figure 2 As shown, this embodiment provides a 34-layer ResNext network structure. Figure 2 In the figure, the solid connection part indicates that the channels are the same. For example, for the 2nd and 4th network structures, each network structure is a 3x3x64 feature map. Since the channels of these two network structures are the same, the calculation method used is H(x)=F(x)+x. The dotted connection part indicates that the channels are different. For example, for the 8th and 10th network structures, the 8th network structure represents a 3x3x64 feature map, and the 10th network structure represents a 3x3x128 feature map. Since the channels of these two network structures are different, the calculation method used is H(x)=F(x)+Wx, where W is a convolution operation used to adjust the x dimension.

[0093] As an example, when training an image recognition model, this embodiment can record a training image with water pollution as a positive example and a training image without water pollution as a negative example; if during the training process, the ResNext network structure classifies a training image with water pollution as a positive example, the classification result is recorded as a true positive example TP; if the ResNext network structure classifies a training image without water pollution as a positive example, the classification result is recorded as a false positive example FP; if the ResNext network structure classifies a training image without water pollution as a negative example, the classification result is recorded as a true negative example TN; if the ResNext network structure classifies a training image with water pollution as a negative example, the classification result is recorded as a false negative example FN. Calculate the false positive rate FPR value and the true positive rate TPR value at the current moment, and you have: TPR = TP / (TP+FN); FPR = FP / (TN+FP). When the FPR value is less than 0.00945 and the TPR value is greater than 0.9364, the ResNext network structure and the corresponding parameters at the current moment are combined and output to generate an image recognition model for identifying whether there is water pollution in the image to be identified. If the FPR value is greater than or equal to 0.00932, and / or the TPR value is less than 0.9467, then after adjusting the network parameters of the ResNext network structure, continue to use the original training image or re-enter a new training image for classification training. Among them, the network parameters of the ResNext network structure include the number of topological structure stacks and the size of the convolution kernel in each topological structure. That is, the first target value in this embodiment is 0.9467, and the second target value is 0.00932.

[0094] According to the above records, in an exemplary embodiment, the water pollution identification module uses the image recognition model to perform image recognition on the image to be identified, and determines whether the target water area has water pollution according to the image recognition result. The process includes: using the image recognition model to classify the image to be identified into pollutant categories, and obtaining the classification probability of the image to be identified being classified into each preset pollutant category; normalizing all classification probabilities, comparing the normalized probability value with the preset probability value, and judging whether there is a normalized probability value greater than or equal to the preset probability value; if there is, the pollutant category corresponding to the maximum value in the normalized probability value is used as the pollutant category of the image to be identified, and it is determined that the target water area has water pollution; if not, it is determined that the image to be identified and the target water area do not have water pollution. As an example, the preset pollutant category can be: water hyacinth pollution, duckweed pollution, etc. The specific pollutant category can be set according to the actual situation, and this embodiment does not make specific restrictions. Specifically, if the image A to be identified is classified and identified using the image recognition model, the probability value of the image A to be identified being classified as water hyacinth pollution is 0.86, and the probability value of the image A to be identified being classified as duckweed pollution is 0.24, then all classification probabilities are normalized; the normalized probability value of the image A to be identified being classified as water hyacinth pollution is 0.86÷(0.86+0.24)=0.782; the normalized probability value of the image A to be identified being classified as duckweed pollution is 0.24÷(0.86+0.24)=0.218. The pre-set probability value of 0.7 is obtained, from which it can be seen that the normalized probability value of the image A to be identified being classified as water hyacinth pollution is greater than or equal to the pre-set probability value of 0.7, indicating that the image A to be identified is contaminated by water hyacinth. Since the image A to be identified is cropped from the original image, and the original image is framed from the video stream shooting the target water area, it is equivalent to that the water hyacinth present in the target water area exceeds the preset area, indicating that the corresponding target water area may have too high phosphorus content.

[0095] In an exemplary embodiment, the system further includes: when water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an entry section and an exit section; if there is an entry section and an exit section, obtaining the pollution concentration data value in the water area of ​​the entry section, recorded as the entry section value concentration value; and obtaining the pollution concentration data value in the water area of ​​the exit section, recorded as the exit section value concentration value; calculating the difference between the entry section value concentration value and the exit section value concentration value, if the difference is greater than zero, determining that the entry pollution of the target water area is greater than the exit pollution; if the difference is less than zero, determining that the exit pollution of the target water area is greater than the entry pollution; if the difference is equal to zero, determining that the exit pollution of the target water area is the same as the entry pollution. Specifically, in this embodiment, for a river basin, if it has an entry section and an exit section, the river basin is regarded as a whole, and the monitoring concentration difference of the entry and exit sections is used to reflect the proportion of internal and external sources in the river basin. If the difference is a positive number, it indicates that the pollution generated inside the basin is greater than the water environment capacity of the basin, and the pollution situation in the basin is relatively poor; if the difference is a negative number, it indicates that the pollution generated inside the basin is less than the water environment capacity of the basin, and the pollution situation in the basin is relatively good. Therefore, this embodiment can be used to analyze the internal and external pollution of the target water area.

[0096] In another exemplary embodiment, the system further includes: when water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an upstream section and a downstream section; if there is an upstream section and a downstream section, obtaining the pollution concentration data value in the water area of ​​the upstream section, recorded as the upstream section value concentration value; and obtaining the pollution concentration data value in the water area of ​​the downstream section, recorded as the downstream section value concentration value; calculating the difference between the upstream section value concentration value and the downstream section value concentration value, if the difference is greater than zero, determining that the upstream pollution of the target water area is greater than the downstream pollution; if the difference is less than zero, determining that the downstream pollution of the target water area is greater than the upstream pollution; if the difference is equal to zero, determining that the downstream pollution of the target water area is the same as the upstream pollution. Specifically, in this embodiment, for a river basin, if it has an upstream section and a downstream section, the river basin is regarded as a whole, and the difference in monitoring concentrations between the upstream and downstream sections is used to reflect the proportion of internal and external sources in the river basin. If the difference is a positive number, it indicates that the pollution generated by the upstream river section is greater than the water environment capacity of the river section, and the pollution situation of the river section is worse; if the difference is a negative number, it indicates that the pollution generated by the upstream river section is less than the water environment capacity of the river section, and the pollution situation of the river section is better. Therefore, this embodiment can perform upstream and downstream pollution analysis on the target water area.

[0097] According to the above records, in an exemplary embodiment, when there is water pollution in the target water area, the system further includes: randomly obtaining a certain volume of water from the target water area as a target water sample; using a light source to generate an incident light; using the incident light to illuminate the target water sample and generate corresponding projection light; obtaining the optical path of the incident light in the target water sample and the light source intensity of the projection light, and calculating the turbidity of the target water sample in combination with the light source intensity of the incident light, there are: Wherein, d is the turbidity of the target water sample; I0 is the light source intensity of the incident light; I is the light source intensity of the projected light; l is the optical path length of the incident light in the target water sample; and K is a constant. When water pollution occurs in the target water area, this embodiment obtains a certain volume of water from the target water area as the target water sample, and then detects the turbidity in the target water sample by a transmission method, and then determines the current pollution level of the target water area based on the turbidity detection result, thereby facilitating management personnel to degrade the corresponding impurity pollution concentration based on the pollution level of the target water area in the later stage. Among them, the schematic diagram of detecting the turbidity in the target water sample by the transmission method is shown in the figure. Figure 3 shown.

[0098] In summary, the present invention provides a water pollution judgment system based on image recognition, which first extracts a video stream within a target time period from an image shooting device; then divides the extracted video stream into frames, and uses each single frame image after the frame division as a target image; then grayscales the target image, and obtains the grayscale value corresponding to each pixel in the target image; compares the grayscale value corresponding to each pixel with a preset grayscale value, and filters out pixels with grayscale values ​​greater than or equal to the preset grayscale value, which are recorded as target pixels; then obtains the image coordinates of each target pixel in the target image, and maps the corresponding image area on the target image according to the obtained image coordinates; calculates the area of ​​the image area, and compares the calculated area result with the preset area value, and when the area of ​​the image area is greater than or equal to the preset area value, cuts out the image area from the target image as an image to be recognized; finally, inputs the image to be recognized into a trained image recognition model, uses the image recognition model to perform image recognition on the image to be recognized, and determines whether there is water pollution in the target water area according to the image recognition result. It can be seen that the system can first obtain the video stream in the image shooting device set at the target water area, and then divide the video stream into frames to obtain multiple single-frame images, and then perform image recognition on each single-frame image to determine whether there is water pollution in the target water area. Therefore, the system can determine whether there is water pollution in the target water area only by obtaining the video stream shot at the target water area. Not only does it not require manual inspection of the target water area, but the system can also maintain all-day inspections, so that the water pollution judgment of the target water area can be realized by low-risk monitoring means. Therefore, the system can not only reduce the risk of water pollution inspections, but also accurately determine whether there is water pollution in the target water area.

[0099] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.

Claims

1. A water pollution judgment method based on image recognition, characterized in that: The method comprises the following steps: Extracting a video stream within a target time period from an image capture device; the image capture device is pre-set close to a target water area, and the image capture device is used to capture the target water area and form a corresponding video stream; Divide the extracted video stream into frames, and use each single frame image after framing as the target image; Performing grayscale processing on the target image and obtaining the grayscale value corresponding to each pixel in the target image; Compare the grayscale value corresponding to each pixel with a preset grayscale value, and select pixel points whose grayscale values ​​are greater than or equal to the preset grayscale value as target pixel points; Obtaining the image coordinates of each target pixel in the target image, and mapping a corresponding image area on the target image according to the obtained image coordinates; Calculating the area of ​​the image region, comparing the calculated area result with a preset area value, and when the area of ​​the image region is greater than or equal to the preset area value, cutting out the image region from the target image as an image to be recognized; The image to be identified is input into a trained image recognition model, the image recognition model is used to perform image recognition on the image to be identified, and whether the target water area is polluted is determined according to the image recognition result.

2. The water pollution judgment method based on image recognition according to claim 1 is characterized in that: The training process of the image recognition model includes: Acquire multiple images containing water pollution and multiple images not containing water pollution as training images; Label each water pollution training image with the pollutant category according to the preset pollutant category, and label each non-water pollution training image with the non-pollutant category. After labeling, all labeled training images are simultaneously input into the ResNet network structure for classification training; The true positive rate and false positive rate in the ResNet network structure at the current moment are calculated, and when the true positive rate is greater than the first target value and the false positive rate is less than the second target value, the ResNext network structure and the corresponding network parameters at the current moment are combined and output to generate an image recognition model for identifying whether water pollution exists in the image to be identified.

3. The water pollution judgment method based on image recognition according to claim 2 is characterized in that: The process of performing image recognition on the image to be recognized by using the image recognition model and determining whether the target water area has water pollution according to the image recognition result includes: Using the image recognition model to classify the image to be recognized into pollutant categories, and obtaining the classification probability of the image to be recognized being classified into each preset pollutant category; All classification probabilities are normalized, and the normalized probability values ​​are compared with the preset probability values ​​to determine whether there is a normalized probability value greater than or equal to the preset probability value; if so, the pollutant category corresponding to the maximum value in the normalized probability value is used as the pollutant category of the image to be identified, and it is determined that water pollution exists in the target water area; if not, it is determined that there is no water pollution in the image to be identified and the target water area.

4. The water pollution judgment method based on image recognition according to claim 1 or 3, characterized in that: The method further comprises: When water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an entry section and an exit section; If there is an entry section and an exit section, the pollution concentration data value in the water area of ​​the entry section is obtained and recorded as the entry section value concentration value; and the pollution concentration data value in the water area of ​​the exit section is obtained and recorded as the exit section value concentration value The difference between the inbound section concentration value and the outbound section concentration value is calculated. If the difference is greater than zero, it is determined that the inbound pollution of the target water area is greater than the outbound pollution; if the difference is less than zero, it is determined that the outbound pollution of the target water area is greater than the inbound pollution; if the difference is equal to zero, it is determined that the outbound pollution of the target water area is the same as the inbound pollution.

5. The water pollution judgment method based on image recognition according to claim 1 or 3, characterized in that: The method further comprises: When water pollution exists in the target water area, determining whether the water area corresponding to the image to be identified has an upstream section and a downstream section; If there is an upstream section and a downstream section, the pollution concentration data value in the water area of ​​the upstream section is obtained, which is recorded as the upstream section value concentration value; and the pollution concentration data value in the water area of ​​the downstream section is obtained, which is recorded as the downstream section value concentration value The difference between the concentration value of the upstream section value and the concentration value of the downstream section value is calculated. If the difference is greater than zero, it is determined that the upstream pollution of the target water area is greater than the downstream pollution; if the difference is less than zero, it is determined that the downstream pollution of the target water area is greater than the upstream pollution; if the difference is equal to zero, it is determined that the downstream pollution of the target water area is the same as the upstream pollution.

6. The water pollution judgment method based on image recognition according to claim 1 is characterized in that: The process of graying the target image and obtaining the gray value corresponding to each pixel in the target image includes: Get the grayscale value of each pixel in the red channel, green channel and blue channel respectively; Perform weighted calculation on the grayscale values ​​of the red channel, green channel, and blue channel of each pixel to obtain the grayscale value of each pixel: Gray(x,y)=0.30*R(x,y)+0.59*G(x,y)+0.11*B(x,y); In the formula, Gray(x, y) represents the gray value of the pixel with image coordinates (x, y); R(x, y) represents the gray value of the pixel with image coordinates (x, y) under the red channel; G(x, y) represents the gray value of the pixel with image coordinates (x, y) under the green channel; B(x, y) represents the grayscale value of the pixel with image coordinates (x, y) under the blue channel.

7. The water pollution determination method based on image recognition according to claim 1 or 3, characterized in that: When water pollution exists in the target water area, the method further comprises: Using a light source to generate an incident light; Utilizing the incident light to illuminate a target water sample and generate corresponding projection light; wherein the target water sample is a water sample of a certain volume randomly obtained in advance from the target water area; The optical path of the incident light in the target water sample and the light source intensity of the projected light are obtained, and the turbidity of the target water sample is calculated in combination with the light source intensity of the incident light, as follows: Wherein, d is the turbidity of the target water sample; I0 is the light source intensity of the incident light; I is the light source intensity of the projection light; l is the optical path length of the incident light in the target water sample; K is a constant.

8. A water pollution judgment system based on image recognition, characterized in that: The system comprises: A video stream acquisition module, used to extract a video stream within a target time period from an image capture device; the image capture device is pre-set close to a target water area, and the image capture device is used to capture the target water area and form a corresponding video stream; A framing module is used to frame the extracted video stream and use each single frame image after framing as a target image; A grayscale processing module, used to perform grayscale processing on the target image and obtain the grayscale value corresponding to each pixel in the target image; A grayscale comparison module is used to compare the grayscale value corresponding to each pixel with a preset grayscale value, and filter out the pixel points whose grayscale value is greater than or equal to the preset grayscale value and record them as target pixel points; An image mapping module, used to obtain the image coordinates of each target pixel point in the target image, and map a corresponding image area on the target image according to the obtained image coordinates; An image cropping module, used to calculate the area of ​​the image region, compare the calculated area result with a preset area value, and when the area of ​​the image region is greater than or equal to the preset area value, crop the image region from the target image as an image to be recognized; The water pollution identification module is used to input the image to be identified into the trained image recognition model, use the image recognition model to perform image recognition on the image to be identified, and determine whether the target water area has water pollution according to the image recognition result.

9. The water pollution judgment system based on image recognition according to claim 8 is characterized in that: The training process of the image recognition model in the water pollution recognition module includes: Acquire multiple images containing water pollution and multiple images not containing water pollution as training images; Label each water pollution training image with the pollutant category according to the preset pollutant category, and label each non-water pollution training image with the non-pollutant category. After labeling, all labeled training images are simultaneously input into the ResNet network structure for classification training; The true positive rate and false positive rate in the ResNet network structure at the current moment are calculated, and when the true positive rate is greater than the first target value and the false positive rate is less than the second target value, the ResNext network structure and the corresponding network parameters at the current moment are combined and output to generate an image recognition model for identifying whether water pollution exists in the image to be identified.

10. The water pollution judgment system based on image recognition according to claim 9 is characterized in that: The process in which the water pollution identification module uses the image recognition model to perform image recognition on the image to be recognized and determines whether the target water area has water pollution according to the image recognition result includes: Using the image recognition model to classify the image to be recognized into pollutant categories, and obtaining the classification probability of the image to be recognized being classified into each preset pollutant category; All classification probabilities are normalized, and the normalized probability values ​​are compared with the preset probability values ​​to determine whether there is a normalized probability value greater than or equal to the preset probability value; if so, the pollutant category corresponding to the maximum value in the normalized probability value is used as the pollutant category of the image to be identified, and it is determined that water pollution exists in the target water area; if not, it is determined that there is no water pollution in the image to be identified and the target water area.

Citation Information

Patent Citations

  • Model-based water pollution risk assessment method and apparatus, and computer device

    CN111950942A

  • Water pollution monitoring and early warning system and method based on image recognition

    CN112329583A

  • Image classification method and device, terminal equipment and storage medium

    CN113269257A

  • Visual measurement method for area of floating object on water surface of river channel

    CN113807238A

  • Medical image recognition method, model training method, and computer device

    US20210042564A1