A chemical leakage liquid identification, detection, early warning and processing method based on visual identification

CN123015998APending Publication Date: 2026-10-30TIANJIN DONGJIANG ZHONGSHI SHIPPING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611065503.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-17
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0003]然而,现有视觉检测方法普遍存在明显缺陷:对于苯系物、醇类、酮类等透明或半透明化学品,液膜在金属表面上呈无色或浅色状态,常规的颜色分割和纹理分析几乎无法识别

Benefits of technology

[0075]本申请通过形貌特征分析,即灰度曲率或薄膜干涉色调梯度提取密封面或包覆层的局部微变形量,将泄漏检测从寻找液斑转变为监测间接物理信号,从而能够在液膜厚度仅为纳米至微米级的超早期阶段发出预警,为现场处置争取宝贵时间。利用薄膜干涉色相梯度单调性和干涉阶次一致性校验,可有效区分透明液膜与金属热变色、油污等干扰,解决了透明化学品不可见的行业痛点。引入重力溯源不连通性特征,通过追踪湿迹源端点是否位于环境水源掩膜内,直接排除冷凝水、雨水等环境水迹造成的误报,判决逻辑清晰、可解释性强且无需训练样本。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015998A_ABST
    Figure CN123015998A_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a chemical leakage liquid identification, detection, early warning and processing method based on visual identification, obtains a visible light image sequence of a target area, identifies a sealing surface or a coating layer area, performs morphology analysis to obtain a first feature vector reflecting a local deformation amount, obtains a predefined second feature vector, which represents a statistical fluctuation range of an environmental interference source under a non-leakage condition, calculates a deviation degree of the two feature vectors and compares the deviation degree with a threshold, and if the deviation degree exceeds the threshold, an early warning signal is output in combination with a trend check of a historical deviation degree sequence. The application uses indirect physical quantities such as a gray scale curvature, a film interference color tone gradient, a gravity traceability discontinuity and a drop time domain statistics to realize low false alarm and extremely early warning for transparent chemicals and super-early leakage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial safety monitoring technology, and in particular to a method for identifying, detecting, and issuing early warnings of chemical spills based on visual recognition. Background Technology

[0002] In the petrochemical and fine chemical industries, pipe flanges, valve sealing surfaces, and equipment coatings are high-risk areas for chemical leaks. Traditional leak detection methods rely heavily on pressure sensors, gas detectors, or manual inspections, which suffer from problems such as slow response, sparse detection points, and difficulty in locating micro-leaks. In recent years, computer vision-based leak detection methods have gained increasing attention, enabling automatic alarms by analyzing the color, texture, or motion characteristics of liquid spots in surveillance videos.

[0003] However, existing visual inspection methods generally have significant drawbacks: for transparent or semi-transparent chemicals such as benzene compounds, alcohols, and ketones, the liquid film on the metal surface appears colorless or light-colored, making conventional color segmentation and texture analysis almost impossible to identify. In the very early stages of leakage, the liquid film thickness is only at the submicron level, and no dripping droplets or obvious wet marks have yet formed. Methods such as frame difference, optical flow, or background subtraction fail because the signal energy is below the noise floor.

[0004] Furthermore, industrial sites present various environmental interference sources, such as condensate, rainwater seepage, spray water stains, oil stains, and metal thermal discoloration. These interference sources exhibit low-grayscale or mottled characteristics in images similar to actual leaks, leading to a persistently high false alarm rate for existing methods. Some solutions have attempted to use deep learning for target detection, but transparent chemical samples are scarce, early film morphologies are highly variable, making model training difficult and resulting in poor generalization ability. Summary of the Invention

[0005] This application provides a vision-based chemical leak detection and early warning method. By detecting indirect physical quantities caused by the leak, such as local micro-deformation, interference hue gradient, wet trace gravity-based source disconnection, and dripping water time-domain statistical characteristics, and comparing the deviation and trend verification with the statistical fluctuation range under normal operating conditions, it achieves an extremely low false alarm rate and extremely early warning for transparent chemicals and ultra-early film leaks. To achieve the above objectives, this application adopts the following technical solution:

[0006] This invention provides a method for identifying, detecting, and issuing early warnings of chemical spills based on visual recognition, the method comprising:

[0007] Acquire a visible light image sequence of the target area;

[0008] Image recognition is performed on the visible light image sequence to obtain the target image region where the sealing surface or the covering layer is located;

[0009] The target image region is subjected to morphological analysis to obtain a first feature vector reflecting the local deformation.

[0010] Obtain a predefined second feature vector, which represents the expected deformation range of the environmental interference source at the same spatial location under leak-free operating conditions;

[0011] Calculate the deviation between the first feature vector and the second feature vector to obtain the deviation.

[0012] The deviation is compared with a preset threshold to obtain a comparison result;

[0013] If the comparison result indicates that the deviation exceeds the threshold, a leakage warning signal is output by combining the trend verification of the historical deviation sequence.

[0014] In some possible implementations, obtaining the first eigenvector reflecting the local deformation further includes:

[0015] Binarization segmentation is performed on the target image region to obtain a wettage mask;

[0016] The wet trace mask is skeletonized and traced along the anti-gravity direction to obtain the source endpoint attribution characteristics;

[0017] The pixel brightness within the fixed detection window above the target image region is sampled in a time sequence and pulse extracted to obtain the statistical characteristics of the water droplet interval;

[0018] The features obtained from the morphology analysis are concatenated with the source endpoint attribution features and the drip interval statistical features to generate the first feature vector.

[0019] In some possible implementations, the topographic analysis of the target image region to obtain a first feature vector reflecting the amount of local deformation includes at least one of grayscale curvature analysis or thin-film interference hue gradient analysis, wherein the thin-film interference hue gradient analysis includes:

[0020] Each frame of the target image region is converted to the HSV color space, and the hue channel image is extracted.

[0021] Calculate the gradients of the hue channel image in the horizontal and vertical directions to obtain a hue gradient map;

[0022] Perform region growing on the hue gradient map to obtain connected regions with monotonically increasing or decreasing hue values;

[0023] Calculate the rate of change of the hue gradient along the normal direction within the connected region to obtain the gradient change sequence;

[0024] Extract the hue value corresponding to the first element from the gradient change sequence as the starting hue value, and extract the hue value corresponding to the last element as the ending hue value;

[0025] The length of the gradient change sequence, the starting hue value, and the ending hue value are encoded as part of the first feature vector.

[0026] In some possible implementations, obtaining a connected component with monotonically increasing or decreasing hue values ​​includes:

[0027] Obtain initial connected component candidates;

[0028] Perform phase unpacking on the pixel hue values ​​within the initial connected component candidate along the normal direction to obtain the unpacked phase sequence;

[0029] Calculate the monotonicity index of the expanded phase sequence;

[0030] If the monotonicity index is lower than the preset monotonicity threshold, the initial connected component candidate is discarded.

[0031] Calculate the phase difference between adjacent extreme points in the expanded phase sequence to obtain the phase difference sequence;

[0032] If the deviation between each phase difference in the phase difference sequence and any order in the preset thin-film interference order library exceeds a preset deviation threshold, then the initial connected component candidate is discarded.

[0033] The initial connected component candidates that were not discarded are used as the connected components.

[0034] In some possible implementations, the morphology analysis includes at least one of grayscale curvature analysis or thin-film interference hue gradient analysis, wherein the grayscale curvature analysis specifically includes:

[0035] For each frame of the target image region, extract the grayscale profile along the direction perpendicular to the generatrix to obtain a set of grayscale curves;

[0036] Gaussian filtering is applied to the grayscale curve to obtain a smooth curve;

[0037] Calculate the second derivative of the smooth curve to obtain a sequence of curvature values;

[0038] Local peak points in the curvature value sequence that exceed a preset curvature threshold are recorded as candidate deformation points;

[0039] The candidate deformation points are clustered according to their spatial location to obtain deformation clusters;

[0040] Calculate the mean curvature and variance of curvature of all candidate deformation points within the deformation cluster, and use the mean curvature and variance of curvature as part of the first feature vector.

[0041] In some possible implementations, obtaining the first eigenvector reflecting the local deformation further includes:

[0042] Binarization segmentation is performed on the target image region to obtain a wettage mask;

[0043] The wet mask is skeletonized to obtain a skeleton line with a width of one pixel;

[0044] By tracing along the skeleton line from the lowest point to the highest point, the coordinates of the source endpoint are obtained;

[0045] Obtain a pre-calibrated legitimate water source mask, which includes a flange drip projection area, a spray coverage area, and a condensate concentrated drip area;

[0046] Calculate the Euclidean distance from the source endpoint coordinates to the legal water source mask. If the Euclidean distance is greater than zero, generate a first feature value as a first preset value; otherwise, generate a first feature value as a second preset value.

[0047] The first feature value is used as part of the first feature vector.

[0048] In some possible implementations, obtaining the first eigenvector reflecting the local deformation further includes:

[0049] The brightness of pixels within a fixed detection window above the target image region is sampled in a time sequence to obtain a brightness time series;

[0050] Perform a difference operation on the brightness time series to obtain a difference series;

[0051] Pulses whose amplitude satisfies the brightness jump condition and whose width satisfies the narrow pulse condition are extracted from the difference sequence. Each pulse corresponds to a dripping event, resulting in a dripping timestamp sequence.

[0052] Calculate the interval between adjacent timestamps in the dripping timestamp sequence to obtain the interval sequence;

[0053] Perform a normality test on the interval sequence to obtain a test statistic, and use the test statistic as the first component of the first feature vector;

[0054] Periodogram analysis is performed on the interval sequence to obtain the dominant frequency intensity, and the dominant frequency intensity is used as the second component of the first feature vector.

[0055] In some possible implementations, the step of performing image recognition on the visible light image sequence to obtain the target image region where the sealing surface or covering layer is located includes:

[0056] Edge detection is performed on the starting frame image in the visible light image sequence to obtain a set of edge pixels;

[0057] Line segment extraction is performed on the edge pixel set to obtain multiple line segments;

[0058] From the plurality of line segments, at least two parallel line segments that meet the geometric constraints of the sealing surface are selected, wherein the geometric constraints include the difference between the line segment spacing and the preset bolt circle diameter being less than a preset difference threshold.

[0059] The polygonal region enclosed by the at least two parallel line segments is marked as the initial region;

[0060] For each subsequent frame in the visible light image sequence, optical flow tracing is performed starting from the initial region of the previous frame to obtain the updated region of the current frame;

[0061] The updated region is taken as the target image region.

[0062] In some possible implementations, obtaining the predefined second feature vector includes:

[0063] Under leak-free operating conditions, a sequence of reference images of the same target area was acquired.

[0064] The steps of edge detection, line segment extraction, optical flow tracking, grayscale profile extraction, curvature calculation, and clustering are repeatedly performed on the reference image sequence to obtain multiple reference deformation clusters;

[0065] The range of fluctuations in the mean curvature of the multiple reference deformation clusters is statistically analyzed to obtain the reference mean interval;

[0066] The range of curvature variance fluctuations of the multiple reference deformation clusters is statistically analyzed to obtain the reference variance interval;

[0067] The upper and lower bounds of the reference mean interval and the upper and lower bounds of the reference variance interval are combined to generate the second feature vector.

[0068] In some possible implementations, calculating the deviation between the first feature vector and the second feature vector includes:

[0069] Extract the current curvature mean and current curvature variance from the first feature vector;

[0070] Extract the upper and lower bounds of the reference mean interval and the upper and lower bounds of the reference variance interval from the second feature vector;

[0071] Calculate the first distance between the current mean curvature value and the reference mean interval. If the current mean curvature value is within the interval, the first distance is zero; otherwise, the first distance is the absolute value of the difference between the current mean curvature value and the upper or lower bound of the reference mean interval.

[0072] Calculate the second distance between the current curvature variance and the reference variance interval. If the current curvature variance is within the interval, the second distance is zero; otherwise, the second distance is the absolute value of the difference between the current curvature variance and the upper or lower bound of the reference variance interval.

[0073] The deviation is obtained by weighted summation of the first distance and the second distance.

[0074] As can be seen from the above technical solution, this application has the following beneficial effects:

[0075] This application utilizes morphological feature analysis, specifically grayscale curvature or thin-film interference hue gradient, to extract local micro-deformation of the sealing surface or coating layer. This transforms leak detection from searching for liquid spots to monitoring indirect physical signals, enabling early warnings at an ultra-early stage when the liquid film thickness is only in the nanometer to micrometer range, thus gaining valuable time for on-site handling. By leveraging the monotonicity of the thin-film interference hue gradient and the consistency verification of interference order, it can effectively distinguish transparent liquid films from interference such as metal thermal discoloration and oil stains, addressing the industry pain point of the invisibility of transparent chemicals. Introducing the gravity-based source-tracing discontinuity feature, by tracking whether the endpoint of the wet trace source is located within an environmental water source mask, it directly eliminates false alarms caused by environmental water traces such as condensate and rainwater. The decision logic is clear, highly interpretable, and requires no training samples.

[0076] This application performs time-domain statistical analysis of dripping events when conducting feature analysis related to morphological features. By analyzing the coefficient of variation and dominant frequency intensity of brightness pulse intervals, it can distinguish between random condensation dripping and quasi-periodic leakage dripping, making it particularly suitable for areas such as pipe corridors and collection tanks. By predefining a second feature vector, i.e., the statistical fluctuation range of environmental interference sources under normal operating conditions, and calculating the deviation from the current first feature vector, and then combining the trend verification, slope, and over-limit ratio of historical deviation sequences, it effectively suppresses instantaneous interference such as single-frame noise, flying insects, and light flicker, achieving an extremely low false alarm rate. The entire solution uses only ordinary visible light cameras, without requiring special hardware such as infrared, ultraviolet, or structured light, nor does it require a large number of labeled samples to train deep learning models. It has low deployment costs, strong adaptability, and can be widely applied in chemical plants, pharmaceutical workshops, tank farms, and other scenarios. Attached Figure Description

[0077] The invention will now be further described with reference to the accompanying drawings.

[0078] Figure 1 The main flowchart of the overall leakage early warning method provided in the embodiments of this application;

[0079] Figure 2 A flowchart of thin-film interference tone gradient analysis provided for embodiments of this application;

[0080] Figure 3 A flowchart of grayscale curvature analysis provided for embodiments of this application;

[0081] Figure 4 A flowchart for generating disconnectivity features for gravity tracing provided in this application embodiment;

[0082] Figure 5 A flowchart for generating time-domain statistical features of a dripping event provided in an embodiment of this application;

[0083] Figure 6 This is a flowchart of image recognition and target area localization provided in an embodiment of this application;

[0084] Figure 7 A flowchart for deviation calculation and trend verification provided in the embodiments of this application. Detailed Implementation

[0085] The terms "first," "second," and "third," etc., used in this application specification, claims, and drawings are for distinguishing different objects, not for specifying a particular order.

[0086] In the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0087] Research has revealed that existing technologies generally directly detect the color, texture, or motion characteristics of liquid spots. However, when transparent chemicals, ultra-early-stage thin films, and interference sources such as condensate and oil contamination coexist, the detection performance is poor and the false alarm rate is high. These methods cannot utilize indirect physical quantities such as liquid film interference hue, gravity-based source non-connectivity, or drip time-domain statistics, thus making it difficult to achieve extremely early, low-false-alarm leak warnings.

[0088] To address the aforementioned issues, this application provides a visual recognition-based method for identifying, detecting, and issuing early warnings of chemical spills.

[0089] Example 1

[0090] like Figures 1-7As shown, this invention relates to a computer vision-based method for early warning of chemical leaks, particularly suitable for very early leak detection in critical components such as pipe flanges, valve sealing surfaces, and equipment coatings in industries such as petrochemicals, fine chemicals, and pharmaceuticals. Existing technologies generally directly detect the color, texture, or motion characteristics of liquid patches, which fails in scenarios involving transparent chemicals, ultra-early film states, or the presence of condensation or oil contamination. This invention uniquely shifts the detection focus from the liquid itself to indirect physical quantities caused by the leak, including local micro-deformation of the sealing surface or coating. This is achieved through characterization using grayscale curvature or film interference hue gradients, the traceability of wet traces, and the temporal statistical structure of dripping events. Furthermore, by comparing the deviation with the statistical fluctuation range of environmental interference sources under leak-free conditions, and combining this with historical trend verification, a very early warning with a low false alarm rate is achieved.

[0091] The process of extracting the microscopic geometry (undulations, curvature, interference fringes) of a target surface from an image is independent of the liquid's color or motion. The output of morphology analysis is a set of numerical feature vectors, with each component corresponding to a quantized value of a geometric property.

[0092] Environmental interference sources: These are naturally occurring image features that may cause false alarms under leak-free conditions, including but not limited to metal thermal discoloration, oil stains, condensation, rainwater seepage, and spray water. These interference sources may also cause local grayscale or hue changes, but their characteristic fluctuation range is fundamentally different from that of a real leak.

[0093] The first feature vector is a multi-dimensional numerical vector extracted from the current frame image to describe the features of local deformation and environmental disturbance sources. This vector may include one or more components from grayscale curvature features, interference tone gradient features, gravity source features, and dripping water temporal statistical features. In this embodiment, the first feature vector is formed by concatenating the features obtained from morphology analysis with other optional features.

[0094] The second eigenvector is a reference vector composed of the characteristic fluctuation ranges of environmental interference sources under pre-statistical conditions without leakage. Each component of this vector is an interval (lower and upper bounds) used for comparison with the first eigenvector.

[0095] Deviation: The weighted distance between the first and second eigenvectors, quantifying the degree to which the current state deviates from the normal environment. The greater the deviation, the less likely the current deformation is caused by environmental disturbances.

[0096] Thin-film interference order library: A set of phase differences corresponding to possible interference orders pre-calculated based on the refractive index of chemicals and the visible light wavelength range. Used to verify whether observed hue changes conform to the physical laws of thin-film interference.

[0097] Phase unrolling: The process of restoring a continuous monotonic sequence of hue angle values ​​within the range of 0° to 360° by adding or subtracting integer multiples of 360°.

[0098] Environmental water source mask: A pre-marked image area that identifies the spatial locations where environmental water sources such as condensate and spray water may appear. The mask is stored in polygon format.

[0099] Trend verification of historical deviation sequence: linear regression is performed on the deviation of the most recent frames, and the slope and the proportion of exceeding the limit are used to judge whether the anomaly is continuous, so as to reduce false alarms caused by instantaneous interference.

[0100] Gray-scale curvature analysis: By calculating the second derivative of the gray-scale profile of the image along a specific direction, it can detect tiny bumps or depressions on the surface, thereby providing early warning of internal wetting of the insulation layer.

[0101] Thin film interference hue gradient analysis: Ultrathin liquid films are detected by analyzing the hue monotonicity and phase consistency of interference fringes caused by transparent liquid films on metal surfaces.

[0102] Source endpoint attribution feature: By tracing the wet trace skeleton line against gravity to the source endpoint, it is determined whether the source endpoint is located within the environmental water source mask, thereby distinguishing between environmental water traces and body leakage. This feature value is either a first preset value (e.g., 1) or a second preset value (e.g., 0).

[0103] Statistical characteristics of dripping intervals: By analyzing the time interval distribution of brightness pulses within a fixed detection window, random condensation dripping can be distinguished from periodic leakage dripping. This characteristic includes two components: the interval variation coefficient and the dominant frequency intensity.

[0104] Regarding the hardware configuration and image acquisition of this system.

[0105] This embodiment was implemented in the benzene series storage tank area of ​​a chemical plant. The target monitoring area includes: a flange connection surface, a horizontal pipe with an aluminum insulation layer, and the edge area of ​​a liquid collection tank below the pipe rack. A standard industrial visible light camera was installed at an appropriate distance from the target area, facing the flange surface and the pipe axis at a fixed angle. The camera was connected to an industrial control computer via Ethernet. The industrial control computer was pre-installed with the algorithm software described in this invention.

[0106] The acquired video stream is segmented into a continuous image sequence, with each frame being an RGB three-channel color image. The images are first subjected to median filtering for noise reduction (kernel size is set according to image resolution, typically 3×3 pixels), and then converted to different color spaces required for subsequent processing. All image processing is executed in real-time on an industrial control computer, with processing time meeting online monitoring requirements.

[0107] Specific implementation methods include:

[0108] (a) Obtain the visible light image sequence of the target area.

[0109] The camera continuously acquires RGB images of the target area. Image data is temporarily stored in a compressed format in a circular memory buffer. The buffer capacity is set according to the actual frame rate and processing latency, typically storing several seconds to tens of seconds of data. Each frame is released after processing to save memory. To reduce computational load, frame skipping can be selected based on on-site requirements, such as processing every other frame. The acquired raw image sequence is recorded as the current frame and historical frames for subsequent steps.

[0110] (ii) Perform image recognition on the visible light image sequence to obtain the target image area where the sealing surface or the covering layer is located.

[0111] The purpose of this step is to automatically crop out a local area from the entire image, including key leak monitoring locations (flange sealing surfaces or aluminum cladding on the insulation layer), to reduce subsequent computation and improve the targeting of feature extraction. The specific implementation method is as follows:

[0112] Edge detection of the initial frame involves performing Canny edge detection (low threshold 50, high threshold 150, both grayscale) on the first frame image after system startup, resulting in a binary edge map. Then, Hough transform is used to detect line segments. The Hough transform maps points in the image space to a parameter space, and the line parameters are determined by the peak values ​​of the accumulator. The detected line segments must meet a minimum length requirement, such as one-tenth of the image width.

[0113] Geometric constraint screening is performed, meaning that for the flange, the bolt circle diameter is a known prior parameter (from the equipment drawings). Camera calibration is required during system installation: using a checkerboard calibration board, multiple images are captured, and the intrinsic parameter matrix is ​​calculated using a standard calibration algorithm to obtain the focal length (in pixels) and principal point coordinates. The object distance can be measured using a laser rangefinder or estimated based on a known reference object. The formula for calculating the pixel distance corresponding to the bolt circle diameter is:

[0114] .

[0115] The pixel distance is stored as a preset value. The length and direction of each line segment are calculated, and line segment pairs with an angular difference less than a preset angle threshold (e.g., 5°) are identified. Their perpendicular distance is then checked to ensure it is close to the pixel distance of the preset bolt diameter; the difference must be less than a preset difference threshold. The preset difference threshold is set to 5% of the bolt diameter pixel value or a fixed pixel value (e.g., the larger of 10 pixels) to accommodate calibration errors, typically 1-3%, with 5% as a safety margin. The polygonal region enclosed by the line segment pairs that meet the criteria, such as a portion of a ring, is marked as the initial region. For pipe cladding, two parallel line segments with a distance equal to the projected width of the pipe diameter must be found; the area between them is the cladding region.

[0116] Optical flow tracking update, that is, for each subsequent frame of image, starting from the target region of the previous frame, uses... Tracking is performed using the sparse optical flow method. The method obtains the pixel motion vector by solving the local gradient constraint equation. Specifically, for each feature point, it employs... Corner detection involves calculating the gradient structure tensor matrix for each pixel, selecting points with smaller eigenvalues ​​greater than a preset threshold, and solving the system of equations:

[0117] ;

[0118] in For image spatial gradient, The summation window is typically 5×5 pixels and represents the temporal gradient (grayscale difference between adjacent frames). The motion vectors are used. After obtaining the motion vectors of all feature points, the global motion parameters (translation, rotation, scaling) of the entire region are estimated through affine transformation or perspective transformation. The region boundaries are then updated to obtain the updated region for the current frame. This updated region is then output as the target image region for the current frame.

[0119] Principle Explanation: Since industrial cameras and monitored targets are fixed, the approximate position of the sealing surface or covering layer in the image remains unchanged, but it may drift slowly due to vibration, thermal expansion, or minute camera displacement. By utilizing edge geometry localization in the initial frame, combined with optical flow tracking, time-consuming global edge detection can be avoided in each frame, while maintaining sub-pixel accuracy of region boundaries. This method does not require training any object detection model, is entirely based on deterministic geometric constraints, and is insensitive to changes in illumination.

[0120] (iii) Perform morphological analysis on the target image region to obtain the first feature vector that quantifies the local deformation.

[0121] Morphology analysis refers to extracting physical quantities from a two-dimensional image of the target image region that can quantify spatial morphological changes such as minute undulations, concavities, or interference fringes on the surface of the sealing surface or coating layer. These physical quantities do not directly describe the presence of liquid, but rather describe the sub-pixel-level geometric deformation of the solid surface caused by internal wetting, expansion, corrosion, or medium adsorption. Morphology analysis specifically includes two selectable modes: grayscale curvature analysis and thin-film interference tone gradient analysis. These can be used independently or in combination. This embodiment illustrates the use of both analyses simultaneously and the concatenation of the results into a first feature vector, but in practical applications, one mode can be selected depending on the scenario.

[0122] The specific implementation of the two analyses is described in detail below.

[0123] 1. Gray-scale curvature analysis.

[0124] Gray-scale curvature analysis is based on the following physical principle: When chemical leakage occurs inside the insulation layer, the insulation material absorbs the liquid and experiences localized weight gain, expansion, or temperature changes, resulting in minute bulges or depressions in the outer aluminum cladding. These bulges are represented in a two-dimensional image as curvature changes in the gray-scale profile along a direction perpendicular to the pipe axis. Even if the bulge amplitude is less than 0.1 mm, it will still cause a nonlinear gradient in grayscale under a specific illumination angle. This minute deformation can be amplified by calculating the second derivative (curvature).

[0125] Specific implementation steps:

[0126] Grayscale conversion involves converting each frame of the target image region into a grayscale image. The conversion uses the standard luminance formula:

[0127] .

[0128] Determine the busbar direction, which is done by using the direction angles of the two parallel line segments extracted in the previous step to determine the busbar direction of the pipe cladding. For flange faces, the busbar direction degenerates into the radial direction of the sealing surface (radiating outwards from the center). If the direction cannot be obtained, for example, if the first frame detection fails, the direction of the previous frame or the default horizontal direction is used.

[0129] Gray-scale profile sampling involves sampling gray-scale profiles at equal intervals along a direction perpendicular to the generatrix. The sampling interval is dynamically set based on the image resolution, for example, 0.5% of the image width, ensuring approximately 5 pixels at typical resolutions. Let N profile lines be sampled in total. The length L of each profile line covers the width from the edge of the overlay layer to the edge, determined by the boundary of the target region. For each profile line, bilinear interpolation is used to extract the gray-scale values ​​of all pixels along that line, resulting in a one-dimensional array.

[0130] Gaussian filtering, which involves applying a Gaussian filter to each one-dimensional array, is used to remove image noise and fine texture lines while retaining low-frequency components that reflect structural deformation. The standard deviation of the Gaussian kernel... Set to 1.0 (experiments show that this value has good results for 1080p images of different resolutions; if the resolution changes significantly, it can be adjusted proportionally), and set the kernel radius to... Integers. The one-dimensional Gaussian kernel formula is: After normalization, it is convolved with the signal. After filtering, a smooth curve is obtained.

[0131] Curvature calculation, specifically, calculating the second derivative (curvature) of a smooth curve. The specific algorithm is as follows:

[0132] For points inside the curve (index) From 2 to The first derivative is obtained using the central difference: ;

[0133] For boundary points ( or The first derivative is obtained by forward or backward difference: , The curvature values ​​at boundary points are not used for subsequent peak detection.

[0134] The second derivative also uses the central difference: It only calculates internal points.

[0135] The formula for calculating curvature value is: ;

[0136] Since the denominator is always greater than or equal to 1, to simplify the calculation and not affect the relative order of peak detection, we can directly use... As an approximation of curvature, the final curvature value sequence is obtained. .

[0137] Candidate Deformation Point Extraction: Local peak points in the curvature value sequence that exceed a preset curvature threshold are recorded as candidate deformation points. A local peak is defined as a point greater than its two adjacent points. The preset curvature threshold is determined as follows: During system debugging, at least 24 hours of grayscale curvature data are collected under leak-free conditions. The 95th percentile or mean of all curvature values ​​plus three times the standard deviation is calculated, and this value is used as the threshold. Each candidate deformation point includes its position coordinates in the image and its curvature value.

[0138] Spatial clustering is performed, which involves clustering candidate deformable points according to their spatial location. Euclidean distance is used as the similarity metric, with a distance threshold set based on image resolution and the expected deformable size, for example, 1% of the image width. Candidate points with a distance less than the threshold are grouped into the same deformable cluster. The clustering algorithm can use a simple distance-based connected component labeling: iterate through all candidate points, and if two points are less than the threshold, they are labeled as belonging to the same cluster. After clustering, several deformable clusters are obtained, each containing a number of pixels.

[0139] Feature extraction is performed by calculating the mean and variance of curvature for all candidate deformation points within each deformation cluster. The mean reflects the average bulge intensity of the region, while the variance reflects the uniformity of the bulge (internal infiltration typically produces more uniform expansion, while external mechanical damage has a larger variance). Finally, the mean and variance of curvature for all deformation clusters are concatenated into a vector in cluster order, which serves as part of the first feature vector. If there are no deformation clusters, this part of the vector is empty, meaning it contributes no component.

[0140] 2. Thin film interference tone gradient analysis.

[0141] Thin-film interference hue gradient analysis is applicable to the detection of extremely thin, transparent liquid films on metal sealing surfaces, such as flange faces and valve stem sealing surfaces. When a chemical leak forms a liquid film with a thickness ranging from tens of nanometers to several micrometers, incident light is reflected and interfered with on the upper and lower surfaces of the liquid film, producing interference colors related to the film thickness. These interference colors appear as a continuous gradient along the leading edge of the liquid film in the hue channel, for example, from purple → blue → green → yellow → pink. Hue changes from metal heat discoloration or oil stains do not exhibit this ordered gradient. This embodiment distinguishes between genuine leaks and interference by the monotonicity of the hue gradient and the consistency of the interference order.

[0142] Specific implementation steps:

[0143] Color space conversion involves transforming the target image region from the RGB color space to the HSV color space. The conversion formula is a standard algorithm: first, normalize the RGB components to the [0,1] interval, then calculate the maximum, minimum, and difference values. The formula for calculating the hue components is a piecewise function.

[0144] If the maximum value equals the minimum value (Undefined);

[0145] If the maximum value is equal to the red component and the green component is greater than or equal to the blue component. ;

[0146] If the maximum value is equal to the red component and the green component is less than the blue component. ;

[0147] If the maximum value equals the green component ;

[0148] If the maximum value equals the blue component. The result range is 0° to 360°. , The conversion results in three independent channels: hue channel, saturation channel, and brightness channel.

[0149] Extracting the hue channel means extracting the hue channel image. Since hue is independent of light intensity and depends only on the wavelength composition of the reflected light, it is insensitive to changes in illumination. In the interference thin film region, the hue value exhibits a monotonic change with increasing film thickness.

[0150] Tone gradient calculation involves calculating the gradient of the tone channel image in the horizontal and vertical directions. Using... The operator has a kernel size of 3×3. (Horizontal direction) Core vertical direction The kernel is its transpose. The horizontal gradient map is obtained after convolution. and vertical gradient plot The gradient magnitude is The gradient direction is .

[0151] Region growing yields connected components, meaning pixels with gradient magnitudes greater than a low threshold are selected as seed points. The low threshold is determined as 0.2 times the average global gradient magnitude of the image. This coefficient is optimized experimentally to ensure a moderate number of seed points in the absence of leakage and sufficient coverage of the interference region in the presence of leakage. If this value is less than 3, it is set to 3. Region growing is performed based on the consistency of gradient direction and the monotonicity of hue. Specific rules:

[0152] Starting from the seed point, examine its four-neighbor pixels or eight-neighbor pixels, and choose according to the connectivity requirements.

[0153] Condition 1: The absolute value of the gradient direction difference is less than a preset angle threshold (e.g., 30°). This threshold is determined by statistically analyzing the gradient direction variation range of multiple known interference fringe samples and taking 1.2 times the maximum direction difference, with a typical value of 30°.

[0154] Condition 2: Hue values ​​are monotonous along the growth direction. Quantization method: Assume the region has already recorded a sequence of hue values ​​according to the growth order. For candidate pixel tone values ,calculate .Require (To avoid package jumps); if Then it requires and Same sign (both positive or both negative); if Then only requires .

[0155] Pixels that satisfy both conditions are added to the region. This process is repeated until the region stops expanding, resulting in a connected component. This connected component must satisfy the condition that the hue value is monotonically increasing or decreasing; otherwise, it is discarded.

[0156] Interference order consistency check: To further eliminate non-interference interference, the following check steps are added after obtaining the connected components:

[0157] The phase unrolling operation involves expanding the hue value sequence along the normal direction within the connected component. The normal direction is determined by the local gradient direction field of the connected component (perpendicular to the isotone lines). Specifically, the connected component is skeletonized. At each point on the skeleton line, the direction perpendicular to the gradient direction at that point is taken as the normal. Then, hue values ​​are sampled along the normal to both sides to obtain a one-dimensional hue sequence. The phase unrolling algorithm is as follows:

[0158] ;

[0159] The final result is a continuous monotonic expanded phase sequence.

[0160] Perform a monotonicity test, which involves calculating the Pearson correlation coefficient between the expanded phase sequence and the position index. If the correlation coefficient is lower than a preset monotonicity threshold, such as 0.9, it indicates that the hue variation is not monotonic, and the candidate connected component is discarded. This threshold is determined by statistically analyzing the correlation coefficients of at least 30 known interference thin film samples and taking the minimum value.

[0161] Perform phase difference calculation, which involves calculating the phase difference between adjacent extreme points in the expanded phase sequence. Extreme points are obtained by solving for the first derivative of the sequence as zero; in the discrete case, the boundary is ignored where the first derivative changes sign. The phase difference between adjacent maxima and minima corresponds to half an interference order. Record the phase difference sequence between all extreme points.

[0162] Order matching is performed, which compares the resulting phase difference sequence with the theoretical orders in a pre-defined thin-film interference order library. The order library is constructed as follows: for the target chemical, its refractive index is known. (This can be obtained from literature or measurement), the interference condition when white light is incident perpendicularly is: ,in For film thickness, For wavelength, The order is an integer. The optical path difference corresponding to different orders differs by one wavelength, which manifests as a phase difference in hue. The order library is all possible orders. A set of values, for example, for common organic materials, with a refractive index of approximately 1.5 and a visible light wavelength range of 400-700 nm. The angles are approximately 90°, 180°, 270°, etc. If the phase difference deviates from any order in the library beyond a preset deviation threshold, such as 20°, it indicates that the hue change is not caused by liquid film interference, and the candidate connected component is discarded. This threshold is derived from interference spectroscopy theory: the minimum phase difference between adjacent orders is usually greater than 30°, and setting a tolerance of 20° can avoid mismatches.

[0163] The remaining connected components will be used for subsequent encoding.

[0164] Calculate the gradient change sequence: For each qualified connected component, calculate its boundary, and within the connected component, calculate the rate of change of the hue gradient along the normal direction pixel by pixel. The normal direction is the same as above. Specifically: Within the connected component, sample hue values ​​along the normal direction. Taking the current point on the skeleton line as the center, extend several pixels to both sides along the normal, with a step size of 1 pixel, stopping at the boundary. This forms a function of hue with distance. Then, calculate its first derivative (rate of change) to obtain a set of gradient change sequences.

[0165] Perform the start and end hue extraction operations: extract the hue value corresponding to the first element in the gradient change sequence as the start hue value (corresponding to the thinnest part of the liquid film), and extract the hue value corresponding to the last element as the end hue value (corresponding to the thickest part of the liquid film or the wetting front). Note that these hue values ​​are values ​​in the original hue space (0°~360°).

[0166] As part of the first feature vector: the length of the gradient change sequence, i.e. the number of sampling points, and the three values ​​reflecting the interference fringe span, the starting hue value, and the ending hue value are used as part of the first feature vector.

[0167] (iv) Obtain a predefined second feature vector to characterize the statistical fluctuation range of environmental interference sources in the same spatial location under leak-free conditions.

[0168] Environmental interference sources refer to image feature sources that exist naturally under leak-free operating conditions and may be misjudged as leaks. By pre-statistically analyzing the characteristic fluctuation range of environmental interference sources under leak-free operating conditions, a second feature vector is established as a comparison benchmark for judgment.

[0169] This embodiment uses grayscale curvature analysis as an example to illustrate the predefinition process of the second feature vector:

[0170] During the initial installation phase, confirm that there are no leaks in the target area (through pressure testing, pressure holding tests, or manual inspection), and collect a continuous reference image sequence for no less than 24 hours. The reference sequence should cover different environmental conditions (day and night, sunny and cloudy days, different temperatures) to include the normal fluctuation range of environmental interference sources.

[0171] The aforementioned image recognition and grayscale curvature analysis steps are repeated on the reference image sequence to obtain multiple reference deformation clusters. Each reference deformation cluster corresponds to a local micro-deformation caused by temperature changes, condensation, or slight vibration.

[0172] Calculate the average of the curvature mean of all reference deformable clusters. and standard deviation Define the reference mean interval as This interval covers approximately 99.7% of the mean deformation under normal operating conditions (assuming a normal distribution). Similarly, the mean of the curvature variance is calculated. and standard deviation The reference variance interval is obtained. Note: If the sample size is less than 30, use the t-distribution instead of the normal distribution, with an interval width of [missing value]. .

[0173] The lower and upper bounds of the reference mean interval and the lower and upper bounds of the reference variance interval are combined into a quadruple, which is the second feature vector. This vector is stored in non-volatile memory and can be directly retrieved during subsequent online detection.

[0174] For thin-film interference hue gradient analysis, the generation of the second eigenvector is similar: the mean and standard deviation of the gradient sequence length, starting hue, and ending hue are calculated respectively, and their respective normal intervals are defined (again using the mean). Meanwhile, the interference order library serves as a store of prior knowledge.

[0175] (v) Calculate the deviation between the first feature vector and the second feature vector to obtain the deviation.

[0176] Deviation is used to quantify the degree of difference between the currently observed deformation characteristics and the characteristic range of environmental disturbance sources under normal operating conditions. The larger the deviation, the less likely the current deformation is to be caused by environmental disturbance sources, and the more likely it is a leak.

[0177] Detailed calculation steps:

[0178] Extract current features: Extract the current curvature mean and current curvature variance from the first feature vector. If multiple deformable clusters exist, the cluster with the largest curvature mean among all deformable clusters is selected as the suspected leakage target by default (because leakage usually leads to the largest deformation); if there are no deformable clusters, the deviation is directly set to 0.

[0179] Extracting the reference range: Extract the lower bound of the reference mean interval from the pre-stored second feature vector. and the Upper Realm The lower bound of the reference variance interval and the Upper Realm .

[0180] Calculating the unidirectional distance: Since leakage typically leads to increased deformation and a higher mean curvature, but not a decrease in deformation, only the portion of the current value exceeding the upper bound is calculated, ignoring cases below the lower bound. Defined as:

[0181] If the current mean curvature Then the first original distance ;otherwise .

[0182] Similarly, if the current curvature variance Then the second original distance ;otherwise .

[0183] Normalization: Because different features have different dimensions, normalization is necessary. The normalization factor is taken as the width of the reference interval. , If the width of a certain interval is zero, meaning all sample values ​​are exactly the same, then the weight of that feature is set to zero and it is not included in the deviation calculation, because that feature has no discriminative power. The normalized distance is: like or If the value is zero, the corresponding normalized distance is set to 0, and its weight is also set to 0.

[0184] Weighted summation: Deviation ,in For the weighting coefficients, satisfying ,and The method for determining the weights is as follows: Collect at least 1000 frames of data from both leak-free and simulated leak conditions. Divide the data into training and validation sets. Using a grid search, for example, within the range [0.1, 0.9] with a step size of 0.1, select the weight combination that maximizes the F1 score on the validation set. Generally, the mean reflects the deformation intensity better than the variance; therefore, a typical value is... .

[0185] For thin-film interference hue gradient analysis, the deviation is calculated similarly: the gradient sequence length, starting hue, and ending hue of the current connected region are compared with the corresponding reference intervals (again, only cases exceeding the upper bound are considered), and the deviation is obtained by weighted summation. The weights of each feature can be determined through grid search based on its discriminative power.

[0186] (vi) Compare the deviation with the preset threshold to obtain the comparison result.

[0187] The preset threshold is an empirical threshold determined through offline experiments. Specifically, it involves collecting a deviation sequence (no less than 10,000 frames) calculated under leak-free conditions, and taking the 99.9th percentile as the threshold (T). This means that under normal conditions, only 0.1% of the frames will exceed the threshold; these can be considered noise or rare interference. Alternatively, if leak samples are available, ROC curve analysis is used to select a threshold that achieves a detection rate of 95% and a false alarm rate of less than 0.5%. In this embodiment, a simulated leak experiment (adding a small amount of toluene to the flange surface) showed that the deviation after interference fringes appeared was significantly higher than normal fluctuations. Based on this, the threshold was set to 1.5 times the maximum value of normal fluctuations.

[0188] Comparison steps: If the current deviation... If the result is positive, the comparison result is considered to be out of bounds; otherwise, it is considered to be within bounds.

[0189] (vii) If the comparison result indicates that the deviation exceeds the threshold, then a leakage warning signal is output by combining the trend verification of the historical deviation sequence.

[0190] Single-frame exceedances may be caused by transient interference, such as light flicker, flying insects, or water droplets. To avoid false alarms, this invention introduces trend verification based on historical deviation sequences. Specific implementation:

[0191] The historical sequence is maintained by keeping a queue that records the deviation values ​​calculated from the most recent few frames. The number of frames N is set based on the video frame rate and the desired response time; for example, when the frame rate is 25fps... (Corresponding to a 1-second time window). The queue is updated according to the first-in, first-out principle.

[0192] Calculating the slope: The slope of the historical deviation series is calculated using linear regression. Let the historical series be... Corresponding frame number Calculate the mean: slope slope A positive value indicates that the deviation is increasing, which is consistent with the physical process of leakage development (the leakage will gradually worsen).

[0193] Calculate the percentage of deviations exceeding the limit, i.e., the percentage of deviations in the historical data that exceed the threshold. Frame count Excessive proportion .

[0194] Judgment: If both conditions are met and ( If the ratio is preset, a leak is confirmed, and a leak warning signal is output. Determination: Through ROC curve analysis, select the option that maximizes the F1 score on the validation set. The value typically ranges from 0.4 to 0.6. If... or If the alarm is suppressed, it is considered to be a momentary disturbance.

[0195] The alarm action is executed as follows: once a leak is confirmed, the system sends an alarm message to the DCS system via industrial Ethernet, including a timestamp, deviation value, and number of frames exceeding the limit, triggering an audible and visual alarm and highlighting the leak area on the monitoring screen. Simultaneously, an alarm log is recorded to the local database.

[0196] The first feature vector is generated by fusing multiple features.

[0197] Specific implementation steps:

[0198] Binarization segmentation yields a wettage mask, which involves adaptive thresholding binarization of the target image region. The OTSU algorithm is used to automatically calculate the global threshold: the image's grayscale histogram is calculated, all possible thresholds are iterated, the inter-class variance is calculated, and the threshold corresponding to the largest variance is selected. Pixels with grayscale values ​​below this threshold are marked as 1 (wettage candidates), and the rest as 0. Since the reflectivity of chemicals or water is generally lower than that of metal surfaces, wettage appears as darker areas. For transparent chemicals, a hue channel can be used as an aid: in the hue channel, liquid film regions typically exhibit a different hue from the metallic background, allowing for further segmentation through hue difference.

[0199] Skeletonization and inverse gravity tracing yield source endpoint attribution features, i.e., morphological refinement of the wettage mask, using... Algorithm. This algorithm alternates between two sub-iterations:

[0200] Sub-iteration 1: For each foreground pixel (value 1), check its 8-neighborhood. Define the number of foreground pixels in the neighborhood. and the number of connected components of the foreground pixels in the neighborhood. (Calculated based on 8-connectivity). If both conditions are met: , , There is at least one background in each of the four directions: north, west, south, and east. If there is at least one background in any of the four specific directions (north, west, south, and east), then that pixel is marked as to be deleted.

[0201] Sub-iteration 2: The conditions are similar, but the direction of the check is changed to: There is at least one background in each of the four directions: east, north, west, and south. There must be at least one background element in each of the four directions: northeast, southeast, southwest, and northwest. Other conditions... Same child iteration 1.

[0202] Repeat the process alternately until no pixels are deleted, resulting in a skeleton line with a width of one pixel. Then, starting from the lowest point of the skeleton line (where the image's ordinate is the largest), trace along the skeleton line in the direction of decreasing ordinate (against gravity) until it cannot continue (choose the branch with the smaller ordinate when encountering a branch), and record the coordinates of the endpoint as the source endpoint. This source endpoint represents the upstream position of the wet trace. Obtain a pre-calibrated environmental water source mask. Calculate whether the source endpoint is located within any environmental water source mask (whether the point is inside the polygon). If it is not within any mask, the source endpoint's attribute feature value is set to a first preset value (e.g., 1); otherwise, it is set to a second preset value (e.g., 0).

[0203] Luminance time-series sampling and pulse extraction yielded statistical features of the drip intervals: A fixed detection window, such as a rectangle, is positioned above the target image region, below the pipe gallery beam, with dimensions of 2% of the image width and 2% of the image height. Average pixel luminance is continuously collected to form a luminance time series. The sampling frequency is the same as the video frame rate. First-order differencing is performed on the luminance time series. Extracting negative pulses: If (Brightness jump condition), and the number of frames that continuously meet this condition. satisfy (Narrow pulse condition) is then recorded as a dripping event, with a timestamp recorded. Threshold Determination: Take 3 times the standard deviation of the mean of the brightness difference values ​​when there is no dripping water; Typically, 5 frames (corresponding to approximately 200ms) are used to obtain the dripping timestamp sequence. Then, calculate the interval between adjacent timestamps. (like If the feature is invalid, then the feature is invalid. Calculate the coefficient of variation of the interval sequence: standard deviation / mean, denoted as... Simultaneously, periodogram analysis is performed: the interval sequence is mean-removed, padded with zeros until it reaches the next power of 2 greater than the sequence length, and then... Calculate the power spectral density, neglecting the DC component, and identify the dominant frequency and its intensity (the ratio of dominant frequency power to total power). The dominant frequency intensity and the two components are used as statistical characteristics of the drip interval.

[0204] Vector concatenation involves sequentially concatenating the feature vectors obtained from morphology analysis with the numerical sequence generated by grayscale curvature analysis and / or thin-film interference tone gradient analysis, along with the source endpoint attribution feature (one scalar) and the droplet interval statistical feature (two scalars), to form the final first feature vector. For example, if morphology analysis produces... If there are 100 values, then the length of the first feature vector is 100. .

[0205] By integrating morphology, gravity tracing, and drip statistics, this implementation method can cover various leakage scenarios: morphology analysis is effective for leaks inside the insulation layer; thin-film interference is effective for micro-leaks in flanges; drip statistics are effective for dripping leaks; and gravity tracing is effective for wet stains on walls. The synergy of multiple features enhances the robustness of the system and reduces the risk of missed detections under single failure modes.

[0206] Feature generation based on gravity-based source disconnection.

[0207] Specific implementation steps:

[0208] Binarization segmentation yields a wettage mask:

[0209] Skeletonization and source endpoint tracing, i.e., using The algorithm obtains the skeleton line. Starting from the lowest point of the skeleton line, it traces along the direction of gravity, prioritizing the branch endpoint with the smallest ordinate, and records the coordinates of that point as the source endpoint.

[0210] Obtain environmental water source masks, i.e., manually calibrated during system installation. Use a polygon tool to draw areas on the image: a certain pixel range downwards from the outer edge of the flange, for example, 10% of the flange's outer diameter, as the flange drip projection zone; the fan-shaped area covered by the spray head; and the concentrated dripping area of ​​condensate, such as directly below the cold pipe. These masks are... The format is stored in a configuration file.

[0211] The calculation involves determining the distance and generating a feature value. Specifically, it involves calculating the shortest Euclidean distance from the source endpoint coordinates to each environmental water source mask, which is the minimum distance from the point to the polygon boundary. If all distances are greater than 0, meaning the source endpoint is outside all masks, a first feature value is generated (e.g., 1). Otherwise, a second preset feature value (e.g., 0) is generated. This feature value serves as a single component in the first feature vector.

[0212] This implementation method involves minimal computation, requiring only segmentation, skeletonization, and point-polygon testing. No model training is needed, and it offers strong physical interpretability. In real-world scenarios, it effectively distinguishes between condensate dripping from the upper flange located inside the mask and chemical leaks from the weld located outside the mask, significantly reducing false alarms.

[0213] Feature generation based on time-domain statistics of dripping events.

[0214] Implementation details:

[0215] Fixed detection window selection: Generally, it is selected on the path where droplets may fall, such as at an appropriate distance directly below the flange or along the lower edge of the pipe rack beam. The size of the detection window is set according to the image resolution, for example, the width is 1% of the image width and the height is 1% of the image height, including at least several tens of pixels.

[0216] Luminance time-series sampling: The average luminance within the detection window is continuously acquired at a sampling frequency of video frame rate. The average luminance of all pixels within the window is calculated for each frame, forming a luminance time series. .

[0217] Difference and Pulse Extraction: Calculating Difference Sequences When a water droplet passes through the detection window, the brightness first decreases and then increases, resulting in a negative pulse followed by a positive pulse in the differential sequence. For simplicity, only the negative pulse is detected: if (Brightness jump condition), and the number of frames that continuously meet this condition. satisfy (Narrow pulse condition) is then recorded as a dripping event, and a timestamp is recorded. Threshold Determination: Collect 100 frames of brightness difference values ​​without water dripping, calculate the mean and standard deviation, and take... Standard deviation; Typically, 5 frames are used (corresponding to approximately 200ms).

[0218] Interval sequence calculation: Obtain the dripping timestamp sequence Afterwards, if If the feature is invalid, calculate the interval between adjacent timestamps. .

[0219] Statistical feature extraction:

[0220] Coefficient of variation: .

[0221] Periodic graph analysis: Obtaining the mean from the interval sequence Let the sequence length be... ,calculate Create an array ,forward The elements are ,back The first element is 0. (The process continues...) Obtaining complex coefficients Power spectral density Only consider (Ignore DC). Main frequency index main frequency strength .

[0222] Will and These are the two components of the first eigenvector.

[0223] In a compressor factory, water stains are frequently found in the collection tank below the pipe rack. Traditional methods cannot distinguish between compressor cylinder head cooling water leakage and rainwater seepage. This implementation analyzes the time interval of dripping events: when cooling water leaks, the reciprocating motion of the compressor causes periodic pressure fluctuations, resulting in a stable dripping interval with a small coefficient of variation and a high dominant frequency. In contrast, rainwater drips randomly, with a coefficient of variation close to 1 and a weak dominant frequency. Through this characteristic, the system accurately identifies the actual leakage event, avoiding multiple false alarms and shutdowns.

[0224] Target region localization based on edge detection and optical flow tracing.

[0225] The second eigenvector is generated by predefinition.

[0226] Additional notes: For the thin-film interference mode, the generation of the second eigenvector also uses 24 hours of leak-free data. The mean and standard deviation of the gradient sequence length, starting hue, and ending hue are calculated, and the normal interval is defined as follows. Meanwhile, the construction of the interference order library needs to be based on the refractive index of the chemical. If there is no refractive index data, the refractive index of 1.5 for general organic materials can be used as an approximation.

[0227] Application process of the complete implementation example.

[0228] The following describes a complete detection cycle, taking toluene leakage on a flange sealing surface as an example, using thin film interference tone gradient analysis and grayscale curvature analysis in morphology analysis, and enabling trend verification.

[0229] In the initial state, the system is in monitoring mode, with cameras capturing images in real time and the industrial control computer running algorithms. The historical deviation queue is empty.

[0230] In the initial few frames, there is no leakage, no obvious gradient change in the tone channels within the target image area, grayscale curvature analysis does not detect any deformation clusters exceeding the threshold, the wet spot mask is empty, and the water droplet detection window has no pulse. The deviation calculation is 0, the comparison result is within the limit, and there is no alarm.

[0231] The leakage start frame marks the beginning of the leak, where toluene seeps from the gasket micropores, forming a thin film approximately 200 nm thick on the flange surface. This area appears pale blue (interference color) in the image. Algorithm processing:

[0232] Image recognition identifies the target region (optical flow tracking is normal).

[0233] The following thin-film interference hue gradient analysis was performed: Connected regions were obtained through region growing; hue values ​​monotonically increased from lower to higher values; the gradient change sequence length, starting hue, and ending hue all exceeded the upper limit of the normal range. The monotonicity index was higher than the threshold (0.9), and the phase difference sequence matched the order library (deviation less than 20°), thus passing the verification. The length, starting hue, and ending hue were used as part of the first feature vector.

[0234] Perform the following grayscale curvature analysis: No obvious deformation was detected, and the mean curvature value is within the normal range, therefore this feature is empty.

[0235] Comparing the first and second feature vectors: the initial hue exceeds the upper bound; calculate the deviation (assuming the normalized deviation is 1.2, other dimensions are 0, and the weight sum is 1). Preset threshold The comparison result is that it exceeds the limit.

[0236] Perform the following steps to enter trend verification: In the historical deviation sequence, the deviation of the previous few frames is 0, the deviation of the current frame is 1.2, and the slope is... The value is positive (linear regression result). However, the proportion exceeding the limit is... Less than the preset ratio Therefore, we will not call the police for now and will continue to observe.

[0237] In the following frames, leakage continued, the liquid film expanded, and interference fringes increased. The initial hue continued to exceed the limit, but the deviation stabilized between 1.0 and 1.5. When the number of frames exceeding the limit in the historical sequence accumulated to more than 13 frames... Meanwhile, the slope remains positive, and the system outputs a leakage warning signal. After receiving the alarm, the DCS system highlights the flange area on the central control room screen and records the alarm log.

[0238] After the leak was dealt with, on-site operators confirmed the leak and took appropriate measures. The system continued to monitor; as the liquid film evaporated, the deviation gradually decreased, the slope became negative, and the alarm stopped.

[0239] This embodiment takes only about 0.5 seconds from the start of a leak to the output of an alarm, while traditional methods require waiting for liquid to drip or form a noticeable patch (for minutes or even hours). This invention achieves extremely early warning, buying valuable time for on-site response. At the same time, trend verification effectively avoids false alarms caused by single-frame noise or transient interference, such as flying insects.

[0240] The foregoing has shown and described the basic principles, main features, and advantages of this application. Those skilled in the art should understand that this application is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of this application. Various changes and modifications can be made to this application without departing from the spirit and scope thereof, and all such changes and modifications fall within the scope of this application as claimed. The scope of protection of this application is defined by the appended claims and their equivalents.

Claims

1. A method for identifying, detecting, and issuing early warnings of chemical leaks based on visual recognition, characterized in that, The method includes: Acquire a visible light image sequence of the target area; Image recognition is performed on the visible light image sequence to obtain the target image region where the sealing surface or the covering layer is located; The target image region is subjected to morphological analysis to obtain a first feature vector reflecting the local deformation. Obtain a predefined second feature vector, which represents the expected deformation range of the environmental interference source at the same spatial location under leak-free operating conditions; Calculate the deviation between the first feature vector and the second feature vector to obtain the deviation. The deviation is compared with a preset threshold to obtain a comparison result; If the comparison result indicates that the deviation exceeds the threshold, a leakage warning signal is output by combining the trend verification of the historical deviation sequence.

2. The method according to claim 1, characterized in that, The process of obtaining the first feature vector reflecting the local deformation includes: Binarization segmentation is performed on the target image region to obtain a wettage mask; The wet trace mask is skeletonized and traced along the anti-gravity direction to obtain the source endpoint attribution characteristics; The pixel brightness within the fixed detection window above the target image region is sampled in a time sequence and pulse extracted to obtain the statistical characteristics of the water droplet interval; The features obtained from the morphology analysis are concatenated with the source endpoint attribution features and the drip interval statistical features to generate the first feature vector.

3. The method according to claim 1, characterized in that, The topography analysis of the target image region yields a first feature vector reflecting local deformation. This topography analysis includes at least one of grayscale curvature analysis or thin-film interference hue gradient analysis, wherein the thin-film interference hue gradient analysis includes: Each frame of the target image region is converted to the HSV color space, and the hue channel image is extracted. Calculate the gradients of the hue channel image in the horizontal and vertical directions to obtain a hue gradient map; Perform region growing on the hue gradient map to obtain connected regions with monotonically increasing or decreasing hue values; Calculate the rate of change of the hue gradient along the normal direction within the connected region to obtain the gradient change sequence; Extract the hue value corresponding to the first element from the gradient change sequence as the starting hue value, and extract the hue value corresponding to the last element as the ending hue value; The length of the gradient change sequence, the starting hue value, and the ending hue value are encoded as part of the first feature vector.

4. The method according to claim 3, characterized in that, The obtained connected components with monotonically increasing or decreasing hue values ​​include: Obtain initial connected component candidates; Perform phase unpacking on the pixel hue values ​​within the initial connected component candidate along the normal direction to obtain the unpacked phase sequence; Calculate the monotonicity index of the expanded phase sequence; If the monotonicity index is lower than the preset monotonicity threshold, the initial connected component candidate is discarded. Calculate the phase difference between adjacent extreme points in the expanded phase sequence to obtain the phase difference sequence; If the deviation between each phase difference in the phase difference sequence and any order in the preset thin-film interference order library exceeds a preset deviation threshold, then the initial connected component candidate is discarded. The initial connected component candidates that were not discarded are used as the connected components.

5. The method according to claim 3, characterized in that, The grayscale curvature analysis includes: For each frame of the target image region, extract the grayscale profile along the direction perpendicular to the generatrix to obtain a set of grayscale curves; Gaussian filtering is applied to the grayscale curve to obtain a smooth curve; Calculate the second derivative of the smooth curve to obtain a sequence of curvature values; Local peak points in the curvature value sequence that exceed a preset curvature threshold are recorded as candidate deformation points; The candidate deformation points are clustered according to their spatial location to obtain deformation clusters; Calculate the mean curvature and variance of curvature of all candidate deformation points within the deformation cluster, and use the mean curvature and variance of curvature as part of the first feature vector.

6. The method according to claim 1, characterized in that, The process of obtaining the first feature vector reflecting the local deformation also includes: Binarization segmentation is performed on the target image region to obtain a wettage mask; The wet mask is skeletonized to obtain a skeleton line with a width of one pixel; By tracing along the skeleton line from the lowest point to the highest point, the coordinates of the source endpoint are obtained; Obtain a pre-calibrated legitimate water source mask, which includes a flange drip projection area, a spray coverage area, and a condensate concentrated drip area; Calculate the Euclidean distance from the source endpoint coordinates to the legal water source mask. If the Euclidean distance is greater than zero, generate a first feature value as a first preset value; otherwise, generate a first feature value as a second preset value. The first feature value is used as part of the first feature vector.

7. The method according to claim 1, characterized in that, The process of obtaining the first feature vector reflecting the local deformation also includes: The brightness of pixels within a fixed detection window above the target image region is sampled in a time sequence to obtain a brightness time series; Perform a difference operation on the brightness time series to obtain a difference series; Pulses whose amplitude satisfies the brightness jump condition and whose width satisfies the narrow pulse condition are extracted from the difference sequence. Each pulse corresponds to a dripping event, resulting in a dripping timestamp sequence. Calculate the interval between adjacent timestamps in the dripping timestamp sequence to obtain the interval sequence; Perform a normality test on the interval sequence to obtain a test statistic, and use the test statistic as the first component of the first feature vector; Periodogram analysis is performed on the interval sequence to obtain the dominant frequency intensity, and the dominant frequency intensity is used as the second component of the first feature vector.

8. The method according to claim 1, characterized in that, The step of performing image recognition on the visible light image sequence to obtain the target image region where the sealing surface or coating layer is located includes: Edge detection is performed on the starting frame image in the visible light image sequence to obtain a set of edge pixels; Line segment extraction is performed on the edge pixel set to obtain multiple line segments; From the plurality of line segments, at least two parallel line segments that meet the geometric constraints of the sealing surface are selected, wherein the geometric constraints include the difference between the line segment spacing and the preset bolt circle diameter being less than a preset difference threshold. The polygonal region enclosed by the at least two parallel line segments is marked as the initial region; For each subsequent frame in the visible light image sequence, optical flow tracing is performed starting from the initial region of the previous frame to obtain the updated region of the current frame; The updated region is taken as the target image region.

9. The method according to claim 1, characterized in that, The step of obtaining the predefined second feature vector includes: Under leak-free operating conditions, a sequence of reference images of the same target area was acquired. The steps of edge detection, line segment extraction, optical flow tracking, grayscale profile extraction, curvature calculation, and clustering are repeatedly performed on the reference image sequence to obtain multiple reference deformation clusters; The range of fluctuations in the mean curvature of the multiple reference deformation clusters is statistically analyzed to obtain the reference mean interval; The range of curvature variance fluctuations of the multiple reference deformation clusters is statistically analyzed to obtain the reference variance interval; The upper and lower bounds of the reference mean interval and the upper and lower bounds of the reference variance interval are combined to generate the second feature vector.

10. The method according to claim 1, characterized in that, The calculation of the deviation between the first feature vector and the second feature vector includes: Extract the current curvature mean and current curvature variance from the first feature vector; Extract the upper and lower bounds of the reference mean interval and the upper and lower bounds of the reference variance interval from the second feature vector; Calculate the first distance between the current mean curvature value and the reference mean interval. If the current mean curvature value is within the interval, the first distance is zero; otherwise, the first distance is the absolute value of the difference between the current mean curvature value and the upper or lower bound of the reference mean interval. Calculate the second distance between the current curvature variance and the reference variance interval. If the current curvature variance is within the interval, the second distance is zero; otherwise, the second distance is the absolute value of the difference between the current curvature variance and the upper or lower bound of the reference variance interval. The deviation is obtained by weighted summation of the first distance and the second distance.