Methods, apparatus, devices, and storage media for recognizing graphic edge contours

By training an edge comparison model using pyramid gradient processing and sparse sampling adaptive threshold segmentation on the image to be recognized, the problem of low target image recognition accuracy in existing technologies is solved, achieving higher recognition accuracy and positioning precision.

CN117291888BActive Publication Date: 2026-05-26SUZHOU MONARCH CONTROL TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUZHOU MONARCH CONTROL TECH
Filing Date
2023-09-26
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing technologies using comparison methods to identify target shapes in images have low accuracy.

Method used

By performing image processing on the image to be recognized, pyramid gradient images of different levels are obtained. Then, using a preset edge comparison model, a model trained based on sparse sampling and adaptive threshold segmentation is used to obtain a set of candidate contour points of the target graphic, and finally the target graphic is obtained.

Benefits of technology

It improves the accuracy and positioning precision of target image recognition and enhances the recognition effect of image pixel positions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117291888B_ABST
    Figure CN117291888B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for recognizing the edge contour of a graphic, relating to the field of machine vision technology. The method includes: image processing of an image to be recognized to obtain pyramid gradient images at different levels of the image; inputting the pyramid gradient images into a preset edge matching model to obtain a set of candidate points for the contour of a target graphic in the image to be recognized, wherein the preset edge matching model is a model trained based on sample images labeled with the target graphic using a sparse sampling method and an adaptive threshold segmentation method; and connecting the candidate points in the candidate point set to obtain the target graphic in the image to be recognized. In this application, the adaptive threshold segmentation method clearly distinguishes the contour of the target graphic from the contours of other graphics, and the sparse sampling method reduces the number of candidate points obtained. Therefore, the preset edge matching model can obtain a small number of accurate candidate points, thereby improving the accuracy of recognizing the target graphic using the matching method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine vision technology, and in particular to a method, apparatus, device and storage medium for recognizing the edge contour of a graphic. Background Technology

[0002] In the field of machine vision, when a positioning camera acquires the position of an image in an image, it often uses the features of the target graphic as a template, compares the template with an existing image to obtain a similarity score, and uses this similarity score to determine whether the graphic exists in the image. If it exists, the position of the graphic in the image is obtained.

[0003] Because robust feature selection is required when training the alignment model using the alignment method, if the selected features are insufficient or the selection method is not robust, the accuracy of identifying target graphics in the image using the alignment method will be greatly reduced. Summary of the Invention

[0004] The main objective of this application is to provide a method, apparatus, device, and storage medium for recognizing the edge contour of a graphic, aiming to solve the technical problem that the accuracy of recognizing target graphics in an image using the comparison method in the prior art is greatly reduced.

[0005] To achieve the above objective, this application provides a method for recognizing the edge contour of a graphic, the method comprising:

[0006] Image processing is performed on the image to be identified to obtain pyramid gradient images of different levels of the image to be identified;

[0007] The pyramid gradient image is input into a preset edge matching model to obtain a set of candidate points for the contour of the target graphic in the image to be identified. The preset edge matching model is a model trained based on sample images labeled with the target graphic by sparse sampling and adaptive threshold segmentation.

[0008] Based on the candidate point set, the target image of the image to be identified is obtained.

[0009] Optionally, before the step of inputting the pyramid gradient image into a preset edge matching model to obtain a candidate point set of the contour of the target graphic in the image to be identified, the method further includes:

[0010] The target graphic is selected from the sample image marked with the target graphic;

[0011] Adaptive threshold segmentation is performed on the sample image to determine the target contour of the target graphic;

[0012] Based on the sparse sampling method, the contour points of the target graphic are collected from the target contour;

[0013] The sample images are then preprocessed to obtain the feature pyramid of the target graphic.

[0014] By fusing the contour points with the feature pyramid layer by layer according to the feature pyramid hierarchy, a preset edge comparison model is obtained.

[0015] Optionally, the step of acquiring contour points of the target graphic from the target contour based on the sparse sampling method includes:

[0016] Based on the sampling interval of the sparse sampling method, the sampling interval range is determined;

[0017] Determine the average gradient direction and average pixel position of the current sampling point in the target contour within the interval range;

[0018] At the average pixel location, query the target gradient within the interval along the average gradient direction, and obtain the reference gradient magnitude of the target gradient;

[0019] Update the gradient magnitude of the current sampling point with the reference gradient magnitude;

[0020] The current sampling point after the gradient magnitude is updated is collected as the contour point of the target graphic.

[0021] Optionally, the step of fusing the contour points with the feature pyramid layer by layer according to the hierarchy of the feature pyramid to obtain a preset edge comparison model includes:

[0022] Extract the contour features corresponding to the contour points in the corresponding layers of the feature pyramid layer by layer.

[0023] By centering the coordinates of the contour points and contour features with the center of the template graphic of the corresponding level as the origin, a preset edge comparison model is obtained.

[0024] Optionally, the step of performing image preprocessing on the sample image to obtain the feature pyramid of the target image includes:

[0025] The sample image is denoised and contrast enhanced to obtain a denoised image;

[0026] The denoised image is convolved to obtain the gradient magnitude and gradient direction of the target image;

[0027] The feature pyramid of the target graphic is constructed based on the gradient magnitude and the gradient direction.

[0028] Optionally, the step of inputting the pyramid gradient image into a preset edge matching model to obtain a candidate point set of the contour of the target graphic in the image to be identified includes:

[0029] The pyramid gradient image is input into the edge matching model. Based on the contour templates of different levels in the edge matching model, the model performs pixel-by-pixel comparison with the pyramid gradient images of different levels in descending order of level, or performs pixel-by-pixel comparison, as well as scale and / or angle comparison, with the pyramid gradient images of different levels in descending order of level to determine the candidate point set of the contour of the target graphic in the image to be identified.

[0030] Optionally, the step of determining the candidate point set of the target graphic's contour in the image to be identified by comparing it pixel-by-pixel, as well as by scale and / or angle, with pyramid gradient images of different levels in descending order of hierarchy includes:

[0031] Based on the comparison scale and / or comparison angle of the contour obtained from the previous layer, within a preset adjustment range, the pyramid gradient image of the current level is compared pixel by pixel, scale and / or angle with the first round template of the corresponding level to determine the contour of the target image at the current level, until the contour of the target image at the lowest level is obtained.

[0032] Based on the contour of the target graphic at the lowest level, a set of candidate points for the contour of the target graphic in the image to be identified is determined.

[0033] Furthermore, to achieve the above objectives, this application also provides a graphic edge contour recognition device, which includes:

[0034] The image processing module is used to perform image processing on the image to be recognized to obtain pyramid gradient images of different levels of the image to be recognized.

[0035] The comparison module is used to input the pyramid gradient image into a preset edge comparison model to obtain a set of candidate points for the contour of the target graphic in the image to be identified. The preset edge comparison model is a model trained based on sample images labeled with the target graphic by sparse sampling and adaptive threshold segmentation.

[0036] The connection module is used to obtain the target graphic of the image to be identified based on the candidate point set.

[0037] In addition, to achieve the above objectives, this application also proposes a graphic edge contour recognition device, the device comprising: a memory, a processor, and a graphic edge contour recognition program stored in the memory and executable on the processor, the graphic edge contour recognition program being configured to implement the steps of the graphic edge contour recognition method described above.

[0038] In addition, to achieve the above objectives, this application also proposes a storage medium storing a graphic edge contour recognition program, wherein when the graphic edge contour recognition program is executed by a processor, it implements the steps of the graphic edge contour recognition method described above.

[0039] This application provides a method, apparatus, device, and storage medium for recognizing the edge contour of a graphic. Compared with the prior art, which uses comparison methods to identify target graphics in an image, which greatly reduces the accuracy of target graphic recognition using comparison methods, this application performs image processing on the image to be recognized to obtain pyramid gradient images of different levels of the image to be recognized; inputs the pyramid gradient images into a preset edge comparison model to obtain a set of candidate points for the contour of the target graphic in the image to be recognized, wherein the preset edge comparison model is a model trained based on sample images marked with the target graphic through sparse sampling and adaptive threshold segmentation; and obtains the target graphic of the image to be recognized based on the set of candidate points. In this application, the received image to be identified is processed to determine the pyramid gradient images of different gray levels of the image to be identified. Then, a set of candidate points for the target graphic is obtained using a preset edge comparison model. The target graphic is obtained by connecting the candidate points, thereby improving the effectiveness of obtaining the features of the target graphic in the image to be identified, and thus improving the accuracy of identification and the precision of the image pixel position. The preset edge comparison model is obtained by training on sample images marked with the target graphic through sparse sampling and adaptive threshold segmentation. That is, in this application, the adaptive threshold segmentation method can make the target graphic significantly different from other images in the sample images, making the outline of the target graphic more obvious. Furthermore, the preset edge comparison model can obtain a small number of accurate candidate points, thereby improving the accuracy of identifying the target graphic using the comparison method. Attached Figure Description

[0040] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0041] To more clearly illustrate the technical solutions in the embodiments of this application 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.

[0042] Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of this application;

[0043] Figure 2 This is a flowchart illustrating the first embodiment of the graphic edge contour recognition method of this application;

[0044] Figure 3 This is a schematic diagram of the comparison of the first layer of the feature pyramid in the graphic edge contour recognition method of this application;

[0045] Figure 4 This is a schematic diagram showing the comparison of the remaining layers of the feature pyramid in the graphic edge contour recognition method of this application;

[0046] Figure 5 This is a flowchart illustrating the second embodiment of the graphic edge contour recognition method of this application;

[0047] Figure 6 This is a flowchart illustrating the third embodiment of the graphic edge contour recognition method of this application;

[0048] Figure 7 This is a schematic diagram of the training process of the preset edge recognition model in the graphic edge contour recognition method of this application;

[0049] Figure 8 This is a schematic diagram of the structural configuration of the graphic edge contour recognition device of this application.

[0050] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0051] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0052] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a graphical edge contour recognition device for the hardware operating environment involved in the embodiments of this application.

[0053] like Figure 1As shown, the device for recognizing the edge contour of a graphic may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to establish communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.

[0054] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the device for recognizing the edge contour of a graphic and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0055] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a graphic edge contour recognition program.

[0056] exist Figure 1 In the graphic edge contour recognition device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and memory 1005 in the graphic edge contour recognition device of this application can be set in the graphic edge contour recognition device, and the graphic edge contour recognition device calls the graphic edge contour recognition program stored in the memory 1005 through the processor 1001 and executes the graphic edge contour recognition method provided in the embodiment of this application.

[0057] This application provides a method for recognizing the edge contour of a graphic, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of a method for recognizing the edge contour of a graphic according to this application.

[0058] It should be noted that the execution subject of this embodiment can be the graphic edge contour recognition device. The graphic edge contour recognition device can be a personal computer, smartphone, tablet computer or other electronic device, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the graphic edge contour recognition device is used as an example to describe the graphic edge contour recognition method of this application.

[0059] In this embodiment, the method for recognizing the graphic edge contour includes:

[0060] Step S10: Perform image processing on the image to be identified to obtain pyramid gradient images of different levels of the image to be identified.

[0061] The image to be identified can be a photograph taken by a camera or an existing image, etc., and there are no specific limitations.

[0062] The layers of the image to be recognized can be divided by the user based on grayscale values ​​of the same length, or they can be automatically divided based on the recognition accuracy required by the user; there is no specific limitation.

[0063] Among them, the pyramid gradient image can be a graphic that represents the contour features of the target graphic, such as the gray value features of the target graphic contour.

[0064] It should be noted that image processing of the image to be recognized can be used to remove noise and specks in the image to reduce the impact of noise and specks on convolution when the image to be recognized is convolved, so that the pyramid gradient image representing the features of the target image obtained after convolution is more accurate. In other words, by removing noise and specks in the image to be recognized, the accuracy of feature extraction from the image to be recognized can be improved.

[0065] It should be noted that, in addition to noise and artifact removal processing of the image to be recognized, convolution processing is also performed on the image to be recognized to determine the gradient magnitude and gradient direction of the grayscale values ​​of the image to be recognized. Based on the gradient magnitude and gradient direction, a gradient pyramid containing pyramid gradient images of different levels is constructed. The grayscale features in each layer of the pyramid gradient image can be accurately extracted based on the gradient magnitude. These grayscale features are then compared with the template of the corresponding layer of the feature pyramid in the preset edge comparison model to improve the accuracy of comparison and recognition. Each layer of the gradient pyramid can be composed of a pyramid gradient image of one level. That is, each layer of the gradient pyramid represents a pyramid gradient image of one level.

[0066] In specific implementation, noise and artifact removal of the image to be recognized can be performed by Gaussian filtering to reduce noise, followed by Sobel convolution to determine the gradient magnitude and gradient direction of the image to be recognized. Based on the gradient magnitude, gradient direction, and a pre-set number of pyramid layers, different levels of pyramid gradient images are established, and the pyramid gradient images are combined to form a gradient pyramid. The number of pyramid layers is the same as the number of feature pyramid layers in the preset edge matching model, so that the corresponding contours of each level can be matched through the preset edge matching model, thereby improving the accuracy of target image recognition.

[0067] Step S20: Input the pyramid gradient image into a preset edge matching model to obtain a set of candidate points for the contour of the target graphic in the image to be identified. The preset edge matching model is a model trained based on sample images marked with the target graphic by sparse sampling and adaptive threshold segmentation.

[0068] The preset edge comparison model includes a feature pyramid, and each layer of the feature pyramid contains a template image containing the contour features of the target image, so as to facilitate the comparison between the pyramid gradient image and the corresponding template image.

[0069] It should be noted that during training, the preset edge matching model can clearly display the contour of the target graphic in the sample image through the adaptive threshold segmentation method, thereby improving the recognition accuracy of contour features. This makes the contour of the target graphic in the template graphic within the feature pyramid fit the target graphic in the sample image more closely. Furthermore, the model uses a sparse sampling method to extract representative contour points from the contour at intervals, thereby reducing the extraction of contour points and preserving the contour features. This improves the accuracy of the preset edge matching model in identifying candidate points.

[0070] It should be noted that candidate points can be the center points of the corresponding layer contour point set in the pyramid gradient image of each layer. The center point is used to represent the contour points. The preset edge comparison model, trained by sparse sampling and adaptive thresholding, identifies the set of candidate points in the image to be identified. The adaptive thresholding method makes the features of the target image accurately displayed on the template image. The sparse sampling method reduces the number of contour points needed to model the pyramid gradient image. Therefore, the number of contour points participating in the subsequent similarity calculation is reduced, the amount of computation is reduced, and the recognition speed is improved.

[0071] It should be noted that the candidate point set can be obtained by filtering layer by layer through the feature pyramid. By filtering the candidate point set from the corresponding pyramid gradient image through template graphics in multiple feature pyramids, more effective contour features can be obtained, thereby improving the accuracy of the comparison method in identifying target graphics.

[0072] In the specific implementation, the pyramid gradient image is input into the preset edge comparison model, so that the feature pyramid in the preset template image determines the candidate matching point set of the target image contour in the pyramid gradient image of the preset level. According to the mapping relationship of the candidate matching point set in the pyramid gradient image of different levels, the similarity between the candidate matching point and the corresponding contour point in the template image of the same level is selected from the candidate matching point set level by level. The candidate matching point with the similarity reaching the preset similarity threshold is recorded as the candidate point, and the candidate point set is obtained. That is, the candidate point is the point most similar to the center point of the target image contour. Therefore, the accuracy of obtaining the contour of the target image based on the candidate point is also the highest.

[0073] The mapping relationship can be the arrangement of pixels in the pyramid gradient image at each level. For example, if the pyramid gradient image has three levels, with the lowest level having a pixel arrangement of 100×100, the middle level having a pixel arrangement of 50×50, and the highest level having a pixel arrangement of 25×25, then the mapping relationship is the multiple of the pixel arrangement of adjacent pyramid gradient images. The relationship between the template graphics in each level of the feature pyramid is the same as the mapping relationship.

[0074] Further, the step of inputting the pyramid gradient image into a preset edge comparison model to obtain a candidate point set of the contour of the target graphic in the image to be identified includes:

[0075] Step S21: Input the pyramid gradient image into the edge matching model. Based on the contour templates of different levels in the edge matching model, perform pixel-by-pixel comparison with the pyramid gradient images of different levels in descending order of level, or perform pixel-by-pixel, scale and / or angle comparison with the pyramid gradient images of different levels in descending order of level, to determine the candidate point set of the contour of the target graphic in the image to be identified.

[0076] In this embodiment, optionally, only pixel-by-pixel comparison can be performed, or pixel-by-pixel and scale comparison can be performed simultaneously, or pixel-by-pixel and angle comparison can be performed simultaneously.

[0077] It should be noted that, in order to identify the pyramid gradient image based on the preset edge comparison model, the template image at the highest level of the preset edge comparison model can be compared pixel by pixel in terms of size and angle with the corresponding level of the pyramid gradient image. This template image can be used to identify the position and general outline of the target image in the pyramid gradient image. Then, by comparing the scale and angle of the pyramid gradient image layer by layer from the high level to the low level, the outline points (candidate points) of the target image in the image to be identified can be accurately identified layer by layer.

[0078] In the specific implementation, the preset edge matching model first uses the highest-level template image to perform pixel-by-pixel size and angle comparison with the corresponding pyramid gradient image to determine the approximate outline of the target image in the pyramid gradient image. When the similarity between the pyramid gradient image and the template image reaches a preset similarity threshold, a set of candidate matching points for the outline is obtained, and this set of candidate matching points is mapped to the next layer of the pyramid gradient image, so that the next layer of the pyramid gradient image obtains the mapped outline based on the set of candidate matching points. The mapped outline is then compared with the corresponding layer template image in terms of size and angle. When the similarity between the mapped outline and the corresponding layer template image reaches the preset similarity threshold of that layer, a set of candidate matching points for the mapped outline is obtained again, and this set of candidate matching points is continued to be mapped down until the outline formed by the set of candidate matching points in the last layer of the pyramid gradient image meets the preset similarity threshold of the last layer of the feature pyramid. Then, a set of candidate points corresponding to the outline of the target image is obtained, and the target image is determined using the set of candidate points.

[0079] Specifically, the step of determining the candidate point set of the target graphic's contour in the image to be identified by comparing it pixel-by-pixel, as well as by scale and / or angle, with pyramid gradient images of different levels in descending order of hierarchy includes:

[0080] Step S21a: Based on the comparison scale and / or comparison angle of the contour obtained in the previous layer, within a preset adjustment range, the pyramid gradient image of the current level is compared pixel by pixel, scale and / or angle with the first round template of the corresponding level to determine the contour of the target graphic at the current level, until the contour of the target graphic at the lowest level is obtained.

[0081] Step S21b: Based on the contour of the target graphic at the lowest level, determine the candidate point set of the contour of the target graphic in the image to be identified.

[0082] In the specific implementation, refer to Figure 3The search parameters are configured, including the number of pyramid layers, the search angle range, the search scale range, and a preset similarity threshold. The search angle step size and search scale step size are determined by comparing the search image and the template image. The gradient magnitude of the target image is searched pixel-by-pixel through the first-layer pyramid to determine its approximate outline. Angle comparison is then performed, followed by scale comparison. Points whose similarity to the corresponding outline points in the template image meets the preset similarity threshold for that layer are identified, and those that do not meet the threshold are filtered out. Based on the angle and / or size of the approximate outline obtained from the previous layer, the accuracy of the outline is further improved within the preset adjustment range of the current layer. This process of cyclical angle and size comparison continues until all points of the entire outline have been compared, and overlapping points are filtered out, resulting in a candidate matching point set (candidate set) for the first layer. For example, if the top layer uses a 10-degree angle for cyclical searching, and a rough outline is found when rotating 90 degrees, then in the next lower layer, the search will be performed within a range of ±5 degrees around 90 degrees, becoming increasingly refined layer by layer. Utilizing the recognition results from the previous layer for recognition from coarse to fine can improve recognition speed.

[0083] In the specific implementation, refer to Figure 4 Based on the preset similarity thresholds for each level, the search range for candidate options is determined by the step size. The candidate option set is then compared with the contours of the remaining pyramid template graphics to determine the search results. The remaining levels are searched layer by layer downwards, and interference items are filtered at each level until the bottom level is reached to obtain the search results that meet the preset similarity thresholds, thus obtaining the candidate point set (final candidate option set).

[0084] The lower the level, the higher the preset similarity threshold.

[0085] Step S30: Based on the candidate point set, obtain the target graphic of the image to be identified.

[0086] In the specific implementation, since the similarity between each candidate point in the bottom-level candidate point set and the contour point at the corresponding position in the template graphic all meet the similarity threshold, the candidate point is the center point of the contour of the target graphic. That is, the candidate point set constitutes the contour of the target graphic.

[0087] It should be noted that the candidate point set can also include contour points of detailed graphic features in the target graphic. For example, if the target graphic is a pet, the candidate point set can include not only candidate points representing the pet's body, but also candidate points representing the pet's facial features, etc., to achieve accurate recognition.

[0088] This embodiment provides a method for recognizing the edge contour of a graphic. Compared with the existing technology that uses comparison methods to identify target graphics in an image, which greatly reduces the accuracy of target graphic recognition using comparison methods, in this application, the image to be recognized is processed to obtain pyramid gradient images of different levels of the image to be recognized; the pyramid gradient images are input into a preset edge comparison model to obtain a set of candidate points for the contour of the target graphic in the image to be recognized. The preset edge comparison model is a model trained based on sample images marked with the target graphic through sparse sampling and adaptive threshold segmentation; based on the set of candidate points, the target graphic of the image to be recognized is obtained. In this application, the received image to be identified is processed to determine the pyramid gradient images of different gray levels of the image to be identified. Then, a set of candidate points for the target graphic is obtained using a preset edge comparison model. The target graphic is obtained by connecting the candidate points, thereby improving the effectiveness of obtaining the features of the target graphic in the image to be identified, and thus improving the accuracy of identification and the precision of the image pixel position. The preset edge comparison model is obtained by training on sample images marked with the target graphic through sparse sampling and adaptive threshold segmentation. That is, in this application, the adaptive threshold segmentation method can make the target graphic significantly different from other images in the sample images, making the outline of the target graphic more obvious. Furthermore, the preset edge comparison model can obtain a small number of accurate candidate points, thereby improving the accuracy of identifying the target graphic using the comparison method.

[0089] refer to Figure 5 , Figure 5 This is a flowchart illustrating the second embodiment of the graphic edge contour recognition method of this application.

[0090] Based on the above embodiments, in this embodiment, in order to improve the accuracy of the preset edge comparison model in recognizing the target image, before step S20, the method further includes:

[0091] Step S01: Select the target graphic from the sample image marked with the target graphic.

[0092] It should be noted that the target graphic marked in the sample image should be selected first to obtain the position of the target graphic in the sample image, so as to facilitate the subsequent extraction of the contour features of the target graphic.

[0093] In practical implementation, the ROI (Region of Interest) can be used to select the target image in the camera image, obtain the position of the target image in the sample image, and the target outline of the target image can be determined by adaptive thresholding of the sample image.

[0094] Step S02: Perform adaptive threshold segmentation on the sample image to determine the target contour of the target graphic.

[0095] It should be noted that performing adaptive threshold segmentation on the sample image can be to determine the segmentation threshold according to the target graphic obtained by frame selection. That is, determine the segmentation threshold according to the grayscale value data of the target graphic, which can make the contour of the target graphic clearly displayed in the sample image, obtain the target contour of the target graphic. By clearly and distinctly displaying the contour of the target graphic, the accuracy of contour feature extraction can be improved, avoiding the decrease in the recognition accuracy of the comparison method caused by the non-standard preset edge template graphic. That is, by improving the standard degree of the template graphic, the recognition accuracy of the target graphic by the comparison method is improved.

[0096] In a specific implementation, the grayscale value of the target graphic can be determined to automatically generate a grayscale value threshold suitable for segmenting the sample image into a binary image, and then the sample image is segmented according to this grayscale value threshold to divide the sample into a binary template image. For example, when the sample image is segmented into a black-and-white image, the target graphic can be segmented into all black, and the graphics outside the target graphic can be segmented into white, etc., so as to clearly display the target contour of the target graphic.

[0097] Optionally, since the contour obtained after binarization may include contour parts that do not need to be recognized, after performing adaptive threshold segmentation on the sample image, unnecessary contour information can also be removed by the user's image mask to obtain the target contour of the target image, so that the contour of the obtained target graphic is more accurate.

[0098] For example, if the target graphic is a graphic similar to "十", and the user needs to use a preset edge comparison model to recognize the "丨" part, then removing the unnecessary contour information by the image mask can be to remove the "一" part in the target graphic. [[ID=~14]]

[0099] Step S03: Based on the sparse sampling method, collect the contour points of the target graphic from the target contour.

[0100] It should be noted that since the color of the target graphic contour in the sample image is similar to the colors of the other patterns, that is, the difference between the grayscale value of the target graphic contour and the grayscale values of the patterns or background near the contour is small, in order to make the extracted contour points of the target graphic clearer, the sparse sampling method can be used to first determine the contour points from the target contour, and update each contour point with the point with the strongest gradient within the sampling interval of each contour point, and finally obtain contour points that can be more distinguishable from other pixel points, so that the contour points of the target graphic can be displayed more clearly in the sample pattern.

[0101] Optionally, before acquiring the contour points of the target graphic using the sparse sampling method, a preset contour point number threshold can be used to remove contours with fewer contour points than the contour point number threshold, in order to remove noise and impurities from the target graphic.

[0102] In the specific implementation, after obtaining the target contour of the target graphic, the target contour can be mapped to the sample image to make the contour of the target graphic in the sample image clearer. Then, through sparse sampling, the unclear sample points in the target contour are replaced with the pixels with the strongest gradient within the preset sampling interval to obtain easily identifiable contour points, making the contour of the target graphic easier to identify.

[0103] Furthermore, in order to make the target contour of the target graphic easier to identify, the step S03 of extracting contour points includes:

[0104] Step S031: Determine the sampling interval range based on the sampling interval of the sparse sampling method;

[0105] Step S032: Determine the average gradient direction and average pixel position of the current sampling point in the target contour within the interval range;

[0106] Step S033: At the average pixel position, query the target gradient within the interval along the average gradient direction, and obtain the reference gradient magnitude of the target gradient;

[0107] Step S034: Update the gradient magnitude of the current sampling point with the reference gradient magnitude;

[0108] Step S035: Collect the current sampling point after the gradient magnitude update as the contour point of the target graphic.

[0109] It should be noted that since the larger the gradient magnitude, the greater the difference in grayscale value between the corresponding pixel and its surrounding pixels, when using sparse sampling to collect contour points of the target contour, one contour point can be collected at every sampling interval. However, since the gradient magnitude of the collected contour point may be too small, the contour point may be difficult to identify. To improve the recognizability of the contour point, the average gradient direction and average pixel position of the current sampling point can be determined within the sampling interval determined by the sampling distance. Then, based on the average pixel position, the pixel with the largest gradient magnitude in the average gradient direction can be found, and the current sampling point can be updated with this pixel. The updated current sampling point can then be collected as the contour point to improve the recognizability of the contour points of the target graphic and make the features of the contour points more prominent.

[0110] Step S04 involves preprocessing the sample image to obtain the feature pyramid of the target graphic.

[0111] It should be noted that during the adaptive segmentation and contour point acquisition of the sample image, image preprocessing can also be performed on the sample image at the same time. The image preprocessing can be to first denoise the sample image, and then perform a convolution operation on the denoised target image to obtain the contour features of the target graphic, that is, the gradient magnitude and gradient direction. Then, a feature pyramid of the target graphic is built according to the preset hierarchical parameters, gradient magnitude and gradient direction.

[0112] Further, the step of performing image preprocessing on the sample image to obtain the feature pyramid of the target image includes:

[0113] Step S041: Denoise and contrast enhancement are performed on the sample image to obtain a denoised image;

[0114] Step S042: Perform a convolution operation on the denoised image to obtain the gradient magnitude and gradient direction of the target image;

[0115] Step S043: Establish the feature pyramid of the target graphic based on the gradient magnitude and the gradient direction.

[0116] It should be noted that noise reduction of the sample image can be achieved by using Gaussian filtering to reduce noise in the sample image and improve the contrast of the sample image, thereby increasing the resolution between adjacent pixels, amplifying the features of each pixel, and improving the accuracy of extracting the features of the target image.

[0117] It should be noted that convolution operations on denoised images can be performed using Sobel convolution operations, which determine the gradient magnitude and gradient direction of the target image through multiple preset directions, making the feature pyramid of the target image built based on the gradient magnitude and gradient direction more effective.

[0118] In the specific implementation, Gaussian filtering and contrast enhancement are performed on the sample image to obtain the denoised image. Then, Sobel convolution is performed on the denoised image to obtain the gradient magnitude and gradient direction of the target image in two preset directions. Based on the gradient magnitude and gradient direction, different levels of comparison models are determined. Each comparison model is built into a feature pyramid according to the level. The gradient magnitude and gradient direction can be understood as the features of the target image.

[0119] Furthermore, to make the features in the template graph of the feature pyramid more effective, step S042 includes:

[0120] Step S0421: Perform convolution operations on the denoised image in a preset first direction and a preset second direction respectively to obtain the gradient magnitude and gradient direction of the gray level of the target image in the preset first direction and the preset second direction respectively.

[0121] It should be noted that the preset first direction and the preset second direction can be two mutually perpendicular directions. The denoised image is convolved in the preset first direction and the preset second direction respectively to accurately obtain the features of the target graphic's contour in the denoised image, making the mapping relationship between different levels of comparison models more accurate, thereby improving the accuracy of the contour in the comparison model, so that when comparing and recognizing the target graphic in the image to be recognized, the specific position of the target contour can be accurately determined.

[0122] For example, if we consider the denoised image as a coordinate system, the first preset direction and the second preset direction can be the X direction and the Y direction, respectively.

[0123] Step S05: Merge the contour points and the feature pyramid layer by layer according to the hierarchy of the feature pyramid to obtain a preset edge comparison model.

[0124] It should be noted that by finding the pixel position corresponding to the feature point in the feature pyramid and fusing the contour point with the corresponding feature in the feature pyramid to that pixel position, the contour point is associated with the corresponding feature. This allows the preset edge recognition model to accurately and quickly determine the contour point of the target graphic in the image to be recognized based on the features of the image to be recognized, thereby improving the accuracy of identifying the target graphic using the comparison method.

[0125] Further, the step of fusing the contour points with the feature pyramid layer by layer according to the hierarchy of the feature pyramid to obtain a preset edge comparison model includes:

[0126] Step S051: Extract the contour features corresponding to the contour points in the corresponding layers of the feature pyramid layer by layer.

[0127] Step S502: Center the coordinates of the contour points and the contour features according to the center of the template graphic of the corresponding level as the origin, and obtain a preset edge comparison model.

[0128] It should be noted that, according to the feature pyramid hierarchy, the contour features corresponding to the contour points in the corresponding level are extracted layer by layer. The contour points and their corresponding features can be extracted starting from the bottom pyramid image, and the contour points and gradient information (features) of the corresponding level are extracted layer by layer upwards. Then, the contour points and gradient information extracted from all feature pyramids are centered with the center of the template image of the corresponding level as the origin. Finally, the contour points and gradient information are saved as model parameters, and a preset edge comparison template is obtained based on the model parameters to enhance the mapping relationship between adjacent levels.

[0129] refer to Figure 6 , Figure 6 This is a flowchart illustrating the third embodiment of the graphic edge contour recognition method of this application.

[0130] Based on the above embodiments, in this embodiment, the specific training process of the preset edge comparison model is as follows:

[0131] Step S1: Use the training bounding box ROI to select the desired shape in the camera image;

[0132] Step S2: Image preprocessing includes Gaussian filtering for noise reduction and contrast enhancement.

[0133] Step S3: Perform Sobel convolution operations on the image in the X and Y directions respectively, calculate the gradient in the X and Y directions of the image, and calculate the gradient magnitude and gradient direction.

[0134] Step S4: Set the pyramid hierarchy parameters and build a feature pyramid of gradient and gradient magnitude;

[0135] Step S5: Set a fixed threshold segmentation or adaptive threshold segmentation method, segment the pixels of the template image to obtain a binarized template image, find contour points, and ignore unnecessary contour information through an image mask.

[0136] Step S6: Set the sparse sampling interval and perform feature sampling on continuous contour points;

[0137] Step S7: According to the preset pyramid hierarchy, extract the contour points and gradient information of the corresponding levels layer by layer from the point features extracted from the bottom pyramid image.

[0138] Step S8: Extract all the contour points and gradient information from the pyramids, center the coordinates of the contour points according to the center of the template graphic of the corresponding level as the origin, and finally save the contour points and gradient information as model parameters, and obtain the preset edge comparison model based on the model parameters.

[0139] Specifically, refer to Figure 7Feature extraction and point extraction can be performed simultaneously. Steps S3 and S4 are feature extraction, steps S5 and S6 are point extraction (contour point extraction), and steps S7 and S8 are point feature fusion.

[0140] Specifically, step S6 can calculate the average gradient direction and average pixel position (or gradient direction and pixel position related to the weight coefficient) of contour points within the sampling interval of the current contour point. Starting from the average pixel position, it searches for points with stronger gradients along the average gradient direction to update the current contour point and gradient magnitude. Finally, contour points are sampled according to the sparse sampling interval. When the contour point threshold segmentation found in step S5 is not ideal, this sampling method can still update contour points with stronger gradient magnitudes. Although sparse sampling reduces model parameters and improves the search speed, it updates the position and gradient information of all contour points within the sampling interval when updating contour points, ensuring the effectiveness of the sampled contour point features.

[0141] This application also provides a device for recognizing the edge contour of a graphic, with reference to... Figure 8 The device for recognizing the edge contour of a graphic includes:

[0142] Image processing module 801 is used to perform image processing on the image to be recognized to obtain pyramid gradient images of different levels of the image to be recognized;

[0143] The comparison module 802 is used to input the pyramid gradient image into a preset edge comparison model to obtain a set of candidate points for the contour of the target graphic in the image to be identified. The preset edge comparison model is a model trained based on a sample image marked with the target graphic by a sparse sampling method and an adaptive threshold segmentation method.

[0144] The connection module 803 is used to obtain the target graphic of the image to be identified based on the candidate point set.

[0145] Optionally, the comparison module 802 is further configured to: select the target graphic from the sample image marked with the target graphic; perform adaptive threshold segmentation on the sample image to determine the target contour of the target graphic; collect the contour points of the target graphic from the target contour based on the sparse sampling method; and perform image preprocessing on the sample image to obtain the feature pyramid of the target graphic; and fuse the contour points and the feature pyramid layer by layer according to the hierarchy of the feature pyramid to obtain a preset edge comparison model.

[0146] Optionally, the comparison module 802 is further configured to: determine a sampling interval range based on the sampling interval of the sparse sampling method; determine the average gradient direction and average pixel position of the current sampling point in the target contour within the interval range; query the target gradient within the interval range along the average gradient direction at the average pixel position, and obtain a reference gradient magnitude of the target gradient; update the gradient magnitude of the current sampling point with the reference gradient magnitude; and collect the current sampling point after the gradient magnitude update as the contour point of the target graphic.

[0147] Optionally, the comparison module 802 is further configured to extract the contour features corresponding to the contour points in the corresponding layers according to the layers of the feature pyramid; and to center the coordinates of the contour points and the contour features with the center of the template graphic of the corresponding layer as the origin, so as to obtain a preset edge comparison model.

[0148] Optionally, the comparison module 802 is further configured to perform noise reduction and contrast enhancement on the sample image to obtain a noise-reduced image; perform a convolution operation on the noise-reduced image to obtain the gradient magnitude and gradient direction of the target image; and establish a feature pyramid of the target image based on the gradient magnitude and gradient direction.

[0149] Optionally, the comparison module 802 is further configured to input the pyramid gradient image into the edge comparison model, and based on the contour templates of different levels in the edge comparison model, perform pixel-by-pixel comparison with the pyramid gradient images of different levels in order of the level, or perform pixel-by-pixel, scale and / or angle comparison with the pyramid gradient images of different levels in order of the level, to determine the candidate point set of the contour of the target graphic in the image to be identified.

[0150] Optionally, the comparison module 802 is further configured to, based on the comparison scale and / or comparison angle of the contour obtained in the previous layer, perform pixel-by-pixel comparison, scale and / or angle comparison between the pyramid gradient image of the current level and the first round template of the corresponding level within a preset adjustment range, to determine the contour of the target graphic at the current level, until the contour of the target graphic at the lowest level is obtained; and based on the contour of the target graphic at the lowest level, determine a set of candidate points for the contour of the target graphic in the image to be identified.

[0151] The specific implementation of the graphic edge contour recognition device of this application is basically the same as the above-described graphic edge contour recognition method embodiments, and will not be repeated here.

[0152] This application provides a storage medium that stores one or more programs, which can be executed by one or more processors to implement the steps of the graphic edge contour recognition method described above.

[0153] The specific implementation of the storage medium in this application is basically the same as the embodiments of the above-described graphic edge contour recognition method, and will not be repeated here.

[0154] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one, etc." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0155] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0156] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of the various embodiments of this application.

[0157] The above are merely preferred embodiments of this application and do not limit the scope of this patent application. Any equivalent structural or procedural changes made based on the description and drawings of this application, or any direct or indirect application in other related technical fields, are similarly included within the scope of patent protection of this application.

Claims

1. A method for recognizing the edge contour of a graphic, characterized in that, The method for recognizing the edge contour of the graphic includes: Image processing is performed on the image to be identified to obtain pyramid gradient images of different levels of the image to be identified; The pyramid gradient image is input into a preset edge matching model to obtain a set of candidate points for the contour of the target graphic in the image to be identified. The preset edge matching model is a model trained based on sample images labeled with the target graphic by sparse sampling and adaptive threshold segmentation. Based on the candidate point set, the target image of the image to be identified is obtained; The training steps of the preset edge comparison model include: The target graphic is selected from the sample image marked with the target graphic; Adaptive threshold segmentation is performed on the sample image to determine the target contour of the target graphic; Based on the sampling interval of the sparse sampling method, the sampling interval range is determined; Determine the average gradient direction and average pixel position of the current sampling point in the target contour within the interval range; At the average pixel location, query the target gradient within the interval along the average gradient direction, and obtain the reference gradient magnitude of the target gradient; Update the gradient magnitude of the current sampling point with the reference gradient magnitude; The current sampling point after the gradient magnitude update is collected is the contour point of the target graphic; The sample images are then preprocessed to obtain the feature pyramid of the target graphic. By fusing the contour points with the feature pyramid layer by layer according to the feature pyramid hierarchy, a preset edge comparison model is obtained.

2. The method for recognizing the edge contour of a graphic as described in claim 1, characterized in that, The step of fusing the contour points with the feature pyramid layer by layer according to the feature pyramid hierarchy to obtain a preset edge comparison model includes: Extract the contour features corresponding to the contour points in the corresponding layers of the feature pyramid layer by layer. By centering the coordinates of the contour points and contour features with the center of the template graphic of the corresponding level as the origin, a preset edge comparison model is obtained.

3. The method for recognizing the edge contour of a graphic as described in claim 1, characterized in that, The step of performing image preprocessing on the sample image to obtain the feature pyramid of the target image includes: The sample image is denoised and contrast enhanced to obtain a denoised image; The denoised image is convolved to obtain the gradient magnitude and gradient direction of the target image; The feature pyramid of the target graphic is constructed based on the gradient magnitude and the gradient direction.

4. The method for recognizing the edge contour of a graphic as described in any one of claims 1-3, characterized in that, The step of inputting the pyramid gradient image into a preset edge comparison model to obtain a candidate point set of the contour of the target graphic in the image to be identified includes: The pyramid gradient image is input into the edge matching model. Based on the contour templates of different levels in the edge matching model, the model performs pixel-by-pixel comparison with the pyramid gradient images of different levels in descending order of level, or performs pixel-by-pixel comparison, as well as scale and / or angle comparison, with the pyramid gradient images of different levels in descending order of level to determine the candidate point set of the contour of the target graphic in the image to be identified.

5. The method for recognizing the edge contour of a graphic as described in claim 4, characterized in that, The step of determining the candidate point set of the contour of the target graphic in the image to be identified by comparing it pixel-by-pixel, as well as by scale and / or angle, sequentially with pyramid gradient images of different levels according to their hierarchical levels includes: Based on the comparison scale and / or comparison angle of the contour obtained from the previous layer, within a preset adjustment range, the pyramid gradient image of the current level is compared pixel by pixel with the first contour template of the corresponding level, as well as the scale and / or angle comparison, to determine the contour of the target graphic at the current level, until the contour of the target graphic at the lowest level is obtained. Based on the contour of the target graphic at the lowest level, a set of candidate points for the contour of the target graphic in the image to be identified is determined.

6. A device for recognizing the edge contour of a graphic, characterized in that, The device for recognizing the edge contour of the graphic includes: The image processing module is used to perform image processing on the image to be recognized to obtain pyramid gradient images of different levels of the image to be recognized. The comparison module is used to input the pyramid gradient image into a preset edge comparison model to obtain a set of candidate points for the contour of the target graphic in the image to be identified. The preset edge comparison model is a model trained based on sample images labeled with the target graphic by sparse sampling and adaptive threshold segmentation. A connection module is used to obtain the target image of the image to be identified based on the candidate point set; The training steps of the preset edge comparison model include: The target graphic is selected from the sample image marked with the target graphic; Adaptive threshold segmentation is performed on the sample image to determine the target contour of the target graphic; Based on the sampling interval of the sparse sampling method, the sampling interval range is determined; Determine the average gradient direction and average pixel position of the current sampling point in the target contour within the interval range; At the average pixel location, query the target gradient within the interval along the average gradient direction, and obtain the reference gradient magnitude of the target gradient; Update the gradient magnitude of the current sampling point with the reference gradient magnitude; The current sampling point after the gradient magnitude update is collected is the contour point of the target graphic; The sample images are then preprocessed to obtain the feature pyramid of the target graphic. By fusing the contour points with the feature pyramid layer by layer according to the feature pyramid hierarchy, a preset edge comparison model is obtained.

7. A device for recognizing the edge contour of a graphic, characterized in that, The graphic edge contour recognition device includes: a memory, a processor, and a graphic edge contour recognition program stored in the memory and executable on the processor, wherein the graphic edge contour recognition program is configured to implement the steps of the graphic edge contour recognition method as described in any one of claims 1 to 5.

8. A storage medium, characterized in that, The storage medium stores a program for implementing a method for recognizing the edge contour of a graphic, and the program for implementing the method for recognizing the edge contour of a graphic is executed by a processor to implement the steps of the method for recognizing the edge contour of a graphic as described in any one of claims 1 to 5.