Method for identifying binary lattice code on surface of mold
By combining deep learning and image processing methods, the YOLOv8 network model is used to identify the binary dot matrix code of the mold surface, which solves the problem of inaccurate identification in strict environments in the existing technology and achieves efficient identification of dynamically changing mold surfaces.
Patent Information
- Application Number
- CN202411599803.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-11
AI Technical Summary
The prior art is difficult to accurately identify binary dot matrix codes under harsh environments such as high temperature, high pressure and corrosion of the mold, and the recognition effect of light changes, pattern rotation, pattern blurring and dimensional changes is poor.
Using a method combining deep learning and image processing, the binary dot matrix code on the mold surface is detected by the YOLOv8 network model, perspective correction, counterclockwise rotation correction and code point recognition, to realize the identification of the binary code of the dynamically changing mold surface.
The recognition rate of binary encoding on the mold surface is greatly improved, and it can effectively deal with complex situations such as light changes, pattern rotation, pattern blurring and size changes.
Smart Images

Figure CN119538954A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of binary dot matrix code recognition, and in particular to a method for recognizing a binary dot matrix code on a mold surface. Background Art
[0002] Moulds are called "the mother of industry". They are processing tools that process raw materials and give them complete configurations and precise dimensions. They are essential key process equipment in industrial production. Metal precision moulds have two characteristics: first, there are many varieties of mould products, with great differences in size and requirements, which are "non-standardized"; second, metal precision moulds have high unit prices and are high-value consumables. Therefore, in order to extend the service life of metal precision moulds, the key to intelligent management of their entire life cycle is to mark the metal moulds with unique coding marks and accurately identify their coding marks to obtain the information of the moulds. Since moulds are usually used in harsh scenarios such as high temperature, high pressure, metal flow erosion, corrosion, etc., the mould coding marks will be worn to a certain extent; in addition, since the surface of the mould is rough and uneven and the colour of the mould surface is different due to air oxidation, how to accurately identify the mould coding marks has become an extremely difficult and complex technical problem.
[0003] There are currently four types of mold information marking and identification technologies used in the industry. The first is the mold surface engraved character ORC recognition technology, the second is the mold surface paper barcode recognition technology, the third is the mold coding recognition technology based on the mold QR code, and the fourth is the binary-based mold coding recognition technology (a binary-based mold coding and recognition method, storage device and intelligent terminal, patent number ZL202311308579.3).
[0004] (1) Technology of engraving mold ID characters on mold surface based on ORC recognition
[0005] This method is to use a milling cutter or steel stamp to engrave the ID character code of the mold on the surface of the mold, and then use image processing methods to segment the processed image and separate the engraved characters from the background. Then use character recognition technology (OCR) to recognize the mold code characters. However, as the mold is used in different processes and different environments, the coded characters may be unclear and the mold may have rust spots. In addition, due to changes in lighting, image scaling, and image rotation, character code recognition errors may occur. However, when the coded characters are recognized incorrectly, the recognition method based on ORC technology lacks the necessary error correction and verification mechanism to ensure the accuracy of character recognition. In industrial production, the accuracy requirement is much higher than the missed detection rate. If the recognition error occurs, the entire mold process record will be wrong, which greatly reduces the quality and efficiency of the mold life cycle management.
[0006] (2) Mold surface paper barcode recognition technology
[0007] This method is to attach a paper barcode label to the surface of the mold, and then use a barcode scanning device to scan and identify the barcode. However, this method has certain limitations in practical applications. In daily maintenance, the mold will undergo polishing (physical friction), alkali washing (corrosion), nitriding (high temperature) and other processes, which will damage the paper barcode pasted on the surface of the mold. For example, the polishing process may wear off the barcode, alkali washing may cause the label to fall off or blur, and high temperature and high pressure treatments such as nitriding will directly damage the paper label. During the entire life cycle of the mold, it is necessary to repeatedly re-paste the paper barcode on the mold many times. However, the production status of the mold (high temperature, high pressure) causes the barcode to be damaged and cannot be re-pasted immediately. Therefore, this method is not suitable for extrusion molds that perform information labeling management under high temperature and high pressure environments.
[0008] (3) Mold QR code recognition technology
[0009] The coding technology of this method is QR code, that is, the QR code pattern is engraved on the surface of the mold by laser technology, and then the QR code pattern is scanned and recognized by the QR code scanning device. The advantage of this method is that there is no need to develop a separate scanning program, and the existing mature QR code scanning program can be used to achieve coding recognition. However, the mold will undergo polishing, alkali cleaning, electric spark, nitriding and other treatment processes in daily maintenance, and these processing processes will also damage the QR code. Because the pattern of the QR code is too complex, when the QR code has too many damaged areas, the QR code will not be recognized. More importantly, the mold will turn black after EDM processing, which is extremely similar to the color of the QR code mark, resulting in recognition failure.
[0010] (4) Mold binary code recognition technology based on image processing
[0011] Patent No. ZL202311308579.3 discloses a binary-based mold coding and identification method, storage device and intelligent terminal. The method redesigns a binary dot matrix code mold coding pattern, which is much simpler than the QR code pattern, greatly reducing the difficulty of code recognition. The method uses edge detection and morphological operations to identify and separate coding features, such as length, width and shape. Then, the template matching technology is used for comparison to achieve code recognition. However, the mold binary code recognition method based on image processing needs to specifically select parameters of image processing methods such as edge detection, morphological operations, template matching, etc. according to the specific coding image position, angle and illumination. Therefore, the recognition effect of mold coding images with different illumination, angle and scale changes is poor, the accuracy is low, and it cannot meet the needs of actual production. More importantly, due to the fact that the mold surface will change from bright metal color to black and even rust spots during the entire life cycle of the mold, this also makes the fixed parameters unable to apply to the changing mold surface color.
[0012] Therefore, in view of the shortcomings of the existing mold binary code recognition technology based on image processing, it is necessary to improve the existing recognition technology to make it suitable for the dynamically changing mold metal surface, and at the same time be able to cope with the binary dot code illumination changes, pattern rotation, pattern blur, size changes, etc. Summary of the invention
[0013] In order to solve the above technical problems, the present invention proposes a binary dot code recognition method that combines deep learning and image processing. This method is not only applicable to dynamically changing mold metal surfaces, but also can cope with binary dot code illumination changes, pattern rotation, pattern blur, size changes, etc.
[0014] To achieve the above object, the technical solution adopted by the present invention is as follows: a method for identifying binary dot matrix codes on a mold surface, the method comprising the following steps:
[0015] Step S1: Data collection: A large number of binary dot matrix code images of the mold surface are collected by a camera, and a positioning mark pattern is set on each of the four corners of the binary dot matrix code image. A target detection frame is marked on each positioning mark pattern to form a training set;
[0016] Step S2: training the model: inputting the training set data into the YOLOv8 network model to train the model, obtaining the optimal weight data of the YOLOv8 network model, and loading the obtained optimal weight data into the YOLOv8 network model again to obtain the trained and upgraded YOLOv8 network model;
[0017] Step S3: Positioning mark detection: The binary dot code image of the surface of the mold to be tested is collected by a camera to form a test set, and the test set image is input into the upgraded YOLOv8 network model. The model detects and outputs the corner points of four target detection frames corresponding to the test set data. Each target detection frame has 4 corner points, for a total of 16 corner points.
[0018] Step S4: calculating the outer vertices: filtering the 16 corner points through a screening strategy to calculate the position coordinates of the outermost vertices of the four target detection frames;
[0019] Step S5 perspective correction: a distorted quadrilateral is obtained according to the position coordinates of the outermost vertices of the four target detection frames, and then the distorted quadrilateral is converted into a standard L×L square pattern through perspective transformation;
[0020] Step S6 calculates the counterclockwise rotation angle: the square pattern obtained in step S5 is input into the Yolov8 network model upgraded in step S2 for detection, and the four corner points of the target detection frame corresponding to the square pattern positioning mark are output;
[0021] The coordinates of the center point G of the target detection frame are obtained according to the four corner points of the target detection frame;
[0022] Compare the coordinates of the center point G of the target detection frame with the center point of the square pattern obtained in step S5 The coordinate position of the square pattern is obtained by rotating the square pattern counterclockwise at an angle θ;
[0023] Step S7: Rotation correction: rotate the square pattern counterclockwise by θ to the correct position through perspective transformation to obtain the standard pattern of the binary dot code image of the test set;
[0024] Step S8: Code point recognition: according to the scale of the binary code point, the standard pattern is equally divided into image blocks of the same size; then the image blocks are sequentially input into the YOLOv8 network model upgraded in step S2 for recognition in the order from top to bottom and from left to right;
[0025] If the code point exists in the image block, the output is 1, if the code point does not exist in the image block, the output is 0;
[0026] Finally, the recognition results are connected to obtain a binary coded sequence data;
[0027] Step S9 decoding: Decoding the binary coded sequence data according to the binary coded decoding rule to obtain the character information corresponding to the binary code.
[0028] There are two screening strategies in step S4, which are set as the first screening strategy and the second screening strategy, wherein:
[0029] The screening method of the first screening strategy is as follows:
[0030] Step S4-a1: construct the 16 corner points of the four target detection boxes output by the YOLOv8 network model in step S3 into a set P,
[0031] Let each corner point be a ij Its coordinates are represented by (x ij ,y ij ), where i represents the number of the target detection box, and its value range is i∈{1,2,3,4}; j represents the jth corner point among the four corner points of the box, and its value range is j∈{1,2,3,4};
[0032] Step S4-a2: The coordinate information of the four corner points of the first target detection frame is:
[0033] a 11 The coordinates are: (x 11 ,y 11 ), a 12 The coordinates are: (x 12 ,y 12 ), a 13 The coordinates are: (x 13 ,y 13 ), a 14 The coordinates are: (x 14 ,y 14 );
[0034] Step S4-a3: Assume that the position coordinates of the outermost vertices of the four target detection frames are Q 1 (x Q1 ,y Q1 ), Q 2 (x Q2 ,y Q2 ), Q 3 (x Q3 ,y Q3 ), Q 4 (x Q4 ,y Q4 ), and Q 1 Located at the top of the binary dot code, Q 2 Located at the bottom of the binary dot code, Q 3 Located on the far left of the binary dot code, Q 4 Located on the rightmost side of the binary dot code, the coordinates of each outermost vertex are calculated as follows:
[0035] Q 1 Located at the top of the binary dot code pattern, then its ordinate is the point with the smallest ordinate in the point set P, as shown in the following formulas (1) and (2):
[0036]
[0037]
[0038] Q 2 Located at the bottom of the binary dot matrix code, its vertical coordinate is the point with the largest ordinate in the point set P, as shown in the following formulas (3) and (4):
[0039]
[0040]
[0041] Q 3 Located on the left side of the binary dot code pattern, then its horizontal coordinate is the point with the smallest horizontal coordinate in the point set P, as shown in the following formulas (5) and (6):
[0042]
[0043]
[0044] Q 4 Located on the far right side of the binary dot code pattern, then its horizontal coordinate is the point with the largest horizontal coordinate in the point set P, as shown in the following formulas (7) and (8):
[0045]
[0046]
[0047] The screening method of the second screening strategy is as follows:
[0048] The 16 corner points of the four target detection boxes output by the YOLOv8 network model in step S3 are constructed into a set W, where each point w i The coordinates are (x i ,y i );
[0049] For any point w i With the other 15 corner points w j The distance (j≠i) is defined as d(w i ,w j ), calculated using the Euclidean distance formula (9):
[0050]
[0051] Next, click w i The sum of the distances to the other 15 corner points can be calculated using the following formula (10):
[0052]
[0053] By comparing all , select the first 4 largest The point w corresponding to the value i These are the four vertices of the binary dot code, and the expression formula is as follows:
[0054] Assume that all Arranged in descending order, the sorted sequence is as follows (11):
[0055]
[0056] Then select the first 4 largest The corresponding point set P′ is:
[0057] P′={w 1 ,w 2 ,w 3 ,w 4} (12).
[0058] Preferably, the transformation formula of the perspective transformation is a transformation process of transforming the pixel coordinates (u, v) from a point on a three-dimensional world coordinate system to a two-dimensional plane pixel coordinate (x′, y′).
[0059] The transformation formula (13) of perspective transformation is as follows:
[0060]
[0061] Where: The coordinates of the original image in the two-dimensional plane are (u, v), where w = 1. (x′, y′, z′) are the three-dimensional space coordinates after conversion;
[0062] Perspective transformation matrix Split into 3 parts, Used as a linear transformation, Used as perspective transformation, (b 31 ,b 32 ) for translation operations.
[0063] Preferably, in the perspective transformation, the pixel coordinates (u, v) are transformed to points on a three-dimensional world coordinate system, and then transformed to a new two-dimensional plane, and the corrected coordinates are obtained as (x, y). The calculation formulas are shown in (14) and (15):
[0064]
[0065]
[0066] Preferably, the steps of obtaining the counterclockwise rotation angle θ of the square pattern in step S6 are as follows:
[0067] Step S6-1: Assume that the four corner points of the square positioning mark target detection box are represented as d i , the coordinates are expressed as (x i ,y i ), where i∈[1,4], the target detection box center point G(x G ,y G ), the coordinates of the center point of the target detection box can be calculated by formulas (16) and (17) as follows:
[0068]
[0069]
[0070] Step S6-2: By comparing the coordinates of the center point of the target detection frame G(x G ,y G ) and the center point coordinates of the square pattern obtained in step S5 Determine the angle θ of the counterclockwise rotation of the square pattern, and the corresponding relationship is as follows:
[0071]
[0072] Preferably, the steps of obtaining the standard pattern in step S7 are as follows:
[0073] Assume that a certain point w(x, y) on the binary dot matrix code after perspective correction in step S5 is rotated counterclockwise by an angle of θ; the steps of the rotation process are as follows:
[0074] Calculate point w relative to the center point Coordinates w′(x′,y′):
[0075]
[0076]
[0077] Apply the rotation matrix R to rotate w′:
[0078]
[0079]
[0080] Translate w″ back to its original position to get the final rotation point w″′(x″,y″):
[0081]
[0082]
[0083] Combining the above steps, we can get the coordinates w″′(x″,y″) after w is rotated θ degrees around the center point of the image:
[0084]
[0085] Preferably, the code point identification in step S8 includes the following steps:
[0086] S8-1 dot matrix code is divided into image blocks: according to the scale of binary code points, the dot matrix code rotated to the correct position in step S7 is equally divided into image blocks of the same size;
[0087] S8-2 Image block code point recognition: Use the YOLOv8 network model upgraded in step S2 to perform code point recognition, and identify the circular binary code points of the image block in order from top to bottom and from left to right. If the code point exists in the image block, it is recorded as 1, and if the binary code point does not exist in the image block, it is recorded as 0. Finally, a binary 01 code sequence is obtained by recognition and reading.
[0088] The beneficial technical effect of the present invention is as follows: the present invention uses the YOLOv8 network model to perform positioning and identification detection on the binary dot code image on the mold surface, and then calculates the outermost vertices of the target detection frame through a screening strategy, and then through perspective correction, calculates the counterclockwise rotation angle, rotation correction, code point recognition and decoding to achieve recognition of the binary code of the mold with different lighting, rotation and size changes, and greatly improves the recognition rate of the binary code on the mold surface. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] Figure 1 It is an overall flow chart of a recognition method based on binary dot matrix code on mold surface of the present invention;
[0090] Figure 2 It is a standard pattern of a binary dot matrix code in an embodiment of a recognition method based on a binary dot matrix code on a mold surface of the present invention;
[0091] Figure 3 It is a schematic diagram of positioning mark target detection in an embodiment of a recognition method based on binary dot matrix code on mold surface of the present invention;
[0092] Figure 4 A schematic diagram of the vertices of a binary dot matrix code in an embodiment of a recognition method based on a binary dot matrix code on a mold surface according to the present invention;
[0093] Figure 5A schematic diagram of a pixel coordinate system of a digital image in an embodiment of a recognition method based on a binary dot matrix code on a mold surface of the present invention;
[0094] Figure 6 The figure is a schematic diagram of dividing image blocks in an embodiment of a recognition method based on binary dot matrix code on a mold surface of the present invention. DETAILED DESCRIPTION
[0095] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments, but the scope of protection claimed in the present invention is not limited to the following specific embodiments.
[0096] In this embodiment, the production rules of the binary dot code image on the mold surface are encoded by a binary-based mold encoding method disclosed in the existing patent CN117375623 B, which includes character encoding: converting the ID character of the marking mold into a character binary code through a character encoding table; generating an error correction code: generating an error correction code according to the Reed-Solomon encoding principle and converting it into an error correction binary code; generating a coding pattern: arranging the error correction binary code in sequence after the character binary code to generate a combined binary code and generate an N*M rectangular coding pattern; coding coding: engraving the coding pattern on the mold surface; coding recognition and decoding: using image recognition technology to recognize the coding pattern, convert it into a binary code and decode it. For detailed coding steps, see the specific implementation method of the patent.
[0097] The method of this patent is a method for identifying the binary dot matrix code on the mold surface obtained by encoding based on the above patent. The specific implementation example is as follows.
[0098] like Figure 1 As shown, a method for identifying a binary dot matrix code on a mold surface comprises the following steps:
[0099] Step S1: Data collection: A large number of binary dot matrix code images of the mold surface are collected by a camera, and a positioning mark pattern is set on each of the four corners of the binary dot matrix code image. A target detection frame is marked on each positioning mark pattern to form a training set;
[0100] As attached Figure 3 and attached Figure 4 As shown, the gray box represents the target detection box, and the black dots in the box represent the corner points of the target detection box, where 0 represents a normal corner point and 1 represents the outermost vertex of the binary dot code image.
[0101] Step S2: training the model: inputting the training set data into the YOLOv8 network model to train the model, obtaining the optimal weight data of the YOLOv8 network model, and loading the obtained optimal weight data into the YOLOv8 network model again to obtain the trained and upgraded YOLOv8 network model;
[0102] The YOLOv8 network model here is an existing network model, a SOTA (State Of The Art, the most advanced technology level) model, built on the success of previous YOLO versions, and introduced new features and improvements, including a new backbone network, a new Anchor-Free detection head and a new loss function, which can run on a variety of hardware platforms from CPU to GPU. It supports a full range of visual AI tasks, including detection, segmentation, pose estimation, tracking and classification.
[0103] Step S3: Positioning mark detection: The binary dot code image of the surface of the mold to be tested is collected again by the camera to form a test set, and the test set image is input into the upgraded YOLOv8 network model. The model detects and outputs the corner points of the four positioning mark target detection frames corresponding to the binary dot code image of the test set. Each target detection frame has 4 corner points, for a total of 16 corner points.
[0104] As attached Figure 3 As shown in the figure, the points marked as 0 and 1 are the corner points of the target detection box.
[0105] Step S4: Peripheral vertex detection: The 16 corner points are screened by a screening strategy to calculate the position coordinates of the outermost vertices of the four target detection frames. Figure 4 As shown in the figure, the points marked as 1 are the outermost vertices of the four target detection frames. The positions of the outermost vertices here correspond to the positions in the four target detection frames: respectively located at the top, bottom, leftmost and rightmost of the entire binary dot code pattern.
[0106] There are two screening strategies here:
[0107] The screening method of the first screening strategy is as follows:
[0108] Step S4-a1: construct the 16 corner points of the four target detection boxes output by the YOLOv8 network model in step S3 into a set P,
[0109] Let each corner point be a ij Its coordinates are represented by (x ij ,y ij), where i represents the number of the target detection box, and its value range is i∈{1,2,3,4}; j represents the jth corner point among the four corner points of the box, and its value range is j∈{1,2,3,4}.
[0110] The coordinates mentioned in this application are coordinates in a digital image, and the origin of the coordinates (0, 0) is at the upper left corner, which is different from the origin of conventional two-dimensional coordinates (0, 0) at the lower left corner.
[0111] The coordinates mentioned in this application are pixel coordinates in digital images. In digital images, the origin of pixel coordinates (0,0) is usually located in the upper left corner of the image. The x coordinate represents the horizontal position of the pixel point: x = 0 is the leftmost side of the image, and as the x value increases, the pixel point moves to the right; the y coordinate represents the vertical position of the pixel point, y = 0 is the top of the image, and as the y value increases, the pixel point moves downward.
[0112] As attached Figure 5 As shown in the figure, the gray area represents a digital image, the point marked as R is the origin of the pixel coordinate (0,0), the point marked as X represents the X axis (the horizontal direction of the image), and the point marked as Y represents the Y axis (the vertical direction of the image).
[0113] Step S4-a2: The coordinate information of the four corner points of the first target detection frame is:
[0114] a 11 The coordinates are: (x 11 ,y 11 ), a 12 The coordinates are: (x 12 ,y 12 ), a 13 The coordinates are: (x 13 ,y 13 ), a 14 The coordinates are: (x 14 ,y 14 );
[0115] Step S4-a3: Assume that the position coordinates of the outermost vertices of the four target detection frames of the binary dot matrix code are Q 1 (x Q1 ,y Q1 ), Q 2 (x Q2 ,y Q2 ), Q 3 (x Q3 ,y Q3 ), Q 4 (x Q4 ,y Q4 ), and Q 1 Located at the top of the binary dot code, Q2 Located at the bottom of the binary dot code, Q 3 Located on the far left of the binary dot code, Q 4 Located in the binary dot code, the coordinates of each vertex are calculated as follows:
[0116] Q 1 Located at the top of the binary dot code pattern, then its ordinate is the point with the smallest ordinate in the point set P, as shown in the following formulas (1) and (2):
[0117]
[0118]
[0119] Q 2 Located at the bottom of the binary dot code pattern, its ordinate is the point with the largest ordinate in the point set P, as shown in the following formulas (3) and (4):
[0120]
[0121]
[0122] Q 3 Located on the left side of the binary dot code pattern, then its horizontal coordinate is the point with the smallest horizontal coordinate in the point set P, as shown in the following formulas (5) and (6):
[0123]
[0124]
[0125] Q 4 Located on the far right side of the binary dot code pattern, then its horizontal coordinate is the point with the largest horizontal coordinate in the point set P, as shown in the following formulas (7) and (8):
[0126]
[0127]
[0128] The screening method of the second screening strategy is as follows:
[0129] The 16 corner points of the four target detection boxes output by the Yolov8 network model in step S3 are constructed into a set W, where each point w i The coordinates are (x i ,y i );
[0130] For any point wi With the other 15 corner points w j The distance (j≠i) is defined as d(w i ,w j ), calculated using the Euclidean distance formula (9):
[0131]
[0132] Next, click w i The sum of the distances to the other 15 corner points can be calculated using the following formula (10):
[0133]
[0134] By comparing all , select the first 4 largest The point w corresponding to the value i These are the four vertices of the binary dot code, and the expression formula is as follows:
[0135] Assume that all Arranged in descending order, the sorted sequence is as follows (11):
[0136]
[0137] Then select the first 4 largest The corresponding point set P′ is:
[0138] P′={w 1 ,w 2 ,w 3 ,w 4} (12).
[0139] The above two methods can select the outermost vertices corresponding to the four target detection boxes.
[0140] Step S5 perspective correction: a distorted quadrilateral is obtained according to the position coordinates of the outermost vertices of the four target detection frames, that is, the four vertices are connected to form an irregular quadrilateral, and then the distorted quadrilateral is converted into a standard L×L square pattern through perspective transformation;
[0141] The transformation formula of the perspective transformation here is the transformation process of transforming the pixel coordinates (u, v) from a point in the three-dimensional world coordinate system to the two-dimensional plane pixel coordinates (x′, y′).
[0142] The transformation formula (13) of perspective transformation is as follows:
[0143]
[0144] Where: The coordinates of the original image in the two-dimensional plane are (u, v), where w = 1. (x′, y′, z′) are the three-dimensional space coordinates after conversion;
[0145] Perspective transformation matrix Split into 3 parts, Used as a linear transformation, Used as perspective transformation, (b 31 ,b 32 ) for translation operations.
[0146] The pixel coordinates (u, v) are transformed to a point on the three-dimensional world coordinate system, and then transformed to a new two-dimensional plane to obtain the corrected coordinates (x, y). The calculation formulas are shown in (14) and (15):
[0147]
[0148]
[0149] Assume that the size of the standard binary lattice code is L, and define the four outer vertices of the standard binary lattice code on the new two-dimensional plane as Q′ 1 (0,0),Q′ 2 (L,0),Q′ 3 (0,L),Q′ 4 (L, L); The four vertices Q of the binary lattice code are obtained through step S4 1 ,Q 2 ,Q 3 ,Q 4 The corresponding point after perspective transformation is Q′ 1 ,Q′ 2 ,Q′ 3 ,Q′ 4 .
[0150] Specifically, here is an example of perspective transformation. Assuming that the size of the standard binary dot code pattern is L=300, the size of the binary dot code is 300×300, and the coordinates of its four vertices are:
[0151] Q′ 1 (0,0),Q′ 2 (300,0),Q′ 3 (0,300),Q′ 4 (300,300).
[0152] Assume that the original binary dot code pattern outer vertex Q 1 ,Q 2 ,Q 3 ,Q 4 The coordinates are:
[0153] Q 1 (23.3625,10.4983), Q 2 (185.0730,206.0371),Q 3 (2.3291,189.7386),Q 4 (211.6296,26.8318).
[0154] The outer vertices Q of the original binary dot code pattern 1 ,Q 2 ,Q 3 ,Q 4 And the outer vertex Q′ of the standard binary dot code pattern after perspective transformation 1 ,Q′ 2 ,Q′ 3 ,Q′ 4 Substituting into formula (13), the perspective transformation matrix can be obtained as follows:
[0155]
[0156] Step S6 calculates the counterclockwise rotation angle: the square pattern obtained in step S5 is input into the YOLOv8 network model upgraded in step S2 for training, and 16 corner points of the target detection frame corresponding to the square pattern positioning mark are output;
[0157] The coordinates of the center point G of the target detection frame are obtained according to the 16 corner points of the target detection frame;
[0158] Compare the coordinates of the center point G of the target detection frame with the center point of the square pattern obtained in step S5 The coordinate position of the square pattern is obtained by rotating the square pattern counterclockwise at an angle θ;
[0159] Specifically, the steps to obtain the counterclockwise rotation angle θ are as follows:
[0160] Step S6-1: Assume that the four corner points of the square positioning mark target detection box are represented as d i , the coordinates are expressed as (x i ,y i ), where i∈[1,4], the target detection box center point G(x G ,y G ), the coordinates of the center point of the target detection box can be calculated by formulas (16) and (17) as follows:
[0161]
[0162]
[0163] Step S6-2: By comparing the coordinates of the center point of the target detection frame G(x G ,y G ) and the center point coordinates of the square pattern obtained in step S5 Determine the angle θ of the counterclockwise rotation of the square pattern, and the corresponding relationship is as follows:
[0164]
[0165] Specifically, here is an example of calculating the rotation angle. Assuming that the coordinates of the center point of the target detection frame are G(40,80), and the size of the square pattern is 100×100, then Then the coordinates have the following relationship:
[0166]
[0167]
[0168] So we can get θ=90.
[0169] Step S7: Rotation correction: rotate the square pattern counterclockwise to the correct position θ by perspective transformation to obtain the standard pattern of the binary dot code image of the set to be tested;
[0170] The specific operations are as follows:
[0171] Assume that a certain point w(x, y) on the binary dot matrix code after perspective correction in step S5 is rotated counterclockwise by an angle of θ; the steps of the rotation process are as follows:
[0172] Calculate point w relative to the center point Coordinates w′(x′,y′):
[0173]
[0174]
[0175] Apply the rotation matrix R to rotate w′:
[0176]
[0177]
[0178] Translate w″ back to its original position to get the final rotation point w″′(x″,y″):
[0179]
[0180]
[0181] Combining the above steps, we can get the coordinates w″′(x″,y″) after w is rotated θ degrees around the center point of the image:
[0182]
[0183] Step S8: Code point recognition: according to the binary code point scale, the standard pattern is equally divided into image blocks of the same size; then the image blocks are sequentially input into the YOLOv8 network model upgraded in step S2 from top to bottom and from left to right for recognition and output of the results;
[0184] If the image block has a code point, the output is 1, if the image block does not have a code point, the output is 0;
[0185] Finally, the recognition results are connected to obtain a binary coded sequence data;
[0186] The specific operations are as follows:
[0187] S8-1 dot matrix code is divided into image blocks: according to the scale of the binary code points, the dot matrix code rotated to the correct position in step S7 is divided into image blocks of the same size. Figure 6 As shown;
[0188] S8-2 Image block code point recognition: The YOLOv8 network model upgraded from S2 is used to identify the circular binary code points of the image block in order from top to bottom and from left to right. If the code point exists in the image block, it is recorded as 1. If the binary code point does not exist in the image block, it is recorded as 0. Finally, a binary 01 code sequence is obtained by recognition and reading.
[0189] Step S9 decoding: Decoding the binary coded sequence data according to the binary coded decoding rule to obtain the character information corresponding to the binary code.
[0190] Specifically, the two screening methods in step 6 of this embodiment are described as follows:
[0191] For the first screening method, assume that after a binary dot code image is detected by the positioning mark, the YOLOv8 network outputs the coordinates of the 16 corner points of the four target detection boxes as follows:
[0192] The first target detection box: a 11 (2.3291,189.7386),a 12 (31.8235,190.5836),
[0193] a 13 (32.6759,160.8312),a 14 (3.1815,159.9861)
[0194] The second target detection box: a 21 (55.0101,42.9026),a 22 (56.1172,11.6590),
[0195] a 23 (23.3625,10.4983),a 24 (22.2553,41.7419)
[0196] The third target detection box: a 31 (180.4171,57.0028),a 32 (210.5101,58.0810),
[0197] a 33 (211.6296,26.8318),a 34 (181.5367,25.7537)
[0198] The fourth target detection box: a 41 (185.0730,206.0371),a 42 (185.9736,177.9098),
[0199] a 43 (154.1791,176.8919),a 44 (153.2786,205.0192)
[0200] Applying vertex screening rules to the coordinates of its 16 corner points yields:
[0201] Q 1 Located at the top of the binary dot code pattern, then its ordinate is the point with the smallest ordinate in the point set P, then the corresponding corner point is a 23 (23.3625,10.4983).
[0202] Q 2 Located at the bottom of the binary dot code pattern, its ordinate is the point with the largest ordinate in the point set P, then the corresponding corner point is a 41 (185.0730,206.0371).
[0203] Q 3 Located on the left side of the binary dot code pattern, then its horizontal coordinate is the point with the smallest horizontal coordinate in the point set P, then the corresponding corner point is a 11 (2.3291,189.7386).
[0204] Q 4 Located on the far right side of the binary dot code pattern, then its horizontal coordinate is the point with the largest horizontal coordinate in the point set P, then the corresponding corner point is a 33 (211.6296,26.8318).
[0205] For the second screening method, an example is given for detailed description: Assuming that a binary dot code image is detected by the positioning mark, the YOLOv8 network outputs the coordinates of the 16 corner points of the 4 target detection boxes as follows:
[0206] w 1 (9,3),w 2 (6,9),w 3 (1,5),w 4 (7,10),w 5 (3,7),w 6 (3,10),w 7 (9,2),w 8 (7,6),w 9 (5,0),w 10 (2,6),w 11 (1,10),w 12 (3,6),w 13 (8,2),w 14 (9,7),w 15 (3,5),w 16 (7,8).
[0207] Then click w i With other points w j The sum of the distances (keep two decimal places) as follows:
[0208] Point w 1 The sum of the distances between (9,3) and other points is: 90.35;
[0209] Point w 2 The sum of the distances between (6,9) and other points is: 72.77;
[0210] Point w 3 The sum of the distances between (1,5) and other points is: 84.92;
[0211] Point w 4 The sum of the distances between (7,10) and other points is: 86.08;
[0212] Point w 5 The sum of the distances between (3,7) and other points is: 66.07;
[0213] Point w 6 The sum of the distances between (3,10) and other points is: 86.36;
[0214] Point w 7 The sum of the distances between (9,2) and other points is: 97.78;
[0215] Point w 8 The sum of the distances between (7,6) and other points is: 66.12;
[0216] Point w 9 The sum of the distances between (5,0) and other points is: 108.03;
[0217] Point w 10 The sum of the distances between (2,6) and other points is: 71.95;
[0218] Point w 11 The sum of the distances between (1,10) and other points is: 101.11;
[0219] Point w 12 The sum of the distances between (3,6) and other points is: 64.81;
[0220] Point w 13 The sum of the distances between (8,2) and other points is: 90.86;
[0221] Point w 14 The sum of the distances between (9,7) and other points is: 82.82;
[0222] Point w 15 The sum of the distances between (3,5) and other points is: 67.90;
[0223] Point w 16 The sum of the distances between (7,8) and other points is: 70.17;
[0224] Through all Sort and select the top 4 largest The results are as follows:
[0225] Point w 9 The sum of the distances between (5,0) and other points is: 108.03;
[0226] Point w 11 The sum of the distances between (1,10) and other points is: 101.11;
[0227] Point w 7 The sum of the distances between (9,2) and other points is: 97.78;
[0228] Point w 13 The sum of the distances between (8,2) and other points is: 90.86;
[0229] Therefore, P′={w 9 ,w 11 ,w 7 ,w 13}.
[0230] The present invention uses the YOLOv8 network model to perform positioning and identification detection on the binary dot code image on the mold surface, and then calculates the outermost vertices of the target detection frame through a screening strategy. Then, through perspective correction, calculation of the counterclockwise rotation angle, rotation correction, code point recognition and decoding, the recognition of the binary code of the mold with different illumination, rotation and size changes is realized, and the recognition rate of the binary code on the mold surface is greatly improved.
[0231] According to the disclosure and teaching of the above description, those skilled in the art to which the present invention belongs may also make changes and modifications to the above embodiments. Therefore, the present invention is not limited to the specific embodiments disclosed and described above, and some modifications and changes to the invention should also fall within the scope of protection of the claims of the present invention. In addition, although some specific terms are used in this specification, these terms are only for the convenience of description and do not constitute any limitation to the invention.
Claims
1. A method for identifying binary dot codes on mold surfaces, characterized in that: The method comprises the following steps: Step S1: Data collection: A large number of binary dot matrix code images of the mold surface are collected by a camera, and a positioning mark pattern is set on each of the four corners of the binary dot matrix code image. A target detection frame is marked on each positioning mark pattern to form a training set; Step S2: training the model: inputting the training set data into the YOLOv8 network model to train the model, obtaining the optimal weight data of the YOLOv8 network model, and loading the obtained optimal weight data into the YOLOv8 network model again to obtain the trained and upgraded YOLOv8 network model; Step S3: Positioning mark detection: The binary dot code image of the surface of the mold to be tested is collected by a camera to form a test set, and the test set image is input into the upgraded YOLOv8 network model. The model detects and outputs the corner points of four target detection frames corresponding to the test set data. Each target detection frame has 4 corner points, for a total of 16 corner points. Step S4 calculates the outer vertices: the 16 corner points are screened by a screening strategy to calculate the position coordinates of the outermost vertices of the four target detection frames; Step S5 perspective correction: a distorted quadrilateral is obtained according to the position coordinates of the outermost vertices of the four target detection frames, and then the distorted quadrilateral is converted into a standard L×L square pattern through perspective transformation; Step S6 calculates the counterclockwise rotation angle: the square pattern obtained in step S5 is input into the YOLOv8 network model upgraded in step S2 for detection, and the four corner points of the target detection frame corresponding to the square pattern positioning mark are output; The coordinates of the center point G of the target detection frame are obtained according to the four corner points of the target detection frame; Compare the coordinates of the center point G of the target detection frame with the center point of the square pattern obtained in step S5 The coordinate position of the square pattern is obtained by rotating the square pattern counterclockwise at an angle θ; Step S7: Rotation correction: by perspective transformation, the square pattern of step S5 is rotated counterclockwise by θ to the correct position, so as to obtain the standard pattern of the binary dot code picture of the test set; Step S8: Code point recognition: according to the scale of the binary code point, the standard pattern is equally divided into image blocks of the same size; then the image blocks are sequentially input into the YOLOv8 network model upgraded in step S2 for recognition in the order from top to bottom and from left to right; If the code point exists in the image block, the output is 1, if the code point does not exist in the image block, the output is 0; Finally, the recognition results are connected to obtain a binary coded sequence data; Step S9 decoding: Decoding the binary coded sequence data according to the binary coded decoding rule to obtain the character information corresponding to the binary code.
2. A method for identifying binary dot codes on a mold surface as claimed in claim 1, characterized in that: There are two screening strategies, which are set as the first screening strategy and the second screening strategy, wherein: The screening method of the first screening strategy is as follows: Step S4-a1: construct the 16 corner points of the four target detection boxes output by the YOLOv8 network model in step S3 into a set P, Let each corner point be a ij Its coordinates are represented by (x ij ,y ij ), where i represents the number of the target detection box, and its value range is i∈{1,2,3,4}; j represents the jth corner point among the four corner points of the box, and its value range is j∈{1,2,3,4}; Step S4-a2: The coordinate information of the four corner points of the first target detection frame is: a 11 The coordinates are: (x 11 ,y 11 ), a 12 The coordinates are: (x 12 ,y 12 ), a 13 The coordinates are: (x 13 ,y 13 ), a 14 The coordinates are: (x 14 ,y 14 ); Step S4-a3: Assume that the outermost vertices of the four target detection boxes are Q1(x Q1 ,y Q1 ), Q2(x Q2 ,y Q2 ), Q3(x Q3 ,y Q3 ), Q4(x Q4 ,y Q4 ), and Q1 is located at the top of the binary dot code pattern, Q2 is located at the bottom of the binary dot code pattern, Q3 is located at the leftmost side of the binary dot code pattern, and Q4 is located at the rightmost side of the binary dot code pattern, then the coordinates of each vertex are calculated as follows: Q1 is at the top of the binary dot code pattern, so its ordinate is the point with the smallest ordinate in the point set P, as shown in the following formulas (1) and (2): Q2 is at the bottom of the binary dot code pattern, so its ordinate is the point with the largest ordinate in the point set P, as shown in the following formulas (3) and (4): Q3 is located at the far left of the binary dot code pattern, so its horizontal coordinate is the point with the smallest horizontal coordinate in the point set P, as shown in the following formulas (5) and (6): Q4 is located at the rightmost side of the binary dot code pattern, so its horizontal coordinate is the point with the largest horizontal coordinate in the point set P, as shown in the following formulas (7) and (8):
3. A method for identifying binary dot codes on a mold surface as claimed in claim 2, characterized in that: The screening method of the second screening strategy is as follows: The 16 corner points of the four target detection boxes output by the YOLOv8 network model in step S3 are constructed into a set W, where each point w i The coordinates are (x i ,y i ); For any point w i With the other 15 corner points w j The distance (j≠i) is defined as d(w i ,w j ), calculated using the Euclidean distance formula (9): Next, click w i The sum of the distances to the other 15 corner points is calculated using the following formula (10): By comparing all , select the first 4 largest The point corresponding to the value w i These are the four outer vertices of the binary dot code, expressed as follows: Assume that all Arranged in descending order, the sorted sequence is as follows (11): Then select the first 4 largest The corresponding point set P′ is: P′={w1,w2,w3,w4} (12).
4. A method for identifying binary dot codes on a mold surface as claimed in claim 1, characterized in that: The transformation formula of the perspective transformation is a transformation process of transforming the pixel coordinates (u, v) to a point on the three-dimensional world coordinate system, and then converting it to another pixel coordinate (x′, y′). The transformation formula (13) of perspective transformation is as follows: Where: the coordinates of the original image in the two-dimensional plane are (u, v), where w = 1, and (x′, y′, z′) are the three-dimensional space coordinates after conversion; Perspective transformation matrix Split into 3 parts, Used as a linear transformation, Used as perspective transformation, (b 31 ,b 32 ) for translation operations.
5. A method for identifying binary dot codes on a mold surface as claimed in claim 4, characterized in that: In the perspective transformation, the pixel coordinates (u, v) are transformed to points on the three-dimensional world coordinate system, and then transformed to a new two-dimensional plane, and the corrected coordinates are obtained as (x, y). The calculation formulas are shown in (14) and (15):
6. A method for identifying binary dot codes on a mold surface as claimed in claim 1, characterized in that: The steps of obtaining the counterclockwise rotation angle θ of the square pattern in step S6 are as follows: Step S6-1: Assume that the four corner points of the square positioning mark target detection box are represented as d i , the coordinates are expressed as (x i ,y i ), where i∈[1,4], the target detection box center point G(x G ,y G ), the coordinate of the center point G of the target detection frame can be calculated by formulas (16) and (17) as follows: Step S6-2: By comparing the coordinates of the center point of the target detection frame G(x G ,y G ) and the center point coordinates of the square pattern in step S5 Determine the angle θ of the counterclockwise rotation of the square pattern, and the corresponding relationship is as follows:
7. A method for recognizing binary dot codes on a mold surface as claimed in claim 6, characterized in that: The steps of obtaining the standard pattern in step S7 are as follows: Assume that a certain point w(x, y) on the binary dot code pattern after perspective correction in step S5 is rotated counterclockwise by an angle of θ; the steps of the rotation process are as follows: Calculate point w relative to the center point Coordinates w′(x′,y′): Apply the rotation matrix R to rotate w′: Translate w” back to its original position to get the final rotation point w″′(x”,y”): Combining the above steps, we can get the coordinates w″′(x”,y”) after w is rotated θ degrees around the center point of the image:
8. A method for identifying binary dot codes on a mold surface as claimed in claim 1, characterized in that: The code point recognition in step S8 includes the following steps: S8-1 Divide the binary dot code standard pattern into image blocks: according to the scale of the binary code points, divide the binary dot code standard pattern rotated to the correct position in step S7 into image blocks of the same size in equal parts; S8-2 Image block code point recognition: The YOLOv8 network model upgraded in step S2 is used to identify the circular binary code points of the image block in order from top to bottom and from left to right. If the code point exists in the image block, it is recorded as 1; if the binary code point does not exist in the image block, it is recorded as 0. Finally, a binary 01 code sequence is obtained by recognition and reading.
Citation Information
Patent Citations
A binary-based pattern encoding and recognition method, storage device, and smart terminal
CN117375623B
Image perspective correction method, system and device
CN108364259A
Two-dimensional code recognition method and device
CN111860027A
Bolt looseness defect detection method, system and device
CN114820620A
Dial pointer reading identification method based on target coding and decoding
CN116612265A