Shut-off valve state recognition method, system, device and program product
By identifying key structural points of the shut-off valve and performing geometric correction and angle difference determination, the problem of recognition accuracy caused by geometric deformation of the shut-off valve image was solved, and efficient state recognition under different perspectives was achieved.
Patent Information
- Application Number
- CN202610416145.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-31
- Publication Date
- 2026-07-03
AI Technical Summary
In existing technologies, geometric deformation of the image of the shut-off valve leads to a decrease in the accuracy of state recognition, especially when the shooting angle is not fixed, making accurate recognition difficult.
By acquiring the reference image and the image to be inspected of the shut-off valve, key structural points are identified, geometric correction is performed, geometric deformation is eliminated, and angle differences are calculated to determine the state. Relative difference is used for judgment instead of fixed absolute thresholds to adapt to individual differences in equipment.
It improves the accuracy and versatility of shut-off valve status identification, reduces misjudgments caused by changes in viewing angle, and adapts to individual differences in different equipment.
Smart Images

Figure CN122336247A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of power equipment condition monitoring technology, and in particular relates to a method, system, device and program product for identifying the condition of a shut-off valve. Background Technology
[0002] Interrupting valves are critical safety components in substations and power equipment, and accurate monitoring of their status is essential for ensuring the safe operation of the power system. Traditional interrupting valve status monitoring mainly relies on manual inspection, which suffers from low efficiency, poor real-time performance, strong subjectivity, and susceptibility to false detections and missed detections.
[0003] To overcome the drawbacks of manual inspection, existing technologies are beginning to adopt automated inspection methods based on computer vision. These methods typically use cameras to capture images of the shut-off valve and then use image processing or deep learning models to analyze the status indicators in the images to determine whether the shut-off valve is in a normal state.
[0004] However, in actual inspection scenarios, the shooting angle of image acquisition equipment often varies, resulting in varying degrees of geometric deformation in the acquired images of the shut-off valve. This deformation directly affects the measurement accuracy of the angle or position of the status indicator on the dial, leading to unstable recognition results and an increased misjudgment rate.
[0005] In existing technologies, some methods attempt to circumvent the aforementioned problems by standardizing the shooting angle or limiting image acquisition conditions, but these are difficult to strictly implement in practical engineering applications. Other methods directly identify the state from the raw image by training a deep learning model, but these methods usually require a large number of labeled samples and have limited generalization ability to different viewpoints. When the shooting viewpoint differs significantly from the distribution of the training data, the recognition accuracy drops significantly.
[0006] Therefore, how to accurately identify the status of the shut-off valve when the shooting angle is not fixed is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0007] This application provides a method, system, device, and program product for identifying the status of a shut-off valve, aiming to solve the technical problem in the prior art where changes in the shooting angle cause geometric deformation in the image of the shut-off valve, thus affecting the accuracy of status identification.
[0008] In a first aspect, embodiments of this application provide a method for identifying the state of a flow-stopping valve, the method comprising: Acquire the reference image and the image to be inspected of the shut-off valve; Identify the first structural key point from the reference image and the second structural key point from the image to be inspected; Based on the first structural key point and the second structural key point, the image to be inspected is geometrically corrected to obtain a corrected image that is consistent with the geometric space of the reference image. The reference angle in the reference image and the current angle in the corrected image are calculated respectively, and the state of the shut-off valve is determined based on the angle difference between the current angle and the reference angle.
[0009] In one possible implementation of the first aspect, the first structural key point and the second structural key point are screw fixing points for fixing the boundary of the flow interruption valve dial.
[0010] In one possible implementation of the first aspect, the step of performing geometric correction on the image to be inspected based on the first structural key points and the second structural key points to obtain a corrected image consistent with the geometric space of the reference image includes: Based on the first and second structural key points, the geometric transformation matrix is calculated. The geometric transformation matrix is used to perform geometric correction on the image to be inspected to obtain the corrected image.
[0011] In one possible implementation of the first aspect, calculating the reference angle in the reference image and the current angle in the corrected image, respectively, includes: The reference state indication region is segmented from the reference image, and the current state indication region is segmented from the corrected image; The reference angle is calculated based on the reference state indication area, and the current angle is calculated based on the current state indication area.
[0012] In one possible implementation of the first aspect, segmenting the reference state indication region from the reference image includes: Convert the reference image to the HSV color space; The converted reference image is binarized using a preset color threshold to obtain the initial reference mask; The initial baseline mask is morphologically processed to obtain the optimized baseline mask; Perform connected component analysis on the benchmark optimization mask and select the connected region with the largest area as the benchmark state indication region; The step of segmenting the current state indication region from the corrected image includes: Convert the corrected image to the HSV color space; The converted and corrected image is binarized using a preset color threshold to obtain the current initial mask; The current initial mask is morphologically processed to obtain the current optimized mask; Perform connected component analysis on the current optimized mask and select the connected region with the largest area as the current state indication region.
[0013] In one possible implementation of the first aspect, calculating the reference angle based on the reference state indication area and calculating the current angle based on the current state indication area includes: Extract the edge point set of the reference state indication area to obtain the reference edge point set; The reference edge point set is fitted to obtain a reference fitted line, and the reference angle is calculated based on the direction of the reference fitted line; Extract the edge point set of the current state indication area to obtain the current edge point set; The current edge point set is fitted to obtain the current fitted line, and the current angle is calculated based on the direction of the current fitted line.
[0014] In one possible implementation of the first aspect, determining the state of the shut-off valve based on the angle difference between the current angle and the reference angle includes: Calculate the absolute value of the angle difference between the current angle and the reference angle; When the absolute value is greater than a preset threshold, the state of the flow interruption valve is determined to be abnormal; When the absolute value is less than or equal to the preset threshold, the state of the shut-off valve is determined to be normal.
[0015] Secondly, embodiments of this application provide a flow-stopping valve status identification system, including: The acquisition module is used to acquire the reference image and the image to be inspected of the shut-off valve; The identification module is used to identify a first structural key point from the reference image and a second structural key point from the image to be inspected. The correction module is used to perform geometric correction on the image to be inspected based on the first structural key point and the second structural key point to obtain a corrected image that is consistent with the geometric space of the reference image. The determination module is used to calculate the reference angle in the reference image and the current angle in the corrected image respectively, and determine the state of the flow-stopping valve based on the angle difference between the current angle and the reference angle.
[0016] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the shut-off valve state identification method described in any of the first aspects above.
[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the shut-off valve state identification method described in any one of the first aspects.
[0018] Fifthly, embodiments of this application provide a computer program product that, when run on a computer device, causes the computer device to execute the shut-off valve status identification method described in any of the first aspects above.
[0019] In this embodiment, a reference image and an image to be inspected of the shut-off valve are acquired, and a first structural key point and a second structural key point are identified from them respectively. Based on these two sets of structural key points, geometric correction is performed on the image to be inspected to obtain a corrected image that is consistent with the geometric space of the reference image. This effectively eliminates the influence of image geometric deformation caused by changes in shooting angle on the accuracy of state recognition. On this basis, the reference angle in the reference image and the current angle in the corrected image are calculated respectively, and the state of the shut-off valve is determined according to the angle difference between the current angle and the reference angle. The judgment is made by using a relative difference rather than a fixed absolute threshold, which can adapt to the individual differences between different devices and avoid the tedious process of setting thresholds for each device individually, thereby improving the accuracy and versatility of shut-off valve state recognition.
[0020] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a schematic flowchart of a flow-stop valve status identification method provided in an embodiment of this application; Figure 2 This is a schematic diagram illustrating the effect of red region segmentation and edge fitting provided in an embodiment of this application; Figure 3 This is a schematic diagram of the result of determining the state of the shut-off valve provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of the shut-off valve status recognition system provided in the embodiments of this application; Figure 5 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0023] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0024] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0025] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0026] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0027] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0028] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0029] Figure 1A schematic flowchart of a flow-stop valve status identification method provided in an embodiment of this application is shown.
[0030] S101, acquire the reference image and the image to be inspected of the shut-off valve.
[0031] The reference image refers to an image taken from a relatively standard angle when the shut-off valve is in normal condition. This reference image can be taken by the inspection equipment and stored in the database after the shut-off valve has been initially installed and commissioned, or after the equipment has been inspected and confirmed to be normal.
[0032] The image to be inspected refers to the current inspection image that requires status recognition, which is captured in real time by the inspection equipment during routine inspections.
[0033] It should be noted that the aforementioned reference image and the image to be inspected should be acquired using the same type of imaging equipment, or the impact of resolution and focal length differences on the accuracy of subsequent key point matching should be eliminated through image normalization preprocessing after acquisition.
[0034] In this embodiment of the application, a reference image corresponding to the current device to be identified is first retrieved from the database, and at the same time, the image to be inspected is uploaded in real time by the inspection device.
[0035] S102, identify the first structural key point from the above reference image, and identify the second structural key point from the above image to be inspected.
[0036] Among them, structural key points refer to the inherent, geometrically stable feature points on the valve dial. The first structural key point refers to the set of coordinates of structural key points identified from the reference image, and the second structural key point refers to the set of coordinates of structural key points identified from the image to be inspected.
[0037] In this embodiment, after acquiring the reference image and the image to be inspected, structural key point identification is performed on both images. Specifically, firstly, a pre-trained flow-stop valve dial detection model is used to locate the bounding box of the dial in the image to be inspected. Then, within this bounding box, a pre-trained key point detection model is used to detect and locate the coordinates of four screw fixing points, which are used as the second structural key points. The reference image is processed in the same way to obtain the corresponding first structural key points.
[0038] As an optional implementation, the identification of the first and second structural key points is achieved using a two-stage cascaded detection strategy based on an improved YOLO network.
[0039] Specifically, the detection strategy includes the following steps: Step 1: Construct a detection model for the shut-off valve dial. This model uses Yolov11s as the backbone network and introduces a Bidirectional Feature Pyramid Network (BiFPN) structure into its neck network to achieve full fusion of multi-scale features, thereby enhancing the model's ability to detect dial targets at different shooting distances. The training dataset includes shut-off valve images acquired under different lighting conditions (strong light, backlight, cloudy, and nighttime supplemental lighting), different shooting angles (0° to 45° tilt), and different background complexities. Data augmentation operations such as random perspective transformation, random hue-saturation-value (HSV) color perturbation, and random Gaussian noise addition are applied to the images to simulate various extreme working conditions in real inspection scenarios.
[0040] Step two involves constructing a key point detection model for the shut-off valve. This model takes the dial area detected in Step one as input and employs a lightweight Yolov11s-Pose network structure. A key point coordinate regression branch is added to the target detection branch to simultaneously predict the position coordinates of the four screw fixing points. The key point regression branch uses a coordinate decoupling design, regressing and predicting the x and y coordinates of each key point separately to reduce coupling errors in key point localization.
[0041] Step 3: Key Point Numbering and Matching. The coordinates of the four detected screw fixing points need to be automatically numbered according to their spatial position. The numbering rule is as follows: with the center of the dial as the origin, number them sequentially in a clockwise direction as upper left point, upper right point, lower right point, and lower left point. This numbering rule is used to establish a one-to-one correspondence between the second structural key points detected in the image to be inspected and the first structural key points pre-stored in the reference image, providing accurate matching point pairs for subsequent geometric correction.
[0042] It should be noted that the above two-stage cascaded detection strategy adopts a coarse-to-fine design approach, starting with the overall picture and then moving to the local area: the first-stage dial detection model filters out most of the background interference in the image, limiting the keypoint detection task to the dial area; the second-stage keypoint detection model performs fine localization within the local area. Compared to directly performing keypoint detection in the entire image, this cascaded structure can effectively reduce the false detection rate of the background and improve the detection accuracy and localization stability of small targets (screw fixing points).
[0043] The first and second key structural points mentioned above are screw fixing points used to secure the boundary of the flow-stop valve dial. These screw fixing points are typically located at the four corners or edges of the dial, possessing distinct geometric features and stable spatial relationships. They are easily and stably identified by the detection model under different shooting angles, providing a reliable correspondence for subsequent geometric correction.
[0044] In this embodiment, the first and second structural key points are screw fixing points used to fix the boundary of the flow-stop valve dial. These screw fixing points are usually located at the four corners or edges of the dial. In this embodiment, the preset number is four. They have obvious geometric features and stable spatial positional relationships, and are easily and stably identified by the key point detection model based on the YOLO improved network under different shooting angles, which can provide a reliable correspondence for subsequent geometric correction.
[0045] It should be noted that the basic scheme of this application embodiment uses four screw fixing points as the structural key point type. Based on this, when identifying the second structural key point from the image to be inspected, a key point quantity verification is performed: the number of identified screw fixing points is checked. If the number of identified second structural key points is not equal to four, it is determined that the current image to be inspected cannot provide a complete geometric correction correspondence. In this case, the state of the shut-off valve is directly determined to be abnormal, and corresponding state abnormality alarm information is output, terminating the subsequent geometric correction and angle calculation process. If the key point quantity verification passes (i.e., four screw fixing points are identified), the screw fixing points are used as structural key points, and the subsequent geometric correction and state recognition process is executed normally.
[0046] Optionally, the first and second structural key points mentioned above can be corner points of the dial frame of the shut-off valve. Screw fixing points can be used as the structural key points initially; when the confidence level of the screw fixing point detection is lower than a preset threshold, the system automatically switches to the corner points of the dial frame as the structural key points to ensure the reliability of geometric correction.
[0047] Optionally, based on the above basic scheme, a detection confidence verification and adaptive switching strategy can be further added: After the number of key points is verified (i.e., 4 screw fixing points are identified), the detection confidence of each screw fixing point is verified. When the detection confidence of any screw fixing point is lower than a preset threshold (e.g., 0.8), an adaptive switching strategy is executed: on the one hand, the state of the shut-off valve is determined to be abnormal, and corresponding abnormal state alarm information is output to prompt maintenance personnel to pay attention to the equipment status in a timely manner; on the other hand, the system automatically switches to the corner point of the shut-off valve dial frame as the structural key point, using the equally stable geometric positional relationship of the frame corner point to replace the screw fixing point, and continues to complete the subsequent geometric correction and state recognition.
[0048] The aforementioned key point quantity verification mechanism ensures the integrity of the corresponding points required for geometric correction; the optional confidence verification and border corner point switching mechanism can further address the degradation of screw fixing points due to long-term operation, such as corrosion and contamination, and output status abnormality alarms in a timely manner when an anomaly occurs, achieving a balance between safety priority and functional robustness, and further improving the reliability of the method.
[0049] S103, based on the first structural key points and the second structural key points, the image to be inspected is geometrically corrected to obtain a corrected image that is consistent with the geometric space of the reference image.
[0050] Geometric correction refers to the process of eliminating image geometric deformation caused by changes in shooting angle by calculating the geometric transformation relationship between images.
[0051] Geometric spatial consistency means that the calibrated image to be inspected and the reference image are in the same reference system in terms of geometric structure, that is, the positional relationship of corresponding points in the image satisfies the preset mapping relationship.
[0052] In this embodiment of the application, after obtaining the first structural key point and the second structural key point, a geometric transformation matrix is calculated based on the correspondence between the two sets of key points, and the geometric transformation matrix is used to perform geometric transformation processing on the image to be inspected to generate a corrected image that eliminates geometric distortion and is consistent with the geometric space of the reference image.
[0053] S104, calculate the reference angle in the reference image and the current angle in the correction image respectively, and determine the state of the shut-off valve based on the angle difference between the current angle and the reference angle.
[0054] The reference angle refers to the angle value of the shut-off valve status indicator calculated from the reference image, and the current angle refers to the angle value of the shut-off valve status indicator calculated from the calibration image.
[0055] Here, the angle difference refers to the absolute value of the difference between the current angle and the reference angle, and the angle difference is calculated as: Δθ = |θ current -θ base |, where θ current θ is the current angle. base The reference angle is used.
[0056] The preset threshold refers to the critical angle difference used to determine whether the state of the shut-off valve is abnormal.
[0057] In this embodiment, angle calculations are performed on the reference image and the corrected image to obtain the reference angle and the current angle. After calculating the reference angle and the current angle, the absolute value of the angle difference between the current angle and the reference angle is calculated and compared with a preset threshold. When the absolute value of the angle difference is greater than the preset threshold, the state of the shut-off valve is determined to be abnormal; when the absolute value of the angle difference is less than or equal to the preset threshold, the state of the shut-off valve is determined to be normal.
[0058] In this embodiment, a reference image and an image to be inspected of the shut-off valve are acquired, and a first structural key point and a second structural key point are identified from them respectively. Based on these two sets of structural key points, geometric correction is performed on the image to be inspected to obtain a corrected image that is consistent with the geometric space of the reference image. This effectively eliminates the influence of image geometric deformation caused by changes in shooting angle on the accuracy of state recognition. On this basis, the reference angle in the reference image and the current angle in the corrected image are calculated respectively, and the state of the shut-off valve is determined according to the angle difference between the current angle and the reference angle. The judgment is made by using a relative difference rather than a fixed absolute threshold, which can adapt to the individual differences between different devices and avoid the tedious process of setting thresholds for each device individually, thereby improving the accuracy and versatility of shut-off valve state recognition.
[0059] In an optional embodiment, S103 performs geometric correction on the image to be inspected based on the first structural key points and the second structural key points to obtain a corrected image that is geometrically consistent with the reference image, including: Step a1: Based on the first structural key points and the second structural key points mentioned above, calculate the geometric transformation matrix.
[0060] The geometric transformation matrix refers to the mathematical matrix representing the mapping relationship between the image plane to be inspected and the reference image plane. This geometric transformation matrix is a homography matrix, and its form can be an n×n (e.g., 3×3) homogeneous coordinate transformation matrix.
[0061] In this embodiment of the application, the coordinate set (x, y, x) of the second structural key points in the image to be inspected is obtained. i ,y i ), and the set of coordinates (x') of the first structural key points in the reference image. i ,y' i In this system, the keypoints of the second structure correspond one-to-one with the keypoints of the first structure, i = 1, 2, ..., n, where n is the number of keypoints. Based on the coordinates of multiple corresponding keypoints, a homogeneous linear system of equations is constructed. Solving this system of equations yields the values of each element in the corresponding matrix.
[0062] Specifically, points in the image plane to be inspected are mapped to points in the reference image plane after geometric transformation, and the two satisfy the following homogeneous coordinate transformation relationship:
[0063] Where H is a 3×3 homography matrix, in the form of:
[0064] By using at least four sets of corresponding structural key point coordinates, that is, the coordinates of the second structural key point (x) in the image to be inspected. i ,yi The coordinates (x') of the first structural key point in the reference image i ,y' i Substituting the above transformation relationships, a system of linear equations containing eight unknowns can be constructed. Solving this system of equations yields the values of each element in the corresponding matrix H. Optionally, when the number of keypoints exceeds four sets, the least squares method is used to solve for the optimal homography matrix to improve the accuracy of geometric correction.
[0065] Step a2: Perform geometric correction on the image to be inspected using the geometric transformation matrix described above to obtain the corrected image.
[0066] In this embodiment of the application, the geometric transformation matrix H calculated in step a1 is obtained, and all pixels in the image to be inspected are traversed. For each pixel (x i ,y i ), calculate its corresponding coordinates (x') in the corrected image based on the geometric transformation matrix H. i ,y' i ), satisfying the following transformation relationship:
[0067] Due to the transformed coordinates (x') i ,y' i The value may be a non-integer. The pixel value is resampled using bilinear interpolation, which calculates the gray value of the target pixel by weighting the gray values of the four neighboring pixels around the target coordinates. The calculated pixel value is then filled into the corresponding coordinate position in the corrected image to generate a complete corrected image.
[0068] Optionally, the geometric correction described above is a perspective transformation. Perspective transformation can effectively handle trapezoidal distortion caused by the tilt of the shooting angle, mapping the original image with a perspective offset to a standard front view, so that the valve dial maintains a regular rectangular structure in the corrected image.
[0069] Optionally, the geometric correction described above can also be an affine transformation. When the change in shooting angle is small and the degree of image distortion is mild, affine transformation can be used for geometric correction to reduce computational complexity and improve processing efficiency.
[0070] In an optional embodiment, S104 calculates the reference angle in the reference image and the current angle in the correction image, respectively, including: Step b1: Segment the reference state indication region from the reference image and segment the current state indication region from the calibration image.
[0071] The status indication area refers to the red area on the shut-off valve dial used to indicate the status of the equipment. The color, shape, and position of this area are related to the current operating status of the shut-off valve.
[0072] Segmentation refers to the process of separating the target region from the background in an image, which can be achieved through color features, shape features, or deep learning models.
[0073] Specifically: the above-mentioned corrected image is converted to the HSV color space; the converted corrected image is binarized using a preset color threshold to obtain the current initial mask; the current initial mask is morphologically processed to obtain the current optimized mask; the current optimized mask is subjected to connected component analysis, and the connected region with the largest area is selected as the current state indication region.
[0074] The reference image is converted to the HSV color space; the converted reference image is binarized using a preset color threshold to obtain the initial reference mask; the initial reference mask is morphologically processed to obtain the optimized reference mask; the optimized reference mask is subjected to connected component analysis, and the connected region with the largest area is selected as the reference state indication region.
[0075] In this embodiment, the corrected image is converted from the Red-Green-Blue (RGB) color space to the HSV color space. Based on the distribution characteristics of red in the HSV color space, multiple color threshold intervals are constructed. The converted image is then binarized to obtain the current initial mask, where pixel value 1 represents a candidate red region and pixel value 0 represents the background. Opening and closing operations are sequentially performed on the current initial mask to remove isolated noise points and fill holes inside the target region, resulting in the current optimized mask. Connected component analysis is performed on the current optimized mask to extract all connected regions. The area of each connected region is calculated, and the connected region with the largest area is selected as the current state indication region.
[0076] The same method is used to process the reference image to obtain the reference state indication area.
[0077] like Figure 2 As shown, the complete process of red region segmentation and edge fitting in this embodiment is as follows: First, the perspective-corrected image is converted from the RGB color space to the HSV color space. Then, a threshold is set using the distribution characteristics of red in the HSV space for segmentation, resulting in the image shown below. Figure 2 (a) shows the initial binary mask, which contains isolated noise points and internal voids. Then, opening and closing operations are performed on the initial mask sequentially: erosion followed by dilation to remove isolated noise points, and dilation followed by erosion to fill internal voids, resulting in the image shown. Figure 2(b) shows the optimized mask; then, all connected regions are extracted through connected component analysis, the area of each region is calculated, and the region with the largest area is selected as the target red region, such as... Figure 2 As shown in (c), this step effectively filters out non-target red interference in the background; then, a line-by-line scanning method is used to extract the leftmost boundary point of each row of the target red region, forming a pattern as shown in (c). Figure 2 (d) shows the left edge point set; finally, the least squares method is used to fit a straight line to the edge point set, resulting in the following: Figure 2 The boundary line shown in (e) is used to calculate the rotation angle of the red region relative to the vertical direction of the image.
[0078] The YOLO keypoint detection model used in this embodiment employs multi-dimensional data augmentation strategies during the training phase to improve the model's generalization ability under different inspection conditions. Specifically, this includes: (1) Geometric transformation enhancement: Randomly rotate (-30° to +30°), randomly scale (0.7x to 1.3x), and randomly transform the perspective of the training images (simulating different shooting angles) to enhance the model’s adaptability to changes in shooting angle; (2) Enhanced illumination transformation: Random brightness adjustment (0.5 to 1.5 times), random contrast adjustment (0.7 to 1.3 times), and random HSV color shift (H shift ±10°, S shift ±30, V shift ±40) are applied to the training images to simulate different lighting conditions such as sunny days, cloudy days, backlighting, and shadows. (3) Noise and degradation enhancement: Gaussian noise and salt-and-pepper noise are randomly added with a probability of 0.3, and image blur (Gaussian blur and motion blur) is randomly simulated with a probability of 0.2 to simulate image degradation that may occur in actual inspections, such as dial dirt, lens dust accumulation, and motion shaking.
[0079] The data augmentation strategies described above cover most of the image quality variations that may occur in the inspection scenario of shut-off valves, enabling the trained model to have good robustness and generalization performance when deployed in real-world scenarios, without the need for secondary optimization for each specific site or device.
[0080] Optionally, the aforementioned color threshold intervals include: a first red threshold interval H∈[0,10]∪[156,180], S∈[43,255], V∈[46,255], and a second red threshold interval H∈[0,10]∪[156,180], S∈[43,255], V∈[221,255]. These threshold intervals are obtained through statistical analysis of color distribution from a large number of on-site sample images and are adaptable to red region segmentation under different lighting conditions.
[0081] Optionally, the above morphological processing includes: opening operation, defined as erosion followed by dilation, used to remove isolated noise points; and closing operation, defined as dilation followed by erosion, used to fill voids inside the target area.
[0082] Optionally, the above connected component analysis includes: using an eight-neighbor connectivity criterion to mark the foreground pixels in the optimized mask as connected regions, resulting in multiple connected regions; calculating the number of pixels in each connected region as its area; and selecting the connected region with the largest area as the final state indication region.
[0083] Step b2: Calculate the reference angle based on the reference state indication area, and calculate the current angle based on the current state indication area.
[0084] The reference angle refers to the angle value of the shut-off valve status indicator calculated from the reference image, and the current angle refers to the angle value of the shut-off valve status indicator calculated from the calibration image.
[0085] In this embodiment of the application, the edge point set of the reference state indication area is extracted to obtain a reference edge point set, the reference edge point set is fitted to obtain a reference fitted line, and the reference angle is calculated according to the direction of the reference fitted line. In addition, the edge point set of the current state indication area is extracted to obtain a current edge point set, the current edge point set is fitted to obtain a current fitted line, and the current angle is calculated according to the direction of the current fitted line.
[0086] The specific method for the current angle is as follows: Let the direction vector of the currently fitted line be (v x ,v y If the current angle θ is 0, then the current angle θ is 0. current The calculation formula is: The calculation results are normalized to the range of 0° to 360°.
[0087] The same method is used to process the reference state indication area to obtain the reference angle θ. base .
[0088] Optionally, the above edge point set can be extracted by scanning the status indicator area line by line according to the vertical coordinate, extracting the leftmost boundary point in each line to form an edge point set.
[0089] It should be noted that the change of the red area of the shut-off valve status indicator between normal and abnormal states is mainly manifested by the offset of the left boundary angle. Therefore, extracting the leftmost boundary point can accurately reflect the state change characteristics and reduce the interference of edge noise on the fitting results.
[0090] Optionally, the objective of the above least-squares linear fitting is to minimize the error function: E=Σ(y i -(kx i +b))², where k is the slope and b is the intercept.
[0091] Optionally, before performing line fitting on the edge point set, the top and bottom regions can be cropped, retaining only the edge points in the stable middle region, to reduce the impact of unstable edge regions on the fitting results.
[0092] It should be noted that the calculation process of the above-mentioned reference angle and current angle is not a simple conventional edge detection and line fitting, but a combined processing flow with synergistic effect designed for the specific interference problem of the flow cut-off valve dial in a complex inspection environment.
[0093] First, converting the image to the HSV color space and performing color thresholding is based on the physical characteristic that the shut-off valve status indicator has a stable hue (red). This can effectively overcome the interference of drastic changes in light intensity and color temperature on color recognition in outdoor inspection scenarios, and its effect is significantly better than RGB space thresholding, which is sensitive to changes in light.
[0094] Secondly, the morphological processing of the binarized mask, involving opening and closing operations, is a targeted purification step designed to address common interferences such as dirt, reflection, and rust on the flow cut-off valve dial. The opening operation removes isolated false areas caused by minor dirt or light noise, while the closing operation fills in internal voids caused by fading or reflection of the indicator. The two operations work together to ensure the integrity and connectivity of the target area.
[0095] Furthermore, selecting the region with the largest area as the status indication region through connected component analysis is based on the prior physical knowledge that the status indicator of the shut-off valve typically occupies the largest red pixel area in the image. This step can accurately locate the target that truly needs analysis with extremely low computational cost when there are multiple red distractions on the dial (such as warning labels or reflections from surrounding devices).
[0096] Finally, a line-by-line scanning method is used to extract the leftmost boundary point and then perform line fitting using the least squares method. This is based on the geometric feature that the change in the state of the shut-off valve is mainly manifested as the angle shift of the left boundary of the red indicator. Compared with conventional line detection methods such as Hough transform, this method can actively eliminate the interference of non-critical features such as the right edge and the top and bottom edges, making the fitting results more stable and accurate, and significantly reducing the computational load.
[0097] The steps described above have an inherent logical progression: HSV segmentation provides a reliable initial mask for subsequent processing; morphological processing purifies the mask to ensure the accuracy of connected component analysis; maximum connected component selection uniquely identifies the target region; edge point extraction focuses key features; and least squares fitting achieves stable angle measurement. This combined process produces a synergistic effect in the inspection scenario of shut-off valves, maintaining extremely high angle measurement accuracy and robustness even under multiple interferences such as changes in lighting, complex backgrounds, and indicator contamination. Furthermore, it does not rely on large-scale labeled data and expensive computing power, making it easy to deploy in real-time on edge devices.
[0098] In an optional embodiment, S104 determines the state of the flow-stopping valve based on the angle difference between the current angle and the reference angle, including: Step c1: Calculate the absolute value of the angle difference between the current angle and the reference angle.
[0099] Among them, the angle difference refers to the absolute value of the difference between the current angle and the reference angle, which is used to measure the degree of deviation of the current state indicator relative to the normal state.
[0100] In this embodiment of the application, the reference angle θ calculated in step b2 is obtained. base and the current angle θ current Calculate the difference between the current angle and the reference angle, and take the absolute value to obtain the angle difference Δθ. The calculation formula is: Δθ = |θcurrent θbase∣.
[0101] Optionally, before calculating the angle difference, the current angle and the reference angle are normalized to a range of 0° to 360° to avoid errors in angle difference calculation caused by the angle crossing the 0° boundary.
[0102] Optionally, the above angle difference can be calculated as follows: Δθ=min(|θ current -θ base |,360°-|θ current -θ base |), to handle the shortest distance of the angle on the circumference.
[0103] Step c2: When the absolute value is greater than the preset threshold, the state of the above-mentioned shut-off valve is determined to be abnormal.
[0104] Step c3: When the absolute value is less than or equal to the preset threshold, the state of the shut-off valve is determined to be normal.
[0105] The preset threshold refers to the critical angle difference used to determine whether the shut-off valve is in an abnormal state. This preset threshold can be set according to the normal allowable deviation range of the shut-off valve status indicator. In this embodiment, the preset threshold can be set to 10°, a value determined based on the normal allowable mechanical deviation range of the shut-off valve status indicator. It should be noted that the preset threshold is not fixed and can be configured and adjusted according to different equipment models or operating conditions.
[0106] In this embodiment, the angle difference Δθ calculated in step c1 is obtained, and a preset threshold T is obtained; the angle difference Δθ is compared with the preset threshold T. When Δθ > T, the state of the shut-off valve is determined to be abnormal. When the angle difference Δθ ≤ T, the state of the shut-off valve is determined to be normal.
[0107] like Figure 3 As shown, the flow cut-off valve status determination process can output the boundary angle of the status indication area and the status determination result. The example in the figure shows the abnormal status recognition effect of oil level drop.
[0108] It should be understood that the sequence number of each step in the above embodiments does not imply 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 this application.
[0109] Corresponding to the flow interruption valve status identification method described in the above embodiments, Figure 4 A structural block diagram of the shut-off valve status identification system provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.
[0110] Reference Figure 4 The shut-off valve status identification system includes: The acquisition module is used to acquire the reference image and the image to be inspected of the shut-off valve; The identification module is used to identify a first structural key point from the reference image and a second structural key point from the image to be inspected. The correction module is used to perform geometric correction on the image to be inspected based on the first structural key point and the second structural key point to obtain a corrected image that is consistent with the geometric space of the reference image. The determination module is used to calculate the reference angle in the reference image and the current angle in the corrected image respectively, and determine the state of the flow-stopping valve based on the angle difference between the current angle and the reference angle.
[0111] In one possible implementation, the first structural key point and the second structural key point are screw fixing points used to fix the boundary of the flow cut-off valve dial.
[0112] In one possible implementation, the correction module is used for: Based on the first and second structural key points, the geometric transformation matrix is calculated. The geometric transformation matrix is used to perform geometric correction on the image to be inspected to obtain the corrected image.
[0113] In one possible implementation, the determination module is used for: The reference state indication region is segmented from the reference image, and the current state indication region is segmented from the corrected image; The reference angle is calculated based on the reference state indication area, and the current angle is calculated based on the current state indication area.
[0114] In one possible implementation, the determination module is used for: Convert the reference image to the HSV color space; The converted reference image is binarized using a preset color threshold to obtain the initial reference mask; The initial baseline mask is morphologically processed to obtain the optimized baseline mask; Perform connected component analysis on the benchmark optimization mask and select the connected region with the largest area as the benchmark state indication region; The step of segmenting the current state indication region from the corrected image includes: Convert the corrected image to the HSV color space; The converted and corrected image is binarized using a preset color threshold to obtain the current initial mask; The current initial mask is morphologically processed to obtain the current optimized mask; Perform connected component analysis on the current optimized mask and select the connected region with the largest area as the current state indication region.
[0115] In one possible implementation, the determination module is used for: Extract the edge point set of the reference state indication area to obtain the reference edge point set; The reference edge point set is fitted to obtain a reference fitted line, and the reference angle is calculated based on the direction of the reference fitted line; Extract the edge point set of the current state indication area to obtain the current edge point set; The current edge point set is fitted to obtain the current fitted line, and the current angle is calculated based on the direction of the current fitted line.
[0116] In one possible implementation, the determination module is used for: Calculate the absolute value of the angle difference between the current angle and the reference angle; When the absolute value is greater than a preset threshold, the state of the flow interruption valve is determined to be abnormal; When the absolute value is less than or equal to the preset threshold, the state of the shut-off valve is determined to be normal.
[0117] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.
[0118] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0119] This application also provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor executes the computer program to implement the steps in any of the above method embodiments.
[0120] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0121] This application provides a computer program product that, when run on a computer device, enables the computer device to execute the steps described in the various method embodiments above.
[0122] Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 5 As shown, the computer device of this embodiment includes: at least one processor 50 ( Figure 5(Only one is shown in the diagram), memory 51, and computer program 52 stored in the memory 51 and executable on the at least one processor 50, wherein the processor 50 executes the computer program 52 to implement the steps in any of the above embodiments of the flow interruption valve state identification method.
[0123] The computer device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will understand that... Figure 5 The examples of computer devices are merely examples and do not constitute a limitation on computer devices. They may include more or fewer components than shown in the illustration, or combinations of certain components, or different components. For example, they may also include input / output devices, network access devices, etc.
[0124] The processor 50 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0125] In some embodiments, the memory 51 may be an internal storage unit of the computer device, such as a hard disk or memory. In other embodiments, the memory 51 may be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. Furthermore, the memory 51 may include both internal and external storage units of the computer device. The memory 51 is used to store the operating system, applications, bootloader, data, and other programs, such as the program code of the computer program. The memory 51 can also be used to temporarily store data that has been output or will be output.
[0126] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or system capable of carrying computer program code to a system / computer device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, such as a USB flash drive, a portable hard drive, a magnetic disk, or an optical disk.
[0127] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0128] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0129] In the embodiments provided in this application, it should be understood that the disclosed systems / computer devices and methods can be implemented in other ways. For example, the system / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0130] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0131] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A shutoff valve state recognition method characterized by, include: Acquire the reference image and the image to be inspected of the shut-off valve; Identify the first structural key point from the reference image and the second structural key point from the image to be inspected; Based on the first structural key point and the second structural key point, the image to be inspected is geometrically corrected to obtain a corrected image that is consistent with the geometric space of the reference image. The reference angle in the reference image and the current angle in the corrected image are calculated respectively, and the state of the shut-off valve is determined based on the angle difference between the current angle and the reference angle.
2. The method of claim 1, wherein, The first and second key structural points are screw fixing points used to fix the boundary of the flow cut-off valve dial.
3. The method of claim 1, wherein, The step of performing geometric correction on the image to be inspected based on the first structural key points and the second structural key points to obtain a corrected image with geometric space consistent with the reference image includes: Based on the first and second structural key points, the geometric transformation matrix is calculated. The geometric transformation matrix is used to perform geometric correction on the image to be inspected to obtain the corrected image.
4. The method of claim 1, wherein, The calculation of the reference angle in the reference image and the current angle in the corrected image includes: The reference state indication region is segmented from the reference image, and the current state indication region is segmented from the corrected image; The reference angle is calculated based on the reference state indication area, and the current angle is calculated based on the current state indication area.
5. The method of claim 4, wherein, The step of segmenting the reference state indication region from the reference image includes: Convert the reference image to the HSV color space; The converted reference image is binarized using a preset color threshold to obtain the initial reference mask; The initial baseline mask is morphologically processed to obtain the optimized baseline mask; Perform connected component analysis on the benchmark optimization mask and select the connected region with the largest area as the benchmark state indication region; The step of segmenting the current state indication region from the corrected image includes: Convert the corrected image to the HSV color space; The converted and corrected image is binarized using a preset color threshold to obtain the current initial mask; The current initial mask is morphologically processed to obtain the current optimized mask; Perform connected component analysis on the current optimized mask and select the connected region with the largest area as the current state indication region.
6. The method of claim 4, wherein, The calculation of the reference angle based on the reference state indication area and the calculation of the current angle based on the current state indication area include: Extract the edge point set of the reference state indication area to obtain the reference edge point set; The reference edge point set is fitted to obtain a reference fitted line, and the reference angle is calculated based on the direction of the reference fitted line; Extract the edge point set of the current state indication area to obtain the current edge point set; The current edge point set is fitted to obtain the current fitted line, and the current angle is calculated based on the direction of the current fitted line.
7. The method of claim 1, wherein, The step of determining the state of the shut-off valve based on the angle difference between the current angle and the reference angle includes: Calculate the absolute value of the angle difference between the current angle and the reference angle; When the absolute value is greater than a preset threshold, the state of the flow interruption valve is determined to be abnormal. When the absolute value is less than or equal to the preset threshold, the state of the shut-off valve is determined to be normal.
8. A shutoff valve condition recognition system, characterized by, include: The acquisition module is used to acquire the reference image and the image to be inspected of the shut-off valve; The identification module is used to identify a first structural key point from the reference image and a second structural key point from the image to be inspected. The correction module is used to perform geometric correction on the image to be inspected based on the first structural key point and the second structural key point to obtain a corrected image that is consistent with the geometric space of the reference image. The determination module is used to calculate the reference angle in the reference image and the current angle in the corrected image respectively, and determine the state of the shut-off valve based on the angle difference between the current angle and the reference angle.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.
10. A computer program product, characterized in that, Includes a computer program that, when run, implements the method as described in any one of claims 1 to 7.
