A method for detecting workpiece marking position based on image processing
By extracting and classifying edges in the workpiece image processing, calculating the importance and effectiveness of corner points, and filtering feature corner points for matching, the inaccurate corner detection problem caused by scratches and lighting problems in the workpiece image is solved, and the accuracy and reliability of marking position detection is improved.
Patent Information
- Application Number
- CN202510027572.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-01-08
AI Technical Summary
In the prior art, when processing workpiece images, corner point detection is inaccurate when facing scratches and poor lighting conditions, resulting in the accuracy and reliability of marking position detection results.
By collecting the surface image of the workpiece, extracting and dividing the edges into straight edges and shifted edges, calculating the characterization importance and characterization effectiveness of each corner point, filtering out the characteristic corner points with high comprehensive characterization values for matching, and determining the marking position.
It effectively avoids the interference of diagonal point recognition by scratches and lighting problems, improves the matching accuracy of workpiece images and template images, and ensures the accuracy and reliability of marking position detection.
Smart Images

Figure CN119444862B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a workpiece marking position detection method based on image processing. Background Art
[0002] In the field of modern manufacturing and commodity circulation, marking is a key process for imprinting logos such as text, patterns, barcodes, etc. on products or their packaging through physical or chemical means. It plays a vital role in the effective management, brand building and market circulation of products. The accuracy of the marking position is of great significance and is directly related to the effectiveness and recognizability of the product logo. Therefore, it is necessary to detect the marking position to effectively guarantee the quality of the engraved logo.
[0003] The prior art usually performs corner detection on the workpiece to be marked, matches the corner detection result with the template image, and then determines the marking position. The ORB (Oriented FAST and Rotated BRIEF) algorithm is a common corner detection algorithm. For example, the existing Chinese patent document with the announcement number CN108171734B discloses a method and device for ORB feature extraction and matching. First, the original image is converted into a grayscale image, and FAST corners, HARRIS corners are extracted, the centroid is calculated, and Gaussian blur is performed to output the key information of the feature points and the Gaussian blurred image. The image is downsampled to obtain multiple sets of key information of feature points and Gaussian blurred images. Then, the descriptor information corresponding to the feature points is calculated, and the descriptor information of the two frames of images is feature matched to obtain the ORB feature matching result.
[0004] However, in actual application scenarios, when faced with various complex situations on the surface of the workpiece image, such as scratches caused by friction and collision during the production process, or reflections caused by the material characteristics of the workpiece surface and poor lighting conditions, the ORB algorithm is used to detect the corner points of the workpiece image. These surface defects and poor lighting conditions will interfere with the algorithm's accurate recognition of the corner points, resulting in some of the extracted corner points being unable to truly and accurately reflect the actual position and shape characteristics of the workpiece. Such corner points will make the matching results between the workpiece image and the template image inaccurate, thereby affecting the accuracy and reliability of the workpiece marking position detection results. Summary of the invention
[0005] In order to solve the problem that when there are scratches and poor lighting conditions on the surface of the workpiece image, there will be corner points that cannot correctly represent the position of the workpiece, resulting in inaccurate matching results between the workpiece image and the template image, affecting the accuracy and reliability of the workpiece marking position detection result, the present invention proposes a workpiece marking position detection method based on image processing, comprising:
[0006] The surface image of the workpiece is collected as the target image, all edges and corner points of the target image are extracted, all edges are divided into straight edges and direction-changing edges, and the minimum belonging distance of each straight edge and the arc factor of each direction-changing edge in the neighborhood edge set of each corner point of the target image are determined;
[0007] Calculate the representation importance of each corner point of the target image based on the minimum belonging distance and the arc factor; the representation importance is positively correlated with the sum of the minimum belonging distances of all straight edges in the neighborhood edge set of the corner point and the arc factors of all turning edges;
[0008] The distance sequence of each corner point is formed by the distance between each corner point and other corner points in the target image and the template image, and the representation effectiveness of each corner point of the target image is calculated: , The target image is The representation effectiveness of the corner points, The target image is The distance sequence of the corner points and the distance sequence of all corner points of the template image The collection of distances, To take the minimum value;
[0009] Calculate the comprehensive representation value of each corner point of the target image , The target image is The comprehensive representation value of the corner points, The target image is The characterization importance of each corner point is determined. The characteristic corner points of the target image are screened out according to the size of the comprehensive characterization value. The characteristic corner points are matched with the template image, and the workpiece marking position is determined according to the corner point matching results.
[0010] The method for obtaining the arc factor of each direction-changing edge is:
[0011] Obtain the second-order difference sequence of the chain code of all the direction-changing edges for linear normalization, and take the sum of the absolute values of the linearly normalized second-order difference sequence of each direction-changing edge as the arc factor of each direction-changing edge;
[0012] The minimum belonging distance of each straight edge is obtained as follows:
[0013] The minimum distance between each endpoint of each straight edge and any endpoint of all other straight edges is taken as the minimum belonging distance of the straight edge.
[0014] The above technical solution further refines the classification of edges by distinguishing between straight edges and turning edges of the target image, which helps to describe image features more accurately. Determining the minimum belonging distance of straight edges and the arc factor of turning edges in the edge set of each corner point neighborhood is to explore more detailed geometric feature information around the corner points. These feature information can reflect the characteristics of the local area where the corner points are located from a microscopic level. And further, the minimum belonging distance of straight edges and the arc factor of turning edges are used to quantify the representation importance of each corner point. This representation importance is a measurement indicator obtained after comprehensively considering the related features of different types of edges in the neighborhood of the corner point. The numerical size of this indicator can reflect those corner points that are truly important for determining the marking position, and weaken the influence of inaccurate corner points caused by interference factors such as surface defects.
[0015] Furthermore, from the perspective of the overall corner point relationship between the target image and the template image, by constructing a distance sequence between the corner points and using the dynamic time warping distance to measure the difference between different corner point distance sequences, the representation effectiveness of each corner point is calculated. The representation effectiveness aims to reflect the degree of conformity between each corner point in the target image and the corresponding corner point in the template image in terms of positional relationship, that is, to measure the effectiveness of the corner point in the process of matching with the template, and further evaluate the quality of the corner point from the perspective of matching. Furthermore, the comprehensive representation value integrates the representation importance and representation effectiveness calculated previously. It is a comprehensive indicator obtained by comprehensively considering the two key dimensions of the importance of the corner point's own local geometric features and the effectiveness of matching with the template image. By screening feature corner points based on the size of the comprehensive characterization value, that is, selecting those corner points that are important in the local feature level of the image and have a high degree of fit with the template matching level from among many corner points, and then using these screened high-quality corner points to match the template image, and finally determining the workpiece marking position. In this way, the problem of inaccurate corner points caused by adverse factors such as scratches and reflections can be effectively overcome, and the multi-faceted feature information of the corner points is fully utilized to make the entire marking position determination process more rigorous and reliable, so that the final determined marking position is more in line with the actual situation of the workpiece, and the accuracy and reliability of marking position detection are improved.
[0016] Preferably, the method of dividing all edges into straight edges and redirected edges is:
[0017] The edge whose fluctuation factor is less than the preset fluctuation factor threshold is classified as a straight edge, and the edge whose fluctuation factor is not less than the preset fluctuation factor threshold is classified as a turning edge; the fluctuation factor is obtained by:
[0018] The differential sequence of the chain code of each edge is obtained, and the first-order differential sequence of the chain code of all edges is linearly normalized. Then, the sum of the absolute values of each value of the linearly normalized differential sequence of each edge is taken as the fluctuation factor of each edge.
[0019] The above technical solution uses the fluctuation factor threshold to divide straight edges and changing edges, which can more accurately distinguish edges with different characteristics. For some workpiece images with complex surface textures and changeable shapes, it can effectively identify relatively simple and stable parts (straight edges) and parts with obvious changes (changing edges) from many edges, thereby enhancing the distinction of edge features in the image. At the same time, the above technical solution can well capture the local change characteristics of the edge by obtaining the first-order difference sequence of the chain code of each edge. The chain code itself is a coding method for representing the boundary shape. The difference sequence further emphasizes the changes between adjacent chain code elements on this basis. This change can serve as an important clue to the change of edge shape and helps to accurately describe the morphological details of the edge.
[0020] Preferably, the method for obtaining the neighborhood edge set of each corner point of the target image is:
[0021] With each corner point as the center, draw a circle according to the preset neighborhood radius to obtain the neighborhood range of each corner point; if any number of pixel points of a certain edge are located in the neighborhood range, the edge is used as the neighborhood edge of the corner point, and the neighborhood edge set of each corner point is obtained in this way.
[0022] Preferably, the distance sequence of each corner point is a sequence of Euclidean distances between each corner point and other corner points, which is formed by arranging the distances in ascending order.
[0023] The above technical solution helps to deeply explore the correlation between corner points by constructing such a distance sequence. Corner points with closer distances often have closer connections in the image structure, and together constitute the local features or specific shapes of the graphics. By observing the distance sequence, we can sort out the associated corner point combinations, thereby better analyzing the composition details of complex shapes.
[0024] Preferably, the method for selecting the characteristic corner points of the target image according to the size of the comprehensive characterization value is:
[0025] A comprehensive characterization value threshold is preset, and the corner points in the target image whose comprehensive characterization value is less than the comprehensive characterization value threshold are screened out, and the remaining corner points are used as feature corner points.
[0026] Preferably, the method for determining the workpiece marking position according to the corner point matching result is:
[0027] Obtaining the position coordinate data of the corner points of the target image and the template image that match each other in the spatial coordinate system, and using a pre-set mathematical transformation algorithm and the position coordinate data to construct a transformation matrix that can reflect the spatial transformation relationship between the target image and the template image;
[0028] Based on the spatial position information contained in the transformation matrix, the corresponding marking position of the workpiece surface in the actual space is determined through coordinate conversion and positioning calculation, and then the marking device is guided to move to the position above the target image according to the calculated position information to realize the positioning of the marking position.
[0029] The present invention has the following effects:
[0030] The present invention collects the surface image of the workpiece and deeply analyzes its edge and corner features, and divides the edges into straight edges and turning edges, and then accurately determines the key parameters such as the minimum belonging distance, arc factor and fluctuation factor in the edge set of each corner neighborhood, fully considering various factors under complex surface conditions, and effectively avoiding the interference of surface defects and lighting problems on corner point identification. Reliable corner points that truly represent the actual position and shape of the workpiece are screened out by relying on the comprehensive characterization value finally calculated, which improves the matching accuracy of the workpiece image and the template image, and ensures the accuracy and reliability of the workpiece marking position detection results. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0032] Figure 1 It is a schematic flow chart of the method of the present invention;
[0033] Figure 2 is the target image of the present invention;
[0034] Figure 3 is a template image of the present invention;
[0035] Figure 4 is a corner point detection result image of the target image of the present invention;
[0036] Figure 5 is a corner point detection result image of the template image of the present invention;
[0037] Figure 6 is an edge image of the target image of the present invention;
[0038] Figure 7 is an image of a scratched area and a reflective area of a target image of the present invention;
[0039] Figure 8 is the image to be marked of the present invention;
[0040] Fig. 9 It is the target image after marking of the present invention. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0042] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0043] Reference Figure 1 The present invention provides a method for detecting a workpiece marking position based on image processing, comprising steps S1 to S7:
[0044] S1: Acquire the surface image of the workpiece as the target image.
[0045] The workpiece marking position is detected based on image processing. Therefore, the surface image of the workpiece is first collected by an industrial camera. Since there is a certain amount of dust in the workshop shooting environment, the dust reflects light and produces noise in the image. Therefore, the image needs to be filtered by Gaussian filtering. The filtered surface image is recorded as the target image, such as Figure 2 As shown in , there is a scratch in the G1 area in the upper right corner of the target image, and there is also a reflective area pointed to by G2 in the target image.
[0046] Since the target image also needs to match the corner points with the template image in the host computer to map the marking position in the template image to the target image, so as to determine the marking position in the target image, Figure 3 Prepare a template image as shown in .
[0047] Since the workpiece marking position detection is based on corner point matching, corner point detection is required first. Since the ORB algorithm has high computational efficiency and good rotation invariance and scale adaptability when performing corner point detection, the ORB algorithm is selected for corner point detection. The ORB algorithm is used to extract the respective corner points from the target image and the template image. Figure 4 and Figure 5 , the corner point detection result is a set of circles existing in each image, and the center position of each circle set is a corner point. Figure 4 As shown in , the corner of the scratch is detected in the upper right corner of the target image. Figure 5 There is no scratched corner in the upper right corner of the template image.
[0048] S2: Divide the edges of the target image into straight edges and changing edges.
[0049] In the corner point detection process of the workpiece image, due to the existence of scratches and reflective areas, some corner points that cannot accurately represent the actual contour of the workpiece will be generated. Figure 4 and Figure 5 As shown in , the position and characteristics of these corner points are significantly affected by lighting conditions and scratch positions, and cannot truly reflect the actual position of the workpiece. If not processed, it will seriously affect the accuracy of subsequent corner point matching, and thus lead to deviations in the determination of the workpiece marking position.
[0050] The reflective area on the metal surface presents a specific shape that scatters outward from the center in the image, while the shape of the scratched area is usually irregular. In order to effectively identify and remove the corner points caused by scratches and reflections, the present invention first obtains the representation importance and representation effectiveness of each corner point. The acquisition of representation importance is intended to determine whether the corner points in the target image are caused by undesirable factors such as scratches and reflections, while the calculation of representation effectiveness focuses on determining whether the distribution of the corner points in the target image is consistent with the distribution of the corner points in the template image, because those corner points that are similar to the corner point distribution of the template image are more likely to accurately reflect the true position of the workpiece, thereby providing strong support for accurate corner point matching.
[0051] Therefore, this step first uses the Canny edge detection algorithm to accurately extract all edges of the target image and obtain an edge image, such as Figure 6 As shown in , the edge image is a binary image, the pixel value of white pixels (edge pixels) is 0, and the pixel value of black pixels is 0 (background pixels).
[0052] Next, get all the edges in the edge image:
[0053] Traverse all the pixels in the edge image of the target image, and extract all the pixels whose value is 1 and are interconnected and located in the same connected domain through connected domain analysis. These pixels constitute an edge. All the edges of the target image are extracted in this way.
[0054] Combination Figure 2 and Figure 7 It can be seen that Figure 2 The edge of the scratch in the upper right corner of the target image corresponds to Figure 7 In The area where the edge changes are more complex. Figure 2 The edge of the reflective area in the center of the target image corresponds to Figure 7 In The area where the edges are located is relatively straight and scattered, and the distance between the edges is relatively close.
[0055] Finally, the chain code of each edge is extracted to reflect the change in the direction of the pixel points of each edge. Chain code is a coding method commonly used to represent the boundaries of objects in images. It describes the edge contour by recording the direction of the boundary pixels in a certain order. It can well represent the direction of the edge. In order to facilitate the subsequent judgment of whether the edge represents a scratch or a reflective area based on the edge direction, it is necessary to first obtain the chain code of each edge.
[0056] This step targets each edge of the target image, takes the pixel point at the upper left corner of the edge as the starting point, encodes all the pixels contained in the edge according to the 8-direction chain code, and obtains the chain code of the edge. For example, there is an image with a shape similar to a right triangle, and the hypotenuse of the triangle needs to be encoded with an 8-direction chain code. First, find the pixel point at the upper left corner of this edge as the starting point. That is, the hypotenuse of the triangle, the coordinates of the pixel point at its upper left corner are assumed to be (1, 1). Since the 8-direction chain code usually has the following 8 standard directions and corresponding numbers:
[0057] 0: represents horizontal right (0° direction);
[0058] 1: represents the upper right direction (45° direction);
[0059] 2: represents vertical upward (90° direction);
[0060] 3: represents the upper left direction (135° direction);
[0061] 4: represents horizontal left (180° direction);
[0062] 5: represents the lower left direction (225° direction);
[0063] 6: represents vertical downward (270° direction);
[0064] 7: represents the lower right direction (315° direction);
[0065] Then, starting from the starting point (1, 1), the direction of the pixels along this hypotenuse edge is checked in turn and encoded according to 8 directions. For example, the direction from the first pixel (1, 1) to the next pixel is in the upper right direction, which is recorded as 1; then the next group of adjacent pixels is in the upper right direction again, which is recorded as 1; then the direction of the next group of pixels becomes vertically upward, which is encoded as 2, and so on, until all the pixels contained in this hypotenuse edge are traversed.
[0066] Finally, by combining these numbers representing different directions recorded in sequence, we get the chain code of this bevel edge. Such a sequence of numbers reflects the specific direction and shape characteristics of this edge in the image.
[0067] Although the edge conditions in actual images are often much more complicated, the basic encoding idea is this: the continuous direction of edge pixels is recorded in digital form through 8-directional chain codes to facilitate subsequent operations such as shape analysis and feature extraction.
[0068] After obtaining the chain code of each edge, this step performs the following operations:
[0069] The first-order difference sequence of the chain code of each edge is obtained. The chain code itself describes the direction of the edge pixels, and the first-order difference sequence further explores the differences between adjacent chain code elements on this basis, highlighting the subtle changes in the edge direction. For example, for a curved edge with slight concave and convex changes, the chain code may only record the direction of each segment in sequence, while the first-order difference sequence can clearly show the turning point of the chain code change at the concave and convex part, providing key clues for detailed analysis of edge shape characteristics and helping to better understand the complexity of edge contours.
[0070] The first-order difference sequences of the chain codes of all edges are linearly normalized so that the edge difference sequences of different lengths and initial states can be unified to a comparable standard scale, eliminating the differences caused by factors such as image size and initial coding, which is convenient for subsequent comparison.
[0071] The absolute value sum of each value in the linear normalized differential sequence of each edge is used as the fluctuation factor of each edge. This is to quantify the comprehensive situation of the contour change of each edge with a value. By taking the absolute value sum of these values, all the change information in the entire differential sequence can be considered comprehensively, rather than focusing on a certain local change. For example, an edge may have a large directional change in some parts, but a small change in other parts. The absolute value sum can incorporate these different degrees of changes into a unified quantitative index, which comprehensively reflects the comprehensive changes of the edge in the entire contour.
[0072] Set the volatility factor threshold to (Empirical value), among all the edges of the target image, the edges whose fluctuation factor is less than the fluctuation factor threshold are recorded as straight edges, and the edges whose fluctuation factor is greater than or equal to the fluctuation factor threshold are recorded as changing direction edges.
[0073] S3: Calculate the minimum belonging distance of each straight edge and the arc factor of each turning edge in the target image.
[0074] First, set the neighborhood range of each corner point in the target image. Take each corner point in the target image as the center and draw a circle with a preset neighborhood radius to obtain the neighborhood range of each corner point. Here, the neighborhood radius is set to 10 (empirical value).
[0075] For any edge in the target image (including straight edges and directional edges), as long as there is one or more pixel points in the neighborhood of a corner point, the edge is the neighborhood edge of the corner point. According to this method, the neighborhood edge set of each corner point in the target image is obtained.
[0076] Next, the minimum belonging distance of each straight edge is obtained as follows:
[0077] Select any straight edge from the neighborhood edge set of each corner point in the target image, and take the minimum distance between the two endpoints of the straight edge and the two endpoints of other straight edges in the neighborhood edge set as the minimum belonging distance of the straight edge.
[0078] The edges formed by the reflective area scatter outward from the center. This type of edge is straighter than other edges, and the overall distance of all edges showing scattering characteristics is closer at one end. Therefore, the smaller the sum of the minimum belonging distances of all straight edges in the neighborhood edge set of a corner point, the greater the possibility that there are straight edges scattering outward from the center near the corner point. This straight edge with scattering characteristics is usually caused by the reflective area on the surface of the workpiece. Therefore, the possibility that the corner point is located in the reflective area is higher, and the reflective area cannot reflect the true contour of the workpiece. This type of corner point is of low importance in characterizing the contour of the workpiece.
[0079] Next, the arc factor of each turning edge is obtained as follows:
[0080] Since there are circular top-view surfaces such as holes, cylinders, and cones on the workpiece, the corner points near the edges of the approximate arcs generated by such structures can well describe the real workpiece contour. The corner points near such edges are relatively important in characterization. Therefore, the second-order difference sequence of the chain code of all the changing edges is obtained for linear normalization, and the sum of the absolute values of the second-order difference sequence of each changing edge after linear normalization is taken as the arc factor of each changing edge. When the arc factor of the changing edge near a corner point is higher overall, the edge near the corner point is more likely to present an arc feature. Such edges are usually caused by holes and chamfers on the workpiece. Therefore, the corner point is more likely to be located in the workpiece contour, and its importance is high when characterizing the workpiece contour.
[0081] S4: Determine the representation importance of each corner point of the target image based on the minimum belonging distance and the arc factor.
[0082] Since the scratches on the workpiece surface and the edges formed by the reflective area are more numerous and rough than the contour edges of the workpiece, and the edges formed by the reflective area are in a shape that scatters outward from the center, the existence of such edges near each corner point can be analyzed to obtain the representation importance of each corner point in the target image.
[0083] By defining the importance of characterization in this way quantitatively, the concept of corner point importance is closely linked to the actual geometric features and the effective characterization of the workpiece, which helps to screen out corner points that are truly valuable for subsequent work such as determining the marking position.
[0084] S5: Determine the representation validity of each corner point according to the consistency between the distance sequence of each corner point of the target image and the distance sequence of each corner point of the template image.
[0085] In the process of workpiece marking position detection, the corner points in the template image show the distribution of corner points under the standard state. The key to judging whether the corner points in the target image have effective representation significance for the workpiece lies in the similarity or conformity of the spatial position distribution between them and the corner points in the template image.
[0086] The specific steps are as follows:
[0087] First, for each corner point of the target image, the Euclidean distance between the corner point and other corner points of the target image is calculated to obtain a Euclidean distance sequence, and the Euclidean distance sequence is sorted in ascending order to form the distance sequence of the corner point. For each corner point of the template image, the Euclidean distance between the corner point and other corner points of the template image is calculated to obtain a Euclidean distance sequence, and the Euclidean distance sequence is sorted in ascending order to form the distance sequence of the corner point.
[0088] Next, the DTW (Dynamic Time Warping) algorithm is used to calculate the DTW (Dynamic Time Warping) distance between the distance sequence of each corner point of the target image and the distance sequence of each corner point of the template image.
[0089] For the target image Corner points, calculate the The DTW distance between the distance sequence of each corner point in the template image and the distance sequence of each corner point in the template image is used to obtain the DTW distance set as the first The DTW distance set of corner points .
[0090] Finally, the target image The representation validity of each corner point is calculated by the following formula:
[0091]
[0092] In the formula, The target image is The representation effectiveness of the corner points, To obtain the minimum function, is the linear normalization operation, for The minimum value in .
[0093] This formula introduces the DTW distance and the corresponding calculation logic to quantify the similarity between the corner points in the target image and the corner points in the template image in terms of spatial position distribution. This quantification is crucial for objectively evaluating the effectiveness of corner points in representing workpieces. It avoids the ambiguity of measuring the matching relationship between corner points and templates by relying on subjective judgment or qualitative description, and makes it possible to clearly distinguish which corner points among many corner points have a higher degree of fit with the template image based on specific values, providing an accurate measurement standard for the subsequent screening and utilization of effective corner points.
[0094] In this formula, This item cleverly combines the distance information between corner points and the matching relationship of corner points. The DTW distance itself measures the difference between the corner point distance sequences. By taking its minimum value and performing a reciprocal operation, the distance is converted into a high or low concept of matching, so that this value can not only reflect the degree of proximity of the corner point to the corner point of the template image in spatial distribution, but also intuitively reflect the matching between the two. This makes the representation effectiveness indicator closely related to the actual spatial position relationship of the corner point and the fit with the standard template, and more comprehensively describes the effectiveness of the corner point in the representation of the workpiece. The target image The degree of correspondence between the corner point and the corner point corresponding to the minimum DTW distance among all corner points in the template image, The smaller the value, the higher the matching degree, which means that the The more corner points can be found in the template image with similar position distribution, the higher the representation effectiveness of the corner point will be, the more significant the characterization effect of the corner point on the workpiece will be, and the more accurately it can reflect the feature information of the workpiece under the standard state, providing strong support for the subsequent precise determination of the workpiece marking position.
[0095] S6: Obtain a comprehensive representation value of each corner point of the target image according to the representation importance and representation validity of each corner point of the target image.
[0096] In the detection of workpiece corners, the comprehensive characterization value can reflect the overall adaptability of the corners to the entire workpiece marking position detection process. It comprehensively considers the importance of the corners themselves in the image structure (characterization importance) and the effectiveness of matching with the template image (characterization effectiveness). The higher the value, the more adaptable the corners are and the more helpful they are in accurately completing the marking position detection work. This helps to focus on those corners that are really important for determining the final marking position. In real-life scenarios where complex situations such as workpiece surface defects and lighting changes interfere with corner judgment, screening corners based on the comprehensive characterization value can improve the reliability and accuracy of the entire marking position detection solution.
[0097] Therefore, the calculation formula for the comprehensive representation value of each corner point in the target image is:
[0098]
[0099] In the formula, The target image is The comprehensive representation value of the corner points, The target image is The representation importance of each corner point, The target image is The representation effectiveness of the corner points.
[0100] This formula embodies the idea of comprehensively evaluating corner points from multiple dimensions. The representation importance and representation effectiveness measure the characteristics of corner points in the image from different perspectives respectively. Multiplying the two together to obtain the comprehensive representation value means integrating the information of these different dimensions together, avoiding the one-sidedness of judging the value of corner points by relying on only a single indicator. For example, in the analysis of complex workpiece images, some corner points may seem important in the local geometric structure, but perform poorly in terms of the effectiveness of matching with the template image; while some corner points may have acceptable matching effectiveness, but their own criticality in the image is not high. The comprehensive representation value can comprehensively weigh these situations.
[0101] S7: Select the characteristic corner points of the target image according to the comprehensive characterization value, perform corner point matching between the characteristic corner points and the template image, and determine the workpiece marking position according to the corner point matching result.
[0102] First, the threshold of the comprehensive characterization value is preset to 0.3 (empirical value), and the corner points in the target image whose comprehensive characterization value is less than the threshold are screened out, and the remaining corner points are used as feature corner points. It can remove corner points that are greatly disturbed, have low reliability, and cannot accurately reflect the features of the workpiece under complex surface conditions, and avoid the corner points with low comprehensive characterization values from reducing the accuracy of corner point matching. The retained feature corner points are of higher quality, and their positions and features can better represent the true geometric shape and spatial position relationship of the workpiece, laying a solid foundation for subsequent accurate matching with the template image.
[0103] Then, the feature corners are matched with the template image:
[0104] An exhaustive matching method can be used. For each remaining corner point in the target image, all corner points in the template image are traversed, and the matching relationship is determined by calculating a certain similarity metric. For example, the similarity of the corner point's position, direction, surrounding grayscale features, and other factors is calculated. Feature vectors can be used to represent these features of the corner point, and then the similarity is measured by calculating the distance between feature vectors (such as Euclidean distance, Mahalanobis distance, etc.), and the two corner points with the greatest similarity are successfully matched.
[0105] Finally, the method for determining the workpiece marking position based on the corner point matching results is:
[0106] Obtain the position coordinate data of the corner points of the target image and the template image that match each other in the spatial coordinate system. As the key feature elements in the image, the position coordinate data of the corner points in the spatial coordinate system can accurately reflect the specific form and distribution of the image in space. Obtaining the coordinates of the matching corner points is equivalent to finding the "anchor point" of the spatial correspondence between the target image and the template image. For example, for irregularly shaped workpieces, the specific orientation of each key position in space can be clearly known through accurate corner point coordinates, avoiding errors caused by inaccurate starting data when calculating subsequent transformation relationships.
[0107] Using a pre-set mathematical transformation algorithm, combined with position coordinate data, a transformation matrix that can reflect the spatial transformation relationship between the target image and the template image is constructed; this transformation matrix accurately summarizes the relative transformation rules of the two images in space. No matter what angle or position changes occur during the actual placement and shooting of the workpiece, these differences can be fully captured through this matrix, providing a key basis for subsequent restoration to the accurate marking position. For example, when the workpiece is tilted at a certain angle, the transformation matrix can accurately reflect the spatial changes of the target image relative to the template image in this tilted state, thereby ensuring the accuracy of the subsequent marking position determination and improving the versatility and reliability of the entire method under different working conditions.
[0108] Based on the spatial position information contained in the transformation matrix, the corresponding marking position of the workpiece surface in the actual space is determined through coordinate transformation and positioning calculation. Through rigorous coordinate transformation and positioning calculation, according to the spatial position information in the transformation matrix, the theoretical spatial transformation relationship is accurately converted into the actual operable marking position coordinates, thereby accurately determining the specific position where the workpiece surface should be marked in the real space. This ensures that the marking operation can be accurately placed at the desired position, avoids deviation in the marking position, directly guarantees the quality of the marking process, and plays a key role in the effectiveness and recognizability of product identification.
[0109] Guide the marking device to accurately reach the position above the target image according to the calculated position information, and mark the current workpiece. That is, after the target image and the template image are accurately matched at the corner points, Figure 8 The pattern to be marked shown in , through the above positioning operation, the image is marked on the current workpiece, and the result is as follows Fig. 9 The marking results are automatically adjusted in the marking position. Compared with the traditional method of manually adjusting the marking position by visual inspection, it not only greatly improves the speed and efficiency of positioning, reduces the errors that may be caused by manual operation, but also is suitable for large-scale and efficient industrial production scenarios.
[0110] In the description of this specification, "multiple" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0111] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A workpiece marking position detection method based on image processing, characterized in that: include: The surface image of the workpiece is collected as the target image, all edges and corner points of the target image are extracted, all edges are divided into straight edges and direction-changing edges, and the minimum belonging distance of each straight edge and the arc factor of each direction-changing edge in the neighborhood edge set of each corner point of the target image are determined; Calculate the representation importance of each corner point of the target image based on the minimum belonging distance and the arc factor; the representation importance is positively correlated with the sum of the minimum belonging distances of all straight edges in the neighborhood edge set of the corner point and the arc factors of all turning edges; The distance sequence of each corner point is formed by the distance between each corner point and other corner points in the target image and the template image, and the representation effectiveness of each corner point of the target image is calculated: , The target image is The representation effectiveness of the corner points, The target image is The distance sequence of the corner points and the distance sequence of all corner points of the template image The collection of distances, To take the minimum value; Calculate the comprehensive representation value of each corner point of the target image , The target image is The comprehensive representation value of the corner points, The target image is The characterization importance of each corner point is determined. The characteristic corner points of the target image are screened out according to the size of the comprehensive characterization value. The characteristic corner points are matched with the template image, and the workpiece marking position is determined according to the corner point matching results. The method for obtaining the arc factor of each direction-changing edge is: Obtain the second-order difference sequence of the chain code of all the direction-changing edges for linear normalization, and take the sum of the absolute values of the linearly normalized second-order difference sequence of each direction-changing edge as the arc factor of each direction-changing edge; The minimum belonging distance of each straight edge is obtained as follows: The minimum distance between each end point of each straight edge and any end point of all other straight edges is taken as the minimum belonging distance of the straight edge.
2. The workpiece marking position detection method based on image processing according to claim 1 is characterized in that: The method to divide all edges into straight edges and turning edges is: The edge whose fluctuation factor is less than the preset fluctuation factor threshold is classified as a straight edge, and the edge whose fluctuation factor is not less than the preset fluctuation factor threshold is classified as a turning edge; the fluctuation factor is obtained by: The differential sequence of the chain code of each edge is obtained, and the first-order differential sequence of the chain code of all edges is linearly normalized. Then, the sum of the absolute values of each value of the linearly normalized differential sequence of each edge is taken as the fluctuation factor of each edge.
3. The workpiece marking position detection method based on image processing according to claim 1 is characterized in that: The method for obtaining the neighborhood edge set of each corner point of the target image is: With each corner point as the center, draw a circle according to the preset neighborhood radius to obtain the neighborhood range of each corner point; if any number of pixel points of a certain edge are located in the neighborhood range, the edge is used as the neighborhood edge of the corner point, and the neighborhood edge set of each corner point is obtained in this way.
4. The workpiece marking position detection method based on image processing according to claim 1, characterized in that: The distance sequence of each corner point is the Euclidean distance sequence between each corner point and other corner points, and is arranged in ascending order.
5. The workpiece marking position detection method based on image processing according to claim 1, characterized in that: The method for selecting the characteristic corner points of the target image according to the size of the comprehensive representation value is: A comprehensive characterization value threshold is preset, and the corner points in the target image whose comprehensive characterization value is less than the comprehensive characterization value threshold are screened out, and the remaining corner points are used as feature corner points.
6. The workpiece marking position detection method based on image processing according to claim 1, characterized in that: The method for determining the workpiece marking position based on the corner point matching results is: Obtaining the position coordinate data of the corner points of the target image and the template image that match each other in the spatial coordinate system, and using a pre-set mathematical transformation algorithm and the position coordinate data to construct a transformation matrix that can reflect the spatial transformation relationship between the target image and the template image; Based on the spatial position information contained in the transformation matrix, the corresponding marking position of the workpiece surface in the actual space is determined through coordinate conversion and positioning calculation, and then the marking device is guided to move to the position above the target image according to the calculated position information to realize the positioning of the marking position.
Citation Information
Patent Citations
A method and apparatus for ORB feature extraction and matching
CN108171734B
Self-adaptive angular-point detection method based on image contour sharpness
CN101887586A
Corner point detection method, device and equipment and computer readable storage medium
CN112561853A