Method for detecting valve handle status, server, and storage medium
By acquiring images and processing algorithms, the directional vector angle difference between the valve handle and the pipeline is obtained, which solves the problems of high hardware cost and delayed early warning in the existing technology, and realizes efficient and accurate valve status detection and data retention.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- YUANJIAN WIND POWER JIANGYINENVISION ENERGY CO LTD
- Filing Date
- 2026-04-27
- Publication Date
- 2026-07-31
AI Technical Summary
Existing valve condition monitoring technologies rely on specialized equipment and manual on-site calibration and sensor installation, which have problems such as high cost, strong intrusiveness, and delayed early warning.
By acquiring on-site images of valve handles and pipelines, generating segmentation masks and performing principal component analysis, and calculating the directional vector angle difference, valve status detection is achieved, avoiding hardware additions and manual calibration.
It reduces testing costs, improves testing efficiency and accuracy, creates data assets, and is suitable for real-time computing on mobile terminals.
Smart Images

Figure CN122492586A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent operation and maintenance of industrial equipment, and in particular to a method for detecting the status of valve handles, a server, and a storage medium. Background Technology
[0002] In the field of intelligent operation and maintenance of industrial equipment, intelligent valve status detection during maintenance operations is a key link in realizing real-time compliance detection and risk warning of operation procedures. It is widely used in onshore and offshore wind farms, equipment manufacturing and assembly workshops and other scenarios. The core requirement is to achieve accurate and efficient identification and monitoring of valve opening and closing status to ensure the safety and standardization of equipment operation and maintenance.
[0003] Valve condition monitoring technologies, due to their design focus on adapting to specialized equipment or adding monitoring hardware, generally have limitations in application: some solutions rely on specialized equipment and manual on-site calibration, which requires highly skilled personnel and supporting equipment, resulting in high labor and operating costs; some solutions require the installation of sensors, monitoring devices, or status tags at pipelines or valves, which involves complex installation processes, is intrusive to existing equipment, and increases subsequent operation and maintenance costs; and some solutions rely on media leakage to trigger monitoring, resulting in significant early warning lag. Summary of the Invention
[0004] The purpose of this application is to provide a method, server, and storage medium for detecting the state of a valve handle, thereby enabling the detection of the valve's open / closed state without altering the original inspection and maintenance process and equipment, and reducing hardware and maintenance costs.
[0005] To address the aforementioned technical problems, embodiments of this application provide a method for detecting the state of a valve handle, comprising: acquiring a field image containing a valve handle to be detected and a corresponding pipeline; determining a first segmentation mask for the valve handle and a second segmentation mask for the pipeline based on the field image; performing principal component analysis on the pixel sets corresponding to the first segmentation mask and the second segmentation mask to obtain a first direction vector for the valve handle and a second direction vector for the pipeline; calculating the angle difference between the first direction vector and the second direction vector, and determining the valve state based on the angle difference and a preset angle threshold.
[0006] Embodiments of this application also provide a server, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the valve handle state detection method as described above.
[0007] The embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for detecting the state of a valve handle.
[0008] To address the compatibility issues of valve status detection technologies, which rely on specialized equipment and require manual on-site calibration, sensor installation, and early warning lag, this application provides a method for detecting the status of valve handles. This method acquires on-site images containing valve handles and pipelines and generates corresponding first and second segmentation masks. This allows for the accurate extraction of target pixel sets from complex maintenance environments, effectively separating the target from the background and eliminating background interference for subsequent orientation detection. Furthermore, Principal Component Analysis (PCA) is used to process the pixel sets of the segmentation masks and extract orientation vectors. Statistical analysis of the first orientation vector of the valve handle and the second orientation vector of the pipeline eliminates the influence of different shooting angles and lighting conditions at the maintenance site, ensuring stable acquisition of the true orientation of the valve handle and pipeline. For the status discrimination problem after orientation detection, a quantitative discrimination logic based on angle difference and preset thresholds replaces inefficient methods such as manual calibration and media triggering, solving the problem of the inability to quickly and objectively convert orientation detection results into valve status in complex scenarios. This method completes detection solely through image acquisition and algorithm processing, eliminating the need for sensors or status tags on valves and pipelines, as well as specialized equipment and manual on-site calibration. It does not alter existing maintenance procedures or equipment, significantly reducing manpower and hardware costs. Furthermore, the entire detection process is algorithmically driven, enabling image acquisition and real-time computation via mobile devices such as smartphones, eliminating the need for on-site debugging. It also visualizes the detection results and creates valuable data assets. Attached Figure Description
[0009] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0010] Figure 1 This is a schematic diagram of a straight-handle manual valve according to some embodiments of this application; Figure 2 This is an exemplary flowchart of a valve handle status detection method according to some embodiments of this application; Figure 3 This is a schematic diagram showing an example of a straight-handle manual valve according to some embodiments of this application; Figure 4This is a flowchart of an early warning system for automatic detection of the on / off status of an oil pump valve based on machine vision, according to some embodiments of this application. Figure 5 This is a schematic diagram of the server structure according to some embodiments of this application. Detailed Implementation
[0011] To more clearly illustrate the technical solutions of the embodiments in this specification, the embodiments will be described in detail below with reference to the accompanying drawings. Obviously, the content described below are some examples or embodiments of this specification. For those skilled in the art, without creative effort, the technical solutions or means disclosed in this specification can be applied to other scenarios based on this technical content.
[0012] It should be understood that the terms "system," "device," "unit," and / or "module" used in this specification are a method of distinguishing different components, elements, parts, sections, or assemblies at different levels. However, if other words can achieve the same purpose, they may be replaced by other expressions.
[0013] Unless otherwise specified, the technical terms used to describe components, elements, etc. in this specification are not singular but may include plural. Generally speaking, terms such as "comprising" or "including" only indicate that explicitly identified steps, elements, or components are included, and these steps, elements, and components do not constitute an exclusive list, as the described method or apparatus may also include other steps or components.
[0014] This specification uses flowcharts to illustrate the operational steps performed by the apparatus or system of related embodiments. However, unless otherwise specified, the order in which these steps are described should not be construed as a limitation on the order of execution. Those skilled in the art can adjust the order of these steps based on the knowledge and information conveyed by the embodiments in this specification. Adjustments include, but are not limited to, reversing the order of steps, merging multiple steps, and splitting a step.
[0015] As the background technology indicates, in production and maintenance scenarios, for valve status monitoring at specific locations, standardized production lines typically employ fixed cameras and calibration templates to detect the angles of parts and equipment. However, this requires high-level system integration and strict adherence to application scenarios, resulting in high costs and poor generalization. Meanwhile, threshold monitoring relying on sensors, such as monitoring valve pressure and temperature anomalies, depends on high-precision low-voltage information systems and periodic personnel checks, leading to high costs and difficulty in creating visualized data archives.
[0016] To address the aforementioned issues, some embodiments of this application provide a method for detecting the status of a valve handle. This method relies on on-site images of the valve to be detected and the corresponding pipeline acquired by an image acquisition terminal. By extracting the direction vectors of the valve handle and the pipeline in the on-site images and calculating the angle difference, the valve's open / closed status is determined. Compared with related technologies for valve status detection, the method of this application does not require professional equipment calibration, additional installation devices, or status tags. It can be implemented using only a common mobile phone, without changing the original maintenance process and equipment, reducing hardware and maintenance costs. The system is easy to deploy and can form data assets for retention, enabling real-time compliance detection and risk warning of maintenance operation processes.
[0017] Figure 1 This is a schematic diagram of a straight-handle manual valve according to some embodiments of this application, such as... Figure 1 As shown, it includes pipes, corresponding pipe sections for valves, and valve handles. In some embodiments, Figure 1 The valve handle and its associated piping in the straight-handle manual valve shown are used as the detection objects in this detection method. The first direction vector of the valve handle and the second direction vector of the piping are extracted through target detection and segmentation, thereby realizing the detection of the valve's status. It should be noted that... Figure 1 The straight-handle manual valve shown is merely an example. The straight-handle manual valve described in the embodiments of this specification is for the purpose of more clearly illustrating the technical solutions of the embodiments of this specification, and does not constitute a limitation on the technical solutions provided in the embodiments of this specification. Those skilled in the art will understand that as long as the valve has a rigid operating component that can be recognized by an image (e.g., a linear, rod-shaped, or disc-shaped structure with extractable direction), and the opening and closing state of this component changes regularly with the direction angle relative to the pipeline, this solution can be adapted, regardless of the specific type of valve. The technical solutions provided in the embodiments of this specification are also applicable to similar valve structures.
[0018] Figure 2 This is an exemplary flowchart of a valve handle status detection method according to some embodiments of this application. Figure 2 The illustrated process can be executed by a processing device, for example, by a server. In some embodiments, the process can be implemented by an edge computing terminal or a cloud server as a database and core processing unit. Figure 2 As shown, in some embodiments, the process of detecting the state of the valve handle may include the following steps.
[0019] Step 210: Obtain a field image containing the valve handle to be tested and the corresponding pipeline.
[0020] Step 210 is the raw data acquisition stage of the inspection process. After completing the valve status confirmation steps in the maintenance workflow, maintenance personnel follow the system prompts to capture images of the valve to be inspected and its associated piping. This image simultaneously includes the valve and its corresponding piping, adapting to actual maintenance scenarios without requiring specialized acquisition equipment and without altering the original maintenance procedures and equipment. The server or edge computing terminal acquires the on-site image uploaded by the maintenance personnel and executes subsequent inspection algorithms based on this image.
[0021] Step 220: Based on the on-site images, determine the first segmentation mask for the valve handle and the second segmentation mask for the pipeline.
[0022] Step 220 uses the instance segmentation algorithm to perform target detection and segmentation on the on-site image, separating the independent target areas of valve handles and pipes from the complex industrial background of operation and maintenance, and generating binary segmentation masks (first and second segmentation masks) that retain only their own pixels for the two targets to remove background interference.
[0023] To ensure that the segmentation mask accurately matches the target areas of the valve handle and the pipeline, and to improve the accuracy of subsequent directional feature extraction, the following operation procedure can be adopted for the first segmentation mask of the valve handle and the second segmentation mask of the pipeline: perform image correction on the field image; perform instance segmentation on the corrected field image based on the instance segmentation algorithm, and extract the first location box of the valve handle and the second location box of the pipeline respectively; binarize the first location box and the second location box respectively to determine the first segmentation mask and the second segmentation mask.
[0024] Specifically, due to the complex shooting environment at maintenance sites, handheld mobile phone shooting can easily lead to problems such as image tilt, perspective distortion, and image shift. Direct segmentation would result in distorted target contours. Therefore, image correction first corrects the geometric distortion caused by the shooting, restoring the true spatial shape and relative position of valve handles and pipes, making subsequent target segmentation more closely match the actual target contours and reducing segmentation errors from the source. The corrected, well-formed image is then used for further processing to improve detection accuracy. Instance segmentation algorithms (such as YOLO11) are used to perform target detection on the corrected image, accurately identifying and separating the valve handle and pipe from the complex industrial background of maintenance. Contour-fitting bounding boxes are generated for each, including a first bounding box corresponding to the valve handle and a second bounding box corresponding to the pipe (e.g., ...). Figure 3 As shown in the figure, the initial separation of the target and the background is achieved. The two location boxes are binarized respectively, and the target pixels inside the location box are marked as valid values (such as 1), while the background pixels outside the location box are marked as invalid values (such as 0). Finally, the first segmentation mask that retains only the pixel information of the valve handle and the second segmentation mask that retains only the pixel information of the pipe are obtained.
[0025] In this way, by performing image preprocessing, example segmentation and bounding, and binarization transformation, the segmentation accuracy problem caused by poor image quality captured on site is solved, making the generated segmentation mask more closely match the actual target and ensuring the accuracy of subsequent orientation detection and valve status determination.
[0026] Step 230: Perform principal component analysis on the pixel sets corresponding to the first segmentation mask and the second segmentation mask respectively to obtain the first direction vector of the valve handle and the second direction vector of the pipe.
[0027] In step 230, the process of extracting direction vectors from the pixel set through principal component analysis can be carried out in the following specific way: extract the first pixel set corresponding to the first segmentation mask and the second pixel set corresponding to the second segmentation mask; perform centering processing on the first pixel set and the second pixel set, and calculate the first covariance matrix corresponding to the first pixel set after centering processing, and the second covariance matrix corresponding to the second pixel set; perform eigenvalue decomposition on the first covariance matrix and the second covariance matrix respectively to obtain the first eigenvalue set and the eigenvector corresponding to each eigenvalue in the first eigenvalue set, and obtain the eigenvector corresponding to each eigenvalue in the second eigenvalue set; determine the largest eigenvalue in the first eigenvalue set and the second eigenvalue set respectively, and use the eigenvector corresponding to the largest eigenvalue as the first direction vector and the second direction vector.
[0028] Specifically, firstly, the two-dimensional coordinates of all pixels belonging to the target (valve handle and pipe) are extracted from the two masks respectively. The sets of these coordinates constitute the first pixel set (valve handle pixel coordinates) and the second pixel set (pipe pixel coordinates). Taking one of the first and second segmentation masks as an example, the extracted pixel sets have... The representation of each pixel and its coordinates is as follows: .
[0029] Centering is performed on the first pixel set and the second pixel set respectively. In some embodiments, the centering process is specifically performed as follows: the first mean coordinates and the second mean coordinates of the first pixel set are calculated respectively; the first mean coordinates are subtracted from the coordinates of each pixel in the first pixel set, and the second mean coordinates are subtracted from the coordinates of each pixel in the second pixel set.
[0030] In one example, the mean coordinates of each pixel set are first calculated. for Axis mean, for The mean of the axes is used to calculate the centered pixel coordinates. Then, the coordinates of each pixel are subtracted from the mean to obtain the centered pixel coordinates. This operation aims to eliminate translational biases caused by the shooting angle and target position, ensuring that the pixel distribution centers of both targets are located at the origin, thus guaranteeing the accuracy of subsequent direction calculations. and The calculation process can be shown below.
[0031]
[0032]
[0033] To ensure that the pixel sets of both targets are centered at the origin, the following method can be used:
[0034]
[0035] In this way, the first and second pixel sets after centering are calculated.
[0036] Based on the centered first and second pixel sets, the corresponding two-dimensional covariance matrices are calculated (the first covariance matrix corresponds to the valve handle, and the second covariance matrix corresponds to the pipe). The covariance matrix reflects the correlation and dispersion of pixel distribution in the x and y axes, and its calculation follows the formula for the two-dimensional covariance matrix:
[0037] Solve the characteristic equations for the first and second covariance matrices respectively. (Eigenvalue decomposition) yields two sets of results: a first set of eigenvalues and the eigenvector corresponding to each eigenvalue (corresponding to the valve handle); and a second set of eigenvalues and the eigenvector corresponding to each eigenvalue (corresponding to the pipe). The eigenvalues... The physical meaning is the degree of dispersion of the target pixel set along the direction of the corresponding feature vector. The greater the degree of dispersion, the more the direction can represent the main extension direction of the target (rod-shaped, line-shaped).
[0038] Since the largest eigenvalue represents the degree of dispersion of data along the principal direction, the eigenvector corresponding to the largest eigenvalue can most accurately reflect the actual direction of the rod-like or linear structure of the valve handle or pipe. Therefore, this application selects the largest eigenvalue from the first eigenvalue set, and its corresponding eigenvector is the first direction vector (representing the core extension direction of the valve handle); and selects the largest eigenvalue from the second eigenvalue set, and its corresponding eigenvector is the second direction vector (representing the core extension direction of the pipe).
[0039] Step 240: Calculate the angle difference between the first direction vector and the second direction vector, and determine the valve state based on the angle difference and the preset angle threshold.
[0040] In some embodiments, the angle difference between the first direction vector and the second direction vector is calculated in the following manner: calculating the first direction angle of the valve handle and the second direction angle of the pipeline based on the first direction vector and the second direction vector, respectively; constraining the calculated first direction angle and the second direction angle within a preset angle range; and calculating the difference between the constrained first direction angle and the second direction angle to obtain the angle difference.
[0041] In one example, based on the extracted first direction vector (components are denoted as...) Valve handle direction vector), second direction vector (components represented as...) (pipeline direction vector), calculate the first direction angle according to the direction angle calculation formula. Second direction angle The formula for calculating the direction angle is divided into:
[0042] Substituting the components of the valve handle direction vector into the formula yields the first direction angle. Substituting the components of the pipe direction vector into the formula, we obtain the second direction angle. The core of this formula is to calculate the actual angle of the vector in the coordinate system by using the ratio of the horizontal and vertical components of the direction vector.
[0043] Since valve handles and pipes are rod-like or linear structures, their direction vectors have two opposing directions (for example, the valve handle's vectors pointing "upper right" and "lower left" actually represent the same direction of extension). If the difference is calculated directly using the original angle, an error of 180° deviation will occur. Constraining the angles within a preset angle range ensures the uniqueness of the direction angles, guaranteeing the accuracy of subsequent difference calculations. This preset angle range is... For the first direction angle calculated in the first step Second direction angle Perform angle constraint processing separately to obtain the final constrained angles. and The constraint rules strictly follow the following piecewise formula:
[0044] in, The initial direction angle is calculated based on the direction vector components. The direction angle after eliminating ambiguity of direction.
[0045] Finally, the first direction angle after being constrained by the preset interval will be... Second direction angle The result of the subtraction operation is the final angle difference between the valve handle and the pipe. .
[0046] Calculated angle difference This is the basis for determining the valve's open / closed state. When the angle difference is greater than a preset angle threshold, the valve is determined to be closed; when the angle difference is not greater than the preset angle threshold, the valve is determined to be open. If the valve is determined to be closed and does not meet the maintenance requirements, the server will push a warning message and provide a correct requirement example for reoperation; the calculation results and the main direction lines drawn in the original diagram will be archived to the cloud server.
[0047] Thus, in one or more of the above embodiments, this application acquires on-site images containing valves and pipelines and generates corresponding first and second segmentation masks. This enables the accurate extraction of target pixel sets from complex on-site maintenance backgrounds, achieving effective separation of targets from the background and clearing background interference for subsequent direction detection. Furthermore, Principal Component Analysis (PCA) is used to process the pixel sets of the segmentation masks and extract direction vectors. By statistically analyzing the first direction vector of the valve handle and the second direction vector of the pipeline, the influence of different shooting angles and lighting conditions at the maintenance site can be eliminated, stably obtaining the true direction of the valve handle and pipeline. Regarding the state discrimination problem after direction detection, a quantitative discrimination logic based on angle difference and preset thresholds replaces inefficient methods such as manual calibration and media triggering, solving the problem that direction detection results cannot be quickly and objectively converted into valve states in complex scenarios. This method completes detection solely through image acquisition and algorithm processing, eliminating the need for sensors or status tags on valves and pipelines, as well as specialized equipment and manual on-site calibration. It does not change the original maintenance process and equipment, significantly reducing the manpower and hardware costs of detection. Furthermore, the entire detection method is algorithm-based, which can collect images and perform real-time calculations using mobile terminals such as smartphones, without the need for on-site debugging. It also visualizes the detection results and creates data assets for future reference.
[0048] Compared to conventional valve status detection technologies, this application has the following advantages: it overcomes the limitations of tools and hardware, utilizes mobile terminals for universal shooting, greatly reducing hardware costs; it adapts to existing workflows without incurring additional process and production costs; the system is easy and quick to deploy, requiring no on-site debugging or subsequent maintenance, and the algorithm is regularly updated to enable long-term use; it forms corresponding industry-specific data assets, creating effective backend archives for convenient subsequent management and traceability.
[0049] In one example, the valve handle status detection method described above can be deployed in a server-side early warning system. This system automatically determines whether the valve is in a closed state through target recognition and angle analysis, and triggers an early warning when an abnormality occurs. It is suitable for operation and maintenance inspections in industrial scenarios. Figure 4 This is a flowchart illustrating the workflow of an early warning system for automatically detecting the on / off status of oil pump valves based on machine vision. Figure 4 As shown, the process proceeds sequentially. First, the initial input and model loading stage begins with on-site images of the oil pump valves captured during maintenance and inspection. A pre-trained instance segmentation and object detection model, such as YOLO11, is then loaded to prepare for subsequent image inference. Next, the image inference and object recognition stage begins. The loaded model is used to infer the input image, executing two parallel recognition tasks: locating and segmenting the valve handle region from the image, and locating and segmenting the corresponding pipe region. After image inference, the process enters the object detection verification branch, which contains two parallel decision nodes to confirm successful object recognition. The first decision is whether the valve handle is detected. If not, object recognition fails, and the process returns to the image inference step for re-inference and recognition. If successfully detected, the process proceeds to the next step of fitting a straight line along the handle's direction. The second decision is whether the pipe is detected. If not, object recognition also fails, and the process returns to the image inference step for re-identification. If successfully detected, the process proceeds to the next step of fitting a straight line along the pipe's direction. After the target detection verification is passed, the process proceeds to the direction fitting and angle difference calculation stage. First, based on the identified valve handle pixel area, algorithms such as principal component analysis are used to fit a straight line representing the extension direction of the wrench, thus obtaining the wrench's direction vector and direction angle. Similarly, based on the identified pipe pixel area, a straight line representing the extension direction of the pipe is fitted, obtaining the pipe's direction vector and direction angle. Then, the angle between the wrench and pipe directions is calculated, the core being to eliminate directional ambiguity, thereby obtaining a unique and accurate angle difference value. Finally, in the threshold judgment and early warning stage, it is necessary to determine whether the calculated angle difference is greater than a preset threshold. If the angle difference is not greater than the threshold, it means the angle difference is within the normal range, the valve is in the open state, conforming to the operation and maintenance specifications, and the process returns to the image reasoning stage to prepare for the next image detection. If the angle difference is greater than the threshold, it means the angle difference exceeds the preset standard, the valve is in the closed state, which does not conform to the operation and maintenance specifications and poses a safety risk. In this case, an early warning is triggered, and an abnormal valve closure warning is pushed to the operation and maintenance personnel, prompting them to handle it promptly.
[0050] The core principle of the above process is as follows: when the valve is normally open, the wrench direction is basically parallel to the pipeline direction with a small angle difference; when the valve is closed, the wrench direction is perpendicular to the pipeline direction with a larger angle difference. By identifying targets and analyzing angles, automated, non-contact valve status detection is achieved, replacing manual inspection and effectively improving detection efficiency and safety. Parallel recognition and fault-tolerant retry methods are adopted, with two target recognition tasks executed simultaneously. If either recognition fails, the process returns to the inference step to retry, ensuring the robustness of the entire process. Simultaneously, using the angle difference as the core judgment criterion, the influence of position and viewing angle is eliminated through direction fitting, using only the angle difference as the sole judgment standard to ensure stable and reliable detection results. Furthermore, a closed-loop detection mode is designed; after detection, the process automatically returns to the inference step, enabling continuous detection of continuous images and real-time video, suitable for automated inspection scenarios.
[0051] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this application. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this patent.
[0052] Another embodiment of this application relates to a server, such as Figure 5 As shown, it includes at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the valve handle state detection method as described above.
[0053] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.
[0054] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.
[0055] Another embodiment of this application relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the method embodiments described above.
[0056] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0057] Those skilled in the art will understand that the above embodiments are specific implementations of this application, and in practical applications, various changes can be made in form and detail without departing from the spirit and scope of this application.
Claims
1. A method of detecting the state of a valve handle, characterized by, include: Acquire a field image containing the valve handle to be inspected and the pipe corresponding to the valve handle; Based on the on-site images, determine the first segmentation mask for the valve handle and the second segmentation mask for the pipeline, respectively; Principal component analysis is performed on the pixel sets corresponding to the first segmentation mask and the second segmentation mask respectively to obtain the first direction vector of the valve handle and the second direction vector of the pipe; Calculate the angle difference between the first direction vector and the second direction vector, and determine the valve state based on the angle difference and a preset angle threshold.
2. The method of claim 1, wherein The step of determining the first segmentation mask for the valve handle and the second segmentation mask for the pipeline based on the on-site image includes: The on-site images are then corrected. The corrected field image is segmented based on the instance segmentation algorithm to extract the first location box of the valve handle and the second location box of the pipe. The first and second location boxes are binarized to determine the first segmentation mask and the second segmentation mask.
3. The method of claim 1, wherein The step of performing principal component analysis on the pixel sets corresponding to the first segmentation mask and the second segmentation mask respectively to obtain the first direction vector of the valve handle and the second direction vector of the pipe includes: Extract the first set of pixels corresponding to the first segmentation mask and the second set of pixels corresponding to the second segmentation mask; The first set of pixels and the second set of pixels are centered, and the first covariance matrix corresponding to the centered first set of pixels and the second covariance matrix corresponding to the second set of pixels are calculated. Eigenvalue decomposition is performed on the first covariance matrix and the second covariance matrix respectively to obtain the first eigenvalue set and the eigenvector corresponding to each eigenvalue in the first eigenvalue set, and the second eigenvalue set and the eigenvector corresponding to each eigenvalue in the second eigenvalue set. The largest eigenvalue in the first eigenvalue set and the second eigenvalue set are determined respectively, and the eigenvector corresponding to the largest eigenvalue is used as the first direction vector and the second direction vector.
4. The method of claim 3, wherein The centering process for the first pixel set and the second pixel set includes: Calculate the first mean coordinates and the second mean coordinates of the first set of pixels, respectively. Subtract the first mean coordinate from the coordinates of each pixel in the first pixel set, and subtract the second mean coordinate from the coordinates of each pixel in the second pixel set.
5. The method of claim 1, wherein The calculation of the angle difference between the first direction vector and the second direction vector includes: Calculate the first direction angle of the valve handle and the second direction angle of the pipe based on the first direction vector and the second direction vector, respectively; The calculated first and second direction angles are constrained within a preset angle range; The difference between the constrained first direction angle and the constrained second direction angle is calculated to obtain the angle difference.
6. The method for detecting the state of a valve handle according to claim 5, characterized in that, The direction angle is constrained using the following formula: in, The initial direction angle is calculated based on the direction vector components. The direction angle after eliminating ambiguity of direction.
7. The method for detecting the state of a valve handle according to claim 5, characterized in that, Determining the valve state based on the angle difference and a preset angle threshold includes: When the angle difference is greater than the preset angle threshold, the valve state is determined to be closed; When the angle difference is not greater than the preset angle threshold, the valve state is determined to be open.
8. The method according to any one of claims 1 to 7, characterized in that, The acquisition of on-site images containing the valve to be inspected and its corresponding pipeline includes: receiving on-site images taken and uploaded by maintenance personnel via mobile terminals; After determining the open / closed state of the valve, the method further includes: When a valve is found to be not in compliance with specifications, a warning message is sent and a correct requirement example is provided for reoperation; the calculation results and the main direction lines drawn in the original drawing are archived to the cloud server.
9. A server, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the valve handle state detection method as described in any one of claims 1 to 8.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for detecting the state of the valve handle as described in any one of claims 1 to 8.