A fast contour recognition method in complex background
By generating standard contour boxes through sample training and combining them with dynamic parameter adjustments, the problem of low efficiency and accuracy of contour recognition in complex backgrounds is solved, enabling fast and accurate recognition in complex environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUILIN MAOS CLOTHES HANGERS
- Filing Date
- 2025-11-22
- Publication Date
- 2026-05-08
AI Technical Summary
Existing contour recognition methods struggle to dynamically adapt to real-time changes in complex backgrounds, resulting in low efficiency and accuracy, and failing to effectively combine sample training with real-world images for fast and accurate matching.
Contour attribute data is obtained through training on sample images to generate standard contour boxes, which are then matched with the contour attributes of actual images. At the same time, when the matching fails, the recognition parameters are dynamically adjusted, including edge detection threshold, filter kernel size, and contour tracking sensitivity.
Balancing speed and accuracy in contour recognition against complex backgrounds, this technology improves recognition efficiency and precision, enhances stability and adaptability in complex environments, reduces redundancy in indiscriminate computation, and ensures the reliability and accuracy of recognition.
Smart Images

Figure CN121280741B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of contour recognition technology, and in particular to a fast contour recognition method under complex backgrounds. Background Technology
[0002] With the integration and development of industrial automation and machine vision technology, target contour recognition in complex backgrounds is playing an increasingly crucial role in product inspection, quality control and other fields. It not only needs to cope with challenges such as changes in lighting and background texture interference, but also needs to meet the dual requirements of real-time performance and accuracy in order to adapt to the pace of efficient production.
[0003] However, existing contour recognition methods mostly rely on fixed parameters and static templates, making it difficult to dynamically adapt to real-time changes in complex backgrounds. They often suffer from low efficiency due to incomplete edge extraction and misidentification caused by background interference. Furthermore, they lack dynamic adjustment mechanisms for differences between samples and actual scenes, making it difficult to function stably in complex environments.
[0004] Chinese Patent Publication No. CN111626326A discloses a method for extracting and identifying diatoms in a large area under complex backgrounds. The method includes: extracting background targets from an image to be detected and classifying the extracted background targets to obtain complete diatom samples; identifying the external contour boundaries and internal texture structures of the diatom samples to obtain the judgment results of boundary features and texture features in the diatom samples; and calculating the similarity of the diatom samples based on the judgment results of the boundary features, the judgment results of the texture features, and the preset weight values of each feature.
[0005] Therefore, it is evident that the existing technology has the following problems:
[0006] Contour recognition under complex background interference does not consider combining sample training with fast and accurate matching of actual images, resulting in low efficiency and accuracy. Summary of the Invention
[0007] To address this issue, the present invention provides a fast contour recognition method under complex backgrounds, which overcomes the problems of low efficiency and accuracy in existing contour recognition technologies that do not consider the interference of complex backgrounds and do not combine sample training with fast and accurate matching of actual images.
[0008] To achieve the above objectives, the present invention provides a fast contour recognition method under complex backgrounds, comprising:
[0009] Contour recognition training is performed using several sample images under pre-set complex background conditions. Contour attribute data of the sample images are collected, including edge intensity distribution, texture contrast parameters, and reflective interference level indicators.
[0010] Based on the contour attribute data, several first contour attribute vectors are generated to divide the first contour attribute space.
[0011] Several first clear contour segments are determined based on the high-confidence regions in the first round of contour attribute space;
[0012] Several clear feature segments are determined based on the performance parameters of several first clear contour segments to determine the corresponding standard contour box, wherein the performance parameters include the length and curvature of the contour segment;
[0013] Collect contour attribute data of the target detection area in the actual production line, and generate several second contour attribute vectors to divide the second contour attribute space.
[0014] Several second clear contour segments are determined based on the high-confidence region of the second contour attribute space;
[0015] Several contour matching segments are determined based on the similarity between each of the second clear contour segments and each of the clear feature segments;
[0016] Whether to trigger fast matching is determined based on the proportion of the contour matching segment;
[0017] If fast matching is not triggered, corresponding contour recognition optimization parameters are obtained based on several second clear contour segments to determine the adjustment amount of the contour recognition optimization parameters, wherein the contour recognition optimization parameters include edge detection threshold, filter kernel size and contour tracking sensitivity;
[0018] The adjusted contour recognition optimization parameters are used to process the image of the target detection area in the actual production line to re-acquire several second clear contour segments;
[0019] Whether to trigger fast matching is determined based on several re-acquired second clear contour segments.
[0020] Furthermore, the process of partitioning the second contour attribute space based on several second contour attribute vectors includes:
[0021] Cluster analysis is performed based on several first contour attribute vectors;
[0022] Obtain the set of vectors in the first contour attribute vector cluster of the cluster center whose confidence is greater than a preset first confidence threshold, and determine it as the first contour attribute space.
[0023] Furthermore, the process of determining several first clear contour segments based on the high-confidence region of the first contour attribute space includes:
[0024] Inverse mapping is performed on each vector in the first contour attribute space to restore the contour segment in the image space.
[0025] Calculate the average gradient intensity and continuity index of each contour segment;
[0026] Based on the first preset conditions, several contour segments are selected and determined as the first clear contour segment.
[0027] The first preset condition is that the average gradient intensity and continuity index of each contour segment are both greater than the corresponding preset threshold.
[0028] Furthermore, the process of determining several sharp feature segments based on the performance parameters of several first sharp contour segments, in order to determine the corresponding standard contour boxes, includes:
[0029] Based on the comparison between the length and curvature of each first clear contour segment and the corresponding preset threshold, several candidate feature segments are determined.
[0030] Candidate feature segments that appear in all samples within a preset proportion are selected as clear feature segments.
[0031] The standard outline is determined based on the minimum bounding rectangle of all clear feature segments.
[0032] Furthermore, the process of partitioning the second contour attribute space based on several second contour attribute vectors includes:
[0033] Cluster analysis is performed based on several second contour attribute vectors;
[0034] Obtain the set of vectors with a confidence level greater than a preset second confidence threshold from the second contour attribute vector cluster of the cluster center, and determine it as the second contour attribute space.
[0035] Furthermore, the process of determining several second sharp contour segments based on the high-confidence region of the second contour attribute space includes:
[0036] Inverse mapping is performed on each vector in the second contour attribute space to restore the contour segment in the image space;
[0037] Calculate the average gradient intensity and continuity index of each contour segment;
[0038] Based on the second preset conditions, several contour segments were selected and determined as the second clear contour segments;
[0039] The second preset condition is that the average gradient intensity and continuity index of each contour segment are both greater than the corresponding preset threshold.
[0040] Furthermore, the process of determining several contour matching segments based on the similarity between each of the second sharp contour segments and each of the sharp feature segments includes:
[0041] Calculate the curvature and relative orientation similarity between each of the second sharp contour segments and each of the sharp feature segments;
[0042] When the curvature and the similarity of the relative directions of each second clear contour segment are both greater than the corresponding preset threshold, it is determined to be a contour matching segment.
[0043] Furthermore, the process of determining whether to trigger fast matching based on the proportion of the contour matching segment includes:
[0044] Calculate the percentage of the total length of the contour matching segments in the perimeter of the standard contour frame;
[0045] When the proportion exceeds a preset proportion threshold, the spatial distribution uniformity of the contour matching segment is analyzed;
[0046] Based on the fact that the spatial distribution uniformity is greater than a preset spatial distribution uniformity threshold, a fast matching is triggered.
[0047] Furthermore, the adjustment amount of the contour recognition optimization parameters is determined based on the difference between the proportion of the contour matching segment and the preset proportion threshold, and the difference between the spatial distribution uniformity and the preset spatial distribution uniformity threshold.
[0048] Furthermore, it also includes determining the corresponding feature centers based on several second clear contour segments, calculating the relative positions of each feature center to match the contour center and the positive direction of the contour, and triggering fast matching.
[0049] Compared with existing technologies, the advantages of this invention lie in its ability to first acquire contour attribute data and generate standard contour boxes using sample images for training, providing a benchmark for actual recognition. Then, it combines the contour attributes of actual images for matching, and dynamically adjusts recognition parameters when matching fails to meet the standards. This approach balances speed and accuracy in contour recognition even in complex backgrounds. This method reduces redundancy in indiscriminate calculations by pre-setting standard contour boxes, improving recognition efficiency, and addresses dynamic background changes in real-world scenarios through a parameter adjustment mechanism, avoiding recognition failures caused by fixed parameters. This makes contour recognition more adaptable and stable in complex backgrounds, improving the efficiency and accuracy of rapid contour recognition.
[0050] Furthermore, this invention divides the first contour attribute space by using cluster analysis based on the first contour attribute vector and high-confidence vector filtering, effectively focusing on representative contour attribute features in the samples. Cluster analysis helps to uncover the inherent distribution patterns of contour attributes and classify vectors with similar attributes, while high-confidence filtering eliminates low-quality, unrepresentative vectors, making the first contour attribute space more targeted and reliable. This process reduces interference factors in subsequent processing, provides high-quality basic data for determining clear contour segments, improves the accuracy of the initial data processing of the entire recognition method, and lays a solid foundation for subsequent steps.
[0051] Furthermore, this invention obtains contour segments by inverse mapping the first contour attribute space vector, and selects the first clear contour segments by combining the average gradient intensity and continuity index, thus accurately extracting high-quality contour parts from the samples. The average gradient intensity reflects the clarity of the contour edges, and the continuity index reflects the integrity of the contour. The combined selection condition effectively eliminates blurry and broken low-quality contour segments, ensuring the reliability of the first clear contour segments. This provides high-quality material for the subsequent determination of clear feature segments, reduces feature misjudgment caused by low-quality contour segments, improves the accuracy of the standard contour boxes obtained based on sample training, and ensures the effectiveness of sample feature extraction.
[0052] Furthermore, this invention filters candidate feature segments based on the length and curvature of the first clear contour segment, selects the candidate segments appearing in the majority of samples as clear feature segments, and then determines the standard contour box. This ensures the universality and representativeness of the standard contour box. The length and curvature filtering conditions exclude unstable contour segments that are too short or too curved, while the requirement for the proportion of samples ensures that the clear feature segments are contour features commonly found in the target object, avoiding the special interference of individual samples. The standard contour box determined in this way can accurately reflect the overall contour range of the target object, providing a unified and reliable benchmark for contour matching in actual recognition, and improving the accuracy and efficiency of matching.
[0053] Furthermore, this invention, by performing cluster analysis on the second contour attribute vectors and selecting a set of high-confidence vectors to divide the second contour attribute space, ensures consistency between the contour attribute analysis of actual images and the sample training phase, while adapting to the characteristics of real-world scenarios. The setting of the second confidence threshold takes into account potential fluctuations in the actual background, avoiding the loss of effective contour attributes due to a strict threshold. The second contour attribute space constructed in this way accurately reflects the distribution characteristics of contour attributes in actual images, providing a reasonable range for the subsequent extraction of the second clear contour segment, and ensuring the targeted and effective data processing during actual recognition.
[0054] Furthermore, this invention obtains contour segments by inverse mapping the second contour attribute space vector and filters the second clear contour segments using average gradient intensity and continuity indices, effectively extracting high-quality contour portions from actual images. While echoing the first clear contour segment filtering condition, the threshold adjustment of the second preset condition adapts to potential image quality fluctuations in real-world scenarios, avoiding missed detection of valid contours due to differences between actual and sample images. This filtering method ensures the clarity and integrity of the second clear contour segments, providing reliable actual contour data for subsequent similarity matching with clear feature segments and improving the accuracy of matching in actual recognition.
[0055] Furthermore, this invention calculates the similarity of curvature and relative direction between the second clear contour segment and the clear feature segment, and sets dual thresholds for matching judgment, enabling accurate identification of the portion of the actual contour that matches the sample features. Curvature reflects the bending characteristics of the contour, and relative direction reflects the orientation of the contour in space. The similarity judgment combining both avoids the limitations of single feature matching and reduces false matching caused by background interference. This method improves the specificity and accuracy of contour matching, ensuring that the contour matching segment can truly reflect the contour features of the target object, providing a reliable basis for triggering subsequent rapid matching judgments.
[0056] Furthermore, this invention combines the length proportion of the contour matching segments and the spatial distribution uniformity to determine whether to trigger fast matching, thereby improving recognition efficiency while ensuring matching reliability. The length proportion ensures the coverage of the matching segments within the overall contour, avoiding misjudgments based on a small number of matches; the spatial distribution uniformity ensures the dispersion of the matching segments on the contour, avoiding overall misjudgments caused by localized matching. This combined judgment condition makes the triggering of fast matching more rigorous, enabling rapid recognition when the conditions are met, reducing unnecessary complex calculations, and avoiding recognition errors due to insufficient matching, thus balancing recognition speed and accuracy.
[0057] Furthermore, this invention determines the adjustment amount of contour recognition optimization parameters based on the difference between the proportion of contour matching segments and the uniformity, making parameter adjustment more targeted and scientific. Insufficient proportion usually reflects insufficient edge detection sensitivity or excessive filtering; adjusting the edge threshold and filter kernel can enhance edge extraction. Insufficient uniformity may lead to local missed detections due to low tracking sensitivity; adjusting the sensitivity can improve this. This method of dynamically adjusting parameters based on specific matching defects avoids blind adjustments, making parameter optimization more efficient, quickly compensating for deficiencies in the recognition process, improving the quality of contour recognition after reprocessing, and increasing the possibility of rapid matching triggering.
[0058] Furthermore, this invention provides a powerful inference capability even when the contour is not fully visible, by utilizing the feature centers of clearly defined contour segments and their relative positional relationships to deduce the position and orientation of the overall contour. It does not rely on 100% complete contour extraction, but rather utilizes key, local geometric constraints to recover global information. This is extremely valuable in practical industrial inspection because it allows for stable and accurate localization and orientation recognition even under non-ideal conditions such as partial target occlusion or uneven lighting leading to missing local contours, greatly enhancing the applicability and robustness of the method in harsh environments. Attached Figure Description
[0059] Figure 1 This is a flowchart of a fast contour recognition method under complex backgrounds according to an embodiment of the present invention;
[0060] Figure 2 A flowchart illustrating the division of the second contour attribute space according to an embodiment of the present invention;
[0061] Figure 3 A flowchart for determining a plurality of first clear outline segments in an embodiment of the present invention;
[0062] Figure 4 A flowchart for determining a standard outline frame in an embodiment of the present invention. Detailed Implementation
[0063] To make the objectives and advantages of the present invention clearer, the present invention will be further described below with reference to embodiments; it should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention.
[0064] Preferred embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0065] It should be noted that in the description of this invention, the terms "upper", "lower", "left", "right", "inner", "outer", etc., which indicate directions or positional relationships, are based on the directions or positional relationships shown in the accompanying drawings. This is only for the convenience of description and is not intended to indicate or imply that the device or element must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation of this invention.
[0066] Furthermore, it should be noted that, in the description of this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0067] Please see Figure 1 The diagram shows a flowchart of a fast contour recognition method under complex backgrounds according to an embodiment of the present invention. The embodiment of the present invention provides a fast contour recognition method under complex backgrounds, including:
[0068] Step S1: Use several sample images to train contour recognition under preset complex background conditions, and collect contour attribute data of the sample images, including edge intensity distribution, texture contrast parameters and reflection interference level index.
[0069] Step S2: Generate several first contour attribute vectors based on the contour attribute data to divide the first contour attribute space;
[0070] Step S3: Determine several first clear contour segments based on the high-confidence regions in the first round of contour attribute space;
[0071] Step S4: Determine several clear feature segments based on the performance parameters of several first clear contour segments to determine the corresponding standard contour box, wherein the performance parameters include the length and curvature of the contour segment;
[0072] Step S5: Collect contour attribute data of the target detection area image in the actual production line, and generate several second contour attribute vectors to divide the second contour attribute space.
[0073] Step S6: Determine several second clear contour segments based on the high-confidence region of the second contour attribute space;
[0074] Step S7: Determine several contour matching segments based on the similarity between each of the second clear contour segments and each of the clear feature segments;
[0075] Step S8: Determine whether to trigger fast matching based on the proportion of the contour matching segment;
[0076] Step S9: If fast matching is not triggered, obtain the corresponding contour recognition optimization parameters based on several second clear contour segments to determine the adjustment amount of the contour recognition optimization parameters, wherein the contour recognition optimization parameters include edge detection threshold, filter kernel size and contour tracking sensitivity.
[0077] Step S10: Use the adjusted contour recognition optimization parameters to process the image of the target detection area in the actual production line to re-acquire several second clear contour segments.
[0078] Step S11: Determine whether to trigger fast matching based on the re-acquired second clear contour segments.
[0079] It is understood that the rapid contour recognition method under complex backgrounds provided in this embodiment is used in industrial production lines with complex background features that require rapid contour recognition. For example, this method can be used for online monitoring of the lithium battery electrode coating process. When the electrode coated with active material passes through the detection station at high speed, the industrial camera continuously captures images, quickly extracts the contour attributes of the current frame, and matches them with pre-stored standard contour box features. If the first match fails due to the strong texture or high reflectivity of the metal foil substrate in the complex background, the image is reprocessed by adjusting the contour recognition optimization parameters to weaken the interference of the complex background. After successful matching, the precise position and contour size of the electrode can be output based on the standard contour box to provide a positioning basis for subsequent cutting or quality assessment.
[0080] In this embodiment, in step S1, 1000 sample images containing target products on the production line are selected. Training is performed under the pre-set conditions of lighting changes and complex background textures based on the actual environmental conditions required by the production line. The edge intensity distribution, texture contrast parameters, and reflective interference level of the target product on each image are collected.
[0081] Please see Figure 2 As shown, it is a flowchart of dividing the second contour attribute space according to an embodiment of the present invention.
[0082] Specifically, in step S2, the process of dividing the second contour attribute space based on several second contour attribute vectors includes:
[0083] Step S21: Perform cluster analysis based on several first contour attribute vectors;
[0084] Step S22: Obtain the set of vectors in the first contour attribute vector cluster of the cluster center whose confidence is greater than the preset first confidence threshold, and determine it as the first contour attribute space.
[0085] In this embodiment, based on the specific numerical values of the contour attributes of the target product on the image and its corresponding spatial relative position, a corresponding first contour attribute vector is generated. The generated first contour attribute vectors are then clustered using the DBSCAN clustering algorithm (why this clustering algorithm is used?), to obtain the confidence score of the vector cluster corresponding to each cluster center. The confidence score is determined based on the cosine similarity between the vector and the center. Preferably, a preset first confidence score threshold of 0.75 is set, and a set of vectors with a confidence score greater than the first confidence score threshold is selected. This set of vectors is then defined as the first contour attribute space.
[0086] Understandably, the cluster center is the core point of each cluster. It represents the typical and clear contour attribute features of the contour attributes within the cluster and can serve as a benchmark reference for contour attributes.
[0087] Please see Figure 3 As shown, it is a flowchart of determining several first clear outline segments in an embodiment of the present invention.
[0088] Specifically, in step S3, the process of determining several first clear contour segments based on the high-confidence region of the first contour attribute space includes:
[0089] Step S31: Perform inverse mapping based on each vector in the first contour attribute space to restore the contour segment in the image space;
[0090] Step S32: Calculate the average gradient intensity and continuity index of each contour segment;
[0091] Step S32: Select several contour segments based on the first preset conditions and determine them as the first clear contour segments;
[0092] The first preset condition is that the average gradient intensity and continuity index of each contour segment are both greater than the corresponding preset threshold.
[0093] In this embodiment, based on each vector in the first contour attribute space, the original image space is inversely restored through coordinate mapping to obtain the corresponding contour segment. For each contour segment, the gradient value of each pixel is obtained and the average value is taken as the average gradient intensity. The proportion of continuous pixels in the contour segment is counted as the continuity index. It can be understood that the pixel gradient value is a basic parameter in image processing, representing the change of image gray value in the spatial direction, and can be calculated using the Sobel operator or any method in the prior art. The calculation formula of the continuity index is: continuity index = number of continuous edge pixels / total number of pixels in the contour segment. Wherein, continuous edge pixels refer to edge pixels that meet the 8-connectivity condition. This index is a dimensionless ratio, with a value range of [0,1]. Preferably, a first preset condition is set, where the preset threshold for the average gradient intensity is 30 gray levels, which can effectively distinguish between real edges and noise, and the preset threshold for the continuity index is 0.8, indicating that at least 80% of the pixels in the contour segment are required to be continuously connected, which can ensure the integrity and usability of the contour segment. Contour segments that simultaneously meet more than two threshold conditions are selected and determined as the first clear contour segments.
[0094] Please see Figure 4 As shown, it is a flowchart for determining the standard outline frame in an embodiment of the present invention.
[0095] Specifically, in step S4, the process of determining several sharp feature segments based on the performance parameters of several first sharp contour segments to determine the corresponding standard contour box includes:
[0096] Step S41: Based on the length and curvature of each first clear contour segment, compare it with the corresponding preset threshold to determine several candidate feature segments;
[0097] Step S42: Select candidate feature segments that appear in all samples within a preset proportion as clear feature segments.
[0098] Step S43: Determine the standard outline based on the minimum bounding rectangle of all clear feature segments.
[0099] In this embodiment, for each first clear contour segment, the number of pixels is counted as the length, and the mean curvature is calculated by fitting a curve using a polynomial. Preferably, a preset threshold for length is set to 80 pixels and a preset threshold for curvature is set to 0.25. Contour segments that simultaneously meet these conditions are selected as candidate feature segments. The occurrence ratio of each candidate feature segment in all sample images is counted, and candidate feature segments with an occurrence ratio exceeding 70% are selected as clear feature segments. All clear feature segments are collected, and their bounding boxes are calculated using the minimum bounding rectangle algorithm. These bounding boxes are the corresponding standard contour boxes.
[0100] Specifically, in step S5, the process of dividing the second contour attribute space based on several second contour attribute vectors includes:
[0101] Step S51: Perform cluster analysis based on several second contour attribute vectors;
[0102] Step S52: Obtain the set of vectors in the second contour attribute vector cluster of the cluster center whose confidence is greater than the preset second confidence threshold, and determine it as the second contour attribute space.
[0103] In this embodiment, several second contour attribute vectors are generated from the target detection area image collected in the actual production line in the same way as the first contour attribute vector. Cluster analysis is performed using the same clustering algorithm as the first contour attribute vector. The confidence of the second contour attribute vector cluster corresponding to each cluster center is calculated. Preferably, a preset second confidence threshold is set to 0.7. It can be understood that the second confidence threshold is slightly lower than the first confidence threshold to adapt to fluctuations in the actual scene. Vector sets with confidence greater than the second confidence threshold are selected. The vector set is determined as the second contour attribute space, and the clustering algorithm is consistent with the first contour attribute space partitioning algorithm.
[0104] Specifically, in step S6, the process of determining several second clear contour segments based on the high-confidence region of the second contour attribute space includes:
[0105] Step S61: Perform inverse mapping based on each vector in the second contour attribute space to restore the contour segment in the image space;
[0106] Step S62: Calculate the average gradient intensity and continuity index of each contour segment;
[0107] Step S63: Select several contour segments based on the second preset conditions to determine the second clear contour segments;
[0108] The second preset condition is that the average gradient intensity and continuity index of each contour segment are both greater than the corresponding preset threshold.
[0109] In this embodiment, each vector in the second contour attribute space is inversely mapped to restore the contour segments in the actual image space. The average gradient intensity and continuity index of each contour segment are obtained using the same calculation method as the first clear contour segment. Preferably, a second preset condition is set, where the preset threshold for the average gradient intensity is 25 and the preset threshold for the continuity index is 0.75. Contour segments that simultaneously meet both threshold conditions are selected and determined as the second clear contour segments. It is understood that the second preset condition is slightly lower than the first preset condition to adapt to fluctuations in the actual scene.
[0110] Specifically, in step S7, the process of determining several contour matching segments based on the similarity between each of the second clear contour segments and each of the clear feature segments includes:
[0111] Step S71: Calculate the curvature and relative direction similarity between each of the second sharp contour segments and each of the sharp feature segments;
[0112] Step S72: When the curvature and the similarity of the relative directions of each second clear contour segment are both greater than the corresponding preset threshold, it is determined to be a contour matching segment.
[0113] In this embodiment, each second clear contour segment is compared with each clear feature segment. The cosine similarity of the curvature curves of the two segments is calculated as the curvature similarity, and the cosine value of the angle between the principal directions is calculated as the relative direction similarity. The values are both in the range of 0-1. Preferably, the preset threshold for curvature similarity is set to 0.85, and the preset threshold for relative direction similarity is set to 0.8. When both similarity values of a second clear contour segment and a clear feature segment are greater than the corresponding threshold, the second clear contour segment is determined to be a contour matching segment.
[0114] Specifically, in step S8, determining whether to trigger fast matching based on the proportion of the contour matching segment includes:
[0115] Step S81: Calculate the proportion of the total length of the contour matching segments to the perimeter of the standard contour frame;
[0116] Step S82: When the proportion exceeds a preset proportion threshold, analyze the spatial distribution uniformity of the contour matching segment;
[0117] Step S83: Based on the fact that the spatial distribution uniformity is greater than the preset spatial distribution uniformity threshold, determine to trigger fast matching.
[0118] In this embodiment, the lengths of all matching segments are summed and divided by the perimeter of the standard contour frame to obtain the percentage of the total matching segment lengths. Preferably, a preset percentage threshold is set to 65%. When the percentage exceeds the threshold, the spatial distribution uniformity is obtained by calculating the standard deviation of the positions of each matching segment within the standard contour frame. The calculation process for the standard deviation of the positions of each matching segment within the standard contour frame is as follows: First, the standard contour frame is normalized to a unit square. The mean coordinates of the center points of each matching segment in the x and y directions are calculated, and then the standard deviation of these center point positions is calculated. This standard deviation is a dimensionless statistic that reflects the dispersion of the matching segments within the contour frame. Spatial distribution uniformity = 1 - (standard deviation in the x direction + standard deviation in the y direction) / 2. Preferably, the spatial distribution uniformity threshold is set to 0.6. When the uniformity is greater than 0.6, it indicates that the matching segments are distributed sufficiently evenly within the contour frame. Therefore, if the uniformity is greater than the spatial distribution uniformity threshold, fast matching is triggered. It should be noted that a larger standard deviation indicates a more dispersed distribution and lower uniformity; a smaller standard deviation indicates a more concentrated distribution and higher uniformity.
[0119] Specifically, step S9 includes: determining that fast matching was not triggered based on the spatial distribution uniformity being less than or equal to a preset spatial distribution uniformity threshold;
[0120] If fast matching is not triggered, corresponding contour recognition optimization parameters are obtained based on several second clear contour segments to determine the adjustment amount of the contour recognition optimization parameters, wherein the contour recognition optimization parameters include edge detection threshold, filter kernel size and contour tracking sensitivity;
[0121] The adjustment amount of the contour recognition optimization parameters is determined based on the difference between the proportion of the contour matching segment and the preset proportion threshold, and the difference between the spatial distribution uniformity and the preset spatial distribution uniformity threshold.
[0122] It is understandable that the edge detection threshold, filter kernel size, and contour tracking sensitivity obtained from several second clear contour segments are the contour recognition optimization parameters updated in the previous recognition cycle.
[0123] In this embodiment, the difference between the proportion of the contour matching segment and a preset proportion threshold, and the difference between the spatial distribution uniformity and a preset uniformity threshold are calculated. The specific formula for calculating the proportion of the contour matching segment is: Proportion = (∑ Matching Segment Length) / Standard Contour Box Perimeter. Both length and perimeter are in pixels, and the proportion is a dimensionless ratio. Preferably, the adjustment amount is determined based on the difference: for every 10% decrease in the proportion difference, the edge detection threshold in the contour recognition optimization parameters is lowered by 3 gray levels, with a maximum reduction of 10 gray levels; the filter kernel size is increased by 1 pixel, with a maximum increase of 5 pixels; for every 0.1 decrease in the uniformity difference, the contour tracking sensitivity is increased by 0.05, with a maximum increase of 0.2.
[0124] Specifically, in step S10, the image of the target detection area in the actual production line is processed using the adjusted contour recognition optimization parameters to re-acquire several second clear contour segments.
[0125] Specifically, in step S11, it is determined whether to trigger fast matching based on several re-acquired second clear contour segments.
[0126] Understandably, steps S7 to S8 are repeated for the re-acquired second clear contour segments to determine whether fast matching is triggered. If so, fast matching is triggered; otherwise, the process jumps to step S12.
[0127] Specifically, it also includes, in step S12, determining the corresponding feature centers based on several second clear contour segments, calculating the relative positions of each feature center to match the contour center and the positive direction of the contour, and triggering fast matching.
[0128] In this embodiment, if the reacquired second clear contour segments still do not trigger fast matching, then for these second clear contour segments, the segments corresponding to key corner points or specific geometric structures within the standard contour frame can be identified, and the geometric centers of these segments can be calculated as feature centers. The relative positional relationships of these feature centers in the image are analyzed, and they are matched with known correspondences within the standard contour frame. By calculating the rotation and translation matrix, the precise center position and rotation angle of the target contour in the current image can be deduced, thus determining the positive direction of the contour and triggering fast matching.
[0129] It is understood that, in this embodiment, triggering fast matching refers to mapping the contour of the target detection area image in the actual production line to the contour of the pre-stored standard sample image based on the second clear contour segment, and scaling it according to the feature correspondence ratio to obtain the precise position of the product corresponding to the target detection area image in the current actual production line. Then, based on the precise position, the contour of the pre-stored standard sample image is replaced in the current image to quickly obtain the product contour in the image. It is understood that the contour of the pre-stored standard sample image is a clear sample contour obtained in a standard environment, which can be obtained based on any existing technology, and will not be elaborated upon here.
[0130] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. A fast contour recognition method under complex backgrounds, characterized in that, include: Contour recognition training is performed using several sample images under pre-set complex background conditions. Contour attribute data of the sample images are collected, including edge intensity distribution, texture contrast parameters, and reflective interference level indicators. Based on the contour attribute data, several first contour attribute vectors are generated to divide the first contour attribute space. Several first clear contour segments are determined based on the high-confidence regions in the first contour attribute space; Several clear feature segments are determined based on the performance parameters of several first clear contour segments to determine the corresponding standard contour box, wherein the performance parameters include the length and curvature of the contour segment; Collect contour attribute data of the target detection area in the actual production line, and generate several second contour attribute vectors to divide the second contour attribute space. Several second clear contour segments are determined based on the high-confidence region of the second contour attribute space; Several contour matching segments are determined based on the similarity between each of the second clear contour segments and each of the clear feature segments; Determining whether to trigger fast matching based on the proportion of the contour matching segment includes: Calculate the percentage of the total length of the contour matching segments in the perimeter of the standard contour frame; When the proportion exceeds a preset proportion threshold, the spatial distribution uniformity of the contour matching segment is analyzed; Based on the fact that the spatial distribution uniformity is greater than a preset spatial distribution uniformity threshold, a fast matching is triggered. If fast matching is not triggered, corresponding contour recognition optimization parameters are obtained based on several second clear contour segments to determine the adjustment amount of the contour recognition optimization parameters, wherein the contour recognition optimization parameters include edge detection threshold, filter kernel size and contour tracking sensitivity; The adjusted contour recognition optimization parameters are used to process the image of the target detection area in the actual production line to re-acquire several second clear contour segments; Whether to trigger fast matching is determined based on several re-acquired second clear contour segments.
2. The fast contour recognition method under complex backgrounds according to claim 1, characterized in that, The process of generating several first contour attribute vectors based on the contour attribute data to divide the first contour attribute space includes: Cluster analysis is performed based on several first contour attribute vectors; Obtain the set of vectors in the first contour attribute vector cluster of the cluster center whose confidence is greater than a preset first confidence threshold, and determine it as the first contour attribute space.
3. The fast contour recognition method under complex backgrounds according to claim 2, characterized in that, The process of determining several first clear contour segments based on the high-confidence region of the first contour attribute space includes: Inverse mapping is performed on each vector in the first contour attribute space to restore the contour segment in the image space. Calculate the average gradient intensity and continuity index of each contour segment; Based on the first preset conditions, several contour segments are selected and determined as the first clear contour segment. The first preset condition is that the average gradient intensity and continuity index of each contour segment are both greater than the corresponding preset threshold.
4. The fast contour recognition method under complex backgrounds according to claim 3, characterized in that, The process of determining several sharp feature segments based on the performance parameters of several first sharp contour segments, and then determining the corresponding standard contour boxes, includes: Based on the comparison between the length and curvature of each first clear contour segment and the corresponding preset threshold, several candidate feature segments are determined. Candidate feature segments that appear in all samples within a preset proportion are selected as clear feature segments. The standard outline is determined based on the minimum bounding rectangle of all clear feature segments.
5. The fast contour recognition method under complex backgrounds according to claim 4, characterized in that, The process of partitioning the second contour attribute space based on several second contour attribute vectors includes: Cluster analysis is performed based on several second contour attribute vectors; Obtain the set of vectors with a confidence level greater than a preset second confidence threshold from the second contour attribute vector cluster of the cluster center, and determine it as the second contour attribute space.
6. The fast contour recognition method under complex backgrounds according to claim 5, characterized in that, The process of determining several second clear contour segments based on the high-confidence region of the second contour attribute space includes: Inverse mapping is performed on each vector in the second contour attribute space to restore the contour segment in the image space; Calculate the average gradient intensity and continuity index of each contour segment; Based on the second preset conditions, several contour segments were selected and determined as the second clear contour segments; The second preset condition is that the average gradient intensity and continuity index of each contour segment are both greater than the corresponding preset threshold.
7. The fast contour recognition method under complex backgrounds according to claim 6, characterized in that, The process of determining several contour matching segments based on the similarity between each of the second sharp contour segments and each of the sharp feature segments includes: Calculate the curvature and relative orientation similarity between each of the second sharp contour segments and each of the sharp feature segments; When the curvature and the similarity of the relative directions of each second clear contour segment are both greater than the corresponding preset threshold, it is determined to be a contour matching segment.
8. The fast contour recognition method under complex backgrounds according to claim 7, characterized in that, The adjustment amount of the contour recognition optimization parameters is determined based on the difference between the proportion of the contour matching segment and the preset proportion threshold, and the difference between the spatial distribution uniformity and the preset spatial distribution uniformity threshold.
9. The fast contour recognition method under complex backgrounds according to claim 1, characterized in that, It also includes determining the corresponding feature centers based on several second clear contour segments, calculating the relative positions of each feature center to match the contour center and the positive direction of the contour, and triggering fast matching.
Citation Information
Patent Citations
Large-area multi-target diatom extraction and recognition method under complex background
CN111626326A
Image contour identification method and device, equipment and medium
CN110222703A
Reflective vest wearing state identification method and system based on deep learning
CN119992602A