A water level recognition method and system based on pre-trained SAM large model

By directly segmenting the water ruler monitoring image using a pre-trained SAM large model, the problem of high resource consumption in the existing technology is solved, efficient and accurate water level recognition is achieved, and cost is reduced.

CN119380284BActive Publication Date: 2025-03-18INST OF MOUNTAIN HAZARDS & ENVIRONMENT CHINESE ACADEMY OF SCI
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411949112.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-03-18
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

Existing water level recognition technology based on SAM large models requires the construction of training data sets and customized models, which are costly and costly.

Method used

Using pre-trained SAM large model, it uses its zero-sample migration capability to segment directly on the water ruler monitoring image without additional training or data set construction.

Benefits of technology

It achieves efficient and accurate water level recognition, reduces R&D and operation costs, and can run on computers without GPUs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380284B_ABST
    Figure CN119380284B_ABST
Patent Text Reader

Abstract

The present invention relates to a water level recognition method and system based on a pre-trained SAM large model. An open source pre-trained SAM large model is obtained and deployed to obtain a model operation instance; the water gauge monitoring image collected by the shooting device is manually calibrated and interpreted to establish a pixel position water level reading table and obtain image segmentation prompt information; the monitoring image and the image segmentation prompt information are then input into the model operation instance for segmentation to obtain the water gauge body pixels; finally, the water gauge body pixels are compared with the pixel position water level reading table to obtain the water level reading. The present invention uses an open source pre-trained SAM large model, does not require additional construction of a training data set, does not require a customized model, does not require self-training, and can be deployed in a computer system without a GPU. The present invention is suitable for application scenarios where a fixed camera position monitors a fixed water gauge, and can be quickly put into operation through simple manual calibration and interpretation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image segmentation and water level measurement, and in particular to a water level recognition method and system based on a pre-trained SAM large model. Background Art

[0002] In the context of global climate change, climate change has led to an accelerated rate of glacier melting. Especially in high-altitude areas, this phenomenon has a direct impact on water bodies such as plateau lakes and rivers. As glaciers retreat, meltwater flows into lakes and rivers, which may initially cause the water levels of these water bodies to rise. However, as glaciers further decrease, the water levels of these water bodies will face the risk of falling. This change not only affects the stability of the ecosystem, but also threatens the lives of residents and socio-economic activities that rely on these water bodies.

[0003] Accurate water level measurement provides key data support for analytical research, enabling scientists and decision makers to monitor and assess water resource conditions in a timely manner. By analyzing the trend of water level changes, people can better understand the impact of climate change on water resources, formulate scientific and reasonable management and response measures, and effectively reduce the impact of extreme weather events on human life and the natural environment. Therefore, the development of efficient and accurate water level measurement technology, especially in high-altitude glacier change active areas, is of great practical significance.

[0004] As a traditional water level measurement tool, the scale water level meter is widely used and deployed in various occasions because of its simple structure, low cost, easy maintenance and good durability. However, it has disadvantages such as inconvenient manual reading and data transmission. People have tried various methods to overcome these shortcomings. One of them is to continuously obtain images of the water gauge area through a shooting device, and then use image segmentation technology to measure the water level. This method combines computer vision technology and artificial intelligence technology to improve the automation of water level recognition and monitoring.

[0005] The SAM (Segment Anything Model) large model is a new AI basic model proposed by Meta. It is used in general scenarios and can achieve efficient and accurate segmentation of any image through some prompt information (such as points, boxes, masks, and text). Due to the large scale of model parameters (its ViT-H image encoder has 632 million parameters) and the huge volume of the SA-1B dataset for training the model (containing more than 1 billion masks and 11 million images), the training process of SAM requires a lot of computing power, electricity, and time. In view of this, Meta officially released its pre-trained models such as ViT-B, ViT-L, and ViT-H. In open source repositories such as Hugging Face and GitHub, there are also SAM large models pre-trained by third parties. In actual applications, users can directly use these pre-trained SAM large models, thus avoiding the tedious training process and resource consumption.

[0006] There have been some explorations into water level identification technology based on the SAM large model.

[0007] Patent application number CN202311219761.1 discloses a water level monitoring method based on the SAM image segmentation model. First, the water gauge image is spatially corrected and distorted, and then the SAM image segmentation model for water gauge image segmentation is established based on the visual self-attention mechanism. Finally, the water gauge area segmentation result is obtained and the water level is obtained through the linear relationship between the mask and the true water level.

[0008] Patent application CN202410842014.1 discloses a water level recognition method based on the SAM large model. First, water level monitoring images in various water environments are collected and labeled to construct a water level image dataset. Then, a water level segmentation model based on the SAM network is constructed and trained. Finally, the water level image to be measured is input into the trained water level segmentation model to obtain the water level mask result and the current water level is obtained by fitting the equation.

[0009] Both of the above solutions use customized and improved models based on SAM. Customized models require building training data sets and retraining the models, which requires high manpower, time, computing power, and energy costs.

[0010] The applicant noted that SAM has a strong zero-sample transfer capability: that is, SAM can segment objects that have never appeared in the training data without additional training. The water gauge body is usually a cylinder, a cuboid, or an inclined plane, and appears as a simple rectangle or a rectangle-like shape in the monitoring image. The applicant found in engineering practice that with the support of SAM's strong zero-sample transfer capability, the accurate segmentation of the water gauge monitoring image can be completed directly using the pre-trained model, without the need to perform spatial correction and distortion correction on the monitoring image, without the need to build additional training data sets, without the need to customize the model, and without the need for self-training. Summary of the invention

[0011] The technical problem to be solved by the present application is to provide a water level recognition method and system based on a pre-trained SAM large model, which has the characteristics of no need for training, low cost, high efficiency and accuracy.

[0012] In a first aspect, an embodiment provides a water level recognition method based on a pre-trained SAM large model, comprising:

[0013] Obtain and deploy the open source pre-trained SAM large model to obtain a model running instance;

[0014] After fixing the shooting device, shoot the water gauge to continuously obtain monitoring images;

[0015] Manually calibrate the water gauge on the monitoring image and establish a water level reading table at the pixel position;

[0016] Manually interpret the water gauge on the monitoring image to obtain image segmentation prompt information;

[0017] Input the monitoring image and image segmentation prompt information into the model running instance to perform image segmentation and obtain the water gauge body pixels;

[0018] The water level reading is obtained by comparing the pixels of the water ruler body with the water level reading table of the pixel position.

[0019] In one embodiment, the water gauge is manually calibrated on the monitoring image to establish a water level reading table at a pixel position, specifically:

[0020] Select the surveillance image where the water gauge is fully exposed or the water level is the lowest;

[0021] Draw the longitudinal center line of the water gauge on the selected monitoring image, and find the intersection of the center line and each horizontal scale line as the representative point pixel;

[0022] Record the X-axis and Y-axis coordinates of each representative point pixel on the monitoring image;

[0023] Record the actual water level reading of the scale line where each representative point pixel is located;

[0024] Establish a correspondence table between the pixel coordinates of each representative point and the actual water level readings.

[0025] In one embodiment, the water gauge is manually interpreted on the monitoring image to obtain image segmentation prompt information, specifically:

[0026] Select one or more pixel points from the scale line of the top area of ​​the water ruler in any monitoring image as positive prompt points;

[0027] Select one or more pixel points as positive prompt points from the periphery of the scale line in the top area of ​​the water ruler in any monitoring image and limited to the water ruler body;

[0028] Select one or more pixel points from the left and right sides of the water gauge in any monitoring image as negative prompt points;

[0029] From the monitoring image where the water gauge is fully exposed or the water level line is the lowest, one or more pixel points below the water gauge or below the lowest water level line are selected as negative prompt points;

[0030] Arrange the X-axis and Y-axis coordinates of each positive prompt point and negative prompt point in the monitoring image in sequence into an array points, and its mathematical expression is: ,in , is the total number of positive prompt points and negative prompt points, The X-axis and Y-axis coordinates of each positive prompt point and negative prompt point;

[0031] The labels of each positive prompt point and negative prompt point are arranged in sequence into an array labels, and its mathematical expression is: ,in , is the total number of positive prompt points and negative prompt points, is the label value of each positive and negative cue point, the label value of the positive cue point is 1, and the label value of the negative cue point is 0;

[0032] Image segmentation hint information consists of points and labels.

[0033] In one embodiment, the monitoring image and the image segmentation prompt information are input into the model running instance for image segmentation to obtain the water gauge body pixels, specifically:

[0034] Input the monitoring image and image segmentation prompt information into the model running instance to obtain the segmentation result;

[0035] The mask with the highest quality score is selected from the segmentation results as the water ruler body pixel.

[0036] In one embodiment, the water level reading is obtained by comparing the water ruler body pixels with the water level reading table of the pixel position, specifically:

[0037] In the pixel position water level reading table, select all pixel positions located within the water gauge body pixels and obtain their water level readings;

[0038] From all the water level readings obtained, select the minimum value as the current water level reading.

[0039] In a second aspect, an embodiment provides a water level recognition system based on a pre-trained SAM large model, including:

[0040] A water gauge module (01) is fixed in the water body and is used to indicate the water level;

[0041] A shooting module (02) is used to continuously obtain monitoring images of the water gauge area;

[0042] A reading calibration module (03) is used to manually interpret the monitoring image and establish a pixel position water level reading table;

[0043] A prompt information acquisition module (04) is used to manually calibrate the monitoring image to obtain image segmentation prompt information;

[0044] An image segmentation module (05) is used to obtain and deploy an open source pre-trained SAM large model, obtain a model running instance, and segment the monitoring image according to the image segmentation prompt information to obtain water gauge body pixels;

[0045] The water level determination module (06) is used to compare the water level gauge body pixels with the water level reading table at the pixel position to obtain the water level reading.

[0046] The beneficial effects of the present invention are:

[0047] Based on the open source pre-trained SAM large model, the zero-sample migration capability is fully utilized. There is no need to build additional training data sets, customize models, or train by yourself. The accurate segmentation of the water gauge can be completed directly, reducing R&D costs. The entire method and system can use a computer without a GPU, reducing operating costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 This is a structural block diagram of a water level recognition system based on a pre-trained SAM large model according to an embodiment of the present application;

[0049] Figure 2 This is a flow chart of a water level recognition method based on a pre-trained SAM large model according to an embodiment of the present application;

[0050] Figure 3is a schematic diagram of step S30 in an embodiment of the present application, wherein: Figure 3 (a) is a monitoring image of the water gauge fully exposed, obtained by the camera module. Figure 3 (b) is a schematic diagram of the water gauge scale lines and center line. Figure 3 (c) is a schematic diagram of the pixel positions of representative points;

[0051] Figure 4 is a schematic diagram of step S50 in an embodiment of the present application, wherein: Figure 4 (a) is a schematic diagram of the distribution of prompt points in the image segmentation prompt information. Figure 4 (b) is a schematic diagram of the relative position relationship between each prompt point in the image segmentation prompt information and the water gauge in the monitoring image;

[0052] Figure 5 is a schematic diagram of step S60 in an embodiment of the present application, wherein: Figure 5 (a) is the water level monitoring image obtained by the camera module. Figure 5 (b) is the water gauge body pixel segmented by the model running example. Figure 5 Middle (c) is a schematic diagram of the relative position relationship between the water gauge contour line and some pixel positions in the pixel position water level reading table.

[0053] Note: Figure 3 , Figure 4 , Figure 5 The numbers on the edge of each sub-image are the X-axis and Y-axis coordinate values ​​of the pixel, and the origin is in the upper left corner; the labels in the figure: L101~L105 are water ruler scale lines, L200 is the water ruler center line, L301~L305 are representative point pixels, L400 is the water ruler contour line, L410 is the water ruler body pixel, L500 is the positive prompt point, and L600 is the negative prompt point. DETAILED DESCRIPTION

[0054] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to the description in the specification and the general technical knowledge in the art.

[0055] In addition, the features, operations or characteristics described in the specification can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.

[0056] The serial numbers assigned to the components in this document, such as "01", "02", etc., are only used to distinguish the objects described and do not have any order or technical meaning.

[0057] To facilitate the description of the inventive concept of the present application, the water level recognition technology is briefly described below.

[0058] Common water level recognition technologies can be divided into two categories: contact and non-contact. Contact water level recognition technology requires the device to directly contact the water surface and obtain water level information through physical means, such as the float method, which uses the float to measure as the water level rises or falls; non-contact water level recognition technology uses remote measurement and calculation without direct contact with the water surface, such as image recognition methods that identify water level gauge readings or water surface changes based on images taken by monitoring equipment and processing algorithms (such as deep learning models).

[0059] Water level recognition based on monitoring images is a hot topic in current research. Its processing algorithms include traditional methods such as edge detection, image filtering, image transformation, etc., as well as various models based on deep learning, such as YOLO (You Only LookOnce) and SAM (Segment Anything Model).

[0060] SAM is widely used in water level identification due to its powerful functions. The usual method is to customize, train and improve the SAM model. Patent application CN202410842014.1 discloses a water level identification method based on the SAM large model, which requires collecting monitoring images in various water environments, annotating and making training sets, and then building and training models, and then using the trained models for reasoning and calculation. The whole process requires a lot of human resources and computing resources, and consumes a lot of electricity and time.

[0061] The applicant found in the research that directly using Meta or a third-party pre-trained model, without making a training set, and without customizing and training the model, can also achieve very good results. At the same time, the applicant also found that if there is no training task for a customized model, all calculations can be performed on the CPU, thereby reducing the system hardware complexity and cost. On a computer based on Intel(R) Xeon(R) Silver 4210R CPU @ 2.40GHz, the applicant can use the SAM large model to complete the reasoning segmentation of a 2560x1440 pixel surveillance image and calculate the water level in 8 seconds, which has high practical value.

[0062] Therefore, the applicant proposed a water level recognition method and system based on a pre-trained SAM large model. The steps are: obtain and deploy an open source pre-trained SAM large model to obtain a model running instance; manually calibrate and interpret the water gauge monitoring image collected by the shooting device to establish a pixel position water level reading table and obtain image segmentation prompt information; then input the monitoring image and image segmentation prompt information into the model running instance for segmentation to obtain the water gauge body pixels; finally, compare the water gauge body pixels with the pixel position water level reading table to obtain the water level reading. This application scheme uses an open source pre-trained SAM large model, which does not require additional construction of training data sets, does not require customized models, and does not require self-training. It can be deployed in a computer system without a GPU. This application scheme is suitable for application scenarios where a fixed camera position monitors a fixed water gauge. It can be quickly put into operation through simple manual calibration and interpretation.

[0063] In order to more clearly explain the present application scheme, the water level recognition system based on the pre-trained SAM large model is first described below.

[0064] In one embodiment of the present application, a water level recognition system based on a pre-trained SAM large model is provided. Figure 1 , including a water gauge module 01, a shooting module 02, a reading calibration module 03, a prompt information acquisition module 04, an image segmentation module 05 and a water level determination module 06.

[0065] The water gauge module 01 is configured as a photographic object and is installed in or beside a body of water in accordance with government and industry standards.

[0066] The shooting module 02 is configured to continuously obtain monitoring images, and continuously shoot the water level module 01 from a fixed position with a fixed focal length, a fixed pitch angle, a fixed yaw angle, and a fixed roll angle.

[0067] In one embodiment, the camera module 02 is fixed at a height directly opposite to the water level scale to obtain a clear field of view and angle.

[0068] In one embodiment, the roll angle of the camera module 02 is configured to be 90 degrees, that is, the long side of the photosensitive plane of the camera module corresponds to the height direction of the water gauge, so as to fully utilize the pixel resolution capability of the camera module.

[0069] The reading calibration module 03 is configured to calibrate the water level reading corresponding to the pixel coordinates in the monitoring image obtained by the shooting module 02. Since the relative position relationship between the shooting module 02 and the water gauge module 01 is fixed and the shooting angle is fixed, the position of the water gauge scale line in the monitoring image is fixed. The system administrator can establish the corresponding relationship between the pixel coordinates and the water level reading through the reading calibration module 03.

[0070] The prompt information acquisition module 04 is configured to obtain prompt information for helping the SAM model to segment the image from the monitoring image acquired by the shooting module 02. Since the relative position relationship between the shooting module 02 and the water gauge module 01 is fixed and the shooting angle is fixed, the position of the water gauge body in the monitoring image is fixed. The system administrator can specify some pixels or pixel areas that belong to or do not belong to the water gauge body as prompt information for image segmentation through the prompt information acquisition module 04.

[0071] The image segmentation module 05 is configured to deploy the open source pre-trained SAM large model, obtain the model running instance and segment the monitoring image obtained by the shooting module 02 according to the image segmentation prompt information generated by the prompt information acquisition module 04 to obtain the water level gauge body pixels.

[0072] The water level determination module 06 is configured to obtain the water level reading according to the water gauge body pixels generated by the image segmentation module 05 and the pixel position water level reading table generated by the calibration module 03 .

[0073] In one embodiment of the present application, a water level recognition method based on a pre-trained SAM large model is provided. The steps are as follows: Figure 2 ,include:

[0074] Step S10, obtain and deploy the open source pre-trained SAM large model to obtain a model running instance.

[0075] In Meta's official repository or the public storage server where it is hosted, you can find the code files, pre-trained weight files and related resources of the SAM large model. Meta provides three pre-trained models:

[0076] ViT-B: A smaller model based on Vision Transformer, fast and suitable for lightweight tasks;

[0077] ViT-L: medium-sized model, balancing performance and speed;

[0078] ViT-H: The largest model, with higher computational requirements, provides the highest segmentation accuracy.

[0079] In July 2024, Meta released the second version of the SAM large model, SAM2. In terms of image segmentation, SAM2 is six times faster and more accurate than SAM. SAM2 provides several pre-trained models such as sam2_hiera_tiny, sam2_hiera_small, and sam2_hiera_large.

[0080] In one embodiment, any of the aforementioned pre-trained models, such as the ViT-H model, is obtained and deployed.

[0081] The reasoning of the deep learning model can be deployed in a computer system with a GPU to achieve faster computing speed, or it can be deployed in a computer system without a GPU to reduce hardware costs. According to the applicant's actual test evaluation, a computer system without a GPU can complete image segmentation and calculate the current water level using the CPU within a few seconds, which can meet the real-time acquisition requirements of most water level monitoring and identification.

[0082] In one embodiment, the pre-trained SAM large model is deployed in a computer system without a GPU.

[0083] Step S20, fix the shooting device to shoot the water gauge and continuously obtain monitoring images.

[0084] The design and installation of the water gauge should comply with the water level observation standards formulated by the relevant country or industry. The camera takes panoramic and continuous monitoring images of the water gauge at a fixed position.

[0085] Step S30, manually calibrate the water gauge on the monitoring image and establish a pixel position water level reading table.

[0086] In one embodiment, the intersection of each water level scale line on the water ruler and the center line of the water ruler is selected as a representative pixel position, and a pixel position water level reading table is established. The process is as follows:

[0087] Select the surveillance image where the water gauge is fully exposed or the water level is the lowest;

[0088] Draw the longitudinal center line of the water gauge on the selected monitoring image, and find the intersection of the center line and each horizontal scale line as the representative point pixel;

[0089] Record the X-axis and Y-axis coordinates of each representative point pixel on the monitoring image;

[0090] Record the actual water level reading of the scale line where each representative point pixel is located;

[0091] Establish a correspondence table between the pixel coordinates of each representative point and the actual water level readings.

[0092] For a clear explanation and understanding of this process, please refer to Figure 3 . Figure 3 (a) is a real surveillance image, in which the water gauge is fully exposed. Each scale line in the water gauge corresponds to a water level reading. Figure 3 (b) Schematic diagram showing five of the scale lines, labeled L101, L102, L103, L104, and L105 (water level readings are 0, 1.0, 3.7, 3.8, and 6.1, respectively). Figure 3 (b) also shows the center line of the water gauge as labeled L200. The intersection of each water level scale line and the center line is a representative pixel location point. Figure 3 (c) shows Figure 3 The representative point pixels corresponding to the five scale lines in (b) are shown as labels L301, L302, L303, L304, and L305. The X-axis and Y-axis coordinates of all representative point pixels in the monitoring image are obtained, for example Figure 3 The X-axis and Y-axis coordinates of the five representative point pixels shown by labels L301, L302, L303, L304, and L305 in (c) are (228, 1115), (230, 960), (237, 482), (239, 446), and (250, 28), respectively. In this embodiment, the pixel position water level reading table is composed of the corresponding relationship between the X-axis and Y-axis coordinates of the representative point pixels of all scale lines and their water level readings, as shown in the following table:

[0093] (X-axis, Y-axis coordinates) Water level reading (228,1115) 0 … … (230,960) 1.0 … … (237,482) 3.7 (239,446) 3.8 … … (250,28) 6.1 … …

[0094] In the above table, the ellipsis indicates the corresponding relationship between some other pixel positions and their water level readings. The 5 specific pixel positions in the above table are only for illustration and should not be understood as only 5 pixel positions.

[0095] Note: The water level readings in the monitoring images used in this application are all in decimeters.

[0096] In one embodiment, sparser or denser pixel positions are selected according to the accuracy requirements of water level identification and monitoring, and a pixel position water level reading table is established.

[0097] Step S40 manually interprets the water gauge on the monitoring image to obtain image segmentation prompt information.

[0098] The image segmentation prompt information SAM can be used to know whether certain areas belong to the segmentation object or not, thereby improving the accuracy of image segmentation.

[0099] In one embodiment, the image segmentation hint information consists of positive hint points and negative hint points:

[0100] Select one or more pixel points from the scale line of the top area of ​​the water ruler in any monitoring image as positive prompt points;

[0101] Select one or more pixel points as positive prompt points from the periphery of the scale line in the top area of ​​the water ruler in any monitoring image and limited to the water ruler body;

[0102] Select one or more pixel points from the left and right sides of the water gauge body in any monitoring image as negative prompt points;

[0103] From the monitoring image where the water gauge is fully exposed or the water level line is the lowest, one or more pixel points below the water gauge or below the lowest water level line are selected as negative prompt points;

[0104] Arrange the X-axis and Y-axis coordinates of each positive prompt point and negative prompt point in the monitoring image in sequence into an array points, and its mathematical expression is: ,in , is the total number of positive prompt points and negative prompt points, The X-axis and Y-axis coordinates of each positive prompt point and negative prompt point;

[0105] The labels of each positive prompt point and negative prompt point are arranged in sequence into an array labels, and its mathematical expression is: ,in , is the total number of positive prompt points and negative prompt points, is the label value of each positive and negative cue point, the label value of the positive cue point is 1, and the label value of the negative cue point is 0;

[0106] Image segmentation hint information consists of points and labels.

[0107] To more intuitively understand the spatial distribution of each prompt point in the image segmentation prompt information, please refer to Figure 4 . Figure 4 (a) is a plurality of prompt points obtained after manual interpretation in an embodiment of the present application, wherein the positive prompt point is shown as label L500, and their coordinates are (230, 35) and (290, 35), respectively, and the negative prompt point is shown as label L600, and their coordinates are (50, 35), (450, 35), (50, 1200), (250, 1200) and (450, 1200), respectively. The positive prompt point can prompt the model, and the position belongs to the water gauge body, and the negative prompt point can prompt the model, and the position does not belong to the water gauge body. Figure 4(b) shows the relative position relationship between these prompt points and the water gauge body. In this embodiment, the image segmentation prompt information composed of these 7 prompt points is:

[0108] ;

[0109] .

[0110] Step S50, input the monitoring image and image segmentation prompt information into the model running instance to perform image segmentation and obtain the water gauge body pixels. The SAM large model can complete the segmentation of the monitoring image according to the image segmentation prompt information, and return the result mask and the corresponding quality score.

[0111] In one embodiment, a mask with the highest quality score is selected from the segmentation results as the water ruler body pixel.

[0112] Step S60, using the pixels of the ruler body to compare with the water level reading table of the pixel position to obtain the water level reading.

[0113] In one embodiment, the specific process of using the water ruler body pixels to compare the pixel position water level reading table to obtain the water level reading is as follows:

[0114] Detect the edge of the water ruler pixel to obtain the edge line;

[0115] Select the closed edge line with the largest area as the water gauge contour line;

[0116] In the pixel position water level reading table, select all pixel position points located within and on the water gauge contour line, and obtain the corresponding water level readings;

[0117] From all water level readings, select the minimum value as the current water level reading.

[0118] To better illustrate this process, please refer to Figure 5 . Figure 5 (a) is a surveillance image actually captured in an embodiment; Figure 5 (b) is the water gauge body pixels (label L410 in the figure) obtained after the monitoring image is segmented by the model running instance; Figure 5 (c) shows the relative position relationship between the contour line obtained after pixel edge detection of the water gauge body (label L400 in the figure) and some pixel position points in the pixel position water level reading table (labels L301, L302, L303, L304, L305 in the figure).

[0119] As mentioned above, the five pixel positions in the figure are only for reference.

[0120] In one embodiment, a ray method is used to determine whether a pixel position point is within a contour line.

[0121] The basic idea of ​​the ray method is to emit a ray from the position to be detected in any direction, and then calculate the number of intersections between the ray and the contour line. If the number of intersections is an odd number, the point is inside the contour line; if it is an even number, the point is outside the contour line.

[0122] exist Figure 5 In the schematic case of (c), if a ray is drawn vertically upward from the pixel position to be detected, it can be found that the number of intersections between the pixel positions labeled L301, L302, L303, L304, and L305 and the contour line are 2, 2 (including itself), 1, 1, and 1. It can be inferred that there is 1 pixel position point outside the contour line (label L301), there is exactly 1 pixel position point on the contour line (label L302), and there are 3 pixel position points inside the contour line (labels L303, L304, and L305).

[0123] From the above-mentioned pixel position water level reading table, we can know that the water level readings of the pixel position points within and on the water gauge contour line (labels L302, L303, L304, L305) are 1.0, 3.7, 3.8 and 6.1 respectively.

[0124] Select the minimum value 1.0 among 1.0, 3.7, 3.8, and 6.1 as the current water level reading.

[0125] Through the scheme proposed in this application, based on the calibrated pixel position water level reading table and image segmentation prompt information, the monitoring image is sent to the model running instance for segmentation to obtain the water gauge body pixels exposed above the water surface, and then the water gauge body pixels are compared with the pixel position water level reading table to obtain the current water level reading, so as to realize automatic, continuous and accurate identification of the water level.

[0126] This application scheme is based on the premise that the relative position of the shooting module and the water level module is fixed and the shooting angle is fixed. If this premise changes, the system can continue to operate after the administrator calibrates the new pixel position water level reading table and image segmentation prompt information.

[0127] The above specific examples are used to illustrate the present invention, which is only used to help understand the present invention and is not intended to limit the present invention. For those skilled in the art, according to the concept of the present invention, some simple deductions, modifications or substitutions can be made.

Claims

1. A water level recognition method based on a pre-trained SAM large model, characterized in that: include: Obtain and deploy the open source pre-trained SAM large model to obtain a model running instance; After fixing the shooting device, shoot the water gauge to continuously obtain monitoring images; The water gauge is manually calibrated on the monitoring image, and a water level reading table of pixel positions is established. Specifically, the following steps are taken: a monitoring image with the water gauge fully exposed or with the lowest water level line is selected; a longitudinal center line of the water gauge is drawn on the selected monitoring image, and the intersection of the center line and each horizontal scale line is found as a representative point pixel; the X-axis and Y-axis coordinates of each representative point pixel on the monitoring image are recorded; the actual water level reading of the scale line where each representative point pixel is located is recorded; and a corresponding relationship table between the coordinates of each representative point pixel and the actual water level reading is established; Manually interpret the water gauge on the monitoring image to obtain image segmentation prompt information; Input the monitoring image and image segmentation prompt information into the model running instance to perform image segmentation and obtain the water gauge body pixels; The water level reading is obtained by comparing the water level gauge body pixels with the water level reading table of the pixel position. Specifically, in the water level reading table of the pixel position, all pixel positions located within the water level gauge body pixels are selected to obtain their water level readings; from all the obtained water level readings, the minimum value is selected as the current water level reading.

2. A water level recognition method based on a pre-trained SAM large model as claimed in claim 1, characterized in that: The manual interpretation of the water gauge on the monitoring image to obtain the image segmentation prompt information is specifically as follows: Select one or more pixel points from the scale line of the top area of ​​the water ruler in any monitoring image as positive prompt points; Select one or more pixel points as positive prompt points from the periphery of the scale line in the top area of ​​the water ruler in any monitoring image and limited to the water ruler body; Select one or more pixel points from the left and right sides of the water gauge in any monitoring image as negative prompt points; From the monitoring image where the water gauge is fully exposed or the water level line is the lowest, one or more pixel points below the water gauge or below the lowest water level line are selected as negative prompt points; The X-axis and Y-axis coordinates of each positive prompt point and negative prompt point in the monitoring image are arranged in sequence into an array points, and its mathematical expression is points = {(x1, y1, (x i ,y i ),...,(x n ,y n )}, where i∈{1, 2, ..., n}, n is the total number of positive and negative prompt points, (x i ,y i ) are the X-axis and Y-axis coordinates of each positive prompt point and negative prompt point; The labels of each positive prompt point and negative prompt point are arranged in sequence into an array labels, and its mathematical expression is labels = {l1, l i ,...l n }, where i∈{1, 2, ..., n}, n is the total number of positive and negative prompt points, l i is the label value of each positive and negative cue point, the label value of the positive cue point is 1, and the label value of the negative cue point is 0; Image segmentation hint information consists of points and labels.

3. A water level recognition method based on a pre-trained SAM large model as claimed in claim 1, characterized in that: The monitoring image and the image segmentation prompt information are input into the model running instance for image segmentation to obtain the water gauge body pixels, specifically: Input the monitoring image and image segmentation prompt information into the model running instance to obtain the segmentation result; The mask with the highest quality score is selected from the segmentation results as the water ruler body pixel.

4. A water level recognition system based on a pre-trained SAM large model, characterized in that: The system comprises: A water gauge module (01), fixed in a water body, for indicating the water level; A shooting module (02) is used to continuously obtain monitoring images of the water gauge area; The reading calibration module (03) is used to manually calibrate the monitoring image and establish a pixel position water level reading table, specifically: select a monitoring image in which the water gauge is completely exposed or the water level line is the lowest; draw a longitudinal center line of the water gauge on the selected monitoring image, and find the intersection of the center line and each horizontal scale line as a representative point pixel; record the X-axis and Y-axis coordinates of each representative point pixel on the monitoring image; record the actual water level reading of the scale line where each representative point pixel is located; and establish a corresponding relationship table between the coordinates of each representative point pixel and the actual water level reading; A prompt information acquisition module (04) is used to manually interpret the monitoring image to obtain image segmentation prompt information; An image segmentation module (05) is used to obtain and deploy an open source pre-trained SAM large model, obtain a model running instance, and segment the monitoring image according to the image segmentation prompt information to obtain water gauge body pixels; The water level determination module (06) is used to compare the water gauge body pixels with the pixel position water level reading table to obtain the water level reading, specifically: in the pixel position water level reading table, all pixel positions located in the water gauge body pixels are selected to obtain their water level readings; from all the obtained water level readings, the minimum value is selected as the current water level reading.

Citation Information

Patent Citations

  • Water level monitoring method based on SAM image segmentation model

    CN117372451B

  • A water level identification method based on SAM large model

    CN118411675B

  • Water level information determination method and device, storage medium and electronic equipment

    CN118865107A

  • Water gauge scale intelligent reading method based on target detection and semantic segmentation

    CN119107635A