A method and system for automatic dual-path recognition of switch machine gap images
By combining a dual-path automatic recognition method with DIC matching and image segmentation algorithms, the reliability and adaptability issues of switch machine gap image recognition were solved, achieving stable and accurate detection under different conditions.
Patent Information
- Application Number
- CN202611379496.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-10
AI Technical Summary
The reliability and adaptability of existing technologies for switch machine gap image recognition are insufficient. In particular, under the influence of factors such as changes in lighting, oil stains, rust, and foreign object obstruction, the recognition results are inaccurate and cannot automatically switch the detection path when mismatch occurs.
A dual-path automatic identification method is adopted, which combines DIC matching and image segmentation algorithms. The DIC comprehensive matching index is used to determine whether to switch the calculation path, ensuring continuous calculation using sub-pixel displacement in a stable state, and re-obtaining the gap boundary through segmentation in a mismatched state.
It improves the reliability and adaptability of switch machine gap image recognition, can automatically select the best path under different detection conditions, reduces the limitation of a single algorithm on continuous detection, and ensures the accuracy of recognition results.
Smart Images

Figure CN123071963A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of rail transit equipment condition monitoring, machine vision, and digital image processing, and in particular to a dual-path automatic recognition method and system for switch machine gap images. Background Technology
[0002] The switch machine is the actuator of the turnout switching system, and the gap status of its switch is important information reflecting the working status and locking reliability of the switch machine. Traditional detection methods include manual inspection, mechanical measurement, and electrical sensing. Manual inspection relies on personnel experience, and the frequency and consistency of inspection are limited; mechanical measurement usually requires on-site operation and is difficult to monitor continuously; although electrical sensing can achieve a certain degree of automation, it may be affected by electromagnetic interference, dust and oil, and component aging, and may not be able to directly show the geometry of the gap.
[0003] Image-based non-contact detection can acquire visualized gap information without interfering with equipment operation and is suitable for integration with condition monitoring systems. Existing image detection methods typically employ threshold segmentation, edge detection, template matching, or machine learning recognition. Switch machine sites are subject to factors such as varying lighting, oil stains, rust, foreign object obstruction, background clutter, camera angle changes, and motion blur. These factors can alter template features or obscure gap boundaries, leading to inaccurate matching, segmentation, or edge localization.
[0004] However, existing technologies rely solely on template matching to maintain stability based on reference features. When image brightness, camera angle, or the surface condition of the notch changes significantly, continuing to calculate the notch based on the template matching result may produce unreliable output; alarms are only triggered when matching fails, and the notch amount cannot be obtained again when the notch boundary can still be extracted through segmentation; moreover, it cannot switch between different detection calculation paths according to the template matching situation, resulting in insufficient reliability and adaptability of switch machine notch image recognition.
[0005] To address this problem, the present invention provides a dual-path automatic identification method and system for switch machine gap images, thereby solving the aforementioned issues. Summary of the Invention
[0006] To address the problems existing in the prior art, this invention innovatively proposes a dual-path automatic recognition method and system for switch machine gap images. This effectively solves the problem of low reliability and adaptability of switch machine gap image recognition caused by the prior art, and effectively improves the reliability and adaptability of switch machine gap image recognition.
[0007] The first aspect of this invention provides an automatic dual-path recognition method for switch machine gap images, comprising: Obtain the current switch machine gap image and preset gap template; Based on the current switch machine gap image and the preset gap template, DIC matching is performed to obtain the matching result value and the calculation accuracy of each matching result value; among them, the matching result value includes the sub-pixel displacement. Based on the distribution of matching result values and the calculation accuracy, weight fitting is performed to obtain the DIC comprehensive matching index; Based on the DIC comprehensive matching index, it is determined whether the preset switching conditions are met. If the preset switching conditions are met, the current gap amount is determined according to the first calculation path. If the preset switching conditions are not met, the current gap amount is determined according to the second calculation path. The first calculation path is determined based on the preset gap template, and the second calculation path is determined based on the processing result of the current switch machine gap image.
[0008] Optionally, the preset gap template records the gap position in the reference state, the nesting relationship between the search area and the feature area; wherein, the search area is used to cover the maximum displacement change range of the gap during operation; the feature area is located within the search area and contains grayscale or texture features for DIC matching of the image.
[0009] Optionally, DIC matching is performed based on the current switch machine gap image and a preset gap template to obtain matching result values. The specific calculation precision of each matching result value is as follows: DIC matching is performed between the feature region in the preset gap template and the search region in the current switch machine gap image to obtain the optimal integer pixel position. Based on the optimal integer pixel position, the sub-pixel displacement is obtained in the neighborhood of the optimal integer pixel position through bilinear interpolation or cubic spline interpolation. The calculation accuracy is the DIC matching correlation coefficient or the DIC matching error.
[0010] Furthermore, based on the distribution of the matching result values and the calculation accuracy, weight fitting is performed to obtain the DIC comprehensive matching index as follows: All matching results are processed using the Shapiro-Wilk algorithm to calculate the Shapiro-Wilk statistic W, which is then used as the distribution weight. ; After normalizing the DIC matching correlation coefficient of each matching result value, the average is used to obtain the calculation precision weight. ; Distribute weights Weights related to calculation accuracy The fit is the DIC comprehensive matching index.
[0011] Furthermore, if the calculation precision is the DIC matching error, the calculation precision weight is... The calculation method is as follows:
[0012]
[0013] in, Let DIC be the matching error of the i-th matching result value. For a calibration scale with an error greater than zero, To normalize the calculation accuracy, n is the number of matching result values. For calculating precision weights.
[0014] Optionally, the current gap amount is determined according to the first calculation path as follows: The current gap amount is determined based on the preset gap position and subpixel displacement in the preset gap template.
[0015] Optionally, the current gap amount is determined according to the second calculation path as follows: The image segmentation algorithm is determined based on the inter-class variance and the total variance of the gap region. The gap region in the current switch machine gap image is then classified into foreground and background using the image segmentation algorithm. The image segmentation algorithm used is Otsu's method and K-means binary classification. Morphological processing of the binary classification results was performed using square structural elements corresponding to the switch machine model to remove isolated noise, fill holes, and connect broken edges. Edge points are extracted using the Canny operator, and candidate lines are obtained using the Hough transform. Candidate lines with an angle less than a preset angle threshold to the vertical direction of the image are first selected as candidate lines for the gap line based on the direction constraint. Then, the gap line is determined based on the number of edge points and the coverage length of the candidate lines. Calculate the current gap amount based on the gap line coordinates.
[0016] Furthermore, the method for determining the Canny double threshold in the Canny operator is as follows:
[0017] in, The lower threshold in the Canny dual thresholding method. This is the higher threshold in the Canny dual thresholding method, where m is the median grayscale value of the ROI. This is the threshold adjustment coefficient. Enter the upper limit of grayscale.
[0018] Optionally, the gap line is specifically defined based on the number of edge points and the coverage length of the candidate line:
[0019] Where S is the score of the candidate line, and L and N are the length of the candidate line and the number of neighborhood edge points, respectively. and These are the maximum values of the candidate line length and the number of neighborhood edge points, respectively. The weighting coefficient is the candidate line length.
[0020] A second aspect of the present invention provides a dual-path automatic recognition system for switch machine gap images, comprising: The acquisition module acquires the current switch machine gap image and the preset gap template; The DIC matching module performs DIC matching based on the current switch machine gap image and a preset gap template to obtain the matching result value and the calculation accuracy of each matching result value; among them, the matching result value includes the sub-pixel displacement amount; The weight fitting module performs weight fitting based on the distribution of matching result values and calculation accuracy to obtain the DIC comprehensive matching index. The path judgment and switching module determines whether the preset switching conditions are met based on the DIC comprehensive matching index. If the preset switching conditions are met, the current gap amount is determined according to the first calculation path. If the preset switching conditions are not met, the current gap amount is determined according to the second calculation path. The first calculation path is determined based on the preset gap template, and the second calculation path is determined based on the processing result of the current switch machine gap image.
[0021] The technical solution adopted in this invention has the following technical effects: 1. This invention performs DIC matching based on the current switch machine gap image and a preset gap template to obtain matching result values and the calculation accuracy of each matching result value; based on the distribution of the matching result values and the calculation accuracy, weight fitting is performed to obtain a comprehensive DIC matching index; according to the comprehensive DIC matching index, it is determined whether the preset switching conditions are met. If the preset switching conditions are met, the current gap amount is determined according to the first calculation path; if the preset switching conditions are not met, the current gap amount is determined according to the second calculation path. This effectively solves the problem of low reliability and adaptability of switch machine gap image recognition caused by existing technologies, and effectively improves the reliability and adaptability of switch machine gap image recognition.
[0022] 2. The technical solution of the present invention can automatically select the gap detection path by using calculable matching states in two states: stable gap image features and significant changes due to on-site interference. In the stable state, the gap boundary can be obtained again by segmentation. This reduces the limitation of continuous detection on the applicability of a single algorithm.
[0023] 3. In the technical solution of this invention, the feature region in the preset gap template is matched with the search region of the current switch machine gap image using DIC to obtain the optimal integer pixel position. Based on the optimal integer pixel position, sub-pixel displacement is obtained in the neighborhood of the optimal integer pixel position through bilinear interpolation or cubic spline interpolation. All matching result values are processed using the Shapiro-Wilk algorithm to calculate the Shapiro-Wilk statistic W, and the Shapiro-Wilk statistic W is used as the distribution weight. After normalizing the DIC matching correlation coefficient of each matching result value, the average is calculated to obtain the calculation precision weight. ; Distribute weights Weights related to calculation accuracy The fitting of the DIC comprehensive matching index not only enables the switching of different detection calculation paths under different matching conditions, but also integrates the distribution of DIC matching and calculation accuracy, further improving the reliability of switch machine gap image recognition.
[0024] 4. In the technical solution of this invention, the image segmentation algorithm is determined based on the inter-class variance and the total variance of the gap region. The gap region in the current switch machine gap image is classified into foreground and background according to the image segmentation algorithm. The morphological processing of the binary classification result is performed using a square structuring element corresponding to the switch machine model to remove isolated noise points, fill holes and connect broken edges. The edge points are extracted using the Canny operator, and then candidate lines are obtained using the Hough transform. Candidate lines with an angle less than a preset angle threshold with the vertical direction of the image are first selected as candidate lines for the gap line according to the direction constraint. Then, the gap line is determined based on the number of edge points and the coverage length of the candidate lines, which ensures reliable detection of the switch machine gap image under mismatch conditions.
[0025] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a flowchart illustrating the method of Embodiment 1 in the present invention; Figure 2 This is another flowchart illustrating the method of Embodiment 1 in the present invention; Figure 3 This is a schematic diagram of the search region and feature region in the method of Embodiment 1 of the present invention; Figure 4 This is a schematic diagram of digital image correlation matching and subpixel displacement in the method of Embodiment 1 of the present invention; Figure 5 This is a schematic diagram of the Otsu method segmentation route in Embodiment 1 of the present invention; Figure 6 This is a schematic diagram of the K-means binary classification route in the method of Embodiment 1 of the present invention; Figure 7 This is a schematic diagram of the square structural element and morphological processing in the method of Embodiment 1 of the present invention; Figure 8 This is a schematic diagram illustrating the extraction of the Canny edge and Hough gap line in the method of Embodiment 1 of the present invention; Figure 9 This is a schematic diagram of the system structure in Embodiment 2 of the present invention. Detailed Implementation
[0028] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings. The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure of the invention, components and arrangements of specific examples are described below. Furthermore, reference numerals and / or letters may be repeated in different examples. This repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed. It should be noted that the components illustrated in the drawings are not necessarily drawn to scale. Descriptions of well-known components, processing techniques, and processes are omitted in this invention to avoid unnecessarily limiting the invention.
[0029] Example 1 like Figures 1-2 As shown, this invention provides an automatic dual-path recognition method for switch machine gap images, comprising: Step S1: Obtain the current switch machine gap image and preset gap template; Step S2: Perform DIC matching based on the current switch machine gap image and the preset gap template to obtain the matching result value and the calculation accuracy of each matching result value; wherein, the matching result value includes the sub-pixel displacement amount; Step S3: Based on the distribution of matching result values and calculation accuracy, perform weight fitting to obtain the DIC comprehensive matching index; Step S4: Based on the DIC comprehensive matching index, determine whether the preset switching conditions are met. If the preset switching conditions are met, determine the current gap amount according to the first calculation path. If the preset switching conditions are not met, determine the current gap amount according to the second calculation path. The first calculation path is determined based on the preset gap template, and the second calculation path is determined based on the processing result of the current switch machine gap image.
[0030] In step S1, the current switch machine gap image, the preset gap template, and the algorithm parameters are input, i.e. Figure 2 101: Obtain the input switch machine gap image and preset gap template.
[0031] The preset notch template records the notch position in the reference state, and the nesting relationship between the search area and the feature area; the nesting relationship between the search area and the feature area is as follows: Figure 3 As shown. The region of interest in the preset notch template includes: The search area is used to cover the maximum displacement range that the gap may experience during operation; Feature regions, located within the search area, contain grayscale or texture features used for digital image correlation matching.
[0032] The current material uses the ZD9 type switch machine as an example to show the configuration of the search area and feature area.
[0033] In step S2, the feature regions of the preset notch template are matched and tracked using digital image correlation to obtain a set of matching result values and the calculation precision of each matching result. The matching results include sub-pixel displacement, i.e. Figure 2 102: DIC matching and subpixel displacement.
[0034] Specifically, step S2 is as follows: DIC matching is performed between the feature region in the preset gap template and the search region in the current switch machine gap image to obtain the optimal integer pixel position. Based on the optimal integer pixel position, the sub-pixel displacement is obtained in the neighborhood of the optimal integer pixel position through bilinear interpolation or cubic spline interpolation. The calculation accuracy is the DIC matching correlation coefficient or the DIC matching error.
[0035] Specifically, grayscale correlation matching is performed between the template feature region and the search region of the current notch image, and the relationship between the data and displacement is as follows: Figure 4 As shown. The correlation matching criterion can use zero-mean normalized cross-correlation to first obtain the optimal integer pixel position, and then obtain the sub-pixel displacement through bilinear interpolation or cubic spline interpolation in its neighborhood. Digital image correlation detection simultaneously outputs a set of result values (sub-pixel displacement) and the corresponding calculation precision for each result.
[0036] In step S3, two weights are formed based on the distribution of result values and the calculation accuracy, and then fitted to obtain the DIC comprehensive matching index. It is then determined whether this index meets the preset matching conditions. Figure 2 103: Does the comprehensive matching index meet the preset matching conditions (preset switching conditions)? Specifically, step S3 is as follows: All matching results are processed using the Shapiro-Wilk algorithm to calculate the Shapiro-Wilk statistic W, which is then used as the distribution weight. ; After normalizing the DIC matching correlation coefficient of each matching result value, the average is used to obtain the calculation precision weight. ; Distribute weights Weights related to calculation accuracy The fit is the DIC comprehensive matching index.
[0037] Specifically, good DIC matching results follow a normal distribution. Distribution weights are formed based on the numerical distribution of the results, and accuracy weights are formed based on the calculation accuracy of each result. The two weights are then fitted together to form a comprehensive DIC matching index that measures the degree of matching.
[0038] The Shapiro-Wilk statistic W is used as the distribution weight. The accuracy weights are obtained by averaging the results after normalizing their accuracy. Then fit the two weights into a DIC comprehensive matching index. If the output is error rather than normalized accuracy, it can be converted using equation (1).
[0039] (1) (2) (3) In equation (1), The error or uncertainty of the i-th matching result value. For a calibration scale with an error greater than zero, To normalize the accuracy; in equation (2), n is the number of matching result values, To calculate the precision weight; in equation (3), α is the distribution weight, α∈[0,1] is the weight coefficient of the matching result value distribution, and M∈[0,1] is the DIC comprehensive matching index.
[0040] In step S4, the DIC comprehensive matching index M is compared with the matching condition corresponding to the algorithm switching threshold. If the comprehensive matching index meets the preset matching condition (DIC comprehensive matching index M is not less than the algorithm switching threshold), it indicates that the template features can still be reliably tracked. At this time, the first calculation path ( The current gap amount is obtained, and the complete segmentation and gap line extraction are no longer repeated on the current image; if the comprehensive matching index does not meet the preset matching conditions (DIC comprehensive matching index M is less than the algorithm switching threshold), it means that the template features cannot be reliably tracked. At this time, according to the second calculation path ( ), thus obtaining the current gap amount.
[0041] Path determination can be performed using equation (4). Wherein, ∈[0,1] represents the algorithm switching threshold; The validation set is labeled using reliable / unreliable matching, and the joint calibration is performed with the goal of maximizing the F1 score or the Youden index.
[0042] (4).
[0043] Furthermore, when the preset matching conditions are met, execution is performed. Figure 2 104: Determine the current gap amount based on the preset gap position and subpixel displacement of the template, and output the result. That is, the first calculation path is: combine the subpixel displacement with the preset gap position recorded in the template to obtain the current gap amount, without repeating the complete segmentation and gap line extraction on the current image.
[0044] Furthermore, if the preset matching conditions are not met, execute... Figure 2 In steps 105, 106, and 107: The system automatically enters the image segmentation path, selects one of the parallel Otsu method route and K-means route, and then performs morphological processing, Canny edge detection, and Hough gap line filtering in sequence. Based on the gap line, the current gap amount is determined and the result is output.
[0045] Specifically, the current gap amount is determined according to the second calculation path as follows: (1) Determine the image segmentation algorithm based on the inter-class variance and the total variance of the gap region, and perform foreground / background binary classification on the gap region in the current switch machine gap image based on the image segmentation algorithm; wherein, the image segmentation algorithm is Otsu's method and K-means binary classification; Specifically, when the DIC comprehensive matching index does not meet the preset matching conditions, it is assumed that the gap features may have changed due to oil stains, rust, brightness changes, camera offset or blur, and the relevant displacement results are no longer output as gap quantities. The control process automatically enters the image segmentation path.
[0046] Otsu's method and K-means are two independent partitioning methods. It's not a matter of executing Otsu's method first and then K-means. For example... Figure 5 and Figure 6 As shown. When choosing the Otsu method, an adaptive threshold is determined based on the principle of maximizing inter-class variance to divide the image into foreground and background; when choosing the K-means method, image pixels are clustered into foreground and background classes.
[0047] The separability of the gray-level histogram is calculated using equation (5). Where, Inter-class variance for image classification η is the total variance of all pixel grayscale values within the notch region, and the separability η∈[0,1]; Select a threshold for the segmentation path; the separability η ≥ When choosing the Otsu method, η < When choosing K-means, Calibrated according to model. K-means uses K=2 as the number of clusters, and initializes the centers with the 25th and 75th percentiles of gray level; the maximum change in the center is no greater than ε (center change tolerance) or the iteration reaches the maximum number of iterations; the categories are mapped according to the center gray level, and the configuration is reversed according to the model when the image polarity is opposite.
[0048] (5) (2) Use the square structural element corresponding to the switch machine model to perform morphological processing on the binary classification results, remove isolated noise points, fill holes and connect broken edges; Specifically, such as Figure 7 As shown, the binary classification results are processed using a square structuring element to perform erosion, dilation, opening, and / or closing operations. Erosion is used to remove small noise points and shrink boundaries; dilation is used to fill gaps between edges; opening is used to remove isolated noise in small areas; and closing is used to fill holes and small cracks. The structuring element size and operation order are adjusted according to different switch machine models and saved as model configuration parameters.
[0049] Square structural elements use odd-numbered pixels for their side length, and are selected from 3×3, 5×5, and 7×7 according to the model and image resolution; when isolated bright noise points and small holes coexist, they are opened first and then closed; when holes or broken edges are the main features, they are closed first and then opened.
[0050] (3) Use the Canny operator to extract edge points, and then use the Hough transform to obtain candidate lines; first, filter the candidate lines whose angle with the vertical direction of the image is less than the preset angle threshold according to the direction constraint as candidate lines for the gap line, and then use the number of edge points and coverage length of the candidate lines as the gap line. Specifically, such as Figure 8As shown, the Canny operator is applied to the morphologically processed image to obtain the edge point set through Gaussian smoothing, gradient calculation, non-maximum suppression, and double thresholding. Then, Hough line detection is performed on the edge points to obtain candidate lines in the parameter space. The Canny double threshold can be determined according to equation (6). In the equation, m is the median gray level of the ROI, and κ is the threshold adjustment coefficient. To input the upper limit of grayscale, The lower threshold in the Canny dual thresholding method. It should be the higher threshold in the Canny dual thresholding method; it should ensure that < .
[0051] (6) Filter gap lines from candidate straight lines according to two types of constraints: In this example, the gap line is nearly vertical (the angle between it and the vertical direction of the image is less than a preset angle threshold, which can be 5). Candidate lines that meet the directional conditions are selected as candidate lines. Among the candidate lines that meet the directional conditions, the line with the most edge points and / or the longest coverage area is selected as the gap line.
[0052] The candidate lines are scored according to equation (7), and the candidate line with the highest score is selected as the gap line. In the equation, S is the score of the candidate line, and L and N are the length of the candidate line and the number of neighboring edge points, respectively. and These are the maximum values of the candidate line length and the number of neighboring edge points, respectively; λ represents the weighting coefficient for the candidate line length, where λ ∈ [0, 1].
[0053] (7) (4) Calculate the current gap amount based on the gap line coordinates.
[0054] Furthermore, the current gap amount (the difference between the current coordinates of the gap line and the reference coordinates) is calculated based on the gap line coordinates and output. The output includes the current gap amount and / or gap status. For images that are excessively blurry and whose gap edges are indistinguishable to the naked eye, existing materials suggest that they cannot be effectively identified, and a reliable gap amount should not be forcibly output. Image quality criteria are composed of Laplacian variance, the ratio of excessively dark / excessively bright pixels, and the number of effective edge points; if any indicator exceeds the limit, or if neither of the two detection paths can produce a qualified result, IMAGE_INVALID is output, and no gap value that can be used for control is output.
[0055] The main objective of this invention is to determine how to automatically select the gap detection path using a calculable matching state under two different states: stable gap image features and significant changes due to on-site interference. This allows for continuous calculation of the gap detection path using sub-pixel displacement in stable states and re-obtaining the gap boundary through segmentation in mismatched states, thereby reducing the limitations of a single algorithm on continuous detection.
[0056] This invention can be used for the automatic detection and continuous monitoring of gap images of urban rail transit and railway turnout switch machines, and can also serve as a source of gap data for switch machine status assessment, fault early warning, and intelligent operation and maintenance systems.
[0057] Additionally, it should be noted that image segmentation in this embodiment of the invention can employ either the Otsu method or the K-means binary classification method, or one can be selected based on the histogram separability; morphological post-processing can utilize one or a combination of erosion, dilation, opening, and closing operations depending on noise, holes, or edge breakage. Hough line filtering can simultaneously use directional constraints and length / edge point count constraints.
[0058] To more clearly illustrate the technical solution of the present invention, different examples are provided below: Example 1: Gap detection when feature matching satisfies the conditions. A template image of a switch machine gap is pre-selected, and the search area and feature area are configured in it. The preset gap position corresponding to the template is recorded.
[0059] Obtain the current switch machine gap image, and use digital image correlation to match template feature regions within the search area.
[0060] The optimal position of integer pixels is calculated, and the sub-pixel displacement is obtained through interpolation, while the feature matching index is also obtained.
[0061] When the feature matching index meets the preset matching conditions, the sub-pixel displacement is combined with the preset gap position to form the current gap amount and output it.
[0062] This implementation method is suitable for situations where the features of the notch image are relatively stable during continuous operation.
[0063] Example 2: Gap detection when feature matching does not meet the conditions Perform digital image correlation matching according to Example 1.
[0064] When oil stains, rust, brightness changes, camera shift, or image blur cause the feature matching index to fail to meet the preset matching conditions, the calculation of the gap amount using the relevant displacement result is stopped, and the segmentation path is automatically entered.
[0065] Based on the segmentation route selection criterion, one of the two independent Otsu method routes and K-means route is selected to perform foreground / background binary classification on the gap region.
[0066] Morphological processing of the binary classification results was performed using square structuring elements corresponding to the switch machine model, removing isolated noise points, filling holes, and connecting broken edges.
[0067] Edge points are extracted using the Canny operator, and then candidate lines are obtained using the Hough transform.
[0068] First, candidate lines with an angle less than a preset angle threshold to the vertical direction of the image are selected as candidate lines for the gap line based on the directional constraints. Then, the gap line is selected based on the number of edge points and the coverage length of the candidate lines.
[0069] Calculate and output the current gap amount based on the gap line coordinates.
[0070] This invention performs DIC matching based on the current switch machine gap image and a preset gap template to obtain matching result values and the calculation accuracy of each matching result value. Based on the distribution of the matching result values and the calculation accuracy, a weighted fitting is performed to obtain a DIC comprehensive matching index. According to the DIC comprehensive matching index, it is determined whether a preset switching condition is met. If the preset switching condition is met, the current gap amount is determined according to the first calculation path. If the preset switching condition is not met, the current gap amount is determined according to the second calculation path. This effectively solves the problem of low reliability and adaptability of switch machine gap image recognition caused by existing technologies, and effectively improves the reliability and adaptability of switch machine gap image recognition.
[0071] The technical solution of this invention can automatically select the gap detection path by using a calculable matching state in two states: stable gap image features and significant changes due to on-site interference. In the stable state, the gap boundary can be obtained again by segmentation. This reduces the limitation of continuous detection on the applicability of a single algorithm.
[0072] In this invention, the feature region of the preset gap template is matched with the search region of the current switch machine gap image using DIC (Discrete Interpolation) to obtain the optimal integer pixel position. Based on the optimal integer pixel position, sub-pixel displacement is obtained in the neighborhood of the optimal integer pixel position through bilinear interpolation or cubic spline interpolation. All matching results are then processed using the Shapiro-Wilk algorithm to calculate the Shapiro-Wilk statistic W, which is used as the distribution weight. After normalizing the DIC matching correlation coefficient of each matching result value, the average is calculated to obtain the calculation precision weight. ; Distribute weights Weights related to calculation accuracy The fitting of the DIC comprehensive matching index not only enables the switching of different detection calculation paths under different matching conditions, but also integrates the distribution of DIC matching and calculation accuracy, further improving the reliability of switch machine gap image recognition.
[0073] In this invention, the image segmentation algorithm is determined based on the inter-class variance and the total variance of the gap region. The image segmentation algorithm is used to perform foreground / background binary classification on the gap region in the current switch machine gap image. A square structuring element corresponding to the switch machine model is used to perform morphological processing on the binary classification results, removing isolated noise points, filling holes, and connecting broken edges. The Canny operator is used to extract edge points, and then Hough transform is used to obtain candidate straight lines. Candidate straight lines with an angle less than a preset angle threshold to the vertical direction of the image are first selected as candidate gap lines based on directional constraints. Then, the gap line is determined based on the number of edge points and the coverage length of the candidate lines, ensuring reliable detection of the switch machine gap image under mismatch conditions.
[0074] Example 2 like Figure 9 As shown, the present invention also provides a dual-path automatic recognition system for switch machine gap images, comprising: The acquisition module acquires the current switch machine gap image and the preset gap template; The DIC matching module performs DIC matching based on the current switch machine gap image and a preset gap template to obtain the matching result value and the calculation accuracy of each matching result value; among them, the matching result value includes the sub-pixel displacement amount; The weight fitting module performs weight fitting based on the distribution of matching result values and calculation accuracy to obtain the DIC comprehensive matching index. The path judgment and switching module determines whether the preset switching conditions are met based on the DIC comprehensive matching index. If the preset switching conditions are met, the current gap amount is determined according to the first calculation path. If the preset switching conditions are not met, the current gap amount is determined according to the second calculation path. The first calculation path is determined based on the preset gap template, and the second calculation path is determined based on the processing result of the current switch machine gap image.
[0075] It should be noted that the acquisition module, DIC matching module (digital image correlation detection module), weight fitting module, path judgment and switching module (including path judgment submodule, image segmentation detection submodule, segmentation result post-processing submodule and gap quantity output submodule) in this embodiment correspond to the method steps in Embodiment 1, and will not be described again in this embodiment.
[0076] This invention performs DIC matching based on the current switch machine gap image and a preset gap template to obtain matching result values and the calculation accuracy of each matching result value. Based on the distribution of the matching result values and the calculation accuracy, a weighted fitting is performed to obtain a DIC comprehensive matching index. According to the DIC comprehensive matching index, it is determined whether a preset switching condition is met. If the preset switching condition is met, the current gap amount is determined according to the first calculation path. If the preset switching condition is not met, the current gap amount is determined according to the second calculation path. This effectively solves the problem of low reliability and adaptability of switch machine gap image recognition caused by existing technologies, and effectively improves the reliability and adaptability of switch machine gap image recognition.
[0077] The technical solution of this invention can automatically select the gap detection path by using a calculable matching state in two states: stable gap image features and significant changes due to on-site interference. In the stable state, the gap boundary can be obtained again by segmentation. This reduces the limitation of continuous detection on the applicability of a single algorithm.
[0078] In this invention, the feature region of the preset gap template is matched with the search region of the current switch machine gap image using DIC (Discrete Interpolation) to obtain the optimal integer pixel position. Based on the optimal integer pixel position, sub-pixel displacement is obtained in the neighborhood of the optimal integer pixel position through bilinear interpolation or cubic spline interpolation. All matching results are then processed using the Shapiro-Wilk algorithm to calculate the Shapiro-Wilk statistic W, which is used as the distribution weight. After normalizing the DIC matching correlation coefficient of each matching result value, the average is calculated to obtain the calculation precision weight. ; Distribute weights Weights related to calculation accuracy The fitting of the DIC comprehensive matching index not only enables the switching of different detection calculation paths under different matching conditions, but also integrates the distribution of DIC matching and calculation accuracy, further improving the reliability of switch machine gap image recognition.
[0079] In this invention, the image segmentation algorithm is determined based on the inter-class variance and the total variance of the gap region. The image segmentation algorithm is used to perform foreground / background binary classification on the gap region in the current switch machine gap image. A square structuring element corresponding to the switch machine model is used to perform morphological processing on the binary classification results, removing isolated noise points, filling holes, and connecting broken edges. The Canny operator is used to extract edge points, and then Hough transform is used to obtain candidate straight lines. Candidate straight lines with an angle less than a preset angle threshold to the vertical direction of the image are first selected as candidate gap lines based on directional constraints. Then, the gap line is determined based on the number of edge points and the coverage length of the candidate lines, ensuring reliable detection of the switch machine gap image under mismatch conditions.
[0080] While the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A dual-path automatic recognition method for switch machine gap images, characterized in that, include: Obtain the current switch machine gap image and preset gap template; Based on the current switch machine gap image and the preset gap template, DIC matching is performed to obtain the matching result value and the calculation accuracy of each matching result value; among them, the matching result value includes the sub-pixel displacement. Based on the distribution of matching result values and the calculation accuracy, weight fitting is performed to obtain the DIC comprehensive matching index; Based on the DIC comprehensive matching index, it is determined whether the preset switching conditions are met. If the preset switching conditions are met, the current gap amount is determined according to the first calculation path. If the preset switching conditions are not met, the current gap amount is determined according to the second calculation path. The first calculation path is determined based on the preset gap template, and the second calculation path is determined based on the processing result of the current switch machine gap image.
2. The dual-path automatic recognition method for switch machine gap images according to claim 1, characterized in that, The preset gap template records the gap position in the reference state, the nesting relationship between the search area and the feature area; wherein, the search area is used to cover the maximum displacement change range of the gap during operation; the feature area is located within the search area and contains grayscale or texture features for DIC matching of the image.
3. The dual-path automatic recognition method for switch machine gap images according to claim 1, characterized in that, Based on the current switch machine gap image and a preset gap template, DIC matching is performed to obtain the matching result value. The specific calculation accuracy of each matching result value is as follows: DIC matching is performed between the feature region in the preset gap template and the search region in the current switch machine gap image to obtain the optimal integer pixel position. Based on the optimal integer pixel position, the sub-pixel displacement is obtained in the neighborhood of the optimal integer pixel position through bilinear interpolation or cubic spline interpolation. The calculation accuracy is the DIC matching correlation coefficient or the DIC matching error.
4. The method for automatic dual-path recognition of switch machine gap images according to claim 3, characterized in that, Based on the distribution of matching result values and the calculation accuracy, a weighted fitting is performed to obtain the DIC comprehensive matching index, which is as follows: All matching results are processed using the Shapiro-Wilk algorithm to calculate the Shapiro-Wilk statistic W, which is then used as the distribution weight. ; After normalizing the DIC matching correlation coefficient of each matching result value, the average is used to obtain the calculation precision weight. ; Distribute weights Weights related to calculation accuracy The fit is the DIC comprehensive matching index.
5. The method for automatic dual-path recognition of switch machine gap images according to claim 4, characterized in that, If the calculation precision is the DIC matching error, then the calculation precision weight is... The calculation method is as follows: in, Let DIC be the matching error of the i-th matching result value. For a calibration scale with an error greater than zero, To normalize the calculation accuracy, n is the number of matching result values. For calculating precision weights.
6. The method for automatic dual-path recognition of switch machine gap images according to claim 1, characterized in that, The current gap is determined based on the first calculation path as follows: The current gap amount is determined based on the preset gap position and subpixel displacement in the preset gap template.
7. The method for automatic dual-path recognition of switch machine gap images according to claim 1, characterized in that, The current gap is determined based on the second calculation path as follows: The image segmentation algorithm is determined based on the inter-class variance and the total variance of the gap region. The gap region in the current switch machine gap image is then classified into foreground and background using the image segmentation algorithm. The image segmentation algorithm used is Otsu's method and K-means binary classification. Morphological processing of the binary classification results was performed using square structural elements corresponding to the switch machine model to remove isolated noise, fill holes, and connect broken edges. Edge points are extracted using the Canny operator, and candidate lines are obtained using the Hough transform. Candidate lines with an angle less than a preset angle threshold to the vertical direction of the image are first selected as candidate lines for the gap line based on the direction constraint. Then, the gap line is determined based on the number of edge points and the coverage length of the candidate lines. Calculate the current gap amount based on the gap line coordinates.
8. The method for automatic dual-path recognition of switch machine gap images according to claim 7, characterized in that, The specific method for determining the Canny double threshold in the Canny operator is as follows: in, The lower threshold in the Canny dual thresholding method. This is the higher threshold in the Canny dual thresholding method, where m is the median grayscale value of the ROI. This is the threshold adjustment coefficient. Enter the upper limit of grayscale.
9. The dual-path automatic recognition method for switch machine gap images according to claim 7, characterized in that, The gap line is specifically defined based on the number of edge points and the coverage length of the candidate line: Where S is the score of the candidate line, and L and N are the length of the candidate line and the number of neighborhood edge points, respectively. and These are the maximum values of the candidate line length and the number of neighboring edge points, respectively; The weighting coefficient is the candidate line length.
10. A dual-path automatic recognition system for switch machine gap images, characterized in that, include: The acquisition module acquires the current switch machine gap image and the preset gap template; The DIC matching module performs DIC matching based on the current switch machine gap image and a preset gap template to obtain the matching result value and the calculation accuracy of each matching result value; among them, the matching result value includes the sub-pixel displacement amount; The weight fitting module performs weight fitting based on the distribution of matching result values and calculation accuracy to obtain the DIC comprehensive matching index. The path judgment and switching module determines whether the preset switching conditions are met based on the DIC comprehensive matching index. If the preset switching conditions are met, the current gap amount is determined according to the first calculation path. If the preset switching conditions are not met, the current gap amount is determined according to the second calculation path. The first calculation path is determined based on the preset gap template, and the second calculation path is determined based on the processing result of the current switch machine gap image.
