Image position matching method and system, electronic device and storage medium
By fitting the set of center points of circles and the set of center points of standard rows and columns in the laser-marked QR code image, and calculating the minimum positional distance, the problem of inaccurate image matching under the influence of materials and lighting is solved, and the success rate of QR code recognition is improved.
Patent Information
- Application Number
- CN202310433638.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-17
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-04-17
AI Technical Summary
Existing image matching methods are affected by different materials, surface treatment processes and lighting when acquiring laser-marked QR code images, resulting in inaccurate matching and potentially leading to QR code recognition errors or failures.
By acquiring the image of the laser-marked QR code, the effective contour is determined and fitted into a circle, generating a set of center points of the fitted circle. This set is then combined with the center point set of the standard row and column grids for image matching, and the minimum positional distance is calculated to improve matching accuracy.
It improves the accuracy of image location matching and enhances the success rate of QR code recognition.
Smart Images

Figure CN116597179B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and in particular to an image position matching method and system, an electronic device, and a storage medium. BACKGROUND
[0002] A two-dimensional code can store some computer-recognizable information through different patterns of characters, and has been widely used in people's work and life in recent years. Using laser marking two-dimensional code images, a combination of round dot two-dimensional code images can be marked on various materials such as metal, plastic, and ceramic. In the related art, image matching needs to be performed on the two-dimensional code on the surface of the material. However, when the laser-marked two-dimensional code image is obtained, it is affected by different materials, different surface treatment processes of the same material, or different light, resulting in a large difference between the actual two-dimensional code image taken by the camera and the original image. The commonly used position matching method is difficult to adapt to different scenes, and may cause two-dimensional code recognition errors or failure due to inaccurate matching. SUMMARY
[0003] The main purpose of the embodiments of the present application is to provide an image position matching method and system, an electronic device, and a storage medium, which can improve the accuracy of image position matching and the success rate of two-dimensional code recognition.
[0004] To achieve the above-mentioned purpose, a first aspect of the embodiments of the present application provides an image position matching method, which comprises: obtaining a first two-dimensional code image marked by laser; determining a plurality of effective contours in the first two-dimensional code image, fitting a plurality of circles according to the plurality of effective contours to obtain a set of circle center points of the fitted circles; generating a second two-dimensional code image corresponding to the size of the first two-dimensional code image, and drawing the set of circle center points on the second two-dimensional code image to obtain a third two-dimensional code image; determining an initial positioning point of a two-dimensional code grid in a row and a column from the third two-dimensional code image, and obtaining a set of standard row and column grid center points of the two-dimensional code based on the initial positioning point and the number of rows and columns and the spacing of a standard two-dimensional code; and performing image matching on the first two-dimensional code image based on the set of circle center points and the set of standard row and column grid center points to obtain an image position matching result.
[0005] According to some embodiments of the present application, the image matching on the first two-dimensional code image based on the set of circle center points and the set of standard row and column grid center points to obtain an image position matching result comprises: obtaining a circle center point coordinate of the set of circle center points based on the set of circle center points; obtaining a center point coordinate of the set of row and column grid center points based on the set of row and column grid center points; determining a minimum position distance between the center point coordinate and the circle center point coordinate according to each center point coordinate and the circle center point coordinate; and performing image matching on the first two-dimensional code image according to the minimum position distance to obtain an image position matching result.
[0006] According to some embodiments of the present application, the image matching of the first two-dimensional code image according to the minimum position distance comprises: obtaining the minimum position distance between each of the center point coordinates and the circle center point coordinates; adding the minimum position distances of the row-column lattice center point set to obtain a minimum position distance total value; obtaining the number of the row-column lattice center point set; calculating a minimum position distance average value according to the minimum position distance total value and the number of the row-column lattice center point set; and performing image matching on the first two-dimensional code image according to the minimum position distance average value to obtain an image position matching result.
[0007] According to some embodiments of the present application, the determination of the plurality of effective contours in the first two-dimensional code image and the fitting of the plurality of effective contours into a plurality of circles to obtain a circle center point set of the fitted circles comprises: performing edge detection on the first two-dimensional code image to obtain an image after edge detection; performing binarization on the image based on the image after edge detection to obtain an image after binarization; and determining the contour of the image according to the image after binarization.
[0008] obtaining a contour parameter of the contour; determining a plurality of effective contours in the contour according to the contour parameter; and fitting the plurality of effective contours into a plurality of circles to obtain a circle center point set of the fitted circles.
[0009] According to some embodiments of the present application, the determination of the plurality of effective contours in the contour according to the contour parameter comprises: obtaining a radius of the fitted circle according to the contour parameter; determining a maximum area and a minimum area of the fitted circle according to the radius; and determining the plurality of effective contours according to the maximum area and the minimum area.
[0010] According to some embodiments of the present application, the generation of a second two-dimensional code image of a size corresponding to the first two-dimensional code image and the drawing of the circle center point set on the second two-dimensional code image to obtain a third two-dimensional code image comprises: generating a second two-dimensional code image of a size corresponding to the first two-dimensional code image according to a preset ratio; and drawing the circle center point set on the second two-dimensional code image to obtain a third two-dimensional code image.
[0011] According to some embodiments of the present application, the determining initial positioning points of the cells in the rows and columns of the two-dimensional code from the third two-dimensional code image, and obtaining a standard row and column cell center point set of the two-dimensional code based on the initial positioning points and the number of rows and columns and the spacing of a standard two-dimensional code, comprises: performing projection in horizontal and vertical directions according to the third two-dimensional code image; determining initial positioning points of the cells in the rows and columns of the two-dimensional code based on the projection positions; selecting a form of the standard two-dimensional code, and obtaining the number of rows and columns and the spacing of the standard two-dimensional code according to the standard two-dimensional code; generating row and column cell center point coordinates according to the initial positioning points, the number of rows and columns and the spacing of the standard two-dimensional code; and obtaining a standard row and column cell center point set of the two-dimensional code according to a plurality of the row and column cell center point coordinates.
[0012] To achieve the above object, the second aspect of the present application provides an image position matching system, which comprises: a first two-dimensional code image acquisition module, configured to acquire a first two-dimensional code image of laser marking; a fitted circle center point set acquisition module, configured to determine a plurality of effective contours in the first two-dimensional code image, fit a plurality of circles according to the plurality of effective contours, and obtain a fitted circle center point set; a second two-dimensional code image acquisition module, configured to generate a second two-dimensional code image of a size corresponding to the first two-dimensional code image, and draw the fitted circle center point set on the second two-dimensional code image to obtain a third two-dimensional code image; a standard row and column cell center point set generation module, configured to determine initial positioning points of cells in rows and columns of a two-dimensional code from the third two-dimensional code image, and obtain a standard row and column cell center point set of the two-dimensional code based on the initial positioning points and the number of rows and columns and the spacing of a standard two-dimensional code; and an image position matching result acquisition module, configured to perform image matching on the first two-dimensional code image based on the fitted circle center point set and the standard row and column cell center point set to obtain an image position matching result.
[0013] To achieve the above object, the third aspect of the present application provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the image position matching method of any one of the first aspect of the present application when executing the computer program.
[0014] To achieve the above object, the fourth aspect of the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the image position matching method of any one of the first aspect of the present application when executed by a processor.
[0015] The image position matching method, system, electronic device and storage medium provided in the application can generate a circle center point set of a fitting circle and a standard row-column grid center point set, and perform minimum position distance matching on the circle center point set and the standard row-column grid center point set. When the minimum position distance is the smallest, it indicates that the row-column grid center point coordinates are aligned with the circle center point coordinates, thereby obtaining an image position matching result, improving the accuracy of image position matching, and improving the success rate of two-dimensional code recognition. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 is a structural schematic diagram of an image position matching system provided by an embodiment of the application;
[0017] Figure 2 is a flowchart of an image position matching method provided by an embodiment of the application;
[0018] Figure 3 is Figure 2 a flowchart of step S105 in
[0019] Figure 4 is Figure 3 a flowchart of step S204 in
[0020] Figure 5 is Figure 2 a flowchart of step S102 in
[0021] Figure 6 is Figure 5 a flowchart of step S405 in
[0022] Figure 7 is Figure 2 a flowchart of step S103 in
[0023] Figure 8 is Figure 2 a flowchart of step S104 in
[0024] Figure 9 is a functional module schematic diagram of an image position matching system provided by an embodiment of the application;
[0025] Figure 10 is a hardware structure schematic diagram of an electronic device provided by an embodiment of the application. DETAILED DESCRIPTION
[0026] In order to make the objectives, technical solutions and advantages of the application clearer, the application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the application and should not be used to limit the application.
[0027] It should be noted that although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in a manner different from the module division in the device or the order in the flowchart. The terms "first", "second", and the like in the description and claims and the above drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this application is for the purpose of describing embodiments of this application only, and is not intended to be limiting of this application.
[0029] The laser marking two-dimensional code image refers to a combined two-dimensional code image of round dots marked on various materials such as metal, plastic, and ceramic using a laser marking device. Two-dimensional codes can store some computer-recognizable information through different pattern characters, and have been widely used in people's work and life in recent years. In the related art, the two-dimensional code on the surface of the material needs to be image matched, but when the laser marked two-dimensional code image is obtained, it will be affected by different materials, different surface treatment processes of the same material, or different light, resulting in a large difference between the actual two-dimensional code image taken by the camera and the original image. The commonly used position matching method is difficult to adapt to different scenes, and may cause two-dimensional code recognition error or failure due to inaccurate matching.
[0030] Based on this, the embodiments of the present application provide an image position matching method, system, electronic device and storage medium, which can improve the accuracy of image position matching and improve the success rate of two-dimensional code recognition.
[0031] The image position matching method, system, electronic device and storage medium provided by the embodiments of the present application are specifically explained by the following embodiments. First, the image position matching system in the embodiments of the present application is described.
[0032] As shown in Figure 1 In some embodiments, the image position matching system can include an image acquisition module 101, a processing module 102, and a display module 103.
[0033] In some embodiments, the image acquisition module 101 is configured to read an image to be matched and a template image. It can be understood that the image acquisition module 101 can be an image taking device, such as a mobile phone, a tablet computer, a code scanner, or other devices that can acquire images. For example, the acquired image can be a two-dimensional code image or other images.
[0034] In some embodiments, the processing module 102 can include one or more processing units, for example: the processing module 102 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processing modules 102. It can be understood that the image processor can process the image collected by the image acquisition module 101, including edge detection of the image, binarization of the image, finding the contour from the binarized image, etc., and the present application embodiment does not make specific limitations thereto.
[0035] In some embodiments, the controller can be the nerve center and command center of the image position matching system. The controller can generate operation control signals according to instruction operation codes and timing signals to complete the control of instruction fetching and instruction execution. For example, the controller can scan the image according to the scanning instruction of the image, or calculate the center point in the image according to the calculation instruction, etc.
[0036] In some embodiments, the display module 103 is used to display the matching result after the image is matched by the processing module 102. It can be understood that the display module 103 can display the matching row and column grid center point coordinates, and the matching result of the row and column grid center point coordinates and the center point coordinates to be matched. Further, the display module 103 can also display the image information after matching.
[0037] The image position matching method in the embodiments of the present application can be illustrated by the following embodiments.
[0038] It should be noted that in various specific embodiments of the present application, when relevant processing needs to be performed on data related to the identity or characteristics of the user, such as user information, user behavior data, user history data, and user location information, the user's permission or consent will be obtained first, for example, when accessing the user's stored data and the user's cached data, the user's permission or consent will be obtained first. Moreover, the collection, use and processing of such data will comply with relevant national and regional laws, regulations and standards. In addition, when the embodiments of the present application need to obtain sensitive personal information of the user, the separate permission or separate consent of the user will be obtained through a pop-up window or a jump to a confirmation page, and after obtaining the separate permission or separate consent of the user, the necessary user-related data for the normal operation of the embodiments of the present application will be obtained.
[0039] Please refer to Figure 2 , Figure 2 is an optional flowchart of the image position matching method provided by the embodiments of the present application, Figure 2 The method in the embodiments of the present application can include but is not limited to steps S101-S105:
[0040] Step S101, acquiring a first two-dimensional code image marked by laser;
[0041] Step S102, determining a plurality of valid contours in the first two-dimensional code image, fitting a plurality of circles according to the plurality of valid contours, and obtaining a set of circle center points of the fitted circles;
[0042] Step S103, generating a second two-dimensional code image of a size corresponding to the first two-dimensional code image, and drawing the set of circle center points on the second two-dimensional code image to obtain a third two-dimensional code image;
[0043] Step S104, determining an initial positioning point of a grid in a two-dimensional code row and column from the third two-dimensional code image, and obtaining a set of standard row and column grid center points based on the initial positioning point and the number of rows and columns and the spacing of a standard two-dimensional code;
[0044] Step S105, performing image matching on the first two-dimensional code image based on the set of circle center points and the set of standard row and column grid center points to obtain an image position matching result.
[0045] In some embodiments, the first two-dimensional code image is a two-dimensional code original image to be matched, which is collected by a two-dimensional code collector. The two-dimensional code collector is a handheld terminal with two-dimensional code scanning function, which can be a mobile phone, a tablet computer, an industrial electronic collector, etc. The present application does not make specific limitation thereto.
[0046] In some embodiments, the first two-dimensional code image, the second two-dimensional code image, and the third two-dimensional code image are different two-dimensional code images. In the embodiments of the present application, the two-dimensional code images are distinguished as the first two-dimensional code image, the second two-dimensional code image, and the third two-dimensional code image according to different states of the two-dimensional code images.
[0047] In some embodiments, the effective contour in the first two-dimensional code image refers to a contour line formed by a region containing effective information in the first two-dimensional code image. The contour includes the outer contour of the first two-dimensional code and the small black-and-white grid contour inside. These contours are necessary information for identifying the two-dimensional code. In some embodiments, the effective contour of the two-dimensional code can be extracted after edge detection, noise removal, and binarization operations are performed on the first two-dimensional code. Specifically, edge detection can be achieved by methods such as the Sobel operator and the Canny operator. The Sobel operator and the Canny operator can detect the obvious edges in the image and form a series of pixel points. However, due to noise and interference factors in the two-dimensional code image, noise removal processing needs to be performed on the image before edge detection to eliminate these interference factors and improve the accuracy of edge detection. Further, after noise removal processing, the image is subjected to binarization processing to convert the gray values in the image to binary values to facilitate subsequent effective contour extraction operations. It can be understood that the binarization processing of the image can be achieved by methods such as threshold segmentation and adaptive binarization. These methods can separate the black and white pixels in the image to form a binary image. By using the edge detection algorithm, the effective contour of the two-dimensional code image can be extracted. These contour information can be used for subsequent two-dimensional code recognition and decoding to obtain the information contained in the two-dimensional code.
[0048] In some embodiments, a plurality of effective contours can be determined in the contour according to the contour parameters. Specifically, the radius Ra of the fitting circle can be set as the distance D between two adjacent circle points divided by 2; the maximum area of the fitting circle maxArea can be set as PI (pi) * Ra * Ra; and the minimum area of the fitting circle minArea can be set as PI * (Ra / 2) * (Ra / 2). Thus, the maximum and minimum areas of the fitting circle can be calculated.
[0049] In some embodiments, the contour area smaller than the maximum area of the fitting circle and the contour area larger than the minimum area of the fitting circle are selected as the effective contour. It can be understood that taking the effective contour of the image can remove the circle points with low reliability in the image and avoid interference with the matching process.
[0050] In some embodiments, since the radius of the fitted circle is known, the center point set of the fitted circle can be obtained according to fitting the plurality of effective contours into a plurality of circles. For example, the contours can be fitted into an ellipse using a fitEllipse function (ellipse fitting function), and then the ellipse fitting result is converted into a circle fitting. In some embodiments, the effective contours can also be fitted into a circle using a HoughCircles operator (Hough circle operator) to locate the center of the circle, and then the center point set of the fitted circle is obtained, and finally the position of the circle is determined in combination with the circumference information and other constraints, such as the size of the radius.
[0051] In some embodiments, according to the first two-dimensional code image, a second two-dimensional code image of a corresponding size is generated, which can be equal to, smaller than, or larger than the first two-dimensional code image, as long as it is enlarged or reduced according to the first two-dimensional code image. Further, the center point set of the circle is plotted on the second two-dimensional code image to obtain a third two-dimensional code image, so as to generate a center point set of a row and column grid for subsequent image matching.
[0052] In some embodiments, the initial positioning point is the initial positioning point of the two-dimensional code, which is used to position the position of the two-dimensional code to be generated. Specifically, the initial positioning point can be located at any position of the third two-dimensional code image, such as the lower right corner point, the lower left corner point, the upper left corner point, etc. In some embodiments, the initial positioning point is set as the lower left corner point. For example, the coordinates of the lower left corner point are converted into coordinates in the image coordinate system, so that the position of the third two-dimensional code can be initially positioned, and the coordinates of the initial positioning point are obtained. It can be understood that in addition to the initial positioning of the lower left corner point of the third two-dimensional code, the initial positioning of the upper left corner, the upper right corner, etc. of the third two-dimensional code can also be performed, which is not specifically limited in the present application.
[0053] In some embodiments, the standard two-dimensional code can be a QR code (Quick Response Code), a Data Matrix code (matrix two-dimensional barcode). Taking the Data Matrix code as an example, the number of row and column grids of the third two-dimensional code image can be determined according to the row and column grid distribution rules of the Data Matrix code (matrix two-dimensional barcode); further, the initially positioned lower left corner point is set as the origin, and the coordinates of the center point of the row and column grid are generated based on the initial positioning point, the distance D between two adjacent circle points, and the row and column grid distribution rules of the Data Matrix code. It can be understood that the coordinates of the center point of the first grid are calculated first, and then the coordinates of the center point of other grids are calculated according to the distance D between two adjacent circle points and the number of grids, so as to obtain the standard row and column grid center point set of the two-dimensional code.
[0054] In some embodiments, the coordinates of the circle center point set and the standard row-column grid center point set can be matched, the matching coincidence of the circle center point set and the standard row-column grid center point set can be matched, if the matching coincidence of the matching of the circle center point set and the standard row-column grid center point set is high, that is, the minimum position distance between the circle center point set and the standard row-column grid center point set is 0 or tends to 0, it is indicated that the image position matching is successful, so as to obtain the image position matching result.
[0055] Further, each row-column grid center point coordinate can be traversed to find the nearest circle center point coordinate of each row-column grid center point coordinate, and the image can be matched by calculating the minimum position distance between each row-column grid center point coordinate and the circle center point coordinate. It can be understood that when the position distance between each row-column grid center point coordinate and the circle center point coordinate is the minimum, that is, the circle center point coordinate and the row-column grid center point coordinate are aligned, the position at this time is the best matching position.
[0056] In some embodiments, the minimum position distance of each row-column grid center point can be added, and then divided by the number of row-column grid center points of the row-column grid center point set, and then the average value of the minimum position distance is obtained. By the minimum position average value, it can be known whether all row-column grid center point coordinates and circle center point coordinates are aligned, when the average value of the minimum position distance is the minimum, the position at this time is the best matching position.
[0057] In some embodiments, a matching threshold and a matching number can be preset, when the matching coincidence of the circle center point set and the standard row-column grid center point set is low, that is, the minimum position distance between the circle center point set and the standard row-column grid center point set is greater than the preset threshold, the number of re-matching of the circle center point set and the standard row-column grid center point set can be set, when the matching exceeds the preset number but the minimum position distance is still greater than the preset threshold, the matching result of the circle center point set and the standard row-column grid center point set is directly used to generate the matching image. In some embodiments, the preset threshold can be set according to actual situation or need, such as the size of the image and the matching accuracy requirement and the like, for example, the preset threshold can be 0.005mm, and the present embodiment does not make specific limitation. Further, the number of re-matching is a positive integer greater than or equal to 1, for example, the preset number is 3 times.
[0058] It can be understood that the two-dimensional code is a common matrix barcode composed of a plurality of black and white small grids. When the image position matching is performed, if the matching accuracy of the center point set of the fitting circle and the center point set of the standard row-column grid is higher, the position and size of the small grid of the two-dimensional code can be more accurately calculated, so that the accuracy of detection and recognition of the two-dimensional code is improved. The image position matching method, system, electronic device and storage medium provided in the application can generate the center point set of the fitting circle and the center point set of the standard row-column grid, and perform minimum position distance matching on each standard row-column grid center point and the center point. When the minimum position distance is minimum and the average value of the minimum position distance is minimum, it indicates that the row-column grid center point coordinates and the center point coordinates are aligned, so that the image position matching result is obtained, the accuracy of image position matching is improved, and the success rate of two-dimensional code recognition is improved.
[0059] Please refer to Figure 3 In some embodiments, step S105 includes but is not limited to steps S201 to S204:
[0060] Step S201, based on the center point set, obtaining the center point coordinates of the center point set of the center point set;
[0061] Step S202, based on the row-column grid center point set, obtaining the center point coordinates of the center point set of the row-column grid center point set;
[0062] Step S203, according to each center point coordinate and the center point coordinate, determining the minimum position distance between the center point coordinate and the center point coordinate;
[0063] Step S204, according to the minimum position distance, performing image matching on the first two-dimensional code image to obtain the image position matching result.
[0064] In some embodiments, the center point coordinates can be obtained according to the center point set, and the center point coordinates can be obtained according to the row-column grid center point set. Further, the distance between the center point coordinates and the center point coordinates can be calculated by using the Pythagorean theorem or the Euclidean distance formula.
[0065] For example, a traversal area can be defined around each row-column grid center point coordinate, and the positions of all center point coordinates in the traversal area are traversed and calculated, and the nearest center point coordinates to the center point coordinates are selected to calculate the minimum position distance between the two. In some embodiments, it is not necessary to define the traversal area, and all center point coordinates in the image range are traversed for each center point coordinate, and the nearest center point coordinates are selected to calculate the minimum position distance between the center point coordinates and the center point coordinates.
[0066] In some embodiments, the minimum position distance between each grid center point coordinate and the circle center point coordinate should be zero or close to zero, so that it can be known that the circle center point coordinate has been aligned with the grid center point coordinate, and the position is the final matching position, so that the image matching result can be obtained according to the matching position.
[0067] Please refer to Figure 4 In some embodiments, step S204 includes but is not limited to steps S301 to S305:
[0068] Step S301, obtaining the minimum position distance between each center point coordinate and the circle center point coordinate;
[0069] Step S302, adding the minimum position distances of the grid center point set to obtain the total minimum position distance value;
[0070] Step S303, obtaining the number of all grid center point sets;
[0071] Step S304, calculating the average minimum position distance according to the total minimum position distance value and the number of grid center point sets;
[0072] Step S305, performing image matching on the first two-dimensional code image according to the average minimum position distance to obtain the image position matching result.
[0073] In some embodiments, let the circle center point coordinate be C i =(x i , y i ), the grid center point coordinate G k =(y k , y k ), for each grid center point coordinate, traverse all circle center point coordinates, and for each center point coordinate, calculate the minimum position distance with the circle center point coordinate. Specifically, the calculation formula of the minimum position distance between the center point coordinate and the circle center point coordinate can be: DIST i = MIN (sqrt ((x i -x k )*(x i -x k )+(y i -y k )*(y i -y k ))).
[0074] In some embodiments, the number of rows and columns of the third two-dimensional code image can be determined according to the row and column grid distribution rules of the Data Matrix code (matrix two-dimensional bar code). Further, the initially positioned lower left corner point is set as the origin, and the coordinates of the center points of the row and column grids are generated based on the initial positioning point, the distance D between the two adjacent circle points, and the row and column grid distribution rules of the Data Matrix code. It can be understood that the coordinates of the center point of the first grid are calculated first, and then the coordinates of the center points of other grids are calculated according to the distance D between the two adjacent circle points and the number of grids, so as to obtain the number of the standard row and column grid center point set of the two-dimensional code. Further, the minimum position distance between each center point coordinate and the circle center point coordinate is added to obtain the total value of the minimum position distance, and then the average value of the minimum position distance is calculated by dividing the total value of the minimum position distance by the number of the row and column grid center point set.
[0075] Further, a rectangular search window can be set with the lower left corner positioning coordinate as the center, or a rectangular window can be set with other positions of the two-dimensional code as the center, such as the upper left corner, the lower right corner, the upper right corner, etc., and the rectangular window is used to define the range of traversal search, so as to reduce the search range, avoid traversing to the range outside the image, save the search time, and avoid wasting computing resources. Further, all positions in the traversal window are traversed, and the minimum position distance DISTn (a function for calculating the distance between points) between Ci (representing a row and column grid center point coordinate) and Gk (representing a row and column grid center point coordinate) at each row and column grid center point coordinate position is calculated, and then the average value of the minimum position distance is obtained by dividing the minimum position distance by the number N of the row and column grid center point, that is, ∑DISTn / N. It can be understood that when each circle center point coordinate is aligned with the row and column grid center point coordinate, the distance between the circle center point coordinate and the row and column grid center point coordinate should be 0 or close to 0, at this time, it indicates that the circle center point coordinate and the center point coordinate are matched successfully, and the image matching result is obtained.
[0076] In some embodiments, a matching threshold and a matching number of times can be preset, when the matching coincidence degree between the standard row and column grid center point coordinate and the circle center point coordinate is low, that is, the minimum position distance between the standard row and column grid center point coordinate and the circle center point coordinate is greater than the preset threshold, the number of times of re-matching the standard row and column grid center point coordinate and the circle center point coordinate can be set, and when the matching number of times exceeds the preset number of times but the minimum position distance is still greater than the preset threshold, the matching result of the current standard row and column grid center point coordinate and the circle center point coordinate is directly used to generate a matching image. In some embodiments, the preset threshold can be set according to actual conditions or needs, such as the size of the image, etc., and the preset threshold can be 0.01 mm, for example, and the present embodiment does not make specific limitations on this. Further, the number of times of re-matching is a positive integer greater than or equal to 1, such as 3 times of preset number of times.
[0077] In some embodiments, to make the embodiments more clear, the process of matching images is exemplified by codes:
[0078]
[0079] Next, the matching process is described in detail.
[0080] First, two loop variables i and j are defined, i is used to search the rows in the image, and j is used to search the columns in the image, and the search range is determined by variables lx, ly, rx, ry, that is, the range of each row and column grid center point traversal is set. Further, in each loop, the current dynamic top-left corner point (curPos) is set, and the function set_matrix_std() (a kind of matching row and column grid function) is called to set the standard row and column grid center point set (matrix), and the dynamic template of the standard row and column grid center point set (matrix) is generated. It can be understood that the dynamic template refers to the pixel points within a certain range around each traversal search position.
[0081] Further, the function match_matrix_std() is called, and the two-dimensional code parameters (mParams), the standard row and column grid center point set, and the center point set are calculated as parameters to obtain the minimum position distance list (distList) of the current row and column grid center point set and the center point set.
[0082] Further, the average of the minimum position distance list is calculated, and is assigned to the variable dist. The average value is calculated by adding all the minimum position distance values and dividing by the number of row and column grid center points.
[0083] Finally, if the calculated average distance is less than minDist (minimum distance), it is updated as the new minimum position distance, and the current search position (i and j) is assigned to the matching position (matchPos). In the whole image matching process, the minimum position distance and the matching position can be updated continuously, and finally the matching position that meets the requirements can be found, and the image matching can be started, and finally the image matching result can be obtained.
[0084] Please refer to Figure 5 In some embodiments, step S102 includes but is not limited to steps S401 to S406:
[0085] Step S401, edge detection is performed on the first two-dimensional code image to obtain an edge detected image;
[0086] Step S402, based on the edge detected image, the image is binarized to obtain a binarized image;
[0087] Step S403, determining the contour of the image according to the binarized image;
[0088] Step S404, obtaining the contour parameters of the contour;
[0089] Step S405, determining a plurality of effective contours in the contour according to the contour parameters;
[0090] Step S406, fitting a plurality of circles according to the plurality of effective contours to obtain a set of centers of the fitted circles.
[0091] It can be understood that edge detection can detect the position where the image characteristics change, specifically, the difference of the image at the boundary can be detected, and the image edge can be segmented. In some embodiments, differential operator, Canny operator (multi-stage edge detection algorithm) and LOG operator (Gaussian Laplace operator) can be used for edge detection of the first two-dimensional code image, and the present embodiment does not make specific limitation.
[0092] Exemplarily, the image after edge detection can be binarized. Specifically, the first two-dimensional code image can be converted into an image including only black and white colors after binarization, so as to distinguish the target area and the background area of the image. For example, the black part in the black and white image is the target object, and the white part is the background; or the white part is the target object, and the black part is the background. It can be understood that if the first two-dimensional code image is a color image, the color image needs to be converted into a gray-scale image before binarization.
[0093] Specifically, the gray-scale image refers to an image in which the information of each pixel is described by a quantized gray-scale value, and the gray-scale value is usually an integer. For example, an 8-bit gray-scale image has 256 levels of gray-scale, and the gray-scale value ranges from 0 to 255. That is, the integers from 0 to 255 are used to describe different levels of gray-scale from black to white, and 0 represents black and 255 represents white. Binarization is to set a threshold, and the pixels in the gray-scale image with a gray-scale value greater than or equal to the threshold are taken as bright points with a value of 1, and the pixels with a gray-scale value less than the threshold are taken as dark points with a value of 0. 0 represents black and 1 represents white. Generally, binarization of an image is to set the gray-scale value of the pixel on the image to 0 or 255, that is, to make the image have only two colors of pure black and pure white.
[0094] It can be understood that the binarization of the gray-scale image can have different binarization algorithms according to different target objects in the image. Specifically, common binarization algorithms include global threshold method, local threshold method and dynamic threshold method, etc.
[0095] In some embodiments, morphological operations such as dilation or closing operation can be performed on the edge detection result to fill the gaps or broken points between edges. Further, the result after morphological operation is thresholded to obtain a binary image. Optionally, the thresholding can select a global threshold or a local threshold method such as Otsu threshold method (maximum inter-class variance method), adaptive threshold method, etc.
[0096] In some embodiments, the first two-dimensional code image can be subjected to edge detection first, and then the image after edge detection can be binarized, or the first two-dimensional code image can be binarized first, and then the binarized image can be subjected to edge detection, and the embodiments of the present application do not make specific limitations in this regard.
[0097] In some embodiments, the findContours function (a function for detecting the contour of an object) can be used to perform contour detection on the binarized image to obtain a list of all contours. In some embodiments, the contour can be optionally subjected to further processing, such as polygon approximation processing using the approxPolyDP function (a polygon fitting function) or convex hull processing using the convexHull function (a convex hull function), etc., so that the extracted image contour is clearer and more effective.
[0098] In some embodiments, the contour parameter refers to the spacing between two adjacent circular points of the laser marking image, which can be denoted as D. Specifically, D = motor shaft step number * pixel / step ratio. It can be understood that the motor shaft step number can be the motor shaft step number of the laser marking device. Different devices can use different motors and control systems, and thus the motor shaft step number can also be different. Further, the pixel and step ratio are the marking parameters set by the laser marking device. Further, the spacing between two adjacent circular points can also be calculated using the Pythagorean theorem or the Euclidean distance formula. For example, if there are two adjacent coordinate points A(x1, y1) and B(x2, y2), the spacing D between them is: D = sqrt[(x2-x1)^2+(y2-y1)^2] where sqrt represents the square root operator.
[0099] In some embodiments, according to the contour parameter, a plurality of effective contours are determined in the contour. Specifically, the radius Ra of the fitting circle can be set as D / 2 of the spacing between two adjacent circular points; the maximum area of the fitting circle can be set as PI * Ra * Ra; and the minimum area of the fitting circle can be set as PI * (Ra / 2) * (Ra / 2). Thus, the maximum and minimum areas of the fitting circle can be calculated.
[0100] In some embodiments, the contour area less than the maximum area of the fitting circle and the contour area greater than the minimum area of the fitting circle are selected as effective contours.
[0101] In some embodiments, the plurality of effective contours are fitted into a plurality of circles to obtain a set of center points of the fitted circles. For example, the contours can be fitted into ellipses using a fitEllipse function, and then the ellipse fitting results are converted into circle fitting. In some embodiments, the plurality of effective contours can also be fitted into a plurality of circles using a HoughCircles operator, the center points of the fitted circles are located first, and then the final position of the circle is determined in combination with the circumference information and other constraints, such as the size of the radius.
[0102] Referring to Figure 6 In some embodiments, step S405 includes but is not limited to steps S501 to S503:
[0103] Step S501, according to the contour parameters, the radius of the fitted circle is obtained;
[0104] Step S502, according to the radius, the maximum area and the minimum area of the fitted circle are determined;
[0105] Step S503, according to the maximum area and the minimum area, the plurality of effective contours are determined.
[0106] In some embodiments, the radius Ra of the fitted circle can be set as D (the distance between two adjacent circle points) / 2; the maximum area maxArea of the fitted circle can be set as PI (pi) * Ra * Ra; and the minimum area minArea of the fitted circle can be set as PI * (Ra / 2) * (Ra / 2), so that the maximum area and the minimum area of the fitted circle can be calculated.
[0107] In some embodiments, the contour area less than the maximum area of the fitted circle and the contour area greater than the minimum area of the fitted circle are selected as the effective contour.
[0108] Referring to Figure 7 In some embodiments, step S103 includes but is not limited to steps S601 to S602:
[0109] Step S601, according to the preset proportion, a second two-dimensional code image corresponding to the size of the first two-dimensional code image is generated;
[0110] Step S602, the set of center points is plotted on the second two-dimensional code image to obtain a third two-dimensional code image.
[0111] In some embodiments, according to a preset size of the second two-dimensional code image, a size of the second two-dimensional code image relative to the first two-dimensional code image and a preset ratio are obtained, and then the content on the first two-dimensional code image is drawn on the second two-dimensional code image according to the ratio. For example, if the preset ratio is 1, then the size of the second two-dimensional code image is the same as that of the first two-dimensional code image, and the content on the first two-dimensional code image is drawn on the second two-dimensional code image without adjustment; if the preset ratio is 2, then the second two-dimensional code image is twice the size of the first two-dimensional code image, and the content on the first two-dimensional code image is drawn on the second two-dimensional code image after being enlarged by twice.
[0112] Referring to Figure 8 In some embodiments, step S104 includes but is not limited to steps S701 to S705, including:
[0113] Step S701, projection in horizontal and vertical directions is performed according to the third two-dimensional code image;
[0114] Step S702, initial positioning points of the cells in the two-dimensional code row and column are determined based on the projection positions;
[0115] Step S703, a form of a standard two-dimensional code is selected, and the number of rows and columns and the spacing of the standard two-dimensional code are obtained according to the standard two-dimensional code;
[0116] Step S704, the center point coordinates of the row and column cells are generated according to the initial positioning points, the number of rows and columns and the spacing of the standard two-dimensional code;
[0117] Step S705, a standard row and column cell center point set of the two-dimensional code is obtained according to the plurality of row and column cell center point coordinates.
[0118] In some embodiments, projection in the horizontal direction of the third two-dimensional code image can be performed by using the np.sum function (array summation function) to sum the pixel values of each row of the third two-dimensional code image to obtain a projection histogram in the horizontal direction; projection in the vertical direction of the third two-dimensional code image can be performed by using the np.sum function to sum the pixel values of each column of the third two-dimensional code image to obtain a projection histogram in the vertical direction.
[0119] In some embodiments, after projection in the horizontal and vertical directions of the third two-dimensional code image, the contour can be sorted to find the leftmost bottom point, which is the lower left corner point of the third two-dimensional code, and then the coordinates of the point are converted into the coordinates in the image coordinate system, so that the position of the third two-dimensional code can be initially positioned, and the coordinates of the initial positioning point are obtained. It can be understood that in addition to the initial positioning of the lower left corner point of the third two-dimensional code, the upper left corner, the upper right corner and other positions of the third two-dimensional code can also be initially positioned, which is not specifically limited in the present application.
[0120] In some embodiments, the number of rows and columns of the third two-dimensional code image can be determined according to the row and column grid distribution rules of the Data Matrix code (matrix two-dimensional bar code); further, the left lower corner point of the initial positioning is set as the origin, and the coordinates of the center points of the row and column grids are generated based on the initial positioning point, the distance D between the two adjacent circular points, and the row and column grid distribution rules of the Data Matrix code. It can be understood that the coordinates of the center point of the first grid are calculated first, and then the coordinates of the center points of other grids are calculated according to the distance D between the two adjacent circular points and the number of grids, so as to obtain the standard row and column grid center point set of the two-dimensional code.
[0121] For example, assuming that the specification of the Data Matrix code is 10x10, the distance D between the two adjacent circular points is 2, and the coordinates of the positioning point at the lower left corner are (0, 0), the grid center point set can be generated according to the following steps:
[0122] The coordinates of the center point of the first grid are (1, 1); the coordinates of the center point of the second grid are (1, 3); the coordinates of the center point of the third grid are (1, 5); and so on, and the coordinates of the center points of all the row and column grids can be calculated.
[0123] Reference Figure 9 In some embodiments, the present application discloses an image position matching system, which comprises:
[0124] The first two-dimensional code image acquisition module 901 is configured to acquire a first two-dimensional code image marked by laser;
[0125] The fitted circle center point set acquisition module 902 is configured to determine a plurality of effective contours in the first two-dimensional code image, fit the plurality of effective contours into a plurality of circles, and obtain a fitted circle center point set;
[0126] The third two-dimensional code image acquisition module 903 is configured to generate a second two-dimensional code image corresponding in size to the first two-dimensional code image, draw the fitted circle center point set on the second two-dimensional code image, and obtain a third two-dimensional code image;
[0127] The standard row and column grid center point set generation module 904 is configured to determine an initial positioning point of a grid in a two-dimensional code row and column from the third two-dimensional code image, and obtain a standard row and column grid center point set of the two-dimensional code based on the initial positioning point and the number of rows and columns and the distance of the standard two-dimensional code.
[0128] The image position matching result acquisition module 905 is configured to perform image matching on the first two-dimensional code image based on the fitted circle center point set and the standard row and column grid center point set, and obtain an image position matching result.
[0129] In some embodiments, the first two-dimensional code image is a two-dimensional code original image to be matched, and the two-dimensional code original image is collected by a two-dimensional code collector. The two-dimensional code collector is a handheld terminal with a two-dimensional code scanning function, which can be a mobile phone, a tablet computer, an industrial electronic collector, or the like. The present application does not make specific limitations in this regard.
[0130] In some embodiments, the first two-dimensional code image, the second two-dimensional code image, and the third two-dimensional code image are different two-dimensional code images. In the embodiments of the present application, the two-dimensional code images are distinguished as the first two-dimensional code image, the second two-dimensional code image, and the third two-dimensional code image according to different states of the two-dimensional code images.
[0131] In some embodiments, the effective contour in the first two-dimensional code image refers to a contour line formed by a region containing effective information in the first two-dimensional code image. The contour includes the outer contour of the first two-dimensional code and the small black-and-white grid contour inside. These contours are necessary information for identifying the two-dimensional code. In some embodiments, the effective contour of the two-dimensional code can be extracted after edge detection, noise removal, and binarization operations are performed on the first two-dimensional code. Specifically, edge detection can be achieved by Sobel operator, Canny operator, or the like. The Sobel operator and the Canny operator can detect the obvious edges in the image and form a series of pixel points. However, due to noise and interference factors in the two-dimensional code image, noise removal processing needs to be performed on the image before edge detection to eliminate these interference factors and improve the accuracy of edge detection. Further, after noise removal processing, the image is subjected to binarization processing to convert the gray value in the image to binary, so as to facilitate subsequent effective contour extraction operations. It can be understood that the binarization processing of the image can be achieved by threshold segmentation, adaptive binarization, or the like. These methods can separate the black and white pixels in the image to form a binary image. By using the edge detection algorithm, the effective contour of the two-dimensional code image can be extracted. These contour information can be used for subsequent two-dimensional code recognition and decoding to obtain the information contained in the two-dimensional code.
[0132] In some embodiments, a plurality of effective contours can be determined in the contour according to the contour parameters. Specifically, the radius of the fitting circle Ra can be set as the distance D between two adjacent circle points divided by 2; the maximum area of the fitting circle maxArea can be set as PI (pi) * Ra * Ra; and the minimum area of the fitting circle minArea can be set as PI * (Ra / 2) * (Ra / 2). Thus, the maximum and minimum areas of the fitting circle can be calculated.
[0133] In some embodiments, the effective contour is selected as the contour with an area smaller than the maximum area of the fitting circle and an area larger than the minimum area of the fitting circle. It can be understood that the effective contour is selected for the image, so that the circle points with low reliability in the image can be removed to avoid interference with the matching process.
[0134] In some embodiments, since the radius of the fitting circle is known, the circle center point set of the fitting circle can be obtained by fitting the plurality of effective contours into a plurality of circles. For example, the contours can be fitted into an ellipse using the fitEllipse function, and then the ellipse fitting result can be converted into a circle fitting. In some embodiments, the effective contours can also be fitted into a circle using the HoughCircles operator, so that the circle center point set of the fitting circle can be obtained by positioning the circle center, and then the final position of the circle can be determined in combination with the circumference information and other constraints, such as the size of the radius.
[0135] In some embodiments, a second two-dimensional code image with a corresponding size is generated according to the first two-dimensional code image. The second two-dimensional code image can be equal in size to the first two-dimensional code image, or can be smaller or larger than the first two-dimensional code image, as long as it is enlarged or reduced according to the first two-dimensional code image. Further, the circle center point set is plotted on the second two-dimensional code image to obtain a third two-dimensional code image, so that the image matching can be performed by generating a row and column grid center point set subsequently.
[0136] In some embodiments, the initial positioning point is the initial positioning point of the two-dimensional code, which is used to position the position of the two-dimensional code to be generated. Specifically, the initial positioning point can be located at any position of the third two-dimensional code image, such as the lower right corner point, the lower left corner point, the upper left corner point, and the like. In some embodiments, the initial positioning point is set as the lower left corner point. For example, the coordinates of the lower left corner point are converted into coordinates in the image coordinate system, so that the position of the third two-dimensional code can be initially positioned, and the coordinates of the initial positioning point can be obtained. It can be understood that in addition to the initial positioning of the lower left corner point of the third two-dimensional code, the initial positioning of the upper left corner, the upper right corner, and the like of the third two-dimensional code can also be performed, which is not specifically limited in the present application.
[0137] In some embodiments, the standard two-dimensional code can be a QR code (Quick Response Code), a Data Matrix code (matrix two-dimensional barcode). Taking the Data Matrix code as an example, the number of rows and columns of the third two-dimensional code image can be determined according to the row and column grid distribution rules of the Data Matrix code (matrix two-dimensional barcode); further, the initially positioned lower left corner point is set as the origin, and based on the initial positioning point, the spacing D of the two adjacent circle points and the row and column grid distribution rules of the Data Matrix code, the coordinates of the center points of the row and column grids are generated. It can be understood that the coordinates of the center point of the first grid are calculated first, and then the coordinates of the center points of other grids are calculated according to the spacing D of the two adjacent circle points and the number of grids, thereby obtaining the standard row and column grid center point set of the two-dimensional code.
[0138] In some embodiments, the coordinates in the circle center point set and the standard row and column grid center point set can be matched, the coincidence degree of the matching circle center point set and the standard row and column grid center point set is matched, and if the matching coincidence degree of the matching circle center point set and the standard row and column grid center point set is high, that is, the minimum position distance between the matching circle center point set and the standard row and column grid center point set is 0 or tends to 0, it is indicated that the image position matching is successful, thereby obtaining the image position matching result.
[0139] Further, each row and column grid center point coordinate can be traversed to find the circle center point coordinate closest to each row and column grid center point coordinate, and the image is matched by calculating the minimum position distance between each row and column grid center point coordinate and the circle center point coordinate. It can be understood that when the position distance between each row and column grid center point coordinate and the circle center point coordinate is the smallest, it indicates that the circle center point coordinate and the row and column grid center point coordinate are aligned, and the position at this time is the best matching position.
[0140] In some embodiments, the minimum position distances of each row and column grid center point can be added and then divided by the number of row and column grid center points in the row and column grid center point set, and then the average value of the minimum position distance is obtained. Through the minimum position average value, it can be known whether all row and column grid center point coordinates and circle center point coordinates are aligned, and when the average value of the minimum position distance is the smallest, the position at this time is the best matching position.
[0141] In some embodiments, a preset matching threshold and matching times can be set. When the matching coincidence degree of the circle center point set and the standard row-column grid center point set is low, i.e., the minimum position distance between the circle center point set and the standard row-column grid center point set is greater than the preset threshold, the number of times of re-matching the circle center point set and the standard row-column grid center point set can be set. When the matching exceeds the preset number of times but the minimum position distance is still greater than the preset threshold, the matching result of the circle center point set and the standard row-column grid center point set is directly used to generate a matching image. In some embodiments, the preset threshold can be set according to actual conditions or needs, such as the size of the image and the matching accuracy requirement, and the like. For example, the preset threshold can be 0.005 mm, and the present embodiment does not make a specific limitation on this. Further, the number of times of re-matching is a positive integer greater than or equal to 1, such as 3 times.
[0142] It can be understood that the two-dimensional code is a common matrix barcode composed of a plurality of small black and white grids. When the image position matching is performed, the higher the matching accuracy of the circle center point set of the fitting circle and the standard row-column grid center point set, the more accurate the position and size of the small grid of the two-dimensional code can be calculated, thereby improving the accuracy of detection and recognition of the two-dimensional code. The present application can generate the circle center point set of the fitting circle and the standard row-column grid center point set, and perform minimum position distance matching on each standard row-column grid center point and the circle center point. When the minimum position distance is minimum and the average value of the minimum position distance is minimum, it indicates that the row-column grid center point coordinates and the circle center point coordinates are aligned, thereby obtaining the image position matching result, improving the accuracy of image position matching, and improving the success rate of two-dimensional code recognition.
[0143] The specific implementation of the image position matching system is basically the same as that of the above-mentioned specific embodiments of the image position matching method, and will not be described here again. The image position matching system can also be provided with other functional modules to realize the image position matching method in the above-mentioned embodiments under the premise of meeting the requirements of the embodiments of the present application.
[0144] The embodiments of the present application also provide an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program. The processor implements the above-mentioned image position matching method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a vehicle-mounted computer, and the like.
[0145] Please refer to Figure 10 , Figure 10 The hardware structure of the electronic device of another embodiment is illustrated, which includes:
[0146] The processor 1001 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is configured to execute related programs to implement the technical solutions provided by the embodiments of the present application.
[0147] The memory 1002 can be implemented by a ROM (Read Only Memory), a static storage device, a dynamic storage device, or a RAM (Random Access Memory), etc. The memory 1002 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory 1002 and are called and executed by the processor 1001 to implement the image position matching method of the embodiments of the present application.
[0148] The input / output interface 1003 is configured to implement information input and output.
[0149] The communication interface 1004 is configured to implement the communication interaction between the device and other devices. The communication can be implemented by a wired manner (for example, a USB, a network cable, etc.) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, etc.).
[0150] The bus 1005 is configured to transmit information between the components (for example, the processor 1001, the memory 1002, the input / output interface 1003, and the communication interface 1004) of the device.
[0151] The processor 1001, the memory 1002, the input / output interface 1003, and the communication interface 1004 are connected to each other by the bus 1005 to realize the communication connection between the components in the device.
[0152] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. The computer program is executed by the processor to implement the above-mentioned image position matching method.
[0153] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory can include a high-speed random access memory and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory disposed remotely from the processor, which can be connected to the processor through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0154] The embodiments described in the embodiments of the present application are used to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0155] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than shown in the figures, or combine certain steps or different steps.
[0156] The device embodiments described above are only schematic, and the units described as separate components can or can not be physically separate, i.e., can be located in one place or distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0157] Those skilled in the art can understand that all or some of the steps in the above disclosed method, the functional modules / units in the system and the device can be implemented as software, firmware, hardware and their appropriate combinations.
[0158] The terms "first", "second", "third", "fourth" and the like used in the specification of the present application and the above-described drawings (if any) are used to distinguish similar objects, and do not necessarily have to describe a particular order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0159] It should be understood that, in the application, "at least one" and "several" refer to one or more, and "multiple" refers to two or more. "And / or" is used to describe the association relationship of the associated objects, which means that there can be three relationships, for example, "A and / or B" can represent three cases of only A, only B, and A and B existing at the same time, wherein A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after it. "At least one of the following" or similar expressions means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c can represent a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, and c can be single or multiple.
[0160] In several embodiments provided in the application, it should be understood that the disclosed system and method can be implemented in other ways. For example, the system embodiments described above are only illustrative, for example, the division of the above units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed units can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0161] The units described above as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0162] In addition, the functional units in each embodiment of the application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0163] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes multiple instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program storage media.
[0164] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, and are not limited to the scope of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.
Claims
1. An image position matching method characterized by, The method comprises: acquiring a first two-dimensional code image of laser marking; determining a plurality of effective contours in the first two-dimensional code image, fitting a plurality of circles according to the plurality of effective contours, and obtaining a circle center point set of the fitted circles; generating a second two-dimensional code image of a size corresponding to the first two-dimensional code image, and drawing the circle center point set on the second two-dimensional code image to obtain a third two-dimensional code image; performing projection in horizontal and vertical directions according to the third two-dimensional code image, determining initial positioning points of cells in a two-dimensional code row and column based on the projection positions, selecting a form of a standard two-dimensional code, and obtaining the number of rows and columns and the spacing of the standard two-dimensional code according to the standard two-dimensional code; generating row and column cell center point coordinates according to the initial positioning points, the number of rows and columns, and the spacing of the standard two-dimensional code; and obtaining a standard row and column cell center point set of the two-dimensional code according to the plurality of row and column cell center point coordinates; obtaining circle center point coordinates of the circle center point set based on the circle center point set, obtaining center point coordinates of the row and column cell center point set based on the row and column cell center point set, determining a minimum position distance between each center point coordinate and the circle center point coordinate according to the center point coordinate and the circle center point coordinate, and performing image matching on the first two-dimensional code image according to the minimum position distance to obtain an image position matching result.
2. The image position matching method according to claim 1, characterized by, The image matching on the first two-dimensional code image according to the minimum position distance to obtain an image position matching result comprises: obtaining a minimum position distance between each center point coordinate and the circle center point coordinate; adding the minimum position distances of the row and column cell center point set to obtain a total value of the minimum position distances; obtaining the number of all the row and column cell center point sets; calculating a minimum position distance average value according to the total value of the minimum position distances and the number of the row and column cell center point sets; and performing image matching on the first two-dimensional code image according to the minimum position distance average value to obtain an image position matching result.
3. The image position matching method according to claim 1, characterized by, The determination of a plurality of effective contours in the first two-dimensional code image, the fitting of a plurality of circles according to the plurality of effective contours, and the obtaining of a circle center point set of the fitted circles comprise: performing edge detection on the first two-dimensional code image to obtain an image after edge detection; performing binarization on the image after edge detection to obtain an image after binarization; determining a contour of the image according to the image after binarization; obtaining a contour parameter of the contour; determining a plurality of effective contours in the contour according to the contour parameter; fitting a plurality of circles according to the plurality of effective contours to obtain a circle center point set of the fitted circles.
4. The image position matching method according to claim 3, characterized by, The determination of a plurality of effective contours in the contour according to the contour parameter comprises: obtaining a radius of the fitted circle according to the contour parameter; determining a maximum area and a minimum area of the fitted circle according to the radius; determining a plurality of effective contours according to the maximum area and the minimum area.
5. The image position matching method according to claim 1, characterized by, The generation of a second two-dimensional code image of a size corresponding to the first two-dimensional code image and the drawing of the circle center point set on the second two-dimensional code image to obtain a third two-dimensional code image comprise: generate a second two-dimensional code image corresponding in size to the first two-dimensional code image according to a preset ratio; draw the set of circle center points on the second two-dimensional code image to obtain a third two-dimensional code image.
6. An image position matching system characterized by comprising: The system comprises: a first two-dimensional code image acquisition module configured to acquire a first two-dimensional code image of laser marking; a set of circle center points acquisition module configured to determine a plurality of effective contours in the first two-dimensional code image, fit a plurality of circles according to the plurality of effective contours, and obtain a set of circle center points of the fitted circles; a third two-dimensional code image acquisition module configured to generate a second two-dimensional code image corresponding in size to the first two-dimensional code image, and draw the set of circle center points on the second two-dimensional code image to obtain a third two-dimensional code image; a standard row-column grid center point set generation module configured to perform projection in horizontal and vertical directions according to the third two-dimensional code image, determine initial positioning points of grids in a two-dimensional code row and column based on the projection positions, select a form of a standard two-dimensional code, and obtain the number of rows and columns and the spacing of the standard two-dimensional code according to the standard two-dimensional code, generate row-column grid center point coordinates according to the initial positioning points, the number of rows and columns, and the spacing of the standard two-dimensional code, and obtain a standard row-column grid center point set of the two-dimensional code according to the plurality of row-column grid center point coordinates; an image position matching result acquisition module configured to obtain circle center point coordinates of the set of circle center points based on the set of circle center points, obtain center point coordinates of the set of row-column grid center points based on the set of row-column grid center points, determine a minimum position distance between the center point coordinates and the circle center point coordinates according to each center point coordinate, and perform image matching on the first two-dimensional code image according to the minimum position distance to obtain an image position matching result.
7. An electronic device, comprising: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the image position matching method of any one of claims 1 to 5 when executing the computer program.
8. A computer readable storage medium, the storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the image position matching method of any one of claims 1 to 5.
Citation Information
Patent Citations
Two-dimensional code correction method, device and equipment
CN110197096A
Granular QR two-dimensional code positioning method
CN111931537A