CN117346846B - A method and device for automatically correcting water-measuring weir flow photography monitoring - Google Patents
A method and device for automatically correcting water-measuring weir flow photography monitoring Download PDFInfo
- Publication number
- CN117346846B CN117346846B CN202311219793.1A CN202311219793A CN117346846B CN 117346846 B CN117346846 B CN 117346846B CN 202311219793 A CN202311219793 A CN 202311219793A CN 117346846 B CN117346846 B CN 117346846B
- Authority
- CN
- China
- Prior art keywords
- weir
- image
- target
- water
- model
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01F—MEASURING VOLUME, VOLUME FLOW, MASS FLOW OR LIQUID LEVEL; METERING BY VOLUME
- G01F1/00—Measuring the volume flow or mass flow of fluid or fluent solid material wherein the fluid passes through a meter in a continuous flow
- G01F1/002—Measuring the volume flow or mass flow of fluid or fluent solid material wherein the fluid passes through a meter in a continuous flow wherein the flow is in an open channel
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01C—MEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
- G01C13/00—Surveying specially adapted to open water, e.g. sea, lake, river or canal
- G01C13/002—Measuring the movement of open water
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01F—MEASURING VOLUME, VOLUME FLOW, MASS FLOW OR LIQUID LEVEL; METERING BY VOLUME
- G01F23/00—Indicating or measuring liquid level or level of fluent solid material, e.g. indicating in terms of volume or indicating by means of an alarm
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/26—Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/77—Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
- G06V10/774—Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/82—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Evolutionary Computation (AREA)
- Computing Systems (AREA)
- Health & Medical Sciences (AREA)
- Multimedia (AREA)
- Artificial Intelligence (AREA)
- Software Systems (AREA)
- General Health & Medical Sciences (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Databases & Information Systems (AREA)
- Fluid Mechanics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Medical Informatics (AREA)
- Mathematical Physics (AREA)
- Biophysics (AREA)
- Biomedical Technology (AREA)
- Computational Linguistics (AREA)
- Molecular Biology (AREA)
- Data Mining & Analysis (AREA)
- Hydrology & Water Resources (AREA)
- Radar, Positioning & Navigation (AREA)
- Remote Sensing (AREA)
- General Engineering & Computer Science (AREA)
- Image Processing (AREA)
Abstract
Description
技术领域Technical Field
本发明涉及水文测验技术领域,尤其涉及一种可自动修正的量水堰流量摄影监测方法及装置。The invention relates to the technical field of hydrological testing, and in particular to a method and a device for automatically correcting a water measuring weir flow photography monitoring method.
背景技术Background Art
量水堰是一种常用的测量水流量的设备,其工作原理是通过安装特定尺寸与几何形状的堰槽,使得流进量水堰的水按照预定方向汇入堰槽时,根据产生的堰槽水位差来计算出流量,目前,堰槽水位的监测通常使用浮子式水位计或各类超声波明渠流量计、雷达水位计等,其中,浮子式水位计虽然稳定可靠、测量精度较好,但通常需要建造水位测井,成本较高;而超声波流量计与雷达水位计价格昂贵,且易受到泥沙、水温、水生生物等水体环境的干扰。A water measuring weir is a commonly used device for measuring water flow. Its working principle is to install weirs of specific size and geometry so that when the water flowing into the water measuring weir flows into the weir in a predetermined direction, the flow rate is calculated based on the water level difference between the weir and the weir. At present, the weir and the weir water level is usually monitored using float-type water level gauges or various ultrasonic open channel flow meters, radar water level gauges, etc. Among them, although float-type water level gauges are stable and reliable with good measurement accuracy, they usually require the construction of water level logging wells, which are costly. Ultrasonic flow meters and radar water level gauges are expensive and easily affected by water environment such as sediment, water temperature, and aquatic organisms.
近年来,基于图像处理的非接触式量水堰流量监测方法逐渐受到关注,比如:公开号为CN115638835A的专利公开了一种基于图像识别算法的量水堰流量自动监测方法及装置,该方法对浮子式水位装置圆盘图像采用圆形边缘检测,并对边界线进行开运算与霍夫直线检测得到连杆角度,从而计算流量大小;公开号为CN113237534A的专利公开了一种旋盘式量水堰水位监测系统,该系统监测控制模块搭建YOLO v3卷积神经网络,检测自制水位尺露出水面的等腰三角形个数,根据三角形的真实高度可计算堰槽水位和流量,但是该方法对露出水面的不完整三角形不能精准识别;胡民泉等人在《基于机器视觉的量水堰堰上水头自动量测技术》中介绍了一款新型水位尺,并配合该水位尺提出了自动量测算法,然而,上述基于图像处理的非接触式量水堰流量监测方法或装置的识别精度往往受到环境条件(光照、阴影、水草、生物残留等)的限制,泛化性能有限;同时无法实现误差修正,标识物一旦发生偏移,识别精度显著降低,稳定性有限且监测成本昂贵。In recent years, non-contact weir flow monitoring methods based on image processing have gradually attracted attention. For example, the patent with publication number CN115638835A discloses a weir flow automatic monitoring method and device based on image recognition algorithm. The method uses circular edge detection for the disk image of the float-type water level device, and performs opening operation and Hough line detection on the boundary line to obtain the connecting rod angle, thereby calculating the flow size; the patent with publication number CN113237534A discloses a rotating disk weir water level monitoring system. The monitoring and control module of the system builds YOLO v3 convolutional neural network, detects the number of isosceles triangles of the homemade water level gauge exposed above the water surface, and calculates the water level and flow of the weir according to the true height of the triangle. However, this method cannot accurately identify incomplete triangles exposed above the water surface; Hu Minquan et al. introduced a new type of water level gauge in "Automatic Measurement Technology of Water Head on Weir Based on Machine Vision", and proposed an automatic measurement algorithm in conjunction with the water level gauge. However, the recognition accuracy of the above-mentioned non-contact water-measuring weir flow monitoring method or device based on image processing is often limited by environmental conditions (light, shadow, aquatic plants, biological residues, etc.), and the generalization performance is limited; at the same time, error correction cannot be achieved. Once the marker is offset, the recognition accuracy is significantly reduced, the stability is limited, and the monitoring cost is expensive.
发明内容Summary of the invention
本发明提供了一种可自动修正的量水堰流量摄影监测方法及装置,解决的技术问题是,现有量水堰流量监测成本昂贵、图像水位识别方法稳定性有限。The present invention provides a method and device for automatically correcting a water-measuring weir flow photography monitoring method, which solves the technical problem that the existing water-measuring weir flow monitoring cost is expensive and the image water level recognition method has limited stability.
为解决以上技术问题,本发明提供了一种可自动修正的量水堰流量摄影监测方法及装置。In order to solve the above technical problems, the present invention provides a method and device for automatically correcting flow photography monitoring of a water measuring weir.
第一方面,本发明提供了一种可自动修正的量水堰流量摄影监测方法,所述方法包括以下步骤:In a first aspect, the present invention provides a method for automatically correcting a water measuring weir flow photography monitoring method, the method comprising the following steps:
获取原始水尺图像,并对原始水尺图像进行透视校正,得到透视校正图像;Acquire an original water gauge image, and perform perspective correction on the original water gauge image to obtain a perspective corrected image;
在所述透视校正图像中标注前景点和背景点,生成标注点信息;Annotating foreground points and background points in the perspective-corrected image to generate annotated point information;
获取预先构建好的融合VIT模型与交叉注意力机制模块的SAM图像分割模型,将所述透视校正图像和所述标注点信息输入所述SAM图像分割模型中进行堰槽内壁分割处理,得到目标堰槽内壁分割结果;其中,所述VIT模型用于提取所述透视校正图像的图像特征;所述交叉注意力机制模块用于对所述图像特征和所述标注点信息进行解码计算;Obtain a pre-built SAM image segmentation model that integrates a VIT model and a cross-attention mechanism module, input the perspective-corrected image and the annotation point information into the SAM image segmentation model to perform weir inner wall segmentation processing, and obtain a target weir inner wall segmentation result; wherein the VIT model is used to extract image features of the perspective-corrected image; and the cross-attention mechanism module is used to decode and calculate the image features and the annotation point information;
根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位;Obtaining a target weir groove water level according to the target weir groove inner wall segmentation result and a pre-established weir groove water level recognition model;
利用水位流量关系模型和目标堰槽水位,计算得到量水堰流量。The flow rate of the measuring weir is calculated using the water level-flow relationship model and the target weir water level.
在进一步的实施方案中,在所述根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位步骤之前,所述方法还包括根据所述目标堰槽内壁分割结果对水尺进行偏移检测,并在水尺发生偏移时,利用预先训练好的YOLO v5目标检测模型对所述标注点信息进行修正,其中,所述利用预先训练好的YOLO v5目标检测模型对所述标注点信息进行修正的步骤具体包括:In a further embodiment, before the step of obtaining the target weir water level according to the target weir inner wall segmentation result and the pre-established weir water level recognition model, the method further includes detecting the offset of the water gauge according to the target weir inner wall segmentation result, and when the water gauge is offset, correcting the marked point information using a pre-trained YOLO v5 target detection model, wherein the step of correcting the marked point information using the pre-trained YOLO v5 target detection model specifically includes:
利用预先训练好的YOLO v5目标检测模型对所述透视校正图像进行识别,得到水尺偏移位置坐标;The perspective-corrected image is identified using a pre-trained YOLO v5 target detection model to obtain the offset position coordinates of the water gauge;
根据所述水尺偏移位置坐标和水尺标准位置坐标,计算得到水尺偏移量;Calculating the water gauge offset according to the water gauge offset position coordinates and the water gauge standard position coordinates;
根据所述水尺偏移量对标注点信息进行修正,生成修正后的标注点信息,并通过所述SAM图像分割模型依据修正后的标注点信息对所述原始水尺图像重新进行分割,动态更新目标堰槽内壁分割结果。The marking point information is corrected according to the water gauge offset to generate the corrected marking point information, and the original water gauge image is re-segmented according to the corrected marking point information through the SAM image segmentation model to dynamically update the target weir inner wall segmentation result.
在进一步的实施方案中,所述根据所述目标堰槽内壁分割结果对水尺进行偏移检测的步骤包括:In a further embodiment, the step of detecting the offset of the water gauge according to the target weir inner wall segmentation result comprises:
根据所述目标堰槽内壁分割结果确定量水堰堰槽与水尺的交界线,利用量水堰堰槽与水尺的交界线和铅锤线方向之间的平均夹角,对水尺进行偏移检测,若所述平均夹角不在预设的水尺夹角范围内,则判定水尺发生偏移。The boundary line between the measuring weir and the water gauge is determined according to the segmentation result of the inner wall of the target weir. The water gauge is detected for offset using the average angle between the boundary line between the measuring weir and the water gauge and the direction of the plumb line. If the average angle is not within the preset water gauge angle range, it is determined that the water gauge is offset.
在进一步的实施方案中,所述对原始水尺图像进行透视校正,得到透视校正图像的步骤之后还包括:In a further embodiment, the step of performing perspective correction on the original water gauge image to obtain the perspective corrected image further includes:
检测所述透视校正图像是否存在有像素缺失值的区域若存在,则采用最近邻插值法或者拉格朗日插值法进行图像插值。It is detected whether there is an area with missing pixel values in the perspective-corrected image. If so, the image is interpolated using the nearest neighbor interpolation method or the Lagrange interpolation method.
在进一步的实施方案中,所述将所述透视校正图像和所述标注点信息输入所述SAM图像分割模型中进行堰槽内壁分割处理,得到目标堰槽内壁分割结果的步骤包括:In a further embodiment, the step of inputting the perspective-corrected image and the annotation point information into the SAM image segmentation model to perform weir inner wall segmentation processing to obtain a target weir inner wall segmentation result comprises:
通过VIT模型对所述透视校正图像进行特征提取,得到图像特征;Extracting features of the perspective-corrected image using a VIT model to obtain image features;
遍历所述图像特征,通过交叉注意力机制对所述图像特征和所述标注点信息进行解码计算,得到解码后的图像特征和掩码特征;Traversing the image features, decoding and calculating the image features and the annotation point information through a cross attention mechanism, and obtaining decoded image features and mask features;
利用所述SAM图像分割模型对所述解码后的图像特征依次进行卷积、上采样和多层感知机处理,得到最终的图像特征,所述掩码特征经过多层感知器调整维度,使其与最终的图像特征一致,两者相乘得到目标堰槽内壁分割结果。The decoded image features are sequentially convolved, upsampled and processed by a multi-layer perceptron using the SAM image segmentation model to obtain the final image features. The mask features are dimensionally adjusted by a multi-layer perceptron to be consistent with the final image features. The two are multiplied to obtain the target weir inner wall segmentation result.
在进一步的实施方案中,所述根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位的步骤包括:In a further embodiment, the step of obtaining the target weir water level according to the target weir inner wall segmentation result and the pre-established weir water level recognition model comprises:
利用所述目标堰槽内壁分割结果,计算得到目标堰槽内壁的像素面积;Calculate the pixel area of the target weir inner wall by using the target weir inner wall segmentation result;
将所述目标堰槽内壁的像素面积输入预先建立的堰槽水位识别模型,得到目标堰槽水位,其中,所述堰槽水位识别模型为:The pixel area of the target weir inner wall is input into a pre-established weir water level recognition model to obtain the target weir water level, wherein the weir water level recognition model is:
L=h-k·SL=h-k·S
式中,L表示目标堰槽水位;h、k均表示回归系数;S表示目标堰槽内壁的像素面积。Where L represents the target weir water level; h and k represent regression coefficients; and S represents the pixel area of the inner wall of the target weir.
在进一步的实施方案中,所述水位流量关系模型为:In a further embodiment, the water level flow relationship model is:
式中,Q表示量水堰流量;Ce表示流量经验系数;θ表示V型堰顶角;g表示重力加速度;he表示V型堰顶角的高度;L表示目标堰槽水位。Where Q represents the flow rate of the measuring weir; Ce represents the flow rate empirical coefficient; θ represents the V-shaped weir top angle; g represents the gravitational acceleration; he represents the height of the V-shaped weir top angle; and L represents the target weir water level.
第二方面,本发明提供了一种可自动修正的量水堰流量摄影监测装置,所述装置包括:In a second aspect, the present invention provides a flow photography monitoring device for a water measuring weir capable of automatic correction, the device comprising:
图像校正模块,用于获取原始水尺图像,并对原始水尺图像进行透视校正,得到透视校正图像;An image correction module is used to obtain an original water gauge image and perform perspective correction on the original water gauge image to obtain a perspective corrected image;
图像标注模块,用于在所述透视校正图像中标注前景点和背景点,生成标注点信息;An image annotation module, used to annotate foreground points and background points in the perspective-corrected image to generate annotation point information;
图像分割模块,用于获取预先构建好的融合VIT模型与交叉注意力机制模块的SAM图像分割模型,将所述透视校正图像和所述标注点信息输入所述SAM图像分割模型中进行堰槽内壁分割处理,得到目标堰槽内壁分割结果;其中,所述VIT模型用于提取所述透视校正图像的图像特征;所述交叉注意力机制模块用于对所述图像特征和所述标注点信息进行解码计算;An image segmentation module is used to obtain a pre-built SAM image segmentation model that integrates a VIT model and a cross-attention mechanism module, and input the perspective-corrected image and the annotation point information into the SAM image segmentation model to perform weir inner wall segmentation processing to obtain a target weir inner wall segmentation result; wherein the VIT model is used to extract image features of the perspective-corrected image; and the cross-attention mechanism module is used to decode and calculate the image features and the annotation point information;
水位识别模块,用于根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位;A water level recognition module, used for obtaining a target weir groove water level according to the target weir groove inner wall segmentation result and a pre-established weir groove water level recognition model;
流量监测模块,用于利用水位流量关系模型和目标堰槽水位,计算得到量水堰流量。The flow monitoring module is used to calculate the water flow of the water measuring weir using the water level flow relationship model and the target weir water level.
本发明提供了一种可自动修正的量水堰流量摄影监测方法及装置,所述方法通过对原始水尺图像进行透视校正,并利用融合VIT模型与交叉注意力机制模块的SAM图像分割模型进行堰槽内壁分割处理,得到目标堰槽内壁分割结果;根据目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位;利用水位流量关系模型和目标堰槽水位,计算得到量水堰流量。与现有技术相比,该方法采用SAM模型和YOLO v5目标检测模型建立自动修正的堰槽水位图像识别模型,同时利用量水堰水位与流量关系模型得到实时流量值,对各种环境或观测角度下的堰槽水位和流量均具有较好的识别性能与适应能力,提高了量水堰流量监测的准确度以及稳定性,有利于长期连续流量监测,且具有监测效率高效、成本低廉、适用范围广等优点。The present invention provides a method and device for automatically correcting the flow photography monitoring of a water measuring weir. The method performs perspective correction on the original water gauge image, and uses the SAM image segmentation model that integrates the VIT model and the cross attention mechanism module to perform weir inner wall segmentation processing to obtain the target weir inner wall segmentation result; obtains the target weir water level according to the target weir inner wall segmentation result and the pre-established weir water level recognition model; and calculates the water measuring weir flow using the water level flow relationship model and the target weir water level. Compared with the prior art, the method uses the SAM model and the YOLO v5 target detection model to establish an automatically corrected weir water level image recognition model, and uses the water measuring weir water level and flow relationship model to obtain the real-time flow value. It has good recognition performance and adaptability for the weir water level and flow under various environments or observation angles, improves the accuracy and stability of the water measuring weir flow monitoring, is conducive to long-term continuous flow monitoring, and has the advantages of high monitoring efficiency, low cost, and wide application range.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本发明实施例提供的可自动修正的量水堰流量摄影监测方法流程示意图;FIG1 is a schematic flow chart of a method for automatically correcting a water-measurement weir flow photography monitoring method provided by an embodiment of the present invention;
图2是本发明实施例提供的量水堰流量监测装置示意图;FIG2 is a schematic diagram of a flow monitoring device for a water measuring weir provided in an embodiment of the present invention;
图3是本发明实施例提供的透视校正图像示意图;FIG3 is a schematic diagram of a perspective-corrected image provided by an embodiment of the present invention;
图4是本发明实施例提供的标注前景点和背景点的透视校正图像示意图;4 is a schematic diagram of a perspective-corrected image with foreground points and background points marked according to an embodiment of the present invention;
图5是本发明实施例提供的目标堰槽内壁分割结果中的二值化掩码示意图;FIG5 is a schematic diagram of a binary mask in a target weir inner wall segmentation result provided by an embodiment of the present invention;
图6是本发明实施例提供的SAM图像分割模型输出的带有提示点和掩码的堰槽图像示意图;6 is a schematic diagram of a weir image with prompt points and masks output by the SAM image segmentation model provided in an embodiment of the present invention;
图7是本发明实施例提供的可自动修正的量水堰流量摄影监测装置框图。FIG. 7 is a block diagram of an automatically correctable water-measurement weir flow photography monitoring device provided in an embodiment of the present invention.
具体实施方式DETAILED DESCRIPTION
下面结合附图具体阐明本发明的实施方式,实施例的给出仅仅是为了说明目的,并不能理解为对本发明的限定,包括附图仅供参考和说明使用,不构成对本发明专利保护范围的限制,因为在不脱离本发明精神和范围基础上,可以对本发明进行许多改变。The following specifically illustrates the implementation mode of the present invention in conjunction with the accompanying drawings. The embodiments are provided for illustrative purposes only and are not to be construed as limitations of the present invention. The accompanying drawings are provided for reference and illustration only and do not constitute limitations on the scope of patent protection of the present invention, because many changes may be made to the present invention without departing from the spirit and scope of the present invention.
参考图1,本发明实施例提供了一种可自动修正的量水堰流量摄影监测方法,应用于量水堰流量监测装置,如图1所示,该方法包括以下步骤:Referring to FIG1 , an embodiment of the present invention provides a method for automatically correcting a water measuring weir flow photography monitoring method, which is applied to a water measuring weir flow monitoring device. As shown in FIG1 , the method includes the following steps:
S1.获取原始水尺图像,并对原始水尺图像进行透视校正,得到透视校正图像。S1. Obtain an original water gauge image, and perform perspective correction on the original water gauge image to obtain a perspective corrected image.
如图2所示,本实施例在量水堰的渠道或水槽内壁垂直于水面的方向上安装有水尺,并在量水堰一侧距离水尺合适距离的位置处固定一立柱,所述立柱上架设有一台延时监控摄像机和太阳能发电板,其中,太阳能发电板功率为100W,配备60AH锂电池,所述太阳能发电板用于为监控摄像机供电;摄像头优先选取型号为羽瞳YT-CAM8008LA-4G的摄像头,800万像素清晰度,定焦4mm,内置4G通讯模块,摄像头距离地面约3m,约呈60°俯拍水尺,拍摄图片大小为3×3840×2160;需要说明的是,为了可以从监控画面中清晰看到水尺刻度,并能较为准确地对水位进行读数,本实施例需要调整摄像机镜头角度,使水尺全长均位于摄像机监控画面中且尽量位于画面中心,同时本实施例设置延时摄像机拍摄间隔为5分钟,摄影机定时拍摄水尺图片,并同步上传至云端服务器,传入图像处理模块进行水位计算,监控人员或抽查人员可从云端查看、下载水尺图片。As shown in FIG2 , in this embodiment, a water gauge is installed on the inner wall of the channel or trough of the water measuring weir in a direction perpendicular to the water surface, and a column is fixed at a position at a suitable distance from the water gauge on one side of the water measuring weir. A time-delay monitoring camera and a solar power generation panel are mounted on the column. The solar power generation panel has a power of 100W and is equipped with a 60AH lithium battery. The solar power generation panel is used to power the monitoring camera. The camera preferably selects a camera model of Yutong YT-CAM8008LA-4G, with a resolution of 8 million pixels, a fixed focus of 4mm, a built-in 4G communication module, and a distance of about 100 meters from the ground. 3m, the water gauge is taken from above at about 60°, and the size of the picture is 3×3840×2160; it should be noted that in order to clearly see the water gauge scale from the monitoring screen and to be able to read the water level more accurately, this embodiment needs to adjust the camera lens angle so that the entire length of the water gauge is located in the camera monitoring screen and is as close to the center of the screen as possible. At the same time, this embodiment sets the time-delay camera shooting interval to 5 minutes. The camera takes water gauge pictures at regular intervals and uploads them to the cloud server simultaneously. The pictures are transmitted to the image processing module for water level calculation, and the monitoring personnel or spot check personnel can view and download water gauge pictures from the cloud.
由于俯拍的水尺图片会存在透视畸变,这说明在图像坐标系中,单位像素对应的水尺真实世界长度不一致,因此,本实施例在通过监控摄像机拍摄到原始水尺图像之后,还需要对拍摄到的原始水尺图像进行透视校正,将其校正到水尺正视方位上,得到透视校正图像,其中,透视校正的计算公式为:Since the water gauge image taken from above will have perspective distortion, this means that in the image coordinate system, the real-world length of the water gauge corresponding to the unit pixel is inconsistent. Therefore, after the original water gauge image is captured by the surveillance camera, this embodiment also needs to perform perspective correction on the captured original water gauge image, correct it to the water gauge front view orientation, and obtain a perspective corrected image, wherein the calculation formula for perspective correction is:
式中,(x,y)表示原始水尺图像的像素点坐标;(m,n)表示透视校正图像的像素点坐标;M表示空间透视变换矩阵;a0、a1、a2、a3表示线性变换参数;b0、b1表示平移参数;c0、c1表示透视变换参数。Wherein, (x, y) represents the pixel coordinates of the original water gauge image; (m, n) represents the pixel coordinates of the perspective corrected image; M represents the spatial perspective transformation matrix; a0 , a1 , a2 , a3 represent linear transformation parameters; b0 , b1 represent translation parameters; c0 , c1 represent perspective transformation parameters.
在本实施例中,由于空间透视变换矩阵M共有8个未知量,需要至少4组校正前后对应点才能解出,因此,本实施例在拍摄到的原始水尺图像上选择4个点,坐标分别为(1817.0,966.4)、(1856.0,966.5)、(1806.0,1457.2)、(1841.4,1457.6),分别对应水尺“9.5”、“0.5”刻度线与水尺左右边缘的交点,校正后四个点的坐标分别为(450,300)、(550,300)、(450,1600)、(550,1600),在图像坐标系中左边缘与右边缘两点构成的直线均为竖直线,经过空间透视矫正后得到的透视校正图像如图3所示,在本实施例中,透视校正图像大小为3×1000×2000。In this embodiment, since the spatial perspective transformation matrix M has a total of 8 unknown quantities, at least 4 groups of corresponding points before and after correction are required to solve it. Therefore, this embodiment selects 4 points on the captured original water level gauge image, with coordinates of (1817.0, 966.4), (1856.0, 966.5), (1806.0, 1457.2), and (1841.4, 1457.6), which correspond to the intersections of the "9.5" and "0.5" scale lines of the water level gauge and the left and right edges of the water level gauge, respectively. The coordinates of the four points after correction are (450, 300), (550, 300), (450, 1600), and (550, 1600), respectively. In the image coordinate system, the straight lines formed by the two points on the left and right edges are both vertical lines. The perspective-corrected image obtained after spatial perspective correction is shown in Figure 3. In this embodiment, the size of the perspective-corrected image is 3×1000×2000.
需要说明的是,原始水尺图像经过透视校正后,若部分区域存在像素缺失值,则将距离其最近的非缺值点的像素值复制给该点或采用拉格朗日插值,得到缺值修补后的图像,具体为:检测所述透视校正图像是否存在有像素缺失值的区域若存在,则采用最近邻插值法或者拉格朗日插值法进行图像插值。It should be noted that after the original water level image is perspective corrected, if there are missing pixel values in some areas, the pixel value of the nearest non-missing point will be copied to the point or Lagrange interpolation will be used to obtain an image with missing value repaired, specifically: detect whether there is an area with missing pixel values in the perspective corrected image. If so, use the nearest neighbor interpolation method or Lagrange interpolation method to perform image interpolation.
S2.在所述透视校正图像中标注前景点和背景点,生成标注点信息。S2. Marking foreground points and background points in the perspective-corrected image to generate marked point information.
本实施例在透视校正图像上标注提示点,并对提示点赋予背景指示信息,背景指示信息是指该提示点是前景提示点(输入为1)还是背景提示点(输入为0),如图4所示,本实施例优先在在透视校正图像上标注三个提示点,其中,两个提示点位于堰槽内壁上,坐标为(171,896)、(880,1103),这两个提示点为前景点,是本实施例重点关注或者感兴趣的区域;第三个提示点位于水尺上,坐标为(475,800),第三个提示点为背景点,是本实施例不相关的区域。This embodiment marks prompt points on the perspective-corrected image and assigns background indication information to the prompt points. The background indication information refers to whether the prompt point is a foreground prompt point (input is 1) or a background prompt point (input is 0). As shown in FIG4 , this embodiment preferentially marks three prompt points on the perspective-corrected image, wherein two prompt points are located on the inner wall of the weir groove with coordinates of (171, 896) and (880, 1103). These two prompt points are foreground points and are the areas of focus or interest of this embodiment; the third prompt point is located on the water ruler with coordinates of (475, 800). The third prompt point is a background point and is an irrelevant area of this embodiment.
S3.获取预先构建好的融合VIT模型与交叉注意力机制模块的SAM图像分割模型,将所述透视校正图像和所述标注点信息输入所述SAM图像分割模型中进行堰槽内壁分割处理,得到目标堰槽内壁分割结果;其中,所述VIT模型用于提取所述透视校正图像的图像特征;所述交叉注意力机制模块用于对所述图像特征和所述标注点信息进行解码计算。S3. Obtain a pre-built SAM image segmentation model that integrates the VIT model and the cross-attention mechanism module, input the perspective-corrected image and the annotation point information into the SAM image segmentation model to perform weir inner wall segmentation processing to obtain the target weir inner wall segmentation result; wherein, the VIT model is used to extract the image features of the perspective-corrected image; and the cross-attention mechanism module is used to decode and calculate the image features and the annotation point information.
在本实施例中,所述将所述透视校正图像和所述标注点信息输入所述SAM图像分割模型中进行分割处理,得到目标堰槽内壁分割结果的步骤包括:In this embodiment, the step of inputting the perspective-corrected image and the annotation point information into the SAM image segmentation model for segmentation processing to obtain the target weir inner wall segmentation result includes:
通过VIT模型对所述透视校正图像进行特征提取,得到图像特征;Extracting features of the perspective-corrected image using a VIT model to obtain image features;
遍历所述图像特征,通过交叉注意力机制对所述图像特征和所述标注点信息进行解码计算,得到解码后的图像特征和掩码特征;Traversing the image features, decoding and calculating the image features and the annotation point information through a cross attention mechanism, and obtaining decoded image features and mask features;
利用所述SAM图像分割模型对所述解码后的图像特征依次进行卷积、上采样和多层感知机处理,得到最终的图像特征,所述掩码特征经过多层感知器调整维度,使其与最终的图像特征一致,两者相乘得到目标掩码,即得到目标堰槽内壁分割结果。The decoded image features are sequentially convolved, upsampled and processed by a multi-layer perceptron using the SAM image segmentation model to obtain the final image features. The mask features are dimensionally adjusted by a multi-layer perceptron to make them consistent with the final image features. The two are multiplied to obtain a target mask, that is, to obtain the target weir inner wall segmentation result.
具体地,考虑到分割水尺像素区域会因水尺倒影干扰分割结果,其与水体的水面线很难通过肉眼辨认,而注意到水尺倚靠的堰槽内壁和水体之间的水面线为明显的白色,有助于模型对水面线的识别,为此我们利用SAM图像分割模型对内壁进行掩码分割,其中,SAM视觉模型融合多个拥有Transformer模块的文本或视觉经典模型,基于提示工程对目标区域进行图像分割,其对图像和标注点信息(标注点、标注框或文本语义)分别利用VIT模型(Vision Transformer,视觉自注意力模型)和Bert模型进行编码,并采用交叉注意力机制计算与标注点信息高度相关的像素点或区域,需要说明的是,标注点信息需要不断尝试,使得SAM模型能够较好地理解并与目标区域掩码分割任务相匹配。Specifically, considering that the segmentation of the water gauge pixel area will interfere with the segmentation result due to the reflection of the water gauge, it is difficult to distinguish it from the water surface line of the water body by the naked eye. However, it is noted that the water surface line between the inner wall of the weir on which the water gauge relies and the water body is obviously white, which helps the model to identify the water surface line. For this reason, we use the SAM image segmentation model to perform mask segmentation on the inner wall. Among them, the SAM visual model integrates multiple text or visual classic models with Transformer modules, and performs image segmentation on the target area based on the prompt engineering. It encodes the image and annotation point information (annotation points, annotation boxes or text semantics) using the VIT model (Vision Transformer, visual self-attention model) and the Bert model respectively, and uses the cross-attention mechanism to calculate the pixel points or areas that are highly correlated with the annotation point information. It should be noted that the annotation point information needs to be continuously tried so that the SAM model can better understand and match the target area mask segmentation task.
SAM图像分割模型遍历VIT模型得到的全部图像特征,通过交叉注意力机制计算各个图像特征是否与标注点信息相关,其中,各个图像特征是否与标注点信息相关由权重矩阵A体现,经过softmax计算得到的权重矩阵A能够反映各个特征的相对重要程度,值越大越相关,越小越不相关,若判断到相关,则对应像素区域输出掩码“1”,不相关则输出掩码“0”,交叉注意力机制具体为:The SAM image segmentation model traverses all image features obtained by the VIT model, and calculates whether each image feature is related to the annotation point information through the cross-attention mechanism. Among them, whether each image feature is related to the annotation point information is reflected by the weight matrix A. The weight matrix A obtained by softmax calculation can reflect the relative importance of each feature. The larger the value, the more relevant it is, and the smaller the value, the less relevant it is. If it is judged to be relevant, the corresponding pixel area outputs a mask "1", and if it is irrelevant, the mask "0" is output. The cross-attention mechanism is specifically as follows:
y=Avy=Av
式中,A表示权重矩阵;q表示图像特征;k表示标注点信息;kT为k的转置;Dh表示特征维度;v表示值向量;y表示解码后的图像特征。In the formula, A represents the weight matrix; q represents the image feature; k represents the annotation point information; k T is the transpose of k; D h represents the feature dimension; v represents the value vector; y represents the decoded image feature.
SAM图像分割模型对交叉注意力机制模块输出的图像特征y进行卷积、上采样和多层感知机处理,得到最终的图像特征。SAM模型输出的掩码特征经过多层感知器调整维度,使其与最终的图像特征一致,两者相乘得到目标掩码,并通过非极大值抑制保留置信度最高的掩码,最终输出置信度最高的水面以上堰槽内壁掩码矩阵,即目标堰槽内壁分割结果。在SAM图像分割模型输出的水面以上堰槽内壁掩码矩阵(二值化矩阵)中,数值为“1”的像素区域为目标分割区域,目标堰槽内壁分割结果如图5所示,本实施例通过对交叉注意力机制模块输出的图像特征进行卷积、上采样和多层感知机处理可以调整特征维度,便于张量之间的计算。The SAM image segmentation model performs convolution, upsampling and multi-layer perceptron processing on the image feature y output by the cross-attention mechanism module to obtain the final image feature. The mask feature output by the SAM model is adjusted in dimension by the multi-layer perceptron to make it consistent with the final image feature. The two are multiplied to obtain the target mask, and the mask with the highest confidence is retained through non-maximum suppression, and finally the mask matrix of the inner wall of the weir groove above the water surface with the highest confidence is output, that is, the target weir groove inner wall segmentation result. In the mask matrix (binarized matrix) of the inner wall of the weir groove above the water surface output by the SAM image segmentation model, the pixel area with a value of "1" is the target segmentation area, and the target weir groove inner wall segmentation result is shown in Figure 5. This embodiment can adjust the feature dimension by performing convolution, upsampling and multi-layer perceptron processing on the image feature output by the cross-attention mechanism module, which is convenient for calculation between tensors.
由于考虑到水流对水尺的冲击和固定螺钉随时间产生的疲劳与老化,水尺会发生小幅度的偏移,此时,标注点可能不能很好地发挥其在SAM模型中的提示作用,因此,在所述根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位步骤之前,本实施例提供的量水堰流量监测方法还包括根据所述目标堰槽内壁分割结果对水尺进行偏移检测,并在水尺发生偏移时,利用预先训练好的YOLO v5目标检测模型对所述标注点信息进行修正,具体为:Considering the impact of water flow on the water gauge and the fatigue and aging of the fixing screws over time, the water gauge will deviate slightly. At this time, the marked points may not be able to play a good role in the SAM model. Therefore, before obtaining the target weir water level according to the target weir inner wall segmentation result and the pre-established weir water level recognition model, the water flow monitoring method provided by this embodiment also includes detecting the offset of the water gauge according to the target weir inner wall segmentation result, and when the water gauge deviates, the pre-trained YOLO v5 target detection model is used to correct the marked point information, specifically:
根据所述目标堰槽内壁分割结果确定量水堰堰槽与水尺的交界线(分割结果的中间边缘线),计算量水堰堰槽与水尺的交界线和铅锤线方向之间的平均夹角,根据平均夹角对水尺进行偏移检测,若所述平均夹角不在预设的水尺夹角范围内,则判定水尺发生偏移,需要对标注点信息进行修正;若所述平均夹角在预设的水尺夹角范围内,则判定水尺未发生偏移;Determine the boundary line between the weir groove and the water gauge (the middle edge line of the segmentation result) according to the target weir groove inner wall segmentation result, calculate the average angle between the boundary line between the weir groove and the water gauge and the plumb line direction, and perform offset detection on the water gauge according to the average angle. If the average angle is not within the preset water gauge angle range, it is determined that the water gauge is offset and the marked point information needs to be corrected; if the average angle is within the preset water gauge angle range, it is determined that the water gauge is not offset.
在水尺发生偏移时,利用预先训练好的YOLO v5目标检测模型对所述透视校正图像进行识别,得到水尺偏移位置坐标;When the water gauge is offset, the perspective-corrected image is identified using a pre-trained YOLO v5 target detection model to obtain the offset position coordinates of the water gauge;
根据所述水尺偏移位置坐标和水尺标准位置坐标,计算得到水尺偏移量;Calculating the water gauge offset according to the water gauge offset position coordinates and the water gauge standard position coordinates;
根据所述水尺偏移量对标注点信息进行修正,生成修正后的标注点信息,并通过所述SAM图像分割模型依据修正后的标注点信息对所述原始水尺图像重新进行分割,动态更新目标堰槽内壁分割结果。The marking point information is corrected according to the water gauge offset to generate the corrected marking point information, and the original water gauge image is re-segmented according to the corrected marking point information through the SAM image segmentation model to dynamically update the target weir inner wall segmentation result.
具体地,为了便于理解,本实施例对偏移检测进行示例性说明:观察量水堰堰槽与水尺的交界线,计算交界线与铅锤方向的平均夹角,若平均夹角小于3°,则认为水尺未发生偏移;若平均夹角超过3°,则认为水尺发生偏移,需对标注点信息进行修正。Specifically, for ease of understanding, this embodiment provides an illustrative explanation of offset detection: observe the boundary line between the weir and the water gauge, calculate the average angle between the boundary line and the plumb bob direction, if the average angle is less than 3°, it is considered that the water gauge has not shifted; if the average angle exceeds 3°, it is considered that the water gauge has shifted, and the marking point information needs to be corrected.
本实施例中的YOLO v5目标检测模型采用了类似于Darknet的网络结构,该结构包括多个卷积层、池化层和全连接层,其中,卷积层用于提取图像特征,池化层用于降低特征图的维度,全连接层用于最终的目标检测,YOLO v5目标检测模型训练过程中采用的损失函数包括预测框回归损失函数、分类损失函数、置信度损失函数,YOLO v5目标检测模型具体的训练过程为:The YOLO v5 target detection model in this embodiment adopts a network structure similar to Darknet, which includes multiple convolutional layers, pooling layers and fully connected layers, wherein the convolutional layer is used to extract image features, the pooling layer is used to reduce the dimension of the feature map, and the fully connected layer is used for final target detection. The loss functions used in the training process of the YOLO v5 target detection model include the prediction box regression loss function, the classification loss function, and the confidence loss function. The specific training process of the YOLO v5 target detection model is as follows:
对透视校正图像的数据集进行人工标注,采用矩形检测框标注水尺在图像中的位置,构成由约100张样本组成的训练集,训练集包括不同水文季节(丰水、平水、枯水期)与环境条件(雨天、雾天、夜晚)下的水尺图,以及对应矩形检测框四个顶点的坐标信息,本实施例使用训练集训练YOLO v5目标检测模型,得到训练好的用于自动识别水尺位置的YOLO v5目标检测模型。The data set of perspective-corrected images is manually annotated, and the position of the water gauge in the image is annotated with a rectangular detection frame to form a training set consisting of about 100 samples. The training set includes water gauge images under different hydrological seasons (flood season, normal water season, and dry season) and environmental conditions (rainy days, foggy days, and nights), as well as coordinate information of the four vertices of the corresponding rectangular detection frame. In this embodiment, the training set is used to train a YOLO v5 target detection model to obtain a trained YOLO v5 target detection model for automatically identifying the position of the water gauge.
训练后的YOLO v5目标检测模型能通过矩形检测框较好地识别水尺在图像中的位置,计算出矩形检测框中心点的坐标(x1,y1);其中,(x1,y1)相较于未发生偏移前水尺矩形框中心坐标(x2,y2)的偏移量为本实施例根据Δx和Δy对标注点信息中的标注点坐标(m,n)进行修正,得到修正后的标注点坐标为(m',n'),得到修正后的标注点信息,其中,SAM图像分割模型根据修正后的标注点信息重新执行分割过程,对目标堰槽内壁的掩码进行动态修正。The trained YOLO v5 target detection model can better identify the position of the water ruler in the image through the rectangular detection frame and calculate the coordinates of the center point of the rectangular detection frame (x 1 , y 1 ); the offset of (x 1 , y 1 ) compared to the center coordinates of the water ruler rectangular frame (x 2 , y 2 ) before the offset is In this embodiment, the coordinates (m, n) of the marking point in the marking point information are corrected according to Δx and Δy, and the corrected coordinates of the marking point are obtained as (m', n'), and the corrected marking point information is obtained, wherein, The SAM image segmentation model re-executes the segmentation process according to the corrected annotation point information and dynamically corrects the mask of the inner wall of the target weir.
S4.根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位。S4. Obtain the target weir water level according to the target weir inner wall segmentation result and the pre-established weir water level recognition model.
在本实施例中,所述根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位的步骤包括:In this embodiment, the step of obtaining the target weir water level according to the target weir inner wall segmentation result and the pre-established weir water level recognition model comprises:
利用所述目标堰槽内壁分割结果,计算得到目标堰槽内壁的像素面积;Calculate the pixel area of the target weir inner wall by using the target weir inner wall segmentation result;
将所述目标堰槽内壁的像素面积输入预先建立的堰槽水位识别模型,得到目标堰槽水位。The pixel area of the target weir inner wall is input into a pre-established weir water level recognition model to obtain the target weir water level.
具体地,如图6所示,由于堰槽内壁掩码边缘(内壁与水尺、内壁与水体)存在少量像素的空隙,且堰渠底部不平整、内壁表面有水泥块凸起导致部分区域水面线不水平(内壁掩码下边缘不完全水平),若直接计算内壁像素高度会对水位识别产生较大的误差,而利用掩码矩阵计算图像坐标系下水面线以上堰槽内壁的像素面积,可较大程度得减小误差,因此,本实施例通过水尺刻度线对水位进行读数,并建立堰槽内壁的像素面积S与真实水位L之间的线性关系,生成堰槽水位识别模型,所述堰槽水位识别模型为:Specifically, as shown in FIG6 , since there are a small number of pixel gaps at the edge of the inner wall mask of the weir (inner wall and water gauge, inner wall and water body), and the bottom of the weir is uneven, and there are cement blocks protruding on the inner wall surface, resulting in the water surface line in some areas not being level (the lower edge of the inner wall mask is not completely level), if the inner wall pixel height is directly calculated, a large error will be caused in water level recognition. However, by using the mask matrix to calculate the pixel area of the inner wall of the weir above the water surface line in the image coordinate system, the error can be reduced to a large extent. Therefore, in this embodiment, the water level is read through the water gauge scale line, and a linear relationship between the pixel area S of the inner wall of the weir and the true water level L is established to generate a weir water level recognition model, which is:
L=h-k·SL=h-k·S
式中,L表示目标堰槽水位;h、k均表示回归系数;S表示目标堰槽内壁的像素面积,其中,由于目标堰槽内壁分割结果的掩码矩阵为二值化矩阵,目标堰槽内壁的像素面积为内壁占有的图像像素点个数,因此,本实施例可通过对目标堰槽内壁分割结果的掩码矩阵进行求和,得到目标堰槽内壁面积,比如:当水尺量程为100cm,堰槽内壁掩码在图像坐标系下的面积S为361826个像素点时,所建立的堰槽水位识别模型如下:Wherein, L represents the target weir water level; h and k represent regression coefficients; S represents the pixel area of the target weir inner wall. Since the mask matrix of the target weir inner wall segmentation result is a binary matrix, the pixel area of the target weir inner wall is the number of image pixels occupied by the inner wall. Therefore, in this embodiment, the target weir inner wall area can be obtained by summing the mask matrix of the target weir inner wall segmentation result. For example, when the water gauge range is 100 cm and the area S of the weir inner wall mask in the image coordinate system is 361826 pixels, the established weir water level recognition model is as follows:
L=68.50-8.71×10-5×S。L = 68.50-8.71×10 -5 ×S.
S5.利用水位流量关系模型和目标堰槽水位,计算得到量水堰流量,其中,所述水位流量关系模型为:S5. Calculate the water flow rate of the water measuring weir using the water level flow relationship model and the target weir water level, wherein the water level flow relationship model is:
式中,Q表示量水堰流量;Ce表示流量经验系数;θ表示V型堰顶角;g表示重力加速度;he表示V型堰顶角的高度;L表示目标堰槽水位。Where Q represents the flow rate of the measuring weir; Ce represents the flow rate empirical coefficient; θ represents the V-shaped weir top angle; g represents the gravitational acceleration; he represents the height of the V-shaped weir top angle; and L represents the target weir water level.
本实施例对透视校正图像进行提示点信息修正与掩码计算,通过堰槽水位识别模型计算目标堰槽水位,再代入量水堰水位-流量计算公式计算所对应的流量值,本实施例中的量水堰为V型堰,量水堰流量计算公式系数和使用条件参照国标JJG-711-1990。In this embodiment, the prompt point information correction and mask calculation are performed on the perspective corrected image, the target weir water level is calculated by the weir water level recognition model, and then the corresponding flow value is calculated by the water level-flow calculation formula of the measuring weir. The measuring weir in this embodiment is a V-shaped weir, and the coefficients and usage conditions of the water measuring weir flow calculation formula refer to the national standard JJG-711-1990.
本发明实施例提供了一种可自动修正的量水堰流量摄影监测方法,所述方法包括对原始水尺图像进行透视校正,利用融合VIT模型与交叉注意力机制模块的SAM图像分割模型对透视校正图像进行分割处理,建立掩码像素与堰槽水位之间的关系,同时利用YOLO v5模型识别水尺因环境因素产生的偏移距离,自动对分割掩码进行修正,在各种环境或观测角度下的水尺或堰槽内壁均具有良好的分割识别能力,极大地提高了量水堰水位和流量监测的准确程度,实现了量水堰水位和流量的快速、连续、低成本、自动化监测,具有很强的应用价值。The embodiment of the present invention provides a method for automatically correcting photographic monitoring of water measuring weir flow, the method comprising performing perspective correction on an original water gauge image, performing segmentation processing on the perspective corrected image by using a SAM image segmentation model that integrates a VIT model and a cross-attention mechanism module, establishing a relationship between mask pixels and the water level of a weir, and simultaneously using a YOLO v5 model to identify an offset distance of the water gauge caused by environmental factors, automatically correcting the segmentation mask, and having good segmentation and recognition capabilities for water gauges or inner walls of weirs in various environments or observation angles, thereby greatly improving the accuracy of water level and flow monitoring of water measuring weirs, and realizing rapid, continuous, low-cost, and automated monitoring of water level and flow of water measuring weirs, and having strong application value.
需要说明的是,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be noted that the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
在一个实施例中,如图7所示,本发明实施例提供了一种可自动修正的量水堰流量摄影监测装置,所述装置包括:In one embodiment, as shown in FIG. 7 , the present invention provides an automatically correctable water measuring weir flow photography monitoring device, the device comprising:
图像校正模块101,用于获取原始水尺图像,并对原始水尺图像进行透视校正,得到透视校正图像;The image correction module 101 is used to obtain an original water gauge image and perform perspective correction on the original water gauge image to obtain a perspective corrected image;
图像标注模块102,用于在所述透视校正图像中标注前景点和背景点,生成标注点信息;An image annotation module 102 is used to annotate foreground points and background points in the perspective-corrected image to generate annotation point information;
图像分割模块103,用于获取预先构建好的融合VIT模型与交叉注意力机制模块的SAM图像分割模型,将所述透视校正图像和所述标注点信息输入所述SAM图像分割模型中进行分割处理,得到目标堰槽内壁分割结果;其中,所述VIT模型用于提取所述透视校正图像的图像特征;所述交叉注意力机制模块用于对所述图像特征和所述标注点信息进行解码计算;The image segmentation module 103 is used to obtain a pre-built SAM image segmentation model that integrates the VIT model and the cross-attention mechanism module, input the perspective-corrected image and the annotation point information into the SAM image segmentation model for segmentation processing, and obtain the target weir inner wall segmentation result; wherein the VIT model is used to extract the image features of the perspective-corrected image; and the cross-attention mechanism module is used to decode and calculate the image features and the annotation point information;
水位识别模块104,用于根据所述目标堰槽内壁分割结果和预先建立的堰槽水位识别模型,得到目标堰槽水位;The water level recognition module 104 is used to obtain the target weir water level according to the target weir inner wall segmentation result and the pre-established weir water level recognition model;
流量监测模块105,用于利用水位流量关系模型和目标堰槽水位,计算得到量水堰流量。The flow monitoring module 105 is used to calculate the water measuring weir flow using the water level flow relationship model and the target weir water level.
关于一种可自动修正的量水堰流量摄影监测装置的具体限定可以参见上述对于一种可自动修正的量水堰流量摄影监测方法的限定,此处不再赘述。本领域普通技术人员可以意识到,结合本申请所公开的实施例描述的各个模块和步骤,能够以硬件、软件或者两者结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。For the specific limitations of an automatically correctable water-measuring weir flow photography monitoring device, please refer to the above-mentioned limitations of an automatically correctable water-measuring weir flow photography monitoring method, which will not be repeated here. A person of ordinary skill in the art will appreciate that the various modules and steps described in conjunction with the embodiments disclosed in this application can be implemented in hardware, software, or a combination of both. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
本发明实施例提供了一种可自动修正的量水堰流量摄影监测装置,所述装置通过图像校正模块对原始水尺图像进行透视校正;通过图像分割模块对透视校正图像进行分割处理;通过水位识别模块和流量监测模块实现对量水堰水位和流量的自动化监测。与现有技术相比,本申请利用YOLO v5模型识别水尺因环境因素产生的偏移距离,自动对分割掩码进行修正,修正过程速度快、实时性好、稳定性和可控性高,有效地实现了水尺图像的自动分割和修正,具有实现方式简单、高效、低成本等优点。The embodiment of the present invention provides a flow photography monitoring device for a water measuring weir that can be automatically corrected. The device performs perspective correction on the original water gauge image through an image correction module; performs segmentation processing on the perspective corrected image through an image segmentation module; and realizes automatic monitoring of the water level and flow of the water measuring weir through a water level recognition module and a flow monitoring module. Compared with the prior art, the present application uses the YOLO v5 model to identify the offset distance of the water gauge caused by environmental factors, and automatically corrects the segmentation mask. The correction process is fast, real-time, stable and controllable, and effectively realizes the automatic segmentation and correction of the water gauge image, which has the advantages of simple implementation, high efficiency and low cost.
以上所述实施例仅表达了本申请的几种优选实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本技术领域的普通技术人员来说,在不脱离本发明技术原理的前提下,还可以做出若干改进和替换,这些改进和替换也应视为本申请的保护范围。因此,本申请专利的保护范围应以所述权利要求的保护范围为准。The above-mentioned embodiments only express several preferred implementation modes of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in the technical field, several improvements and substitutions can be made without departing from the technical principles of the present invention, and these improvements and substitutions should also be regarded as the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be based on the protection scope of the claims.
Claims (7)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311219793.1A CN117346846B (en) | 2023-09-20 | 2023-09-20 | A method and device for automatically correcting water-measuring weir flow photography monitoring |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311219793.1A CN117346846B (en) | 2023-09-20 | 2023-09-20 | A method and device for automatically correcting water-measuring weir flow photography monitoring |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN117346846A CN117346846A (en) | 2024-01-05 |
| CN117346846B true CN117346846B (en) | 2024-06-25 |
Family
ID=89354938
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202311219793.1A Active CN117346846B (en) | 2023-09-20 | 2023-09-20 | A method and device for automatically correcting water-measuring weir flow photography monitoring |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN117346846B (en) |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118093840B (en) * | 2024-04-25 | 2024-07-30 | 腾讯科技(深圳)有限公司 | Visual question-answering method, device, equipment and storage medium |
| CN118570700A (en) * | 2024-05-31 | 2024-08-30 | 中国农业大学 | Channel flow measurement method and device based on bionic eagle eye vision |
| CN118411675B (en) * | 2024-06-27 | 2024-09-06 | 武汉大水云科技有限公司 | Water level identification method based on SAM large model |
| CN119600253B (en) * | 2024-10-21 | 2025-09-16 | 浣江实验室 | Weapon and equipment recognition method based on YOLOv7 |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109443480A (en) * | 2018-11-02 | 2019-03-08 | 南京邮电大学 | Gauge positioning and water level measurement method based on image procossing |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9541432B2 (en) * | 2013-05-17 | 2017-01-10 | The United States Of America As Represented By The Administrator Of The U.S. Environmental Protection Agency | Flow imaging and monitoring for synchronized management of wide area drainage |
| CN118159805A (en) * | 2021-09-24 | 2024-06-07 | 水力雷达有限公司 | Flow and level monitor for fluid systems |
| CN114812701A (en) * | 2022-04-08 | 2022-07-29 | 新疆坎儿井灌溉技术有限责任公司 | Flow measuring method for gentle slope channel |
| CN115638835A (en) * | 2022-10-09 | 2023-01-24 | 中国电建集团华东勘测设计研究院有限公司 | Automatic flow monitoring method and device for measuring weir based on image recognition algorithm |
| CN115861616B (en) * | 2022-12-09 | 2025-09-12 | 复旦大学 | Semantic Segmentation System for Medical Image Sequences |
| CN219328482U (en) * | 2023-01-10 | 2023-07-11 | 湖北清江水电开发有限责任公司 | Manual observation device for dam measuring weir |
| CN116189180A (en) * | 2023-04-28 | 2023-05-30 | 青岛理工大学 | Urban streetscape advertisement image segmentation method |
-
2023
- 2023-09-20 CN CN202311219793.1A patent/CN117346846B/en active Active
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109443480A (en) * | 2018-11-02 | 2019-03-08 | 南京邮电大学 | Gauge positioning and water level measurement method based on image procossing |
Also Published As
| Publication number | Publication date |
|---|---|
| CN117346846A (en) | 2024-01-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN117346846B (en) | A method and device for automatically correcting water-measuring weir flow photography monitoring | |
| CN111260615B (en) | Laser and machine vision fusion-based method for detecting apparent diseases of unmanned aerial vehicle bridge | |
| CN105678742B (en) | A kind of underwater camera scaling method | |
| CN112766274A (en) | Water gauge image water level automatic reading method and system based on Mask RCNN algorithm | |
| CN108564065B (en) | A method for identifying open flames in cable tunnels based on SSD | |
| Feng et al. | Crack assessment using multi-sensor fusion simultaneous localization and mapping (SLAM) and image super-resolution for bridge inspection | |
| CN111598098B (en) | A fully convolutional neural network-based method for water level detection and validity identification of water gauge | |
| CN115578695B (en) | A water gauge water level machine vision detection method and device with free shooting angle | |
| CN111292371A (en) | Intelligent water level detection equipment, intelligent water level monitoring management device and detection method | |
| CN112215125A (en) | A Water Level Recognition Method Based on YOLOv3 | |
| CN114998308A (en) | Defect detection method and system based on photometric stereo | |
| CN115983141A (en) | Method, medium and system for inverting wave height based on deep learning | |
| CN111998910A (en) | A multi-level water gauge water level visual measurement method and measurement system | |
| CN113705564B (en) | Pointer type instrument identification reading method | |
| WO2020093631A1 (en) | Antenna downtilt angle measurement method based on depth instance segmentation network | |
| CN117197010A (en) | Method and device for carrying out workpiece point cloud fusion in laser cladding processing | |
| CN110851978A (en) | Camera position optimization method based on visibility | |
| CN115830140B (en) | Offshore short-range photoelectric monitoring method, system, medium, equipment and terminal | |
| CN116137509A (en) | Photovoltaic panel infrared image fault detection and location system and method based on UAV | |
| CN116109869B (en) | Method and device for identifying reservoir water level fluctuation based on water bank image matching | |
| CN118887572B (en) | Method for identifying density of floating objects on water surface based on image | |
| Li et al. | Automatic tiny crack positioning and width measurement with parallel laser line‐camera system | |
| CN114529815A (en) | Deep learning-based traffic detection method, device, medium and terminal | |
| CN110211148A (en) | A kind of underwater picture pre-segmentation method estimated based on dbjective state | |
| CN113822104B (en) | Artificial intelligence surface of water detecting system based on virtual scale of many candidates |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |