Knob switch state reading method and device based on graphical marker recognition

By constructing a deep collaborative framework that combines graphic markers to carry areas with arrow direction and character semantic recognition, the problems of automation and accuracy in reading the state of rotary switches are solved, achieving high-precision, robust, and multi-type compatible rotary switch state recognition.

CN122244872APending Publication Date: 2026-06-19UNIV OF JINAN

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
UNIV OF JINAN
Filing Date
2026-05-15
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In existing technologies, the reading of the status of rotary switches relies on manual judgment, which is highly dependent on human intervention, inefficient, greatly affected by changes in lighting, and difficult to automate and remotely link. Furthermore, existing image processing methods lack a unified method for extracting graphic marker-carrying areas and recognizing characters, resulting in low recognition accuracy and difficulty in compatibility with different types of rotary switches.

Method used

By constructing a graphic marker carrying area, combining arrow direction recognition and character semantic reading, and employing optical character recognition and preset pattern matching, the automatic reading of the knob switch status is achieved, including arrow direction angle calculation and character standardization processing, forming a deep collaborative framework.

Benefits of technology

It improves the accuracy and stability of rotary switch status reading, achieves high precision, robustness and multi-type compatibility, reduces hardware costs, and is suitable for rotary switch recognition in complex backgrounds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122244872A_ABST
    Figure CN122244872A_ABST
Patent Text Reader

Abstract

This application discloses a method and apparatus for reading the state of a rotary switch based on graphic marker recognition, belonging to the field of image processing technology. The method includes the following steps: acquiring an image containing a rotary switch and extracting the surface area of ​​the knob as a graphic marker carrying area; recognizing arrow graphic markers within the graphic marker carrying area and calculating the direction angle of the arrow graphic markers based on the positional relationship between the arrow tip and the center of the knob; reading the character graphic markers using optical character recognition and standardizing the recognition results to obtain a standardized character sequence; matching a preset switch category pattern according to the standardized character sequence and matching the state mapping rule of that category according to the direction angle, and outputting the state recognition result of the rotary switch. This invention significantly improves the accuracy and compatibility of rotary switch state reading by combining high-precision arrow direction angle calculation with character semantic fusion and a pattern matching mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to a method and apparatus for reading the state of a rotary switch based on graphic mark recognition, belonging to the field of image processing technology. Specifically, it relates to a method and apparatus for determining the direction and angle of the arrow graphic mark on a rotary switch using image analysis and combining it with the character graphic mark for state mapping. Background Technology

[0002] Rotary switches are widely used as a common operating element in industrial control equipment, power distribution equipment, automated production lines, and various human-machine interface panels. Rotary switches typically use graphic markings such as arrows, pointers, or colored blocks on their surface to indicate the current position, while surrounding or printed character markings (such as "On / Off," "Local / Remote," "Unlock / Interlock," etc.) indicate the functional status corresponding to different positions. Reading the status of rotary switches is a fundamental step in equipment inspection, system monitoring, and fault diagnosis.

[0003] Currently, the reading of the status of rotary switches in existing technologies mainly relies on manual visual inspection: staff members make a comprehensive judgment and record the information by observing the direction of the arrow on the knob and combining it with the surrounding text. However, this manual method has the following drawbacks: (1) It is highly dependent on human intervention, and the results are affected by subjective experience, attention and other factors, which is not conducive to standardization and automation; (2) It is inefficient and cannot meet the needs of high-frequency inspection and large-scale equipment monitoring; (3) Changes in lighting, shooting angle, oil stains and other factors make it difficult to identify arrows or characters, and human eyes are prone to deviation; (4) It is difficult to directly connect to the back-end management system and cannot realize automatic alarm and remote linkage.

[0004] In recent years, some image processing and machine vision-based technologies have been attempted to be applied to knob status recognition. For example, object detection algorithms are used to locate the knob area, edge detection or template matching is used to estimate the arrow rotation angle, or a general classification network is used to determine the status category. However, these methods typically have significant drawbacks: on the one hand, most existing technologies simplify knob recognition to a single "angle regression" or "image classification" task, ignoring the switch category semantics inherent in the character graphic markings, leading to incorrect status outputs for the same angle on different types of knobs; on the other hand, there is a lack of a unified framework for extracting and jointly processing the graphic marking carrying area, with arrow recognition and character recognition being isolated from each other, making it difficult to adapt to knob switch reading tasks from different manufacturers and under different backgrounds. Furthermore, existing methods lack sufficient standardization for character deformation, mixed uppercase and lowercase letters, and connectors, resulting in low category matching accuracy and poor stability.

[0005] In the process of developing this application, the inventors discovered at least the following problems in the prior art: a complete technical solution is lacking to abstract the rotary switch into a graphic marker-bearing area and simultaneously parse the arrow marker direction information and character marker semantic information; the diversity of character markers is not systematically processed, leading to difficulties in switch category recognition; a category-related state mapping mechanism is lacking, making it incompatible with the differentiated state definitions of multi-functional rotary knobs, resulting in unreliable reading results. Existing image processing-based direction angle detection methods typically lack adaptive extraction of the rotary knob surface area, and the arrow tip positioning accuracy is insufficient, leading to large angle calculation deviations and making it difficult to meet the high-precision state reading requirements in industrial scenarios. Summary of the Invention

[0006] This application provides a method and apparatus for reading the state of a rotary switch based on graphic mark recognition, aiming to solve the technical problems in the prior art where rotary switch reading relies on manual operation, has poor compatibility with various types of switches, and is prone to misjudgment of state based solely on directional information.

[0007] The technical solution adopted by this application to solve its technical problem is: On the one hand, a method for reading the state of a rotary switch based on graphic mark recognition is provided, including the following steps: acquiring an image containing a rotary switch, and extracting the surface area of ​​the knob in the image as a graphic mark carrying area; recognizing an arrow graphic mark within the graphic mark carrying area, and calculating the direction angle of the arrow graphic mark based on the positional relationship between the arrow tip and the center of the knob; reading the character graphic mark using optical character recognition within the graphic mark carrying area, and standardizing the recognition result to obtain a standardized character sequence; matching a preset switch category pattern according to the standardized character sequence, and matching the state mapping rule of the category according to the direction angle, and outputting the state recognition result of the rotary switch.

[0008] On the other hand, a rotary switch state reading device based on graphic mark recognition is provided, including a rotary surface area extraction module, an arrow recognition module, a character recognition module, and a state mapping module, for performing the steps of the rotary switch state reading method based on graphic mark recognition described above.

[0009] In another aspect, an electronic device and a computer-readable storage medium are provided for implementing the steps of the above-described method for reading the state of a rotary switch based on graphic marker recognition.

[0010] One of the above technical solutions has the following advantages or beneficial effects: This application overcomes the ambiguity of single-angle classification by constructing a unified graphic marker carrying area and combining arrow direction recognition with character semantic reading. It introduces a switch category pattern matching mechanism, enabling the direction angle to be dynamically mapped to the corresponding state semantics under different switch categories, significantly improving the compatibility of the solution with different types of rotary switches. Character standardization processing (confidence filtering, position selection, cleaning, and case unification) enhances the stability of character recognition in complex image environments. In particular, this application solves the problem of robust arrow pointing detection in complex backgrounds by calculating the direction angle based on the spatial geometric relationship between the knob center and the arrow tip, representing an important application of orientation detection in image analysis technology.

[0011] This application integrates arrow recognition and character recognition to form a deep collaborative framework of "unified region modeling → multimodal arrow recognition (color detection and complementary edge shapes) → character-driven category mapping → angle-differentiated interpretation". Specifically, the graphic marker carrying area provides a focusing space for both arrow detection and OCR, reducing the false detection rate; the character category pattern library endows the direction angle with semantic context, enabling the same angle to output different states under different categories, correcting the inherent ambiguity of single-direction recognition; and the introduction of an alternative arrow recognition method based on edge detection and shape matching expands the application scope beyond red arrows. These multiple technical features are interdependent and mutually supportive, producing unexpected technical effects: without increasing hardware costs, it simultaneously achieves high accuracy, strong robustness, and plug-and-play compatibility with various switch types. Its overall recognition accuracy is significantly improved compared to using direction recognition or text classification alone, and its resistance to light interference is significantly enhanced. Especially in the direction angle calculation method based on the geometric relationship between the knob center and the arrow tip, the tip is accurately located by using image moments and the farthest point of the contour, which has a sub-pixel level accuracy advantage compared with conventional template matching or centroid method. Attached Figure Description

[0012] Figure 1 This is a flowchart illustrating a method for reading the state of a rotary switch based on graphic marker recognition, according to an exemplary embodiment. Figure 2 This is a schematic diagram of a rotary switch status reading device based on graphic mark recognition, according to an exemplary embodiment. Figure 3 This is a schematic diagram illustrating arrow graphic mark extraction and tip positioning according to an exemplary embodiment; Figure 4 This is a schematic diagram illustrating the calculation of the direction angle of an arrow graphic marker according to an exemplary embodiment; Figure 5This is a schematic diagram illustrating character graphic mark detection and standardization processing according to an exemplary embodiment. Detailed Implementation

[0013] To more clearly illustrate the technical features of this application, the following detailed description is provided through specific embodiments and in conjunction with the accompanying drawings.

[0014] like Figure 1 As shown in the figure, a method for reading the state of a rotary switch based on graphic mark recognition in this embodiment includes the following steps: An image containing a knob switch is acquired, and the surface area of ​​the knob in the image is extracted as the graphic marker carrying area. The extraction of the knob surface area from the image as the graphic marker carrying area includes: converting the input image from the RGB color space to the HSV color space; generating a binary mask based on a preset color threshold range for the knob area; filling holes and broken connection areas through morphological closing operations; extracting the largest connected component as the main outline of the knob; calculating the center of the knob based on image moments; and defining the area covered by the largest connected component as the graphic marker carrying area.

[0015] An arrow graphic mark is identified within the graphic mark carrying area, and the direction angle of the arrow graphic mark is calculated based on the positional relationship between the arrow tip and the knob center. The identification of the arrow graphic mark includes: constraining the image using a graphic mark carrying area mask; extracting candidate arrow regions based on color detection; performing morphological opening operations to remove noise; extracting the largest connected component as the main contour of the arrow; calculating the point in the contour point set farthest from the knob center as the arrow tip; and calculating the direction angle using the arctangent function based on the knob center coordinates and the arrow tip coordinates. ,in The coordinates of the knob's center are... The coordinates are for the arrowhead tip. The color detection includes: converting the graphic marker area to HSV space, and using a red dual-threshold range. Generate candidate arrow masks and extract the red arrow graphic markers, where, This represents the candidate region mask for the arrow. and These represent two threshold range masks for red in the HSV space. The color detection also includes an alternative method based on edge detection and shape matching: converting the graphic marker area into a grayscale image, extracting edges using Canny edge detection, determining the arrow's main direction using Hough transform line detection or the minimum bounding rectangle of the contour, and verifying the arrow's shape using template matching, outputting the direction angle.

[0016] Within the area carrying the graphic marker, optical character recognition (OCR) is used to read the graphic marker, and the recognition result is standardized to obtain a standardized character sequence. Specifically, the process of reading the graphic marker within the area carrying the graphic marker and standardizing the recognition result includes: obtaining the text region and confidence level based on OCR recognition; filtering out recognition results with a confidence level below a preset threshold; selecting the target graphic marker based on the vertical position of the text box; and performing character cleaning and English letter standardization on the target graphic marker. Character cleaning includes removing spaces, newlines, connectors, and irrelevant special symbols; English letter standardization includes converting English letters to a uniform uppercase format.

[0017] The system matches a preset switch category pattern to the standardized character sequence and matches the state mapping rule of that category to the direction angle, outputting the state recognition result of the rotary switch. The matching of the preset switch category pattern to the standardized character sequence includes: constructing a switch category pattern library, which contains multiple keyword sets corresponding to ordinary merging / disconnecting switch patterns, control mode switch patterns, and interlocking function switch patterns; matching the ordinary merging / disconnecting switch pattern when the standardized character sequence contains the keywords "merge," "disconnect," or "KK"; matching the control mode switch pattern when it contains the keywords "local," "remote," "synchronous," or "ZK"; matching the interlocking function switch pattern when it contains the keywords "lock" or "SK"; and defaulting to the ordinary merging / disconnecting switch pattern if no match is found. The state mapping rules define the interval mapping relationship from direction angle to state semantics according to the switch type. For ordinary closing and opening switch mode, the direction angle interval corresponds to the "closing", "pre-closing", "pre-opening" and "opening" states. For control mode switch mode, the direction angle interval corresponds to the "local synchronization", "remote", and "local non-synchronization" states. For interlocking function switch mode, the direction angle interval corresponds to the "unlocking" and "interlocking" states.

[0018] In another embodiment of this application, optionally, a time-based smoothing mechanism is introduced to address situations where arrow detection fails or the confidence level of the direction angle is low: by comparing angle changes across multiple consecutive frames, abrupt angle changes are filtered out to ensure stable state output. This supplementary method further enhances reliability in real-world industrial scenarios.

[0019] like Figure 2 As shown, this embodiment of a rotary switch status reading device based on graphic mark recognition includes: The knob surface area extraction module is used to acquire an image containing a knob switch and extract the knob surface area in the image as a graphic marker carrying area; An arrow recognition module is used to recognize arrow graphic marks within the graphic mark bearing area and calculate the direction angle of the arrow graphic mark based on the positional relationship between the arrow tip and the center of the knob; The character recognition module is used to read the character graphic mark using optical character recognition within the area carrying the graphic mark, and to standardize the recognition result to obtain a standardized character sequence; The state mapping module is used to match a preset switch category pattern according to the standardized character sequence, and match the state mapping rule of the category according to the direction angle, and output the state recognition result of the knob switch.

[0020] The knob surface region extraction module is specifically used to: convert the input image to the HSV color space, generate a binary mask based on the color threshold range of the knob region, obtain an enhanced mask through morphological closing operations, extract the largest connected component as the main outline of the knob, calculate the center coordinates of the knob using image moments, and define the region corresponding to the largest connected component as the graphic marker carrying area.

[0021] The character recognition module includes: an OCR engine unit for detecting text regions and outputting character content and confidence level; a confidence level filtering unit for retaining text regions with confidence levels higher than a preset threshold; a position selection unit for selecting the text corresponding to the bottommost text box based on the vertical center coordinates of the text box; and a normalization unit for performing space and line break cleaning and English letter case unification processing to output a standardized character sequence.

[0022] To address the problems of existing rotary switch status reading methods relying on manual judgment, the difficulty of simultaneously handling arrow direction recognition and character semantic recognition in general image recognition methods, and the difficulty of uniformly processing the status mapping relationships of different types of rotary switches, this application proposes a rotary switch status reading method based on graphic marker recognition. This method extracts a region on the rotary switch surface as a graphic marker carrying area, identifies arrow graphic markers and character graphic markers within this area, matches the standardized results of the character graphic markers with a preset switch category pattern library, and then combines this with the direction angle of the arrow graphic markers to complete the status mapping, thereby achieving automatic reading of the rotary switch status.

[0023] This technical solution introduces a joint processing mechanism of "graphic marker carrying area extraction + arrow graphic marker direction recognition + character graphic marker reading + category pattern matching + state mapping," which improves the system's compatibility with different types of rotary switches and its stability in practical applications while ensuring the accuracy of state reading. This method is applicable to various rotary switch reading scenarios where the state is expressed through both arrows and characters.

[0024] like Figure 1As shown, the specific process of reading the state of a rotary switch based on graphic mark recognition in this application is as follows.

[0025] 1. Obtain an image containing a rotary switch, and extract the surface area of ​​the rotary switch in the image as the area to carry the graphic marker.

[0026] The core objective of this step is to segment the surface area where the rotary switch is located from the acquired image and define this area as the "graphic mark carrying area". All subsequent recognition of arrow graphic marks and character graphic marks will be carried out within this area.

[0027] (1) Initialize image input and preprocessing parameters: First, the system initializes the image input and preprocessing parameters based on the size and resolution of the image to be recognized and the subsequent display requirements, in order to ensure the stability of the subsequent image reading, scaling, segmentation and output processes.

[0028] In this embodiment, the input image can be represented as: , in, Indicates the image height. Indicates the image width. This indicates the number of image channels.

[0029] To ensure image processing efficiency, the system presets a maximum display width. With maximum display height And calculate the scaling ratio based on the input image size. : , when When, the input image is scaled; when At the same time, the original image size remains unchanged.

[0030] (2) Read and validate the input image: In this step, the system first reads the image to be recognized and determines whether the image has been successfully loaded. If the image is empty, the path is incorrect, or the data is corrupted, the subsequent process is terminated and an error message is output; if the image is successfully read, the system proceeds to the knob area extraction step. This step ensures that subsequent graphic marker carrying area extraction is based on valid input.

[0031] (3) Initialize the knob surface area segmentation parameters: In this step, the system initializes the knob surface area extraction module to segment the main knob area from the input image and calculate the knob's center position. Since the knob surface area usually exhibits obvious dark or low-brightness features, the system preferentially uses a combination of color space conversion and threshold segmentation for knob localization.

[0032] Specifically, the system converts the input image from the RGB or BGR color space to the HSV color space and initializes the knob region segmentation threshold: , in, This represents a color space conversion function.

[0033] Furthermore, set the threshold range for the knob area: , in, This represents the binary mask for the knob area. and These represent the lower and upper limits of the color threshold for the knob area, respectively.

[0034] This step initializes the color space conversion parameters and the color threshold of the knob surface area, providing an initial mask for subsequent knob body extraction.

[0035] (4) Initialize morphological processing parameters and enhance region integrity: To improve the integrity of the knob surface area, the system simultaneously initializes the morphological closing operation structure element. It is used to fill gaps in the area, connect fractured areas, and reduce noise interference.

[0036] The knob area mask after the closing operation can be represented as: , in, This represents the expansion operation. This represents the erosion operation.

[0037] This step allows for more stable extraction of the knob body area against complex backgrounds.

[0038] (5) Extract the main outline of the knob and calculate the center of the knob: After completing region segmentation and morphological processing, the system performs contour extraction on the knob region mask and selects the connected region with the largest area as the main contour of the knob.

[0039] Let the set of contours be: , The outline of the knob body It can be represented as: , After obtaining the main outline of the knob, the system calculates the center coordinates of the knob based on the image moments. : , in, , , These are the image moments corresponding to the contour regions.

[0040] (6) Generate the graphic marker carrying area: In this step, the system generates a knob area mask based on the knob's main outline and defines this area as the graphic marker carrying area. All subsequent detection and reading of arrow and character graphic markers will be performed within this area.

[0041] The area that a graphic marker carries can be represented as: , in, This indicates the area of ​​the graphic mark that corresponds to the surface area of ​​the knob.

[0042] This step provides a unified recognition range for subsequent recognition of arrow graphic markers and character graphic markers.

[0043] 2. Identify the arrow graphic mark within the area to which the graphic mark is located, and calculate the direction angle of the arrow graphic mark based on the positional relationship between the arrow tip and the center of the knob.

[0044] The core objective of this step is to identify the pointing arrow graphic markers from the graphic marker carrying area, extract their directional features, and calculate the directional angle values ​​used for state mapping.

[0045] (1) Initialize the detection range of the arrow graphic marker: First, the system uses the graphic marker carrying area obtained in step S1. The arrow detection range is constrained, searching for arrow graphic markers only within the knob surface area, thereby reducing interference from background color and irrelevant targets.

[0046] Let the constrained recognition region image be: , in, This indicates an image that is confined within the area carried by the graphic marker.

[0047] This step limits arrow detection to the knob surface area by calling the graphic marker carrying area mask, reducing the probability of false detection in the background.

[0048] (2) Initialize arrow color detection parameters: Since the arrow graphic markings on the surface of the knob are usually marked in red, the system prioritizes the detection method based on red pixels.

[0049] Specifically, the system converts the graphic marker carrying area to the HSV color space and initializes the dual threshold range for red area detection: , in, This represents the candidate region mask for the arrow. and These represent the two threshold range masks for red in the HSV space.

[0050] Since red spans two intervals in the HSV hue space, a dual-threshold strategy can improve the extraction completeness of red arrow graphic markers.

[0051] (3) Initialize the morphological processing parameters of the arrow region: To remove red noise regions while preserving the main arrow outline, the system initializes the morphological opening structuring element. The morphologically processed arrow region mask can be represented as: , Opening operations can remove isolated noise points and small interference areas while preserving the main shape of the arrow graphic marker.

[0052] (4) Initialize the arrow body extraction and tip positioning mechanism: In this step, the system performs contour extraction on the arrow region mask and selects the largest connected component as the main body of the arrow graphic marker, such as... Figure 3 As shown. Let the set of arrow outlines be: , Then the main outline of the arrow It can be represented as: , Furthermore, the system extracts the main outline point set of the arrow: , And calculate the contour point set and the center of the knob. The point furthest away is used as the tip of the arrow. : .

[0053] (5) Initialize the arrow direction angle calculation model: Obtain the center coordinates of the knob and arrow tip coordinates Then, the system initializes the direction and angle calculation model. For example... Figure 4As shown, the knob arrow direction angle It can be represented as: , In some implementations, the system can also convert it into an angle representation so that it corresponds to the angle range in the subsequent state mapping rules.

[0054] The direction angle Used for subsequent knob status determination.

[0055] This step calculates the direction angle of the arrow graphic marker using the initialized knob direction angle analysis model, providing directional feature values ​​for subsequent state mapping.

[0056] (6) Output the arrow graphic marker recognition results: After completing the arrow graphic marker recognition, the system outputs the arrow candidate region mask, arrow tip position, and direction angle results.

[0057] The recognition result can be represented as: , in, Indicates the mask for the arrow region. Indicates the coordinates of the arrowhead tip. Indicates the direction and angle of the arrow.

[0058] The above process accurately determined the direction angle of the arrow on the knob using image analysis technology. It is a typical image target direction detection and localization method, which together with character recognition constitutes a complete switch status reading scheme.

[0059] Third, optical character recognition is used to read the graphic character mark within the area to which the graphic mark is carried, and the recognition result is standardized to obtain a standardized character sequence.

[0060] The core objective of this step is to read the graphic character markings on the knob surface and convert them into a standardized character sequence, such as... Figure 5 As shown, this is used for subsequent pattern matching and category determination.

[0061] (1) Initialize text detection and OCR recognition parameters: In this step, the system initializes the optical character recognition module to recognize text information within the area carrying the graphic mark, preferably recognizing the graphic mark on the knob surface, especially the area near the bottom.

[0062] Let the set of text regions in the input image be: , in, Indicates the first The bounding box of a text region This indicates the identified text content. This indicates the confidence level of identification.

[0063] (2) Initialize the text recognition confidence filtering parameters: The system presets a text recognition confidence threshold. Only retain those that meet the requirements. The text recognition results are used to improve the stability and accuracy of text recognition.

[0064] The filtered set of text regions can be represented as: , This step improves the accuracy of character graphic tag reading and reduces the impact of erroneous character recognition results on subsequent category matching.

[0065] (3) Initialize the target character graphic marker selection mechanism: In this step, the system selects the target character graphic marker based on the spatial position of the text box. Preferably, the system filters the target text based on the vertical coordinates of the candidate text boxes, selecting the text corresponding to the text box with the largest vertical position as the target recognition result.

[0066] Let the first The vertical center coordinates of the text boxes are The target character graphic mark can then be represented as: , By establishing a correspondence between the knob area and the target character, the character graphic mark closest to the state description position on or below the knob surface is extracted first.

[0067] (4) Initialize text cleaning and normalization rules: To improve pattern matching capabilities under different character formats, the system initializes text normalization rules to clean up spaces, newlines, connectors, and other characters in the recognized text, resulting in standardized text output. , in, Represents a normalized character sequence. This represents the text normalization function.

[0068] In some implementations, the normalization process includes: removing spaces, removing newlines, removing connectors, and removing irrelevant special characters.

[0069] (5) Initialize the English alphabet standardization rules: Since character graphic tags may contain mixed uppercase and lowercase English letters, such as “KK”, “kk”, etc., the system also initializes character unification rules to convert English letters into a unified format to enhance the consistency of category pattern matching.

[0070] Let the unified character sequence be: , in, This represents a character unification function.

[0071] This step standardizes the uppercase and lowercase format of English letters, improves the consistency of character pattern matching, and provides standard input for subsequent switch category recognition.

[0072] (6) Output the normalized character sequence: After completing OCR recognition, confidence filtering, target text selection, and normalization processing, the system outputs a standardized character sequence to provide input for subsequent category pattern matching.

[0073] The output can be represented as: , in, The bounding box of the target character graphic marker. Represents a normalized character sequence. This indicates the corresponding recognition confidence level.

[0074] Fourth, match the preset switch category pattern according to the standardized character sequence, and match the state mapping rule of the category according to the direction angle, and output the state recognition result of the rotary switch.

[0075] The core objective of this step is to match the read character graphic markers with the preset pattern library to determine the switch category to which the current knob belongs; then, based on the angle-state mapping rule of that category, convert the direction angle of the arrow graphic markers into a specific state, and finally output the recognition result.

[0076] (1) Initialize the switch category pattern library: In this step, the system constructs a preset switch category pattern library, which includes at least the following three types of rules: 1) Standard closing / opening switch mode; 2) Control mode: Switch mode; 3) Interlocking function switch mode.

[0077] in: When the standardized character sequence contains keywords such as "merge", "divide", or "KK", the system calls the normal merge / divide switch mode; When the standardized character sequence contains keywords such as "local", "distant", "synchronous", and "ZK", the system calls the control mode switch mode; When the standardized character sequence contains keywords such as "lock" or "SK", the system invokes the interlocking function switch mode; If no of the above keywords are matched, the default mode for normal combination / disconnection switches will be invoked.

[0078] The category pattern can be represented as: , in, Represents a normalized character sequence. This represents the pattern matching function. This indicates the switch type mode corresponding to the current knob.

[0079] (2) Initialize the state mapping rules corresponding to the categories: In this step, the system establishes mapping rules from direction angle to state semantics based on different switch categories, which are used to represent the arrow direction angle. Transform into the actual state.

[0080] Let the state mapping function corresponding to the category be: , in, Indicates the type of switch. Indicates the direction and angle of the arrow. This indicates the final state recognition result.

[0081] In some implementation methods: For ordinary closing and opening switches, the angle range can be mapped to "closing", "pre-closing", "pre-opening", and "opening". For the control mode switch, the angle range can be mapped as "local synchronization", "remote", and "local non-synchronization"; For the interlocking function switch, the angle range can be mapped to "unlock" and "interlock".

[0082] This step establishes the correspondence between angle intervals and state semantics by initializing state mapping rules under different categories, thus providing a rule basis for the final state output.

[0083] (3) Determine the current switch category based on the character pattern matching result: The system will output the standardized character sequence from step three. The system matches keywords with a preset pattern library to determine the switch category to which the current knob belongs.

[0084] This step allows the system to no longer rely solely on the knob's direction for a unified interpretation. Instead, it first determines the semantic category of the current knob and then calls the corresponding state mapping rules, thereby improving the accuracy and interpretability of the state reading results.

[0085] (4) Match the state rules corresponding to the category based on the direction and angle: After determining the current switch type, the system will use the direction angle obtained in step two. Substitute the corresponding state mapping rule into the category to output the state recognition result of the rotary switch.

[0086] The final state recognition result can be represented as: , In some implementations, the system can output an "unknown" state when the direction angle is in the boundary region, character recognition is abnormal, or category matching is unreliable; in the case of continuous video frames, the result of the previous frame can also be retained; this not only improves the stability of the state output, but also supports unknown states or backtracking output in abnormal scenarios.

[0087] (5) Output knob switch status recognition result: After completing category pattern matching and state mapping, the system outputs the final state recognition result.

[0088] The output can be represented as: , in, Represents a normalized character sequence. This indicates the matched switch category pattern. Indicates the direction and angle of the arrow. This indicates the final state recognition result.

[0089] The corresponding angle-state mapping table is called based on the category: For example, in a normal closing / opening switch, the angle range [-45°, 45°] is mapped to "closing", [45°, 135°] to "pre-closing", [135°, 225°] to "pre-opening", and [225°, 315°] to "opening"; in a control mode switch, [0°, 90°] is mapped to "local synchronization", [90°, 180°] to "remote", and [180°, 270°] to "local non-synchronous"; in an interlocking mode, [0°, 180°] is "unlocked", and [180°, 360°] is "interlocked". The final output is the status text.

[0090] An electronic device provided in this application includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of any of the above-described rotary switch state reading methods based on graphic mark recognition.

[0091] Specifically, the aforementioned memory and processor can be general-purpose memory and processor, without any specific limitations. When the processor runs the computer program stored in the memory, it can execute the aforementioned method for reading the state of a rotary switch based on graphic mark recognition.

[0092] Corresponding to the above application startup method, this application embodiment also provides a computer-readable storage medium storing a computer program, which, when run by a processor, executes the steps of any of the above-described rotary switch state reading methods based on graphic mark recognition.

[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and not to limit them. Although this application has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation methods of this application. Any modifications or equivalent substitutions that do not depart from the spirit and scope of this application should be covered within the protection scope of the claims of this application.

Claims

1. A method for reading the state of a rotary switch based on pattern recognition, characterized in that, Includes the following steps: Acquire an image containing a rotary switch, and extract the surface area of ​​the rotary switch in the image as the area to carry the graphic marker; The arrow graphic mark is identified within the graphic mark bearing area, and the direction angle of the arrow graphic mark is calculated based on the positional relationship between the arrow tip and the center of the knob; Within the area carrying the graphic mark, optical character recognition is used to read the graphic mark, and the recognition result is standardized to obtain a standardized character sequence; The state recognition result of the rotary switch is output by matching the preset switch category pattern with the standardized character sequence and matching the state mapping rule of the category with the direction angle.

2. The graphical marker identification based knob switch state reading method according to claim 1, characterized in that, The step of extracting the knob surface area from the image as the graphic marker carrying area includes: The input image is converted from the RGB color space to the HSV color space. A binary mask is generated based on the preset color threshold range of the knob area. Holes and broken connection areas are filled by morphological closing operations. The largest connected component is extracted as the main outline of the knob. The center of the knob is calculated based on the image moments. The area covered by the largest connected component is defined as the graphic mark carrying area.

3. The graphical marker identification based knob switch state reading method according to claim 1, wherein, The identification arrow graphic marker includes: The image is constrained by a graphical mark bearing area mask, an arrow candidate region is extracted based on color detection, a morphological open operation is performed to remove noise, a maximum connected domain is extracted as an arrow main body contour, a point farthest from the knob center in the contour point set is calculated as an arrow tip, and an inverse tangent function is used to calculate a direction angle based on the knob center coordinates and the arrow tip coordinates: wherein is the knob center coordinates, is the arrow tip coordinates.

4. The method for reading the state of a rotary switch based on graphic marker recognition according to claim 3, characterized in that, The color detection includes: converting the graphic marker-carrying area to the HSV space, and using a red dual-threshold range. Generate candidate arrow masks and extract the red arrow graphic markers, where, This represents the candidate region mask for the arrow. and These represent the two threshold range masks for red in the HSV space.

5. The method for reading the state of a rotary switch based on graphic marker recognition according to claim 3, characterized in that, The color detection includes: The graphic marker area is converted into a grayscale image. Canny edge detection is used to extract the edges. The direction of the arrow body is determined by Hough transform line detection or minimum bounding rectangle of the contour. The arrow shape is verified by template matching, and the direction angle is output.

6. The method for reading the state of a rotary switch based on graphic marker recognition according to claim 1, characterized in that, The step of using optical character recognition to read the character graphic mark within the area carrying the graphic mark, and then standardizing the recognition result, includes: Based on OCR recognition, text regions and confidence levels are obtained. Recognition results with confidence levels below a preset threshold are filtered out. Target character graphic markers are selected according to the vertical position of the text box, and character cleaning and English letter unification processing are performed on the target character graphic markers. The character cleaning includes removing spaces, newlines, connectors, and irrelevant special symbols. The English letter unification processing includes converting English letters to a unified uppercase format.

7. The method for reading the state of a rotary switch based on graphic mark recognition according to any one of claims 1 to 6, characterized in that, The step of matching a preset switch category pattern according to the standardized character sequence includes: A switch category pattern library is constructed, which contains multiple keyword sets, each corresponding to a normal closing / opening switch mode, a control mode switch mode, and an interlocking function switch mode. When the standardized character sequence contains the keywords "close," "open," or "KK," the normal closing / opening switch mode is matched; when it contains the keywords "local," "remote," "synchronous," or "ZK," the control mode switch mode is matched; when it contains the keywords "lock" or "SK," the interlocking function switch mode is matched; if no match is found, the normal closing / opening switch mode is invoked by default.

8. A rotary switch status reading device based on graphic mark recognition, characterized in that, include: The knob surface area extraction module is used to acquire an image containing a knob switch and extract the knob surface area in the image as a graphic marker carrying area; An arrow recognition module is used to recognize arrow graphic marks within the graphic mark bearing area and calculate the direction angle of the arrow graphic mark based on the positional relationship between the arrow tip and the center of the knob; The character recognition module is used to read the character graphic mark using optical character recognition within the area carrying the graphic mark, and to standardize the recognition result to obtain a standardized character sequence; The state mapping module is used to match a preset switch category pattern according to the standardized character sequence, and match the state mapping rule of the category according to the direction angle, and output the state recognition result of the knob switch.

9. An electronic 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 program, it implements the steps of the rotary switch state reading method based on graphic mark recognition as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the rotary switch state reading method based on graphic mark recognition as described in any one of claims 1 to 7.