Water level acquisition method, device and electronic equipment based on image recognition

Through the water ruler detection model based on image recognition, the water ruler image is identified and the water level data is calculated, and the existing water level monitoring solution is solved, and simple installation, real-time detection and high-precision water level monitoring are realized.

CN114543930BActive Publication Date: 2025-04-25HARBIN INST OF TECH SHENZHEN GRADUATE SCHOOL
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210149821.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-18
Publication Date
2025-04-25
Estimated Expiration
2042-02-18

AI Technical Summary

Technical Problem

The existing water level monitoring solution is complex in operation, high labor costs, troublesome in installation of sensors, and uncertain working status.

Method used

The water ruler detection model recognizes the target water ruler area of ​​the water ruler image, determines the pixel distance, calculates the second-order derivative by dividing the molecular area, obtains the water ruler scale information, and calculates the water level data.

Benefits of technology

It realizes simple camera installation and real-time detection of water level, reduces labor costs and improves the accuracy of water level data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114543930B_ABST
    Figure CN114543930B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a water level acquisition method, device and electronic device based on image recognition, wherein the method includes: identifying the target water gauge area of ​​the water gauge image through a water gauge detection model; determining the pixel distance between each adjacent row of pixel vectors in the target water gauge area; determining the upper boundary line of the water gauge according to the maximum pixel distance among the pixel distances; dividing the target water gauge area into multiple sub-areas, calculating the second-order derivative of each sub-area through a gradient function, and determining the lower boundary line of the water gauge according to each second-order derivative; obtaining the water gauge scale information of the target water gauge area; determining the water level data according to the upper boundary line of the water gauge, the lower boundary line of the water gauge and the water gauge scale information. In this way, the water level data can be calculated using the water gauge scale information, and there is no need to predetermine the correspondence between the pixel coordinates and the real coordinates. The camera is simple to install, simple to operate, low in labor cost, and high in water level data accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image recognition technology, and in particular to a water level acquisition method, device and electronic equipment based on image recognition. Background Art

[0002] In water conservancy monitoring technology, the water level of rivers and lakes is often monitored. The water level generally refers to the height of the water surface relative to the selected base surface, which is the most intuitive indicator of the water body's water conditions. There are two traditional water level detection schemes. One is to rely on manual detection to obtain the water level. The labor cost required for manual monitoring is high and real-time detection is not possible. The other is to obtain other characteristics of the water body through sensors to calculate the water level value. In this scheme, the sensor installation is more troublesome, and due to the complex natural environment, the working state of the sensor is uncertain, and the working condition of the sensor needs to be checked frequently.

[0003] The existing image-based water level monitoring scheme generally includes the following process: capture an image through a camera, detect the water gauge area in the image, then accurately cut the water gauge area to obtain a water gauge object, and then calculate the water level based on the correspondence between the pixel coordinates of the image and the real coordinates and the accurately cut water gauge object. This method requires the correspondence between the pixel coordinates and the real coordinates to be determined in advance, has strict requirements on the installation position of the camera, and the camera installation operation is complicated and requires a lot of manpower. In summary, the existing water level monitoring scheme has the problems of complex operation and high labor cost. Summary of the invention

[0004] In order to solve the above technical problems, the embodiments of the present application provide a water level acquisition method, device and electronic device based on image recognition.

[0005] In a first aspect, an embodiment of the present application provides a water level acquisition method based on image recognition, the method comprising:

[0006] Identify the target water gauge area of ​​the water gauge image through the water gauge detection model;

[0007] Determine the pixel distance between each two adjacent rows of pixel vectors in the target water gauge area;

[0008] Determine the upper boundary line of the water ruler according to the maximum pixel distance among the pixel distances;

[0009] Divide the target water gauge area into multiple sub-areas, calculate the second-order derivative of each sub-area by a gradient function, and determine the lower boundary line of the water gauge according to each second-order derivative;

[0010] Acquire the water gauge scale information of the target water gauge area;

[0011] The water level data is determined according to the water gauge upper boundary line, the water gauge lower boundary line and the water gauge scale information.

[0012] In a second aspect, an embodiment of the present application provides a water level acquisition device based on image recognition, the device comprising:

[0013] A recognition module, used for identifying a target water gauge area of ​​a water gauge image through a water gauge detection model;

[0014] A first determination module is used to determine the pixel distance between two adjacent rows of pixel vectors in the target water gauge area;

[0015] The second determination module is used to determine the upper boundary line of the water ruler according to the maximum pixel distance among the pixel distances;

[0016] A calculation module, used for dividing the target water gauge area into a plurality of sub-areas, calculating the second-order derivative of each sub-area by a gradient function, and determining the lower boundary line of the water gauge according to each second-order derivative;

[0017] An acquisition module, used for acquiring water gauge scale information of the target water gauge area;

[0018] The third determination module is used to determine the water level data according to the upper boundary line of the water ruler, the lower boundary line of the water ruler and the water ruler scale information.

[0019] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is run by the processor, the water level acquisition method based on image recognition provided in the first aspect is executed.

[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when running on a processor, executes the water level acquisition method based on image recognition provided in the first aspect.

[0021] The water level acquisition method, device and electronic device based on image recognition provided by the present application above identify the target water gauge area of ​​the water gauge image through the water gauge detection model; determine the pixel distance between each two adjacent rows of pixel vectors in the target water gauge area; determine the upper boundary line of the water gauge according to the maximum pixel distance among the pixel distances; divide the target water gauge area into multiple sub-areas, calculate the second-order derivative of each sub-area through the gradient function, and determine the lower boundary line of the water gauge according to each second-order derivative; obtain the water gauge scale information of the target water gauge area; determine the water level data according to the upper boundary line of the water gauge, the lower boundary line of the water gauge and the water gauge scale information. The water level acquisition solution based on image recognition provided by this embodiment has a simple camera installation, can detect water gauge images in real time, can calculate water level data using water gauge scale information, does not need to predetermine the correspondence between pixel coordinates and real coordinates, and the camera is simple to install, simple to operate, low in labor cost, and high in water level data accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present application and should not be regarded as limiting the scope of protection of the present application. In each of the drawings, similar components are numbered similarly.

[0023] Figure 1 A schematic diagram of a process of a water level acquisition method based on image recognition provided by an embodiment of the present application is shown;

[0024] Figure 2 A schematic diagram of a water gauge image provided by an embodiment of the present application is shown;

[0025] Figure 3 A partial schematic diagram of a target water gauge area provided in an embodiment of the present application is shown;

[0026] Figure 4 Another partial schematic diagram of the target water gauge area provided in an embodiment of the present application is shown;

[0027] Figure 5 A schematic diagram showing a sample water gauge image provided by an embodiment of the present application is shown;

[0028] Figure 6 Another structural schematic diagram of the water level acquisition device based on image recognition provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0030] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0031] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present application, are intended only to indicate specific features, numbers, steps, operations, elements, components, or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations of the foregoing items.

[0032] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0033] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.

[0034] Example 1

[0035] The embodiment of the present disclosure provides a water level acquisition method based on image recognition.

[0036] For details, see Figure 1 ,The water level acquisition method based on image recognition includes:

[0037] Step S101, identifying a target water gauge area of ​​a water gauge image through a water gauge detection model.

[0038] In one embodiment, the water gauge detection model can be a model trained according to the target detection model. For example, the target detection model can be a yolov5 target detection model. A camera is installed in a water area such as a lake or a river where water level monitoring is required. A water gauge is set in the water area. The camera is used to capture video, and a frame is extracted from the video as a water gauge image.

[0039] See also Figure 2 , Figure 2The figure shows a schematic diagram of a water gauge image. The water gauge image 20 includes a water gauge area, a water body area, and a background area. The water gauge image 20 can also display information such as the shooting time and shooting location, which is not limited here. For example, the water gauge image 20 can be input into a water gauge detection model, and the target water gauge area 201 can be identified through the water gauge detection model. Subsequently, the extracted water gauge image can be continuously input into the water gauge detection model for subsequent identification to ensure the visibility of the water gauge area in the current water gauge image. If the water gauge area is not detected, wait for the next frame of water gauge image input to continue to identify the water gauge area.

[0040] In this way, the approximate range of the water gauge in the water gauge image can be determined through the water gauge detection model, which facilitates the precise positioning and identification of the boundary of the water gauge.

[0041] Step S102, determining the pixel distance between each two adjacent rows of pixel vectors in the target water gauge area.

[0042] It should be noted that a pixel point has three components (r, g, b), so a row of pixel vectors can be regarded as all the pixel points in the same row of the target water level area. The pixel point is regarded as a point in three-dimensional space. The pixel distance between pixel point A (r1, g1, b1) and pixel point B (r2, g2, b2) can be calculated according to the following formula 1:

[0043] Formula 1: ;

[0044] For example, the pixel distance between pixel (1, 0, 0) and pixel (0, 1, 0) is .

[0045] The pixel distance between two adjacent rows of pixel vectors is obtained by calculating the pixel distance between two pixel points at corresponding positions of the two adjacent rows of pixel vectors and then summing them.

[0046] In one embodiment, step S102 includes the following steps:

[0047] According to the pixel positions in each row of pixel vectors, the pixel pairs between two adjacent rows of pixel vectors are determined, and the pixel distance between each pixel pair is calculated;

[0048] The sum of the pixel distances of all pixel point pairs in two adjacent rows of pixel vectors is determined as the pixel distance between the two adjacent rows of pixel vectors.

[0049] For example, if the first row of pixel vectors and the second row of pixel vectors are two adjacent rows of pixel vectors, the first row of pixel vectors includes pixel A, pixel B, and pixel C in sequence, and the second row of pixel vectors includes pixel D, pixel E, and pixel F in sequence, pixel A and pixel D are pixel pairs with the same sorting number, pixel B and pixel E are pixel pairs with the same sorting number, and pixel C and pixel F are pixel pairs with the same sorting number, the first pixel distance between pixel A and pixel D is calculated, the second pixel distance between pixel B and pixel E is calculated, and the third pixel distance between pixel C and pixel F is calculated, and the sum of the first pixel distance, the second pixel distance, and the third pixel distance is used as the pixel distance between the first row of pixel vectors and the second row of pixel vectors. It should be noted that the number of pixels in the first row of pixel vectors and the second row of pixel vectors can be multiple, which is determined according to actual conditions and is not limited here.

[0050] Step S103, determining the upper boundary line of the water ruler according to the maximum pixel distance among the pixel distances.

[0051] It should be noted that, because the similarity between the background row pixel vectors and the background row pixel vectors in the background area is high, and the similarity between the water gauge row pixel vectors and the water gauge row pixel vectors in the water gauge area is high, the pixel distance between the two adjacent rows of pixel vectors is relatively small, while the similarity between the background area and the water gauge area is low, and the pixel distance between the background row pixel vectors in the background area and the water gauge row pixel vectors in the water gauge area is relatively large. For example, please refer to Figure 3 , Figure 3 The target water-level area 30 is a partial schematic diagram. The target water-level area 30 includes a background area 31 , a water-level area 32 , and an upper water-level boundary line 33 between the background area 31 and the water-level area 32 .

[0052] In one embodiment, step S103 includes the following steps:

[0053] Determine two rows of target pixel vectors corresponding to the maximum pixel distance among the pixel distances;

[0054] The upper boundary line of the water ruler is determined according to the two rows of target pixel vectors.

[0055] Please refer again Figure 3If the pixel distance between the last row of pixel vectors in the background area 31 and the first row of pixel vectors in the water gauge area 32 is determined to be the maximum value among the pixel distances between all two adjacent rows of pixel vectors, then the middle line between the last row of pixel vectors in the background area 31 and the first row of pixel vectors in the water gauge area 32 is determined to be the upper boundary line of the water gauge, or the last row of pixel vectors in the background area 31 is determined to be the boundary line of the water gauge, or the first row of pixel vectors in the water gauge area 32 is determined to be the upper boundary line of the water gauge. The background area here is the background object at the top of the water gauge, for example, the background area can be a weed area.

[0056] Step S104, dividing the target water gauge area into a plurality of sub-areas, calculating the second-order derivative of each sub-area by a gradient function, and determining the lower boundary line of the water gauge according to each second-order derivative.

[0057] In one embodiment, the target water gauge area can be divided into multiple sub-areas according to needs. The purpose of dividing the sub-areas is to be able to calculate the derivatives in the x and y directions in the water gauge area and obtain mutation information in the two directions. If the sub-area is too small, that is, the number of sub-areas is large, the y-direction derivative contains less implicit change information; if the sub-area is too large, that is, the number of sub-areas is small, the result accuracy is poor. Generally, 3 or 5 rows of pixels in the water gauge area image are taken as a sub-area. The step function can be a Laplace operator or a Tenengrad gradient function using a Sobel operator. There is a packaged Laplace operator in the opencv library, and the packaged Laplace operator can be directly called from the opencv library.

[0058] See also Figure 4 , Figure 4 The target water level area 40 is a partial schematic diagram. The target water level area 40 includes a water level area 41 and a water body area 42 , and a water level lower boundary line 43 between the water level area 41 and the water body area 42 .

[0059] In one embodiment, determining the lower boundary line of the water gauge according to each second-order derivative in step S104 includes the following steps:

[0060] Determine a first second-order derivative that is less than or equal to a preset derivative threshold value among the second-order derivatives, determine the sub-region corresponding to the first second-order derivative as a water body sub-region, determine a second second-order derivative that is greater than the preset derivative threshold value among the second-order derivatives, and determine the sub-region corresponding to the second second-order derivative as a water ruler sub-region;

[0061] The water gauge lower boundary line is determined according to the water body sub-area and the water gauge sub-area.

[0062] It should be noted that the Laplace derivative value of an image is often associated with the sudden change of the image. For the water body area, the image changes smoothly and the water body area has a high similarity, so the second-order derivative value is small; for the water gauge area, due to the existence of the scale symbol, there will be areas of sharp changes, so the second-order derivative value is large. The preset derivative threshold can be obtained based on experience or experimental tests and adjusted according to specific circumstances. In one embodiment, according to the actual water gauge image, the boundary direction of the water body sub-area and the water gauge sub-area can be determined as the lower boundary line of the water gauge.

[0063] Step S105, obtaining the water gauge scale information of the target water gauge area.

[0064] In this embodiment, the water ruler scale information includes the scale symbol of the water ruler, the reference scale pixel size, and the actual scale size, wherein the reference scale pixel size can be understood as the number of pixel rows occupied by the scale symbol in the target water ruler area, and the actual scale size represents the scale size of the water ruler in the physical world, for example, the actual scale size is 1 scale symbol corresponding to 5 centimeters. Figure 2 The scale symbols in the "There are two scale symbols, each representing 5 cm.

[0065] In one embodiment, step S105 includes the following steps:

[0066] Performing image recognition on the target water gauge area to obtain a plurality of initial scale symbols;

[0067] Determine the reference scale pixel size according to the number of pixel rows of the plurality of initial scale symbols;

[0068] Obtaining a pixel length between two adjacent initial scale symbols, and determining a target pixel length that is greater than the reference scale pixel size among the pixel lengths, and adding a first correction scale symbol between two initial scale symbols corresponding to the target pixel length according to the reference scale pixel size;

[0069] Completing the local scale mark where the lower boundary line of the water gauge is located to obtain a second revised scale mark;

[0070] The actual scale size is obtained, and the first correction scale symbol, the second correction scale symbol, the reference scale pixel size, each of the initial scale symbols and the actual scale size are determined as the water ruler scale information.

[0071] Specifically, multiple initial scale symbols can be multiple "E" and " "Two initial scale symbols, the detected "E" and " "The two initial scale symbols may be the scale symbols that can be seen clearly in the water gauge image. For some blurred and damaged scale symbols, they need to be supplemented to obtain the complete scale information of the entire water gauge area. The average value of the number of pixel rows of the multiple initial scale symbols can be used as the reference scale pixel size of the detected scale symbol. For example, if the number of pixel rows of the first initial scale symbol, the second initial scale symbol, and the third initial scale symbol is 20 rows, 21 rows, and 22 rows, the reference scale pixel size is 21 rows. Assume that the reference scale The pixel size is s. Since the scale symbols are distributed on a straight line, it can be considered that there is a scale symbol every s on the straight line. When the pixel length of two adjacent initial scale symbols is greater than the reference scale pixel size s, it can be considered that there is a detection omission, and it is necessary to add the first correction scale symbol between the two initial scale symbols to complete it. When the initial scale symbols are all above the water level line and do not intersect with the water level line, the scale symbols are continued to be completed downward until a scale symbol intersects with the water level line to obtain the second correction scale symbol.

[0072] Step S106, determining water level data according to the water gauge upper boundary line, the water gauge lower boundary line and the water gauge scale information.

[0073] In one embodiment, step S106 includes the following steps:

[0074] Determining a middle pixel row of the second revised scale symbol;

[0075] Determine a first water level according to the last pixel row of the lower boundary line of the water ruler, the middle pixel row, the reference scale pixel size, and the actual scale size;

[0076] Determine the number of complete scale symbols according to the first revised scale symbol, the second revised scale symbol, and each initial scale symbol;

[0077] Subtract 1 from the number of complete scale symbols to obtain a difference, and determine a second water level according to the difference and the actual scale size;

[0078] The sum of the first water level and the second water level is determined as the water level data.

[0079] In one embodiment, the second correction scale symbol is "E" or " " scale symbol, determine the middle pixel row of the second revised scale symbol, and then calculate the length of the second revised measurable symbol where the lower boundary line of the water ruler is located above the water surface based on the middle pixel row. The first water level is the length of the second revised measurable symbol where the lower boundary line of the water ruler is located above the water surface, and the second water level is the length corresponding to all the completed scale symbols exposed above the water surface. The first water level and the second water level are added together to obtain the water level data.

[0080] In addition, water level data can also be calculated by establishing a coordinate system. Specifically, let the water level line coordinate be y, and the center coordinate of the scale symbol be {x i |i=1,2,…,n}, where n is the number of scale symbols after the scale symbols are completed in the water gauge area, the coordinate origin is the top coordinate of the water gauge, the pixel size of a single reference scale is s, and the actual scale size is k. The length of the water gauge above the water can be calculated according to the following formula 2;

[0081] Formula 2: L = (n-1) × k + ((y-(x n -s / 2)) / s)×k;

[0082] Where n is the number of complete scale symbols after completion, k represents the actual scale size, y is the water level coordinate, x is the n Indicates the center coordinates of the last complete scale symbol after completion, s indicates the pixel size of the base scale. (n-1)×k indicates the first water level above the water surface corresponding to the first n-1 complete scale symbols, ((y-(x n -s / 2)) / s)×k represents the second water level of the last local scale symbol above the water surface, and the sum of the first water level and the second water level is the water level data of the water gauge above the water surface. For example, the actual scale size can be 5cm.

[0083] In this embodiment, the water gauge area and water gauge scale information of the water gauge image are first detected, and the water level line coordinates and the water gauge top coordinates are obtained by accurately positioning the water gauge area. The scale value above the water level line is judged by the scale coordinates of the water gauge and the water level line coordinates, thereby calculating the water level data. There is no need to consider the correspondence between the pixel coordinates and the real coordinates, and there is no strict regulation on the distance between the camera and the water gauge, which improves the applicability of the system. Water level monitoring based on image recognition reduces the difficulty and cost of installation and ensures the real-time monitoring. The water gauge area and the background area are distinguished by the pixel distance between two rows of pixel vectors, and the water gauge area and the water body area are distinguished by the high-order derivative value. The segmentation accuracy of different areas is high. Taking into account the incompleteness of the water gauge scale, all the scale information is inferred using the existing scale information, the water gauge scale is completed, and the accuracy of the water gauge scale information is improved. The number of scales of the water gauge part on the water surface is calculated by the water level line coordinates and the scale coordinates, thereby determining the water level value and improving the accuracy of the water level data.

[0084] In one embodiment, the training step of the water gauge detection model comprises the following steps:

[0085] Acquire multiple initial training water gauge images, detect the water gauge area, background area and water body area in each initial training water gauge image, generate a correction area according to the background area and the water body area, and cover the correction area on the water gauge area of ​​each initial training water gauge image to obtain a correction image;

[0086] Adjust the water gauge area according to a preset adjustment multiple to obtain a corrected water gauge area;

[0087] Generate a sample water gauge image according to the corrected water gauge area and the corrected image;

[0088] The sample water gauge image is input into the target detection model for training to obtain the water gauge detection model.

[0089] In one embodiment, the target detection model can adopt the yolov5 target detection model, and the target water gauge area is detected based on the yolov5 target detection model. In the existing technology, the size and position of the water gauge area in the water gauge image in the training data set are fixed. In order to increase the generalization ability of the model for water gauge detection, the data is augmented before training. The specific method is to randomly generate water gauge areas in the water gauge image, so that the water gauge image used for training the model includes water gauge areas at different positions and with different sizes. In addition, according to the shape feature of the water gauge, which is generally a rectangular shape, the anchor point of the yolov5 target detection model is changed to a rectangular shape.

[0090] It should be noted that the anchor point is a priori box in the target detection process of the target detection model, which represents the approximate shape of the detected target. The existing anchor point is obtained by clustering the coco dataset, which is universal and suitable for general detection tasks. In this embodiment, the anchor point is modified to a rectangle based on the task of detecting the water level, so that the regression of the priori box is more accurate during detection.

[0091] For example, the process of acquiring a sample water scale image may include the following steps: performing a translation operation on areas other than the water scale area in the initial training water scale image to cover the water scale area in the initial training water scale image to obtain a corrected image, and randomly generating multiple corrected water scale areas of 0.4-1 times the water scale area on the corrected image to obtain a sample water scale image.

[0092] See also Figure 5 , Figure 5 The figure shows a schematic diagram of a sample water scale image. The sample water scale image 50 includes a first water scale area 51, a second water scale area 52, a third water scale area 53, a fourth water scale area 54 and a fifth water scale area 55. The first water scale area 51, the second water scale area 52, the third water scale area 53, the fourth water scale area 54 and the fifth water scale area 55 have different sizes and positions, and the water scale areas do not overlap.

[0093] In this way, the sample water scale image has multiple water scale areas of different sizes, different positions, and non-overlapping. Using the sample water scale image to train the target detection model can improve the generalization ability of the water scale detection model, and ensure that the water scale detection model can detect water scale areas of different positions and sizes in the water scale image to be detected, so as to adapt to various forms of water scale areas in the water scale image. For example, if the camera position is changed, the camera shooting angle and position will change, resulting in changes in the position and size of the water scale area in the water scale image.

[0094] The water level acquisition method based on image recognition provided in this embodiment identifies the target water gauge area of ​​the water gauge image through the water gauge detection model; determines the pixel distance between each two adjacent rows of pixel vectors in the target water gauge area; determines the upper boundary line of the water gauge according to the maximum pixel distance among the pixel distances; divides the target water gauge area into multiple sub-areas, calculates the second-order derivative of each sub-area through the gradient function, and determines the lower boundary line of the water gauge according to each second-order derivative; obtains the water gauge scale information of the target water gauge area; and determines the water level data according to the upper boundary line of the water gauge, the lower boundary line of the water gauge and the water gauge scale information. The water level acquisition solution based on image recognition provided in this embodiment has a simple camera installation, can detect the water gauge image in real time, can calculate the water level data using the water gauge scale information, does not need to predetermine the correspondence between the pixel coordinates and the real coordinates, and the camera is simple to install, simple to operate, low in labor cost, and high in water level data accuracy.

[0095] Example 2

[0096] In addition, an embodiment of the present disclosure provides a water level acquisition device based on image recognition.

[0097] Specifically, Figure 6 As shown, the water level acquisition device 600 based on image recognition includes:

[0098] Recognition module 601, used for recognizing the target water gauge area of ​​the water gauge image through the water gauge detection model;

[0099] A first determination module 602 is used to determine the pixel distance between two adjacent rows of pixel vectors in the target water gauge area;

[0100] The second determination module 603 is used to determine the upper boundary line of the water ruler according to the maximum pixel distance among the pixel distances;

[0101] A calculation module 604 is used to divide the target water gauge area into multiple sub-areas, calculate the second-order derivative of each sub-area by a gradient function, and determine the lower boundary line of the water gauge according to each second-order derivative;

[0102] An acquisition module 605 is used to acquire the water gauge scale information of the target water gauge area;

[0103] The third determination module 606 is used to determine the water level data according to the upper boundary line of the water ruler, the lower boundary line of the water ruler and the water ruler scale information.

[0104] In one embodiment, the first determining module 602 is further configured to determine pixel pairs between two adjacent rows of pixel vectors according to pixel positions in each row of pixel vectors, and calculate pixel distances of each pixel pair;

[0105] The sum of the pixel distances of all pixel point pairs in two adjacent rows of pixel vectors is determined as the pixel distance between the two adjacent rows of pixel vectors.

[0106] In one embodiment, the second determination module 603 is further used to determine two rows of target pixel vectors corresponding to the maximum pixel distance among the pixel distances;

[0107] The upper boundary line of the water ruler is determined according to the two rows of target pixel vectors.

[0108] In one embodiment, the calculation module 604 is further used to determine a first second-order derivative of each of the second-order derivatives that is less than or equal to a preset derivative threshold, determine the sub-region corresponding to the first second-order derivative as a water body sub-region, determine a second second-order derivative of each of the second-order derivatives that is greater than a preset derivative threshold, and determine the sub-region corresponding to the second second-order derivative as a water ruler sub-region;

[0109] The water gauge lower boundary line is determined according to the water body sub-area and the water gauge sub-area.

[0110] In one embodiment, the acquisition module 6045 is further used to perform image recognition on the target water gauge area to obtain a plurality of initial scale symbols;

[0111] Determine the reference scale pixel size according to the number of pixel rows of the plurality of initial scale symbols;

[0112] Obtaining a pixel length between two adjacent initial scale symbols, and determining a target pixel length that is greater than the reference scale pixel size among the pixel lengths, and adding a first correction scale symbol between two initial scale symbols corresponding to the target pixel length according to the reference scale pixel size;

[0113] Completing the local scale mark where the lower boundary line of the water gauge is located to obtain a second revised scale mark;

[0114] The actual scale size is obtained, and the first correction scale symbol, the second correction scale symbol, the reference scale pixel size, each of the initial scale symbols and the actual scale size are determined as the water ruler scale information.

[0115] In one embodiment, the third determination module 606 is further configured to determine a middle pixel row of the second modified scale symbol;

[0116] Determine a first water level according to the last pixel row of the lower boundary line of the water ruler, the middle pixel row, the reference scale pixel size, and the actual scale size;

[0117] Determine the number of complete scale symbols according to the first revised scale symbol, the second revised scale symbol, and each initial scale symbol;

[0118] Subtract 1 from the number of complete scale symbols to obtain a difference, and determine a second water level according to the difference and the actual scale size;

[0119] The sum of the first water level and the second water level is determined as the water level data.

[0120] In one embodiment, the water level acquisition device 600 based on image recognition further includes:

[0121] A training module is used to obtain a plurality of initial training water gauge images, detect a water gauge area, a background area and a water body area in each initial training water gauge image, generate a correction area according to the background area and the water body area, and cover the correction area on the water gauge area of ​​each initial training water gauge image to obtain a correction image;

[0122] The water gauge area is adjusted according to a preset adjustment factor to obtain a corrected water gauge area;

[0123] Generate a sample water gauge image according to the corrected water gauge area and the corrected image;

[0124] The sample water gauge image is input into the target detection model for training to obtain the water gauge detection model.

[0125] The water level acquisition device 600 based on image recognition provided in this embodiment can implement the water level acquisition method based on image recognition provided in Embodiment 1, and will not be described again here to avoid repetition.

[0126] The water level acquisition device based on image recognition provided in this embodiment identifies the target water gauge area of ​​the water gauge image through the water gauge detection model; determines the pixel distance between each two adjacent rows of pixel vectors in the target water gauge area; determines the upper boundary line of the water gauge according to the maximum pixel distance among the pixel distances; divides the target water gauge area into multiple sub-areas, calculates the second-order derivative of each sub-area through the gradient function, and determines the lower boundary line of the water gauge according to each second-order derivative; obtains the water gauge scale information of the target water gauge area; and determines the water level data according to the upper boundary line of the water gauge, the lower boundary line of the water gauge and the water gauge scale information. The water level acquisition solution based on image recognition provided in this embodiment has a simple camera installation, can detect the water gauge image in real time, can calculate the water level data using the water gauge scale information, does not need to predetermine the correspondence between the pixel coordinates and the real coordinates, and the camera is simple to install, simple to operate, low in labor cost, and high in water level data accuracy.

[0127] Example 3

[0128] In addition, an embodiment of the present disclosure provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program runs on the processor, the water level acquisition method based on image recognition provided in the above-mentioned embodiment 1 is executed.

[0129] The electronic device provided in this embodiment can implement the water level acquisition method based on image recognition provided in Embodiment 1, and will not be described again here to avoid repetition.

[0130] Example 4

[0131] The disclosed embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run on a processor, the water level acquisition method based on image recognition provided in Embodiment 1 is executed.

[0132] In this embodiment, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0133] The computer-readable storage medium provided in this embodiment can implement the water level acquisition method based on image recognition provided in Embodiment 1, and will not be described again here to avoid repetition.

[0134] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.

[0135] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0136] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A water level acquisition method based on image recognition, characterized in that: The method comprises: Identify the target water gauge area of ​​the water gauge image through the water gauge detection model; Determine the pixel distance between each two adjacent rows of pixel vectors in the target water gauge area; Determine the upper boundary line of the water ruler according to the maximum pixel distance among the pixel distances; Divide the target water gauge area into multiple sub-areas, calculate the second-order derivative of each sub-area by a gradient function, and determine the lower boundary line of the water gauge according to each second-order derivative; Acquire the water gauge scale information of the target water gauge area; Determine water level data according to the water ruler upper boundary line, the water ruler lower boundary line and the water ruler scale information; The step of determining the lower boundary line of the water gauge according to each second-order derivative comprises: Determine a first second-order derivative that is less than or equal to a preset derivative threshold value among the second-order derivatives, determine the sub-region corresponding to the first second-order derivative as a water body sub-region, determine a second second-order derivative that is greater than the preset derivative threshold value among the second-order derivatives, and determine the sub-region corresponding to the second second-order derivative as a water ruler sub-region; The water gauge lower boundary line is determined according to the water body sub-area and the water gauge sub-area.

2. The method according to claim 1, characterized in that The step of determining the pixel distance between each two adjacent rows of pixel vectors in the target water gauge area comprises: According to the pixel positions in each row of pixel vectors, the pixel pairs between two adjacent rows of pixel vectors are determined, and the pixel distance between each pixel pair is calculated; The sum of the pixel distances of all pixel point pairs in two adjacent rows of pixel vectors is determined as the pixel distance between the two adjacent rows of pixel vectors.

3. The method according to claim 1, characterized in that: The step of determining the upper boundary line of the water ruler according to the maximum pixel distance among the pixel distances comprises: Determine two rows of target pixel vectors corresponding to the maximum pixel distance among the pixel distances; The upper boundary line of the water ruler is determined according to the two rows of target pixel vectors.

4. The water level acquisition method based on image recognition according to claim 1, characterized in that: The step of obtaining the water gauge scale information of the target water gauge area comprises: Performing image recognition on the target water gauge area to obtain a plurality of initial scale symbols; Determine the reference scale pixel size according to the number of pixel rows of the plurality of initial scale symbols; Obtaining a pixel length between two adjacent initial scale symbols, and determining a target pixel length that is greater than the reference scale pixel size among the pixel lengths, and adding a first correction scale symbol between two initial scale symbols corresponding to the target pixel length according to the reference scale pixel size; Completing the local scale mark where the lower boundary line of the water gauge is located to obtain a second revised scale mark; The actual scale size is obtained, and the first correction scale symbol, the second correction scale symbol, the reference scale pixel size, each of the initial scale symbols and the actual scale size are determined as the water ruler scale information.

5. The method according to claim 4, characterized in that The step of determining the water level data according to the upper boundary line of the water ruler, the lower boundary line of the water ruler and the water ruler scale information comprises: Determining a middle pixel row of the second revised scale symbol; Determine a first water level according to the last pixel row of the lower boundary line of the water ruler, the middle pixel row, the reference scale pixel size, and the actual scale size; Determine the number of complete scale symbols according to the first revised scale symbol, the second revised scale symbol, and each initial scale symbol; Subtract 1 from the number of complete scale symbols to obtain a difference, and determine a second water level according to the difference and the actual scale size; The sum of the first water level and the second water level is determined as the water level data.

6. The water level acquisition method based on image recognition according to claim 1, characterized in that: The training steps of the water gauge detection model include: Acquire multiple initial training water gauge images, detect the water gauge area, background area and water body area in each initial training water gauge image, generate a correction area according to the background area and the water body area, and cover the correction area on the water gauge area of ​​each initial training water gauge image to obtain a correction image; The water gauge area is adjusted according to a preset adjustment factor to obtain a corrected water gauge area; Generate a sample water gauge image according to the corrected water gauge area and the corrected image; The sample water gauge image is input into the target detection model for training to obtain the water gauge detection model.

7. A water level acquisition device based on image recognition, characterized in that: The device comprises: A recognition module, used for identifying a target water gauge area of ​​a water gauge image through a water gauge detection model; A first determination module is used to determine the pixel distance between two adjacent rows of pixel vectors in the target water gauge area; The second determination module is used to determine the upper boundary line of the water ruler according to the maximum pixel distance among the pixel distances; A calculation module, used for dividing the target water gauge area into a plurality of sub-areas, calculating the second-order derivative of each sub-area by a gradient function, and determining the lower boundary line of the water gauge according to each second-order derivative; An acquisition module, used for acquiring water gauge scale information of the target water gauge area; A third determination module is used to determine the water level data according to the upper boundary line of the water ruler, the lower boundary line of the water ruler and the scale information of the water ruler; The calculation module is further used to determine a first second-order derivative of each of the second-order derivatives that is less than or equal to a preset derivative threshold, determine the sub-region corresponding to the first second-order derivative as a water body sub-region, determine a second second-order derivative of each of the second-order derivatives that is greater than the preset derivative threshold, and determine the sub-region corresponding to the second second-order derivative as a water ruler sub-region; The water gauge lower boundary line is determined according to the water body sub-area and the water gauge sub-area.

8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program, the method for obtaining a water level based on image recognition according to any one of claims 1 to 6 is executed.

9. A computer-readable storage medium, characterized in that: The computer program is stored therein, and when the computer program is run on a processor, the water level acquisition method based on image recognition as claimed in any one of claims 1 to 6 is executed.

Citation Information

Patent Citations

  • A water gauge reading detection method based on video

    CN109376740A