An edge recognition method and device, electronic equipment and storage medium

CN120976251BActive Publication Date: 2026-10-13GOVION TECHNOLOGY (SUZHOU) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511517032.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-10-13
Estimated Expiration
2045-10-23

AI Technical Summary

Benefits of technology

[0016]通过如上所提供的边缘识别方法、装置、电子设备及存储介质,本申请实施例通过获取包含目标对象的目标图像,对目标图像上的目标对象的边缘进行识别,得到至少一个数据对,然后针对每一数据对,调用与该数据对中的边缘标签对应的处理算法对该数据对中的边缘区域进行处理,得到边缘区域中边缘的识别结果,实现了对目标对象的边缘、角度以及中心的识别,可适用于芯片检测以及工业视觉中对边缘、角度以及中心进行高精度提取的应用场景。进一步地,通过对目标图像中目标对象的边缘进行分类识别,针对不同类型的边缘采用不同的算法进行处理,以提高边缘识别的准确性和效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120976251B_ABST
    Figure CN120976251B_ABST
Patent Text Reader

Abstract

The application discloses an edge recognition method and device, electronic equipment and a storage medium. The edge recognition method comprises the following steps: obtaining a target image containing a target object; recognizing the edge of the target object on the target image to obtain at least one data pair; each data pair comprises a corresponding edge region and an edge label; for each data pair, calling a processing algorithm corresponding to the edge label in the data pair to process the edge region in the data pair to obtain the recognition result of the edge in the edge region. Through the implementation of the application, the extraction of the edge, angle and center of the target object is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application generally relates to the field of computer vision technology. More specifically, this application relates to an edge recognition method, apparatus, electronic device, and storage medium. Background Technology

[0002] In modern industrial production and precision manufacturing, image processing and computer vision technologies have become core supporting technologies for ensuring product quality and improving production efficiency. Especially in chip inspection and industrial vision applications, high-precision extraction of the edges, angles, and centers of target objects is a prerequisite and foundation for subsequent critical processes such as defect detection, dimensional measurement, and positioning assembly. Therefore, there is an urgent need to provide an edge recognition method, device, electronic device, and storage medium to extract the edges, angles, and centers of target objects. Summary of the Invention

[0003] In order to at least solve one or more of the technical problems mentioned above, this application proposes an edge recognition method, apparatus, electronic device and storage medium in several aspects.

[0004] In a first aspect, this application provides an edge recognition method, comprising: acquiring a target image containing a target object; recognizing the edges of the target object on the target image to obtain at least one data pair; each data pair including a one-to-one corresponding edge region and an edge label; for each data pair, calling a processing algorithm corresponding to the edge label in the data pair to process the edge region in the data pair to obtain the edge recognition result in the edge region.

[0005] In some embodiments, the edge label includes: a flat edge, a rounded edge, and a notch.

[0006] In some embodiments, when the edge label is a flat edge, the processing algorithm corresponding to the edge label in the data pair is invoked to process the edge region in the data pair to obtain the edge recognition result in the edge region, including: performing a preprocessing operation on the edge region to obtain a first candidate region; performing a candidate contour extraction operation on the first candidate region and selecting a flat edge candidate contour from the extracted candidate contours; removing abnormal boundary points in the flat edge candidate contour to obtain a first boundary point sequence; calculating the slope at each boundary point in the first boundary point sequence to obtain a target gradient sequence; performing dilation and erosion operations on the target gradient sequence respectively, and determining a morphological gradient sequence based on the gradient sequence after dilation and the gradient sequence after erosion; comparing each morphological gradient in the morphological gradient sequence with a set threshold to obtain a flat edge region; and obtaining the flat edge angle of the flat edge based on the slope at each boundary point of the flat edge region.

[0007] In some embodiments, after selecting a flat-edge candidate contour from a plurality of extracted candidate contours, the method further includes: performing a morphological closing operation on the flat-edge candidate contour to repair the gaps in the flat-edge candidate contour.

[0008] In some embodiments, when the edge label is a notch, the processing algorithm corresponding to the edge label in the data pair is invoked to process the edge region in the data pair to obtain the edge recognition result in the edge region, including: performing a preprocessing operation on the edge region to obtain a second candidate region; performing a candidate contour extraction operation on the second candidate region, selecting a notch candidate contour from the extracted multiple candidate contours, and mapping the coordinates of each contour point in the notch candidate contour to the whole image coordinate system to obtain a second boundary point sequence; calculating the angle corresponding to each window based on the constructed first sliding window on the second boundary point sequence to obtain an angle sequence, and determining the bottom boundary point of the notch based on the angle sequence; calculating the initial direction angle at the bottom boundary point based on the line connecting the set point and the bottom boundary point, and calculating the candidate direction angle at each boundary point in the set neighborhood based on the line connecting the set point and the bottom boundary point in the set neighborhood; and calculating the target direction angle of the notch based on the initial direction angle and multiple candidate direction angles.

[0009] In some embodiments, when the edge label is an arc, the processing algorithm corresponding to the edge label in the data pair is invoked to process the edge region in the data pair to obtain the edge recognition result in the edge region, including: performing a preprocessing operation on the edge region to obtain a third candidate region; performing a candidate contour extraction operation on the third candidate region and selecting an arc candidate contour from the extracted multiple candidate contours; removing abnormal boundary points in the arc candidate contour to obtain a third initial boundary point sequence; filtering the vertical coordinates of the boundary points in each window based on the constructed second sliding window on the third initial boundary point sequence to obtain a third target boundary point sequence; and fitting the third target boundary point sequence using the least squares method to obtain the center coordinates and radius of the arc.

[0010] In some embodiments, after selecting an arc candidate contour from a plurality of extracted candidate contours, the method further includes: performing a morphological closing operation on the arc candidate contour to repair gaps in the arc candidate contour.

[0011] In some embodiments, the preprocessing operation includes at least one of binarization, inversion, and morphological opening.

[0012] In some embodiments, the binarization operation is an adaptive binarization operation; the preprocessing operation on the edge region includes: converting the edge region into a grayscale image and generating a histogram of the grayscale image; extracting a first brightness peak from a first sub-segment of the histogram and a second brightness peak from a second sub-segment of the histogram, and extracting a brightness valley between the first brightness peak and the second brightness peak; wherein the first sub-segment and the second sub-segment constitute the entire segment of the histogram; and performing binarization processing on the grayscale image based on the brightness valley.

[0013] In a second aspect, this application provides an edge recognition device, comprising: an image acquisition module for acquiring a target image containing a target object; an edge recognition module for recognizing the edges of the target object on the target image to obtain at least one data pair; each data pair including a one-to-one corresponding edge region and an edge label; and a recognition result acquisition result for processing the edge region in each data pair by calling a processing algorithm corresponding to the edge label in the data pair to obtain the edge recognition result in the edge region.

[0014] In a third aspect, this application provides an electronic device comprising: a processor configured to execute program instructions; and a memory configured to store the program instructions, which, when loaded and executed by the processor, cause the processor to perform an edge recognition method according to the first aspect or any of the embodiments of the first aspect.

[0015] In a fourth aspect, this application provides a computer-readable storage medium storing program instructions that, when loaded and executed by a processor, cause the processor to perform the edge recognition method according to the first aspect or any of the embodiments of the first aspect.

[0016] Using the edge recognition method, apparatus, electronic device, and storage medium provided above, embodiments of this application acquire a target image containing a target object, identify the edges of the target object in the target image to obtain at least one data pair, and then, for each data pair, call the processing algorithm corresponding to the edge label in that data pair to process the edge region in that data pair, obtaining the edge recognition result in the edge region. This achieves the recognition of the edges, angles, and centers of the target object, and is applicable to chip inspection and industrial vision applications requiring high-precision extraction of edges, angles, and centers. Furthermore, by classifying and recognizing the edges of the target object in the target image, different algorithms are used to process different types of edges to improve the accuracy and efficiency of edge recognition. Attached Figure Description

[0017] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, and the same or corresponding reference numerals denote the same or corresponding parts, wherein: Figure 1 An exemplary flowchart of an edge recognition method according to some embodiments of this application is shown; Figure 2 The following diagrams illustrate the effect of flat edge detection results in some embodiments of this application; Figure 3 The following diagrams illustrate the effect of notch detection results in some embodiments of this application; Figure 4 The following diagrams illustrate the effect of arc detection results in some embodiments of this application; Figure 5 An exemplary structural block diagram of an edge recognition device according to some embodiments of this application is shown; Figure 6 An exemplary structural block diagram of an electronic device according to some embodiments of this application is shown. Detailed Implementation

[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0019] It should be understood that the terms "comprising" and "including" used in the specification and claims of this application indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0020] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used in this specification and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this specification and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.

[0021] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0022] The specific embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0023] Exemplary application scenarios In modern industrial production and precision manufacturing, especially in chip inspection and industrial vision applications, high-precision extraction of the edges, angles, and centers of target objects is the prerequisite and foundation for subsequent key processes such as defect detection, dimensional measurement, and positioning assembly.

[0024] In view of this, embodiments of this application provide an edge recognition method to recognize the edges, angles, and center of a target object.

[0025] Figure 1 An exemplary flowchart of an edge recognition method 100 according to some embodiments of this application is shown. It is understood that the edge recognition method 100 described above can be executed by any suitable device with data processing capabilities, such as including but not limited to terminal devices, processors, and servers.

[0026] like Figure 1 As shown, the edge recognition method 100 includes: step S110: acquiring a target image containing the target object; step S120: recognizing the edges of the target object on the target image to obtain at least one data pair; step S130: for each data pair, calling the processing algorithm corresponding to the edge label in the data pair to process the edge region in the data pair to obtain the edge recognition result in the edge region.

[0027] For example, in step S110 above, the target object refers to the object that needs to be edge-recognized, such as a chip or mechanical part. The target image is an image containing the target object captured by an image acquisition device (e.g., a regular camera, an industrial camera, etc.), which can be a color image or a black and white image. This application embodiment does not specifically limit this.

[0028] In the embodiments of this application, the target image is directly acquired and transmitted by the image acquisition device, or it can be a saved image obtained directly from the storage device (e.g., hard disk, cloud). The embodiments of this application do not specifically limit the method of acquiring the target image, and can be determined according to the actual situation.

[0029] For example, in step S120 above, the data pair refers to an integration composed of two related elements. In this embodiment, the data pair includes a one-to-one corresponding edge region and an edge label. The edge region here refers to an image sub-region that includes the edge of the target object, which can be delineated by a rectangular box, a polygonal box, etc. The edge label refers to a mark used to identify the edge type, which is the basis for subsequent selection processing algorithms. In this embodiment, the edge label may include: flat edge, arc, and notch.

[0030] Here, a flat edge refers to an edge whose outline is approximately a straight line, and the tangent directions of each outline point are basically the same; an arc refers to an edge whose outline is part of a circle, and the tangent directions of each outline point change uniformly with position; a notch refers to an edge whose outline is recessed into the target object to form a notch-like edge, such as a V-shaped notch, a circular cut, or a groove.

[0031] In the embodiments of this application, there are many methods for identifying the edges of target objects on target images. For example, identification can be performed using AI models, or by setting algorithms (e.g., edge detection operators, gradient operators, etc.). The embodiments of this application do not specifically limit the methods for edge identification.

[0032] Taking AI model recognition as an example, the specific method for recognizing the edges of target objects in a target image can be to input the target image into a pre-trained recognition model, which will then locate and recognize the edges of the target objects in the target image and output at least one data pair.

[0033] In this embodiment, when there are multiple data pairs, the edge labels in the multiple data pairs can be the same or different. That is, a target object can include multiple different types of edges or only one type of edge. As a specific implementation of this application, the edge labels in the multiple data pairs can include only arcs, or they can include arcs and flat edges, or they can include notches and arcs.

[0034] For example, in step S130 above, each edge label corresponds to a processing algorithm, that is, the processing algorithm is a calculation method designed for a specific edge type, such as the angle calculation method for a flat edge, the center coordinates and radius calculation method for an arc, etc. Based on this, for each data pair, the processing algorithm corresponding to the edge label in the data pair is called to process the edge region in the data pair.

[0035] In the embodiments of this application, the above-mentioned recognition result refers to the quantitative description of the key features of the edge. Specifically, when the edge label is a flat edge, the recognition result is the flat edge angle; when the edge label is an arc, the recognition result is the center coordinates and radius of the arc; when the edge label is a notch, the recognition result is the direction angle of the notch.

[0036] Step S130: For each data pair, call the processing algorithm corresponding to the edge label in the data pair to process the edge region in the data pair and obtain the edge recognition result in the edge region.

[0037] This application embodiment acquires a target image containing the target object, identifies the edges of the target object in the target image to obtain at least one data pair, and then, for each data pair, calls the processing algorithm corresponding to the edge label in the data pair to process the edge region in the data pair, and obtains the edge recognition result in the edge region. This realizes the recognition of the edge, angle and center of the target object, and can be applied to chip inspection and industrial vision applications that require high-precision extraction of edges, angles and centers. Furthermore, the edge recognition method of this application embodiment can simultaneously recognize flat edges, arcs and notches, making it more versatile.

[0038] Furthermore, the embodiments of this application obtain edge regions through AI models and process edge regions through traditional image processing algorithms, which greatly reduces the risk of false detection. Moreover, the above-mentioned AI models can run directly on the CPU of the device without the need for additional dedicated graphics cards, resulting in low edge recognition costs.

[0039] The following describes the processing methods for edge areas with flat edges, notches, and rounded edges: As an optional embodiment of this application, when the edge label is a flat edge, the processing algorithm corresponding to the edge label in the data pair is called to process the edge region in the data pair to obtain the edge recognition result in the edge region, including: performing a preprocessing operation on the edge region to obtain a first candidate region; performing a candidate contour extraction operation on the first candidate region and selecting a flat edge candidate contour from the extracted candidate contours; removing abnormal boundary points in the flat edge candidate contour to obtain a first boundary point sequence; calculating the slope at each boundary point in the first boundary point sequence to obtain a target gradient sequence; performing dilation and erosion operations on the target gradient sequence respectively, and determining a morphological gradient sequence based on the gradient sequence after dilation and the gradient sequence after erosion; comparing each morphological gradient in the morphological gradient sequence with a set threshold to obtain a flat edge region; and obtaining the flat edge angle of the flat edge based on the slope at each boundary point of the flat edge region.

[0040] For example, to simplify subsequent processing and highlight edge features, preprocessing is required for the edge region, i.e., the preprocessing operation described above. In this embodiment, the preprocessing operation may include at least one of binarization, inversion, and morphological opening. As a specific embodiment of this application, the preprocessing operation for flat-edge regions includes binarization and morphological opening.

[0041] In this embodiment of the application, in order to facilitate processing, the edge region can be cropped from the target image before performing preprocessing operations on the edge region, and then the edge region can be preprocessed to obtain the first candidate region.

[0042] Taking preprocessing operations including binarization and morphological opening as an example, the binarization operation here refers to adaptive binarization. Specifically, adaptive binarization of edge regions can be performed as follows: converting the edge region to a grayscale image and generating a histogram of the grayscale image; extracting a first brightness peak from the first sub-segment of the histogram and a second brightness peak from the second sub-segment of the histogram, and extracting a brightness valley value between the first and second brightness peaks; wherein the first and second sub-segments constitute the entire interval of the histogram; and performing binarization processing on the grayscale image based on the brightness valley value.

[0043] For example, a grayscale image refers to an image where each pixel in the edge region includes only brightness information, and the pixel value is within the range of 0 (black) to 255 (white). A histogram refers to the distribution of the number of pixels with each grayscale value (0~255) in a grayscale image, with the grayscale value on the horizontal axis and the number of pixels on the vertical axis.

[0044] It should be noted that the methods described above for converting edge regions to grayscale images and generating histograms of grayscale images are conventional methods, which can be found in relevant literature and will not be elaborated here.

[0045] For example, in this embodiment of the application, the entire interval of the histogram is divided into two sub-intervals, referred to as the first sub-interval and the second sub-interval, respectively. For example, the first sub-interval refers to the interval with lower gray values, such as the interval with pixel values ​​ranging from 0 to 127, and the second sub-interval refers to the interval with higher gray values, such as the interval with pixel values ​​ranging from 128 to 255.

[0046] In this embodiment, the first brightness peak value refers to the grayscale value with the most pixels in the first sub-interval; the second brightness peak value refers to the grayscale value with the most pixels in the second sub-interval; and the brightness valley value refers to the grayscale value with the fewest pixels between the first brightness peak value and the second brightness peak value.

[0047] For example, in the embodiments of this application, binarizing a grayscale image based on the brightness valley value can be done by directly using the brightness valley value as a segmentation threshold, or by optimizing the brightness valley value and using the optimized brightness valley value as a segmentation threshold. This application does not specifically limit the approach in this regard.

[0048] In the embodiments of this application, there are many methods to optimize the brightness valley value. For example, a brightness threshold is set in advance. If the brightness valley value is less than the brightness threshold, the brightness threshold is used as the segmentation threshold. If the brightness valley value is greater than or equal to the brightness threshold, the brightness valley value is used as the segmentation threshold.

[0049] In this embodiment of the application, the binarization of the grayscale image can be specifically performed as follows: for each pixel in the grayscale image, if its pixel value is greater than the segmentation threshold, the pixel value of the pixel is set to 255; if its pixel value is less than or equal to the segmentation threshold, the pixel value of the pixel is set to 0.

[0050] This application embodiment uses adaptive binarization to binarize the grayscale image, thereby separating the background and foreground and highlighting the edge features of the target.

[0051] As for the other preprocessing operation, morphological opening, it refers to performing erosion on the image first, followed by dilation, in order to remove small noise points in the image.

[0052] This application embodiment obtains a noise-suppressed binary image (i.e., the first candidate region) by performing adaptive binarization and morphological opening operations on the edge image. That is, by introducing intelligent thresholding and morphological preprocessing, a stable contour can still be obtained in scenes with weak contrast or burrs.

[0053] For example, after preprocessing the edge region to obtain the first candidate region, a candidate contour extraction operation is performed on the first candidate region. Here, a conventional contour tracking algorithm can be used to extract all possible continuous pixel sequences that constitute the edge from the first candidate region, i.e., candidate contours. Then, a flat-edge candidate contour is selected from the extracted candidate contours. Specifically, the candidate contour with the largest area can be selected as the flat-edge candidate contour.

[0054] Of course, in the above scheme, after selecting the flat-edge candidate contours, morphological closing operations can be performed on the flat-edge candidate contours to repair the gaps in the flat-edge candidate contours (i.e., discontinuous parts in the flat-edge candidate contours caused by noise or image blur). The morphological closing operation here is also a morphological image processing operation, which is composed of dilation and erosion operations. In contrast to the morphological opening operation, it first performs a dilation operation to expand the boundary of the flat-edge candidate contour to fill the gaps, and then performs an erosion operation to restore the contour size, ultimately repairing the gaps in the flat-edge candidate contours and making the flat-edge candidate contours more continuous.

[0055] This application embodiment ensures the integrity of the flat-edge candidate contour by performing a morphological closing operation on the flat-edge candidate contour, thus avoiding misjudgment caused by edge breakage.

[0056] For example, after obtaining the flat-edge candidate contour or the repaired flat-edge candidate contour (both collectively referred to as flat-edge candidate contour), abnormal boundary points in the flat-edge candidate contour are removed to obtain a stable first boundary point sequence. Here, abnormal boundary points refer to pixels in the flat-edge candidate contour that deviate from the overall trend due to noise. By removing abnormal boundary points in the flat-edge candidate contour, this embodiment of the application significantly reduces the fluctuation of the recognition results caused by individual noise points or defects, and improves the accuracy of the recognition results.

[0057] Then, a one-dimensional gradient sequence is constructed based on the first boundary point sequence. Specifically, for each boundary point in the first boundary point sequence, the slope at that boundary point is calculated to obtain the target gradient sequence. In this embodiment, for each boundary point in the first boundary point sequence, when calculating the slope at that boundary point, adjacent boundary points can be taken to the left or right of that boundary point, and then the slope at that boundary point is calculated according to the conventional slope calculation formula. The slopes at each boundary point constitute the aforementioned target gradient sequence.

[0058] After obtaining the target gradient sequence, dilation and erosion operations are performed on the target gradient sequence. That is, dilation and erosion operations are performed on each element in the target gradient sequence to obtain the dilated gradient sequence and the eroded gradient sequence. Then, the morphological gradient sequence is determined based on the gradient sequence after the dilation operation (i.e., the above-mentioned dilated gradient sequence) and the gradient sequence after the erosion operation (i.e., the eroded gradient sequence). Specifically, the sequence obtained by the difference between the dilated gradient sequence and the eroded gradient sequence is used as the morphological gradient sequence, which can reflect the regions of drastic change in the gradient sequence.

[0059] Then, each morphological gradient in the morphological gradient sequence is compared with a preset threshold, which is pre-defined, for example, 0.01. In this embodiment, regions with morphological gradients less than the preset threshold are defined as flat-edge regions. By using the gradient morphological difference as a flat-edge discrimination index, this embodiment can effectively suppress interference from burrs, jagged edges, and textures, resulting in stronger robustness in flat-edge recognition.

[0060] In this embodiment of the application, after obtaining the flat edge region, the flat edge angle can be obtained based on the slope at each boundary point of the flat edge region. Specifically, the average slope of each boundary point of the flat edge region is taken, and then the average slope is converted into an angle through the arctangent function (arctan (slope)) to obtain the flat edge angle. Compared with taking the angle of a single point, the method for determining the flat edge angle in this embodiment of the application has a smaller error in obtaining the flat edge angle.

[0061] Figure 2 The following are example diagrams illustrating the effects of flat edge detection results in some embodiments of this application, such as... Figure 2 As shown, Figure 2 The angle of the horizontal side in the left-hand diagram is -25.233449 degrees. Figure 2 The angle of the flat side in the middle right figure is -24.254350 degrees.

[0062] As an optional embodiment of this application, when the edge label is a notch, the processing algorithm corresponding to the edge label in the data pair is called to process the edge region in the data pair to obtain the edge recognition result in the edge region, including: performing a preprocessing operation on the edge region to obtain a second candidate region; performing a candidate contour extraction operation on the second candidate region, selecting the notch candidate contour from the extracted multiple candidate contours, and mapping the coordinates of each contour point in the notch candidate contour to the whole image coordinate system to obtain a second boundary point sequence; calculating the angle corresponding to each window based on the constructed first sliding window on the second boundary point sequence to obtain an angle sequence, and determining the bottom boundary point of the notch based on the angle sequence; calculating the initial direction angle at the bottom boundary point based on the line connecting the set point and the bottom boundary point, and calculating the candidate direction angle at each boundary point in the set neighborhood based on the line connecting the set point and the bottom boundary point; and calculating the target direction angle of the notch based on the initial direction angle and multiple candidate direction angles.

[0063] For example, similar to the case where the edge label is a flat edge, to facilitate processing, the edge region can be cropped from the target image before performing preprocessing operations on the edge region, and then preprocessing operations can be performed on the edge region to obtain the second candidate region. The preprocessing operations here can include: binarization, inversion, and morphological opening. The specific implementation methods and effects of the binarization and morphological opening operations are the same as those for the case where the edge label is a flat edge, and can be found in the description of the above embodiment, which will not be repeated here.

[0064] The inversion operation can be performed after the binarization operation and before the morphological opening operation. In the embodiments of this application, by performing the inversion operation on the binarized image after the binarization operation and before the morphological opening operation, small interference contours (e.g., small black dots) can be filtered out, and only larger areas can be retained.

[0065] Furthermore, the method of performing candidate contour extraction on the second candidate region and selecting the notch candidate contour from the extracted candidate contours is the same as the method of determining the flat edge candidate contour when the edge label is a flat edge. Please refer to the description in the above embodiment, which will not be repeated here.

[0066] In this embodiment of the application, the whole image coordinate system refers to the image coordinate system of the target image. The coordinates of each contour point in the notch candidate contour obtained above refer to their coordinates in the image coordinate system of the edge region. Specifically, mapping the coordinates of each contour point in the notch candidate contour to the whole image coordinate system can be done by multiplying the coordinates of each contour point in the notch candidate contour with the pre-calibrated mapping matrix (including rotation matrix and offset matrix) to map the coordinates of each contour point in the notch candidate contour to the whole image coordinate system, thereby obtaining the second boundary point sequence. Here, the coordinates of each contour point in the second boundary point sequence refer to their coordinates in the whole image coordinate system.

[0067] In the embodiments of this application, the aforementioned first sliding window refers to a window of a fixed length that has been set in advance, such as a window composed of 5 consecutive boundary points, or for example, a window composed of 3 consecutive boundary points. The embodiments of this application do not specifically limit this.

[0068] Based on this, on the second boundary point sequence, the angle corresponding to each window is calculated based on the first sliding window mentioned above. Here, the angle corresponding to the window refers to the angle between the center point of the window and the three points formed by its left and right neighboring points. The first sliding window slides on the second boundary point sequence, and finally calculates the angle sequence. It can detect the angle with the largest local change, which is convenient for locating the bottom boundary point of the notch. Specifically, the position corresponding to the smallest angle in the angle sequence can be taken as the bottom boundary point of the notch.

[0069] For example, in the embodiments of this application, the setting point can be set in many ways. For example, it can be a fixed point set in advance, or it can be the center of the arc in the target image. The embodiments of this application do not specifically limit this. The embodiments of this application only describe the setting point as the center of the arc in the target image. The method for determining the center of the arc can be found in the description of the embodiments below, which will not be repeated here.

[0070] In this embodiment, the arctangent value of the line connecting the set point and the bottom boundary point (i.e., the vector) is calculated and used as the initial direction angle at the bottom boundary point. Similarly, candidate direction angles at each boundary point within the set neighborhood can be calculated based on the line connecting the set point and the bottom boundary point. This set neighborhood can be predefined, for example, within a 25-pixel range from the bottom boundary point. This embodiment does not specifically limit the set neighborhood and can determine it according to actual conditions.

[0071] Then, the target orientation angle of the notch is calculated based on the initial orientation angle and multiple candidate orientation angles. For example, the average of the initial orientation angle and multiple candidate orientation angles can be used as the target orientation angle of the notch. This embodiment of the application significantly improves the stability of the target orientation angle of the notch under noise and boundary defects by combining the initial orientation angle of the bottom boundary point with "neighborhood statistics".

[0072] Figure 3 The diagram shows example illustrations of the notch detection results for some embodiments of this application. For example... Figure 3 As shown, Figure 3 The orientation angle of the left image is -10.001385 degrees; Figure 3 The orientation angle of the image on the right is 14.069721.

[0073] As an optional embodiment of this application, when the edge label is an arc, the processing algorithm corresponding to the edge label in the data pair is called to process the edge region in the data pair to obtain the edge recognition result in the edge region, including: performing a preprocessing operation on the edge region to obtain a third candidate region; performing a candidate contour extraction operation on the third candidate region and selecting an arc candidate contour from the extracted multiple candidate contours; removing abnormal boundary points in the arc candidate contour to obtain a third initial boundary point sequence; filtering the vertical coordinates of the boundary points in each window based on the constructed second sliding window on the third initial boundary point sequence to obtain a third target boundary point sequence; and fitting the third target boundary point sequence using the least squares method to obtain the center coordinates and radius of the arc.

[0074] For example, similar to the case where the edge label is a flat edge, to facilitate processing, the edge region can be cropped from the target image before preprocessing, and then preprocessed to obtain a third candidate region. When the edge label is an arc, the preprocessing operations can include binarization and morphological opening. The specific implementation and effects of the binarization and morphological opening operations are the same as when the edge label is a flat edge, and can be found in the description of the above embodiment, which will not be repeated here.

[0075] Furthermore, the method of extracting candidate contours for the second candidate region, selecting the notch candidate contour from the extracted candidate contours, and removing abnormal boundary points from the arc candidate contour to obtain the third initial boundary point sequence is the same as the method of determining the flat edge candidate contour and the first boundary point sequence when the edge label is a flat edge. Please refer to the description of the above embodiment, which will not be repeated here.

[0076] It should be noted that after selecting the arc candidate contour from the extracted candidate contours, a morphological closing operation can be performed on the arc candidate contour to repair the gaps in the arc candidate contour. Specific implementation methods and effects can be found in the description of the above embodiments, and will not be repeated here.

[0077] In this embodiment, after obtaining the third initial boundary point sequence, the vertical coordinates of the boundary points within each window can be filtered based on the pre-constructed second sliding window to obtain the third target boundary point sequence. The aforementioned second sliding window is a pre-defined fixed-length window, such as a window with 7 consecutive boundary points, a window with 5 consecutive boundary points, etc.

[0078] There are many methods for filtering the vertical coordinates (i.e., the Y-axis coordinates in the image coordinate system) of boundary points within each window, such as median filtering, mean filtering, etc., and this application embodiment does not specifically limit this method. This application embodiment can use median filtering (i.e., taking the median of the vertical coordinates of the boundary points within each window and using this median to replace the vertical coordinate of the window center) to remove noise fluctuations in the vertical coordinates and obtain a smooth sequence of third target boundary points. This application embodiment filters the vertical coordinates of boundary points by median filtering, reducing interference from local burrs and false edges, making the arc contour more continuous and stable.

[0079] For example, in the embodiments of this application, the least squares method is a method for finding the best-fit curve of data by minimizing the sum of squares of errors; the center coordinates of the arc refer to the center coordinates of the circle in which the arc is located, and the radius refers to the radius of the circle in which the arc is located.

[0080] Understandably, using the least squares method to fit the sequence of boundary points of the third target to obtain the center coordinates and radius of the arc is a conventional method, which can be found in relevant literature and will not be elaborated here.

[0081] Figure 4 The diagram shows example illustrations of the results of arc detection according to some embodiments of this application. For example... Figure 4 As shown, Figure 4 The center of the arc in the left image is (630, -713), and the radius is 1164; Figure 4 The center of the arc in the right-hand image is (740, -1748), and the radius is 2608.

[0082] Figure 5 An exemplary structural block diagram of an edge recognition device 500 according to some embodiments of this application is shown.

[0083] like Figure 5As shown, the edge recognition device 500 includes: an image acquisition module 510 for acquiring a target image containing a target object; an edge recognition module 520 for recognizing the edges of the target object in the target image to obtain at least one data pair; each data pair includes a one-to-one corresponding edge region and an edge label; and a recognition result acquisition result 530 for processing the edge region in each data pair by calling the processing algorithm corresponding to the edge label in the data pair to obtain the edge recognition result in the edge region.

[0084] As an optional embodiment of this application, the edge label includes: a flat edge, a rounded edge, and a notch.

[0085] As an optional embodiment of this application, when the edge label is a flat edge, the recognition result 530 is specifically used for: performing a preprocessing operation on the edge region to obtain a first candidate region; performing a candidate contour extraction operation on the first candidate region, and selecting a flat edge candidate contour from the extracted candidate contours; removing abnormal boundary points in the flat edge candidate contour to obtain a first boundary point sequence; calculating the slope at each boundary point in the first boundary point sequence to obtain a target gradient sequence; performing dilation and erosion operations on the target gradient sequence respectively, and determining a morphological gradient sequence based on the gradient sequence after dilation and the gradient sequence after erosion; comparing each morphological gradient in the morphological gradient sequence with a set threshold to obtain a flat edge region; and obtaining the flat edge angle of the flat edge based on the slope at each boundary point of the flat edge region.

[0086] As an optional embodiment of this application, after selecting the flat-edge candidate contour from the extracted multiple candidate contours, the edge recognition device further includes: a first repair module, used to perform a morphological closing operation on the flat-edge candidate contour to repair the gap in the flat-edge candidate contour.

[0087] As an optional embodiment of this application, when the edge label is a notch, the recognition result 530 is specifically used for: performing preprocessing operations on the edge region to obtain a second candidate region; performing candidate contour extraction operations on the second candidate region, selecting the notch candidate contour from the extracted candidate contours, and mapping the coordinates of each contour point in the notch candidate contour to the whole image coordinate system to obtain a second boundary point sequence; calculating the angle corresponding to each window based on the constructed first sliding window on the second boundary point sequence to obtain an angle sequence, and determining the bottom boundary point of the notch based on the angle sequence; calculating the initial direction angle at the bottom boundary point based on the line connecting the set point and the bottom boundary point, and calculating the candidate direction angle at each boundary point in the set neighborhood based on the line connecting the set point and the bottom boundary point in the set neighborhood; and calculating the target direction angle of the notch based on the initial direction angle and multiple candidate direction angles.

[0088] As an optional embodiment of this application, when the edge label is an arc, the recognition result 530 is specifically used for: performing preprocessing operations on the edge region to obtain a third candidate region; performing candidate contour extraction operations on the third candidate region and selecting an arc candidate contour from the extracted candidate contours; removing abnormal boundary points in the arc candidate contour to obtain a third initial boundary point sequence; filtering the vertical coordinates of the boundary points in each window based on the constructed second sliding window on the third initial boundary point sequence to obtain a third target boundary point sequence; and fitting the third target boundary point sequence using the least squares method to obtain the center coordinates and radius of the arc.

[0089] As an optional embodiment of this application, after selecting the arc candidate contour from the extracted multiple candidate contours, the edge recognition device further includes: a second repair module, used to perform a morphological closing operation on the arc candidate contour to repair the gap in the arc candidate contour.

[0090] As an optional embodiment of this application, the preprocessing operation includes at least one of the following: binarization operation, inversion operation, and morphological opening operation.

[0091] As an optional embodiment of this application, the binarization operation is an adaptive binarization operation; the preprocessing operation on the edge region includes: converting the edge region into a grayscale image and generating a histogram of the grayscale image; extracting a first brightness peak from a first sub-segment of the histogram and a second brightness peak from a second sub-segment of the histogram, and extracting a brightness valley value between the first brightness peak and the second brightness peak; wherein the first sub-segment and the second sub-segment constitute the entire interval of the histogram; and performing binarization processing on the grayscale image based on the brightness valley value.

[0092] Correspondingly, embodiments of this application also provide Figure 5 The hardware structure diagram of the device shown is as follows: Figure 6 As shown, the electronic device 600 can be a device that implements the edge recognition method 100 described above. For example... Figure 6 As shown, the electronic device 600 includes a processor 610 and a memory 620. The memory 620 is configured to store program instructions; the processor 610 is configured to load and execute the program instructions stored in the memory 620 to implement an embodiment of the edge recognition method 100 as shown above.

[0093] As one embodiment, memory 620 can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as program instructions, data, etc. For example, memory 620 can be volatile memory, non-volatile memory, or similar storage media. Specifically, memory 620 can be RAM (Random Access Memory), flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.

[0094] This concludes the process. Figure 6 Description of the electronic device shown.

[0095] While numerous embodiments of this application have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will arise for those skilled in the art without departing from the spirit and intent of this application. It should be understood that various alternatives to the embodiments of this application described herein may be employed in the practice of this application. The appended claims are intended to define the scope of protection of this application and therefore cover equivalents or alternatives within the scope of these claims.

Claims

1. An edge recognition method, characterized in that, include: Get the target image containing the target object; The target image is input into a pre-trained recognition model, which identifies the edges of the target object in the target image and outputs a classification result indicating the geometric category of the edge, resulting in at least one data pair, which are different; each data pair includes a one-to-one corresponding edge region and an edge label. The edge labels include: flat edges, rounded edges, and notches; For each data pair, based on the edge label corresponding to the classification result, the processing algorithm corresponding to the edge label in the data pair is invoked to process the edge region in the data pair, thereby obtaining the edge recognition result in the edge region; wherein, the recognition result is the geometric parameter corresponding to the edge label. When the edge label is a flat edge, the recognition result is the flat edge angle; when the edge label is an arc, the recognition result is the center coordinates and radius of the arc; when the edge label is a notch, the recognition result is the direction angle of the notch.

2. The method according to claim 1, characterized in that, When the edge label is notched, the processing algorithm corresponding to the edge label in the data pair is invoked to process the edge region in the data pair, obtaining the edge recognition result in the edge region, including: The edge region is preprocessed to obtain the second candidate region; Perform candidate contour extraction on the second candidate region, select the notch candidate contour from the multiple extracted candidate contours, and map the coordinates of each contour point in the notch candidate contour to the whole image coordinate system to obtain the second boundary point sequence. On the second boundary point sequence, the angle corresponding to each window is calculated based on the constructed first sliding window to obtain an angle sequence, and the bottom boundary point of the notch is determined based on the angle sequence; wherein, the angle corresponding to each window is determined by the included angle of three points formed by the center point of the window and its left and right neighboring points; The initial orientation angle at the bottom boundary point is calculated based on the line connecting the set point and the bottom boundary point, and the candidate orientation angle at each boundary point in the set neighborhood is calculated based on the line connecting the set point and each boundary point in the set neighborhood. The target direction angle of the notch is calculated based on the initial direction angle and multiple candidate direction angles.

3. The method according to claim 1, characterized in that, When the edge label is a flat edge, the processing algorithm corresponding to the edge label in the data pair is invoked to process the edge region in the data pair, and the edge recognition result in the edge region is obtained, including: The edge region is preprocessed to obtain the first candidate region; Perform candidate contour extraction on the first candidate region, and select the flat-edge candidate contour from the extracted candidate contours. Abnormal boundary points in the flat-edge candidate contours are removed to obtain the first boundary point sequence; For each boundary point in the first boundary point sequence, calculate the slope at that boundary point to obtain the target gradient sequence; Dilation and erosion operations are performed on the target gradient sequence, and the morphological gradient sequence is determined based on the gradient sequence after dilation and the gradient sequence after erosion. Each morphological gradient in the morphological gradient sequence is compared with a set threshold to obtain a flat-edge region; The flat-side angle is obtained based on the slope at each boundary point of the flat-side region.

4. The method according to claim 3, characterized in that, After selecting the flat-edge candidate contour from the extracted candidate contours, the method further includes: A morphological closing operation is performed on the flat-edge candidate contour to repair the gaps in the flat-edge candidate contour.

5. The method according to claim 1, characterized in that, When the edge label is an arc, the processing algorithm corresponding to the edge label in the data pair is invoked to process the edge region in the data pair, obtaining the edge recognition result in the edge region, including: The edge region is preprocessed to obtain the third candidate region; Perform candidate contour extraction on the third candidate region, and select the arc candidate contour from the extracted candidate contours; Abnormal boundary points in the candidate arc contour are removed to obtain the third initial boundary point sequence; On the third initial boundary point sequence, the vertical coordinates of the boundary points in each window are filtered based on the constructed second sliding window to obtain the third target boundary point sequence. The least squares method is used to fit the sequence of boundary points of the third target to obtain the center coordinates and radius of the arc.

6. The method according to claim 5, characterized in that, After selecting the arc candidate contour from the extracted candidate contours, the method further includes: A morphological closing operation is performed on the candidate arc contour to repair the gaps in the candidate arc contour.

7. The method according to any one of claims 2-6, characterized in that, The preprocessing operations include at least one of binarization, inversion, and morphological opening.

8. The method according to claim 7, characterized in that, The binarization operation is an adaptive binarization operation; the preprocessing operation on the edge region includes: The edge region is converted into a grayscale image, and a histogram of the grayscale image is generated; A first brightness peak is extracted from the first sub-segment of the histogram, and a second brightness peak is extracted from the second sub-segment of the histogram. A brightness valley is extracted between the first brightness peak and the second brightness peak. The first sub-segment and the second sub-segment constitute the entire segment of the histogram. The grayscale image is binarized based on the brightness valley value.

9. An edge recognition device, characterized in that, include: The image acquisition module is used to acquire a target image containing the target object; An edge recognition module is used to input the target image into a pre-trained recognition model, which identifies the edges of the target object in the target image and outputs a classification result indicating the geometric category of the edge, resulting in at least one data pair; the at least one data pair is different; each data pair includes a one-to-one corresponding edge region and an edge label; The edge labels include: flat edges, rounded edges, and notches; The recognition result acquisition module is used to, for each data pair, call the processing algorithm corresponding to the edge label in the data pair to process the edge region in the data pair according to the edge label corresponding to the classification result, and obtain the recognition result of the edge in the edge region; wherein, the recognition result is the geometric parameters corresponding to the edge label; when the edge label is a flat edge, the recognition result is the flat edge angle; when the edge label is an arc, the recognition result is the center coordinates and radius of the arc; when the edge label is a notch, the recognition result is the direction angle of the notch.

10. An electronic device, characterized in that, include: A processor, configured to execute program instructions; as well as A memory configured to store the program instructions, which, when loaded and executed by the processor, cause the processor to perform the edge recognition method according to any one of claims 1-8.

11. A computer-readable storage medium storing program instructions, characterized in that, When the program instructions are loaded and executed by the processor, the processor performs the edge recognition method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Semantic edge detection method, device and equipment based on dynamic feature fusion

    CN112465848A

  • Data enhancement system for battery welding anomaly detection

    CN116630308A

  • Image processing method and device and related equipment

    CN117237681A

  • Photovoltaic module defect intelligent identification and positioning method and system based on multi-modal image

    CN120182288A