Two-dimensional code image processing method and device and terminal equipment

By determining and fitting the location of the missing positioning target area in the QR code image, the analysis failure caused by the missing positioning target information in the QR code image is solved, and the success rate and scope of application of QR code analysis are improved.

CN119250090APending Publication Date: 2025-01-03NANNING QIANHAI YANXIANG ELECTRONIC TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411303023.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-01-03

Smart Images

  • Figure CN119250090A_ABST
    Figure CN119250090A_ABST
Patent Text Reader

Abstract

The invention discloses a two-dimensional code image processing method and apparatus, and a terminal device. The method comprises the steps of obtaining a first image of a two-dimensional code; according to the pixel value of each pixel in the first image, determining the attribute of each suspected localizer area in the first image; judging whether the first image is a two-dimensional code image without one positioning mark area or not according to the attribute of each suspected positioning mark area; if yes, screening out two intact localizer areas from each suspected localizer area; according to the attributes of the two intact localizer areas, determining the orientation to which the missing localizer area in the first image belongs; and according to the orientation and the first positions of the two intact localizer areas, fitting a second position of the missing localizer area in the first image so as to execute a two-dimensional code analysis operation on the first image according to the second position and the first positions of the two intact localizer areas. According to the scheme, the application range is wider, and the probability of successfully analyzing the two-dimensional code is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing technology, and in particular, relates to a method, apparatus and terminal device for processing a two-dimensional code image. Background Art

[0002] With the popularity of smart phones and the development of mobile Internet, QR code recognition technology has been widely used in many fields such as mobile payment, commercial marketing, and smart logistics. Usually, it is necessary to capture the QR code image through a camera based on computer vision and image processing technology, and use an algorithm to parse the image to extract the text, links or other information contained therein. Most QR codes are usually set with three positioning marks. In order to improve the efficiency and accuracy of QR code parsing, before parsing the QR code, it is usually necessary to first locate the three positioning marks in the QR code image to be parsed by image processing methods, and then correct the QR code image according to the positions of the three positioning marks, and then perform subsequent downsampling and decoding based on the corrected QR code image.

[0003] However, in the process of collecting the QR code image, there may be reflections, obstructions, etc., which may cause the information of the positioning mark in the QR code image to be missing, and the position of the missing positioning mark cannot be located, which in turn causes the QR code parsing to fail. Summary of the invention

[0004] The embodiments of the present application provide a method, apparatus, terminal device and computer-readable storage medium for processing a two-dimensional code image, which can quickly and effectively locate the position of a missing positioning mark area when a positioning mark area is missing in the two-dimensional code image, thereby increasing the probability of successfully parsing the two-dimensional code.

[0005] A first aspect of an embodiment of the present application provides a method for processing a two-dimensional code image, comprising:

[0006] Obtaining a first image of the QR code;

[0007] Determining the attributes of each suspected positioning mark region in the first image according to the pixel value of each pixel in the first image, wherein the attributes of the suspected positioning mark region include the first position of the suspected positioning mark region, or also include the size of the suspected positioning mark region;

[0008] According to the attributes of each suspected positioning mark area, determining whether the first image is a two-dimensional code image that lacks a positioning mark area;

[0009] If so, two intact positioning marker regions are selected from each suspected positioning marker region;

[0010] Determine the position of the missing positioning mark region in the first image according to the attributes of the two intact positioning mark regions;

[0011] According to the orientation and the first positions of the two intact positioning mark areas, the missing positioning mark area is fitted at the second position in the first image, so as to perform a QR code parsing operation on the first image according to the second position and the first positions of the two intact positioning mark areas.

[0012] A second aspect of an embodiment of the present application provides a two-dimensional code image processing device, including:

[0013] An acquisition module, used for acquiring a first image of the QR code;

[0014] A first determination module, configured to determine the attributes of each suspected positioning mark region in the first image according to the pixel value of each pixel in the first image, wherein the attributes of the suspected positioning mark region include the first position of the suspected positioning mark region, or further include the size of the suspected positioning mark region;

[0015] A judgment module, used for judging whether the first image is a two-dimensional code image lacking a positioning mark area according to the attributes of each suspected positioning mark area;

[0016] A screening module, for screening out two intact positioning marker regions from each suspected positioning marker region if yes;

[0017] A second determination module is used to determine the position of the missing positioning mark area in the first image according to the attributes of the two intact positioning mark areas;

[0018] A fitting module is used to fit the missing positioning mark area to the second position in the first image according to the orientation and the first positions of the two intact positioning mark areas, so as to perform a QR code parsing operation on the first image according to the second position and the first positions of the two intact positioning mark areas.

[0019] A third aspect of an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the steps of the above-mentioned two-dimensional code image processing method are performed when the processor executes the computer program.

[0020] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the above-mentioned two-dimensional code image processing method are implemented.

[0021] The first aspect of the embodiment of the present application provides a method for processing a two-dimensional code image. Before parsing the two-dimensional code image, the properties of each suspected positioning mark area in the first image are accurately determined based on the pixel values ​​of each pixel in the first image of the two-dimensional code. Then, based on the properties of each suspected positioning mark area, it is accurately determined whether the first image is a two-dimensional code image that is missing a positioning mark area. And for the case where a positioning mark area is missing, the second position of the missing positioning mark area is quickly and accurately fitted based on the first positions of the two intact positioning mark areas located. This solution realizes the automatic and efficient positioning of the missing corner points of the two-dimensional code, which makes the application scope of the two-dimensional code parsing wider and can significantly improve the probability of successfully parsing the two-dimensional code.

[0022] It can be understood that the beneficial effects of the second to fourth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0024] Figure 1 It is a schematic diagram of the parsing principle of a two-dimensional code image provided by an embodiment of the present application;

[0025] Figure 2 It is a flowchart of a method for processing a two-dimensional code image provided by an embodiment of the present application;

[0026] Figure 3a It is a schematic diagram of a principle of determining the attributes of a suspected positioning mark area provided by an embodiment of the present application;

[0027] Figure 3b is a schematic diagram of a first image lacking an upper left positioning mark provided by an embodiment of the present application;

[0028] Figure 3c is a schematic diagram of a first image with a missing upper right positioning mark provided by an embodiment of the present application;

[0029] Figure 3d is a schematic diagram of a first image with a lower left positioning mark missing provided by an embodiment of the present application;

[0030] Figure 4a This is an embodiment of the present application. Figure 3b A schematic diagram of multiple reference pixels in ;

[0031] Figure 4b Another embodiment of the present application provides Figure 3d A schematic diagram of multiple reference pixels in ;

[0032] Figure 5 is a schematic diagram of a principle of screening a first reference pixel or a second reference pixel provided by an embodiment of the present application;

[0033] Figure 6a An embodiment of the present application provides a determination Figure 3b A schematic diagram showing the principle of the orientation to which the missing positioning mark area should belong;

[0034] Figure 6b An embodiment of the present application provides a determination Figure 3d A schematic diagram showing the principle of the orientation to which the missing positioning mark area should belong;

[0035] Figure 7a This is a fitting provided by an embodiment of the present application Figure 3b A schematic diagram of the principle of finding the second position of the missing positioning mark area;

[0036] Figure 7b This is a fitting provided by an embodiment of the present application Figure 3c A schematic diagram of the principle of finding the second position of the missing positioning mark area;

[0037] Figure 7c This is a fitting provided by an embodiment of the present application Figure 3d A schematic diagram of the principle of finding the second position of the missing positioning mark area;

[0038] Figure 8 It is a structural schematic diagram of a two-dimensional code image processing device provided by an embodiment of the present application;

[0039] Fig. 9 It is a structural diagram of a terminal device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0040] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0041] It should be understood that, as used in the specification of this application and the appended claims, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their combinations.

[0042] It should also be understood that the term "and / or" as used in the specification of this application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0043] In addition, in the description of the specification of this application and the appended claims, the terms "first", "second", "third", etc. are only used for differential description and should not be construed as indicating or implying relative importance.

[0044] Reference to "one embodiment" or "some embodiments" etc. described in the specification of this application means that a specific feature, structure or characteristic described in connection with the embodiment is included in one or more embodiments of this application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0045] A two-dimensional code (Quick Response Code, abbreviated as QR code) is a two-dimensional bar code that encodes data in a matrix form. Compared with traditional bar codes, QR codes can store more information and have a faster scanning speed. QR codes are usually composed of black and white squares and can nestedly contain a large amount of text, website addresses, telephone numbers, e-mails, images and other data.

[0046] Before parsing a QR code, the following operations are usually required on the QR code image: 1) Extract the QR code symbol information using image binarization technology. In a QR code, a small black square or a small white square is the smallest symbol unit, and the entire QR code is composed of a combination of multiple symbol units. Image binarization technology is usually used to process it, where the black part is the black symbol and the white part is the white symbol in binarization; 2) QR code corner point positioning technology. A QR code usually contains three positioning marks in the shape of a double-square character, and these three positioning marks can be used to determine the position and size of the QR code. 3) QR code lower right corner positioning technology. Usually, the internal geometric relationship of the QR code is used to determine the position of the lower right corner.

[0047] Generally speaking, before parsing the QR code, the three positioning mark areas (for example, the imaging area of the positioning mark in the shape of a square within a square) in the image can be located first through the contour relationship of the QR code image or the line scan method. After the three positioning mark areas are located, the corner point in the lower right corner of the QR code can be calculated according to the geometric relationship between these three areas. For example, as Figure 1 shown, after obtaining the three corner points (points A, B, and D in the figure) of the three positioning mark areas in the QR code image, the corner point C (C x , C y ) in the lower right corner can be calculated through the following formula:

[0048] C x = D x + (B x - A x );

[0049] C y = D y + (B y - A y );

[0050] where the coordinates of point A are (A x , A y ), the coordinates of point B are (B x , B y ), and the coordinates of point D are (D x , D y ).

[0051] After that, the affine transformation of the QR code image can be performed through the coordinates of these four points to achieve the correction of the QR code image. In this way, the downsampling decoding can be performed on the corrected QR code image.

[0052] Therefore, accurately locating the three positioning mark areas in the QR code image is the key to successful decoding. However, during the process of collecting the QR code image, it may be interfered by various factors. For example, there may be reflections, the QR code may be blocked, etc., resulting in the missing information of the positioning mark in the QR code image, and the position of the missing positioning mark cannot be located, thus causing the failure of QR code parsing.

[0053] In order to at least partially solve the above technical problems, the embodiments of the present application provide a method, device, terminal device and computer-readable storage medium for processing a two-dimensional code image. The scheme can be used to process images of various types of two-dimensional codes, which can be static two-dimensional codes or dynamic two-dimensional codes. The information carried by the two-dimensional code can be arbitrary and can be applied to various fields, including but not limited to storing text, website, telephone number, e-mail and other information, mobile payment, and event promotion. The appearance style of the two-dimensional code can also be arbitrary. It can be a traditional two-dimensional code composed of black and white pixels, or it can be made more artistic and ornamental through creative design in the fields of brand promotion and artistic creation. The image of this two-dimensional code can be a color image. The scheme can accurately determine whether a positioning mark area is missing in the two-dimensional code image before parsing the two-dimensional code image. And it can effectively fit the missing positioning mark area according to the two intact positioning mark areas located for the case where a positioning mark area is missing. This scheme makes the scope of application of two-dimensional code parsing wider and can significantly improve the probability of successfully parsing the two-dimensional code.

[0054] like Figure 2 As shown, the method for processing a two-dimensional code image provided in the embodiment of the present application includes the following steps:

[0055] Step S210, obtaining a first image of a QR code.

[0056] The first image is an image containing the desired two-dimensional code to be parsed. The first image may be an image acquired by any suitable image acquisition device. It may be a black and white image or a color image. The first image may be an image of any suitable size and resolution. Of course, the first image may also be an image that meets preset requirements. For example, the first image may be a color RGB image that meets resolution requirements. The first image may be an original image directly acquired by the image acquisition device, or it may be an image after a preset processing is performed on the original image. For example, the original image may be cropped into a local image of a preset size to obtain the first image. For another example, the original image may be filtered according to a preset filtering method to obtain the first image. Alternatively, the original color image may be binarized to obtain the binarized first image.

[0057] Step S220, determining the attributes of each suspected positioning mark region in the first image according to the pixel value of each pixel in the first image, wherein the attributes of the suspected positioning mark region include the first position of the suspected positioning mark region, or also include the size of the suspected positioning mark region.

[0058] In the embodiment of the present application, the suspected positioning mark area may be the imaging area of ​​the positioning mark in the desired two-dimensional code to be parsed, that is, the positioning mark area, or it may not be the positioning mark area. Any two different suspected positioning mark areas may correspond to different positioning marks, or may correspond to the same positioning mark.

[0059] The attributes of the suspected positioning mark area determined in this step may include at least the first position of the suspected positioning mark area, that is, the specific position of the area in the first image. The first position can be represented by any suitable position indicator. Exemplarily and non-restrictively, the coordinates of the center pixel of the suspected positioning mark area can be used to represent it; or, it can also be represented by the coordinates of the corner pixels of the suspected positioning mark area. Exemplarily, the attributes of the suspected positioning mark area may also include the size of the area. The size of the area can also be represented by various suitable indicators. For example, the length, width, and area (for example, the total number of pixels contained) of the entire suspected positioning mark area. For another example, it can also be represented by the size of a unit sub-area in the suspected positioning mark area (such as length, width, area, etc.). In this example, the size of the unit sub-area can accurately reflect the size of the entire suspected positioning mark area. For example, there is a functional relationship between the size of the unit sub-area and the size of the entire suspected positioning mark area. As Figure 3a As shown in the figure, for a two-dimensional code including a U-shaped positioning mark, the imaging area of ​​the U-shaped positioning mark can be regarded as consisting of three nested square areas. The size of the suspected positioning mark area can be represented by the side length of the outermost black square area, or by the side length of the innermost black square area, or by the difference between the side lengths of two adjacent layers of square areas. For example, the distances a1a2, a2a3, b1b2, and b2b3 in the figure are used to represent the size of the suspected positioning mark area.

[0060] In this step, a variety of suitable methods can be used to statistically analyze the pixel values ​​of each pixel in the first image, and a variety of suitable logics can be used to locate all suspected positioning mark areas in the first image. In one example, a line scan method can be used to traverse each row of pixels (or each column of pixels) of the entire first image to find whether the row (or column) includes sub-regions where pixels with different pixel values ​​meet the preset distribution requirements, and then, a variety of suitable methods can be used to determine the first position of the suspected positioning mark area according to the position of these sub-regions. In this example, the number of suspected positioning mark areas located is relatively large. The suspected positioning mark areas located for different rows of pixels may correspond to the same positioning mark or may correspond to different positioning marks. In some special cases, the individual suspected positioning mark areas located may not correspond to the positioning mark. In another example, the sliding window method can also be used to extract the edge of the image area in each sliding window to determine whether its edge feature has a multi-layer nested feature. If so, the first position of the corresponding suspected positioning mark area can be determined based on the position of the image area with multi-layer nested features. In this example, the first image can be processed in advance to roughly locate the imaging area of ​​the entire two-dimensional code (for example, referred to as the two-dimensional code area). Then, sliding is performed in the two-dimensional code area, and the size of the sliding window can be determined according to the size of the two-dimensional code area. For example, the window size and the sliding step size of the sliding window can be set according to actual needs. For example, the window size is set equal to 1 / 2 of the width of the two-dimensional code area, and the sliding step size can be set to 1 / 4 of the width of the two-dimensional code area. In this example, the number of suspected positioning mark areas located for different windows is relatively small. The suspected positioning mark areas located for different windows may correspond to the same positioning mark, or may correspond to different positioning marks. Of course, other suitable methods can also be used to locate the suspected positioning mark area in the first image.

[0061] Step S230: judging whether the first image is a two-dimensional code image that lacks a positioning mark region according to the attributes of each suspected positioning mark region.

[0062] In this step, a variety of suitable methods can be used to determine whether the first image is a two-dimensional code image with a missing positioning mark area according to the attributes of each suspected positioning mark area. As mentioned above, any two suspected positioning mark areas located may correspond to the same positioning mark or may correspond to different positioning marks. Of course, in the case of positioning errors, there are some suspected positioning mark areas that do not correspond to any positioning mark. In one example, in the case where there is no positioning error and different suspected positioning mark areas correspond to different positioning marks, it can be directly determined whether the first image is a two-dimensional code image with a missing positioning mark area according to the number of located suspected positioning mark areas and the position difference between different suspected positioning mark areas. For example, if the number of located suspected positioning mark areas is equal to 2, and the position difference between these suspected positioning mark areas is greater than or equal to the position difference threshold, it can be determined that the first image is a two-dimensional code image with a missing positioning mark area. In another example, for the case where any two suspected positioning mark areas located may correspond to the same positioning mark, these suspected positioning mark areas can be grouped according to the attributes of each suspected positioning mark area. For example, each suspected positioning mark area can be traversed, and it can be determined whether any two suspected positioning mark areas correspond to the same positioning mark according to the first position of the suspected positioning mark area. If so, the two suspected positioning mark areas can be divided into one area group. Afterwards, it can be determined whether the first image is a two-dimensional code image with a missing positioning mark area according to the grouping situation. Exemplarily, if only one area group is divided, it can be determined that the first image is not a two-dimensional code image with a missing positioning mark area. Exemplarily, if only two area groups are divided, it can be directly determined that only two intact positioning mark areas are located from the first image, that is, it is determined that the first image is a two-dimensional code image with a missing positioning mark area. Alternatively, considering the positioning error, for the case where only two area groups are divided, it can also be further determined whether the first image is a two-dimensional code image with a missing positioning mark area according to the number of suspected positioning areas contained in each of the two area groups. For example, when the number of suspected positioning areas contained in each of the two area groups is greater than the number threshold, it is determined that the first image is a two-dimensional code image with a missing positioning mark area. Exemplarily, if the number of divided area groups is greater than or equal to 3, it can also be further determined whether the first image is a two-dimensional code image with a missing positioning mark area according to the number of suspected positioning areas contained in each of the two area groups. For example, for the three area groups containing the largest number of suspected positioning areas, it can be determined whether there is a preset quantitative relationship between the numbers of the three area groups. If so, it can be determined that the first image is a two-dimensional code image that lacks a positioning mark area. The preset quantitative relationship can be set according to actual needs.

[0063] Step S240: If yes, two intact positioning mark areas are selected from each suspected positioning mark area.

[0064] In an embodiment of the present application, the intact positioning mark area can be the complete imaging area of ​​the positioning mark (there is no missing part), that is, the complete positioning mark area. In some special examples, the intact positioning mark area can also be a partial imaging area of ​​the positioning mark, but the missing part is less, and it can accurately reflect the position and size of the positioning mark. In this step, various suitable methods can be used to screen out two intact positioning mark areas from each suspected positioning mark area. For example, when there is no positioning error and different suspected positioning mark areas correspond to different positioning marks, and it is determined that the first image is a two-dimensional code image with a missing positioning mark area, the two located suspected positioning mark areas can be directly used as two intact positioning mark areas.

[0065] Step S250: Determine the position of the missing positioning mark region in the first image according to the attributes of the two intact positioning mark regions.

[0066] like Figure 1 As shown, the positions of the three positioning marks in the figure can be defined according to their positions in the two-dimensional code image. The position of the positioning mark at the upper left corner of the two-dimensional code image (the positioning mark at point A) can be defined as the upper left position, the position of the positioning mark at the upper right corner (the positioning mark at point B) can be defined as the upper right position, and the position of the positioning mark at the lower left corner (the positioning mark at point D) can be defined as the lower left position. Figure 3b , Figure 3c and Figure 3d Understandably, Figure 3b The missing location mark area should be located in the upper left position. Figure 3c The missing location mark area should be located in the upper right position. Figure 3d The missing positioning mark area should be in the lower left position.

[0067] According to an embodiment of the present application, the position to which the missing positioning mark area in the first image should belong can be determined based at least on the relative position relationship between the two intact positioning mark areas. In one example, the position to which the missing positioning mark area in the first image should belong can be determined based only on the first positions of the two intact positioning mark areas. Exemplarily and non-restrictively, the position to which the missing positioning mark area in the first image should belong can be determined based on the coordinate difference between the center pixels O1 and O2 of the two intact positioning mark areas. For example, the first absolute value of the difference between the horizontal coordinates of O1 and O2 and the second absolute value of the difference between the vertical coordinates can be calculated. Then, when both the first absolute value and the second absolute value are greater than the preset absolute value threshold (which can be set according to actual needs, such as 10px), it can be determined that the position to which the missing positioning mark area in the first image should belong is the upper left position; when the first absolute value is less than or equal to the first absolute value threshold (which can be set according to actual needs, such as 10px) and the second absolute value is greater than the second absolute value threshold (which can be set according to actual needs, such as 30px), it can be determined that the position to which the missing positioning mark area in the first image should belong is the upper right position; when the second absolute value is less than or equal to the first absolute value threshold and the first absolute value is greater than the second absolute value threshold, it can be determined that the position to which the missing positioning mark area in the first image should belong is the lower left position. For another example, the overall area of ​​the QR code in the image can also be roughly located first. Then, the center point of the overall area is located, recorded as O3. Then, the midpoint of the line connecting O1 and O2 can be located, recorded as O4. Afterwards, the distance between O3O4 can be calculated. If O3O4 is less than a preset distance threshold (e.g., 10px), it can be determined that the position to which the missing positioning mark area in the first image should belong is the upper left position; otherwise, it can be determined that the position to which the missing positioning mark area in the first image should belong is the upper right position or the lower left position. In another example, the position to which the missing positioning mark area in the first image should belong can be determined based on the first positions and sizes of the two intact positioning mark areas. For example, the first absolute value of the difference between the horizontal coordinates of O1 and O2, the second absolute value of the difference between the vertical coordinates, and the distance O1O2 between O1 and O2 can be calculated. Then, the ratio between O1O2 and the first absolute value (e.g., called the first absolute ratio) is calculated, and the ratio between O1O2 and the second absolute value (e.g., called the second absolute ratio) is calculated. The two ratios are respectively compared with the preset coordinate ratio threshold (which can be set according to actual needs, such as 1.15), and the position to which the missing positioning mark area in the first image should belong is determined based on the comparison result.For example, when both ratios are greater than 1.15, the position to which the missing positioning mark area in the first image should belong is determined to be the upper left position; when the first absolute ratio is greater than 1.15 and the second absolute ratio is less than or equal to 1.15, the position to which the missing positioning mark area in the first image should belong is determined to be the upper right position; when the first absolute ratio is less than or equal to 1.15 and the second absolute ratio is greater than 1.15, the position to which the missing positioning mark area in the first image should belong is determined to be the lower left position. Of course, other suitable methods can also be used to determine the position to which the missing positioning mark area in the first image should belong based on the first positions and sizes of the two intact positioning mark areas. Specific examples of some schemes will be explained later and will not be repeated here.

[0068] Step S260, fitting the missing positioning mark area to the second position in the first image according to the orientation and the first positions of the two intact positioning mark areas, so as to perform a QR code parsing operation on the first image according to the second position and the first positions of the two intact positioning mark areas.

[0069] In this step, a variety of suitable methods can be used to fit the missing locator area in the first image according to the orientation to which the missing locator area should belong and the first position of the two intact locator areas. For example, for a QR code, when the locator marks are all complete, the lines of the same position (e.g., center point, upper left corner point) of the three locator marks can form an isosceles right triangle. Therefore, the same position of the two intact locator areas can be connected to obtain one side of the isosceles right triangle (e.g., referred to as the reference side). Then, according to the orientation of the missing locator area, it can be determined whether the reference side is the hypotenuse or the right side of the right triangle, and then the right triangle is fitted. And then the second position of the missing locator area in the first image can be determined according to the position of the other vertex of the right triangle. For another example, the same position of the three locator marks is connected, and the angle of any two of the three lines obtained is 90 ° or 45 °. Therefore, the same position (e.g., center pixel) of the two intact locator areas can be connected to obtain a reference line. Then, the angle between the reference line and the other two lines can be determined to be 45° or 90° according to the orientation of the missing positioning mark area, and then the reference line can be rotated by a corresponding angle, and the second position of the missing positioning mark area in the first image can be determined according to the position of the rotated straight line. Figure 3b, with O2 as the center, O2O1 can be rotated 45° counterclockwise to obtain the first rotation line l1 (not shown in the figure); with O1 as the center, O1O2 can be rotated 45° clockwise to obtain the first rotation line l2 (not shown in the figure); then the intersection of the first rotation line l1 and the first rotation line l2 can be used as the center of the missing positioning mark area. Figure 3c , O2 can be rotated 90° counterclockwise with O1 as the center to obtain the rotated O2* (not shown in the figure). The position of O2* can be used as the center position of the missing positioning mark area. Similarly, for Figure 3d , O1 can be rotated 90° clockwise with O2 as the center to obtain the rotated O1' (not shown in the figure). The position of O1' can be used as the center position of the missing positioning mark area. In some examples, when capturing the image of the QR code, the QR code may have a large rotation angle. For example, the QR code is inverted. In this case, it may not be possible to strictly distinguish between the missing upper right positioning mark and the missing lower left positioning mark. These two cases can be combined to fit multiple possible results of the second position of the missing positioning mark area. Afterwards, the QR code can be parsed according to each possible result for trial and error. If the QR code is not successfully parsed, the QR code is parsed according to the next possible result until the decoding is successful.

[0070] As mentioned above, accurately locating the three positioning mark areas in the two-dimensional code image is the key to successful decoding. However, in the process of collecting the two-dimensional code image, it may be disturbed by various factors, for example, there are reflections, the two-dimensional code is blocked, etc., resulting in the missing information of the positioning mark in the two-dimensional code image, and the position of the missing positioning mark cannot be located, thereby causing the failure of the two-dimensional code parsing. According to the above scheme of the embodiment of the present application, before parsing the two-dimensional code image, the attributes of each suspected positioning mark area in the first image are accurately determined according to the pixel value of each pixel in the first image of the two-dimensional code. Then, according to the attributes of each suspected positioning mark area, it is accurately determined whether the first image is a two-dimensional code image missing a positioning mark area. And for the situation where a positioning mark area is missing, according to the first position of the two intact positioning mark areas located, the second position of the missing positioning mark area is quickly and accurately fitted. This scheme realizes the automatic and efficient completion of the positioning of the missing corner points of the two-dimensional code, so that the scope of application of the two-dimensional code parsing is wider, and the probability of successfully parsing the two-dimensional code can be significantly improved.

[0071] In one implementation, step S220 determines the attributes of each suspected positioning mark region in the first image according to the pixel value of each pixel in the first image, including:

[0072] For each row of the first image,

[0073] Determining whether there is at least one positioning row sub-region in the row region according to the pixel values ​​of each pixel in the row region, wherein pixels with different pixel values ​​in the positioning row sub-region meet a preset distribution requirement;

[0074] If yes, determining the second center pixel of each positioning row sub-region;

[0075] Determine whether there is a positioning column sub-region including the second central pixel in the column region where the second central pixel is located, wherein pixels with different pixel values ​​in the positioning column sub-region meet a preset distribution requirement;

[0076] If so, it is determined that the row area corresponds to a suspected positioning mark area, and the attributes of the suspected positioning mark area are determined according to the attributes of the positioning column sub-area.

[0077] In this embodiment, the suspected positioning mark area can be positioned by line scanning. The positioning mark is, for example, a U-shaped positioning mark. The positioning row sub-area can be a pixel area where pixels with different pixel values ​​in the row area of ​​each row of pixels meet the preset distribution requirements. The positioning column sub-area can be a pixel area where pixels with different pixel values ​​in the column area of ​​each row of pixels meet the preset distribution requirements. Figure 3a As shown, the row where line1 is located in the two-dimensional code image can be regarded as a row area, and the column where line2 is located can be regarded as a column area. If the size of the two-dimensional code image is 1024px*1024px, then the image may include 1024 row areas and 1024 column areas. The preset distribution requirements can be defined according to the pixel distribution characteristics of the positioning mark area. For example, the first image is a binary image, and the ratio of black and white pixels in each row and each column containing the center of the U-shaped positioning mark area conforms to 1:1:3:1:1. Therefore, in this step, the sub-area in which the continuous distribution ratio of black and white pixels in each row area satisfies 1:1:3:1:1 can be determined as the positioning row sub-area, and the sub-area in which the continuous distribution ratio of black and white pixels in each column area satisfies 1:1:3:1:1 can be determined as the positioning column sub-area.

[0078] In one example, a method of first scanning rows and then scanning columns may be used to gradually determine the suspected positioning areas corresponding to the row areas in the first image.

[0079] like Figure 3aAs shown, the image data of each row can be scanned line by line. First, for each row, you can first search whether the row contains a positioning row sub-region (line1 in the figure) whose black and white pixel distribution conforms to 1:1:3:1:1. Specifically, you can record the pixel values ​​of each row in the binary first image. For example, black pixels are recorded as 0 and white pixels are recorded as 1. For example, the color distribution of pixels in a sub-region of the current row is: black black black black black black black white white white white white black black, then it is recorded as black black black (000) white (1) black black (00) white white white white (1111) black black (00), and the numbers are extracted to get 00010011100, and then the distribution ratio is calculated to be 3:1:2:3:2, which means that the sub-region is not a positioning row sub-region. It should be noted that Figure 3a The 1:1:3:1:1 shown in the figure is a proportional relationship, not an actual length relationship. For example, the distribution of black and white pixel values ​​in line1 in the figure may be 10:10:30:10:10 or other situations. If the current row area does not contain a positioning row sub-area, continue to scan the next row. If a positioning row sub-area is contained, a column scan is performed along the column area where the midpoint of the positioning row sub-area (the second center pixel, i.e., C1 in the figure) is located. If a positioning column sub-area (line2 in the figure) including C1 and whose black and white pixel distribution conforms to 1:1:3:1:1 is scanned in the column direction, it can be determined that this row of pixels corresponds to a suspected positioning mark area. For example, C1 can be used as the base point to scan upwards, and the positions of the pixels where the pixel values ​​jump in turn are obtained, recorded as a1, a2, and a3. Scan downwards, and the positions of the other three points where the pixel values ​​jump in turn are obtained, recorded as b1, b2, and b3. Using a1, a2, a3, c1, b1, b2, and b3, five line segments a3a2, a2a1, a1b1, b1b2, and b2b3 are obtained. The lengths are L1, L2, L3, L4, and L5, respectively. If L1: L2: L3: L4: L5 = 1:1:3:1:1, it indicates that the row and column scans are successful, indicating that the row may contain a positioning mark, that is, the row area corresponds to a suspected positioning mark area. Exemplarily, the area range of the suspected positioning mark area can also be determined based on the positioning row sub-area and the positioning column sub-area. For example, the minimum circumscribed rectangular area of ​​the positioning row sub-area and the positioning column sub-area can be used as the suspected positioning mark area. In an embodiment of the present application, the position of the central pixel of the positioning column sub-area can be determined as the first position of the suspected positioning mark area, that is, the midpoint of the positioning column sub-area is used as the positioning point, such as Figure 3a The midpoint c2 of line2 is used as the positioning point. For example, the length of line1 or the length of line2 can be used as the width / height of the suspected positioning mark area. Figure 3a The distances of a1a2, a2a3, b1b2, and b2b3 represent the size of the suspected positioning mark area.

[0080] In another embodiment, step S220 determines the attributes of each suspected positioning mark area in the first image according to the pixel value of each pixel in the first image, including:

[0081] For each column region of the first image,

[0082] Determining whether there is at least one positioning column sub-region in the column region according to the pixel value of each pixel in the column region, wherein pixels with different pixel values ​​in the positioning column sub-region meet a preset distribution requirement;

[0083] If yes, determine the second center pixel of each positioning column sub-region;

[0084] Determine whether there is a positioning row sub-region including the second central pixel in the row region where the second central pixel is located, wherein pixels with different pixel values ​​in the positioning row sub-region meet the preset distribution requirement;

[0085] If so, it is determined that the column area corresponds to a suspected positioning mark area, and the attributes of the suspected positioning mark area are determined according to the attributes of the positioning row sub-area.

[0086] In this embodiment, a method of scanning columns first and then rows may be adopted to gradually determine the suspected positioning areas corresponding to the column areas in the first image. A person skilled in the art can know the specific implementation of this example solution based on the previous example solution, and for the sake of brevity, it will not be repeated here.

[0087] The above scheme can traverse the entire first image by line scanning to orderly find suspected positioning mark areas in the first image that may correspond to positioning marks, and determine the attributes of each suspected positioning mark area. The suspected positioning mark areas located by this scheme are more accurate and can avoid omissions.

[0088] In one implementation, step S230 determines whether the first image is a two-dimensional code image that lacks a positioning mark region according to the attributes of each suspected positioning mark region, including:

[0089] According to the attributes of each suspected positioning mark area, each suspected positioning mark area is grouped to obtain at least one area group, wherein the difference between the corresponding attributes of any two suspected positioning mark areas in each area group is less than or equal to a third difference threshold;

[0090] At least based on the fact that the number of divided area groups is greater than or equal to 2, it is determined that the first image is a two-dimensional code image that lacks a positioning mark area.

[0091] Step S240 selects two intact positioning mark areas from each suspected positioning mark area, including:

[0092] One suspected positioning marker region is selected from each of the two region groups to obtain two intact positioning marker regions.

[0093] The third difference threshold may include a third position difference threshold, or may also include a third size difference threshold. These difference thresholds may be arbitrarily set according to actual requirements.

[0094] It can be understood that the positions of different suspected positioning mark areas corresponding to the same positioning mark located by different row areas or column areas are usually the same or close. Therefore, in this embodiment, each suspected positioning mark area can be grouped directly according to the first position of each suspected positioning mark area. In one example, the third position difference threshold may include a first distance threshold. Each suspected positioning mark area can be grouped according to the distance between the center pixels of each suspected positioning mark area and the first distance threshold. For example, the first distance threshold is 5px. For example, a suspected positioning mark area (for example, called area A) is randomly selected as an area group 1. Then, the distance between the center pixels of other suspected positioning mark areas and the center pixels of area A can be calculated. If the distance is less than or equal to 5px, these suspected positioning mark areas are added to area group 1. Then, a suspected positioning mark area (for example, called area B) is randomly selected from the suspected positioning mark areas that are not added to area group A as an area group 2. Then, the distance between the center pixels of each other suspected positioning mark area that is not added to area group A and the center pixel of area B can be calculated. If the distance is less than or equal to 5px, these suspected positioning mark areas are added to area group 2. And so on, finally one or more area groups are obtained.

[0095] It can be understood that the positions of different suspected positioning mark areas corresponding to the same positioning mark located by different row areas or column areas are usually the same or close, and the sizes of the located suspected positioning mark areas should also be the same or close. Therefore, in this embodiment, the suspected positioning mark areas can be grouped according to the first position and size of each suspected positioning mark area. That is, not only the position difference between different suspected positioning mark areas needs to be considered, but also the size difference needs to be considered. For example, Figure 3aThe distance of any one of a1a2, a2a3, b1b2, and b2b3 in represents the size of the suspected positioning mark area. For ease of understanding, such sizes can be referred to as the module size of the suspected positioning mark area. Exemplarily, the third difference threshold may include the first distance threshold in the aforementioned example, and may also include the first size difference threshold. The suspected positioning mark areas can be grouped according to the distance between the center pixels of each suspected positioning mark area, the first distance threshold, the absolute value of the difference between the module sizes of each suspected positioning mark area (for example, called the third absolute value), and the first size difference threshold. The first distance threshold is, for example, 5px, and the first size difference threshold is, for example, 2px. Similar to the aforementioned example, a suspected positioning mark area (area A) can be randomly selected as an area group 1. Then, the distances between the center pixels of other suspected positioning mark areas and the center pixels of area A can be calculated, and the absolute values ​​of the differences between the module sizes of other suspected positioning mark areas and the module sizes of area A can be calculated. If the distance is less than or equal to 5px and the difference is less than or equal to 2px, these suspected positioning mark areas are added to area group 1. According to this method, suspected positioning mark areas with similar positions and module sizes can be divided into a region group. In addition, in another example, the third position difference threshold can also include a region non-overlap threshold, which can be set according to actual needs, for example, the region non-overlap threshold is 5%. That is, by calculating the region non-overlap between different suspected positioning mark areas (region non-overlap = 1-region non-overlap), and comparing the region non-overlap with the set region non-overlap threshold, if the region non-overlap is less than or equal to 5%, these suspected positioning mark areas can be divided into a region group.

[0096] It can be understood that, ideally, if the line scan error, calculation error, and the missing portion of the positioning mark area are not taken into account, the number of area groups divided according to the above method is usually the same as the number of intact positioning marks contained in the first image. Therefore, when the number of divided area groups is equal to 2, it can be determined that the first image is a two-dimensional code image that is missing a positioning mark area. And when the number of divided area groups is not equal to 2, it can be determined that the first image is not a two-dimensional code image that is missing a positioning mark area. For example, if the number of divided area groups is equal to 1, it is determined that the first image is a two-dimensional code image that is missing two positioning mark areas; if the number of divided area groups is equal to 3, it is determined that the first image is not missing a positioning mark area.

[0097] However, considering the line scan error, calculation error, and the small missing part of the positioning mark area, the number of area groups divided according to the above method may be different from the number of intact positioning marks contained in the first image, for example, the number of divided area groups is greater than the number of intact positioning marks. Therefore, it is possible to determine whether the first image is a two-dimensional code image with a missing positioning mark area based on the number of divided area groups and other information of the area groups. Specifically, when the number of divided area groups is greater than or equal to 2, combined with the number corresponding to each area group, it can be determined whether the first image is a two-dimensional code image with a missing positioning mark area. For example, the area groups can be sorted in descending order according to the number corresponding to the area groups.

[0098] In one example, if only two area groups are divided, the difference between the number corresponding to the first area group and the number corresponding to the second area group can be calculated to obtain a first quantity difference. If the first quantity difference is less than the quantity difference threshold (for example, the quantity difference threshold is 5), it can be determined that a positioning mark area is missing in the first image, and it is a two-dimensional code image that lacks a positioning mark area. Otherwise, it is determined that the number of positioning mark areas missing in the first image is greater than or equal to 2, and it is not a two-dimensional code image that lacks a positioning mark area. If the number of divided area groups is greater than or equal to 3, the difference between the number corresponding to the first area group and the number corresponding to the second area group can be calculated to obtain a first quantity difference. And the difference between the number corresponding to the first area group and the number corresponding to the third area group can be calculated to obtain a second quantity difference. If both the first quantity difference and the second quantity difference are less than the quantity difference threshold, it can be determined that the first image does not lack a positioning mark area (not a two-dimensional code image that lacks a positioning mark area). If the first quantity difference is less than the quantity difference threshold, and the second quantity difference is greater than the quantity difference threshold, it can be determined that a positioning mark area is missing in the first image, and it is a two-dimensional code image that lacks a positioning mark area. If both the first quantity difference and the second quantity difference are greater than the quantity difference threshold, it can be determined that two positioning mark areas are missing in the first image, rather than a two-dimensional code image that lacks one positioning mark area.

[0099] Of course, in other examples, if the number of divided area groups is greater than or equal to 3, other methods may be used to determine whether the first image is a two-dimensional code image that lacks a positioning mark area according to the number of area groups. In one embodiment, the number of area groups is greater than or equal to 3. At least based on the situation that the number of divided area groups is greater than or equal to 2, determining that the first image is a two-dimensional code image that lacks a positioning mark area includes:

[0100] When the number of divided regional groups is greater than or equal to 3, three first regional groups are determined from at least one regional group according to the number corresponding to each regional group, wherein the number corresponding to each of the three first regional groups is greater than the number corresponding to other regional groups;

[0101] Determining whether the relationship between the quantities corresponding to the three first area groups satisfies a preset relationship;

[0102] If so, it is determined that the first image is a two-dimensional code image that lacks a positioning mark area.

[0103] Similar to the above example, the respective area groups may be sorted in descending order according to the number of corresponding area groups. After sorting, it is calculated whether the numbers corresponding to the first area group, the second area group, and the third area group satisfy a preset relationship. If so, it is determined that the first image is a two-dimensional code image lacking a positioning mark area. The preset relationship may be arbitrarily set according to actual needs.

[0104] Exemplarily but not limitingly, determining whether the relationship between the quantities corresponding to the three first area groups satisfies a preset relationship includes:

[0105] Calculate the sum of the first quantity and the second quantity to obtain a fourth quantity;

[0106] calculating a second ratio of the third quantity to the fourth quantity;

[0107] Determining whether the second ratio is less than a second ratio threshold;

[0108] If so, determining that the relationship between the quantities corresponding to the three first area groups satisfies a preset relationship;

[0109] If not, it is determined that the relationship between the quantities corresponding to the three first area groups does not satisfy the preset relationship;

[0110] The first number, the second number and the third number are numbers corresponding to the three first area groups respectively, and the first number and the second number are both greater than the third number, and the second ratio threshold is less than or equal to 0.5.

[0111] The second ratio threshold can be set to any number less than or equal to 0.5 according to actual needs. In a specific example, taking into account the influence of line scan error, calculation error and image quality, the second ratio threshold is set to 0.5*0.7, that is, the second ratio threshold is 0.35. For example, after sorting the regional groups in order from large to small according to the number corresponding to the regional group, the first number corresponding to the first regional group is calculated to be equal to 109, the second number corresponding to the second regional group is equal to 100, and the third number corresponding to the third regional group is equal to 30. The sum of the first number and the second number can be calculated to obtain a fourth number of 209, and the second ratio of the third number to the fourth number can be calculated to be 30 / 209=0.14, so according to 0.14<0.35, it can be determined that the first image is a two-dimensional code image missing a positioning mark area.

[0112] This solution has higher calculation accuracy and can improve the accuracy of judgment. In addition, this solution also has a small amount of calculation, so it can significantly improve the accuracy and efficiency of two-dimensional code decoding.

[0113] In the case where it is determined that the first image is a two-dimensional code image that lacks a positioning mark area, two area groups may be screened out from at least one of the divided area groups (if there are only two area groups, no screening is required), and one suspected positioning mark area may be screened out from each of the two screened area groups (for example, randomly selected, or based on the first position, finding a suspected positioning mark area located at the center of the area group), and the screened two suspected positioning mark areas are used as two intact positioning mark areas. For example, in the above example where it is determined that the relationship between the quantities corresponding to the three first area groups satisfies the preset relationship, a suspected positioning mark area may be randomly selected from the sorted first area group as a intact positioning mark area, and a suspected positioning mark area may be randomly selected from the second area group as another intact positioning mark area.

[0114] The above scheme groups the located suspected positioning mark areas and can quickly and accurately determine whether the first image is a two-dimensional code image that lacks a positioning mark area according to the grouping situation. The scheme has simple execution logic and more accurate judgment, which helps to achieve real-time accurate decoding.

[0115] In one implementation, each suspected positioning mark region is grouped according to the attributes of each suspected positioning mark region, including:

[0116] At the first moment when the first suspected positioning mark area is determined, the first suspected positioning mark area is taken as the first area group, and the attribute array corresponding to the first area group is added to the array set, wherein the attribute array includes a representative position, a representative size, and a quantity corresponding to the first area group of the first area group, the representative position is equal to the first position of the first suspected positioning mark area, the representative size is equal to the size of the first suspected positioning mark area, and the initial value of the quantity corresponding to the first area group is 1;

[0117] At the second moment when the i-th suspected positioning mark area is determined, the attributes of the i-th suspected positioning mark area are respectively compared with the attribute arrays of each area group in the array set at the moment, and it is determined whether the i-th suspected positioning mark area matches any second area group according to the comparison result, wherein i≥2, and the second area group is any one of the area groups;

[0118] If yes, then add the i-th suspected positioning mark area to the second area group, and update the number corresponding to the second area group in the array set;

[0119] If not, the i-th suspected positioning mark area is taken as a new third area group, and based on the attributes of the i-th suspected positioning mark area, the attribute array of the third area group to which the i-th suspected positioning mark area belongs is determined, and the attribute array of the third area group is added to the array set.

[0120] For example, if no suspected positioning mark area is located in the first row to the sixth row of the first image, and a suspected positioning mark area is located in the seventh row, the area is the first suspected positioning mark area located. After the first suspected positioning mark area is located, the coordinates of the center pixel of the area (for ease of description, it can be called coordinate 1), the size of the area (for example, Figure 3aThe distance between a1a2 in the image is the module size of the area. For the sake of description, it can be called module size 1). The first suspected positioning mark area can be divided into an area group 1. Record the attribute array 1 (coordinate 1, module size 1, 1) of area group 1. Among them, coordinate 1 represents the representative position of area group 1, module size 2 represents the representative size of area group 1, and 1 represents the number of suspected positioning mark areas contained in the current area 1. Add attribute array 1 to the array set that is initially an empty set. Then, continue line scanning, and after locating the second suspected positioning mark area, also record the coordinates of the center pixel of the area (for the sake of description, it can be called coordinate 2) and the size of the area (for example, for the sake of description, it can be called module size 2). Coordinate 2 can be compared with coordinate 1 (for example, the absolute value of the coordinate difference is calculated), and module size 2 can be compared with module size 1 (for example, the absolute value of the module size difference is calculated). Similar to the above example, it is possible to determine whether the second suspected positioning mark area matches the area group 1 (i.e., determine whether the second suspected positioning mark area and the suspected positioning mark area in the first area group correspond to the same positioning mark) based on the corresponding difference threshold. If it matches, the second suspected positioning mark area can be added to the area group 1, and the number corresponding to the area group 1 is updated, that is, the attribute array 1 is updated to (coordinate 1, module size 1, 2). If it does not match, the second suspected positioning mark area is used as a new area group 2, and the attribute array 2 (coordinate 2, module size 2, 1) of the area group 2 is added to the array set. That is, when the i-th (i≥2) suspected positioning mark area is located, the coordinate i of the central pixel of the i-th suspected positioning mark area and the module size i can be compared with the representative position and representative size in the attribute array of each area group in the array set, and it is determined whether the i-th suspected positioning mark area matches a certain area group based on the comparison result. If there is a match, the area group is added and the attribute array of the area group is updated; if there is no match with any area group, the i-th suspected positioning mark area is taken as a new area group, and the attribute array of the new area group is added to the array collection... In this way, in the process of locating the suspected positioning mark area, the various suspected positioning mark areas can be grouped quickly and orderly.

[0121] The following describes an implementation method of the solution from the perspective of software computing.

[0122] The positioning point of the 2D code's Chinese-shaped positioning mark has three values: the center point center, the module size moudleSize, and the number of overlapping center points count. You can define the pattern (i.e., attribute array) corresponding to each Chinese-shaped positioning mark:

[0123] pattern={center,moudleSize,count}.

[0124] like Figure 3a As shown, when C1 and C2 are scanned in a row for the first time, the center point of the located Chinese character 'Hui' (suspected Chinese character 'Hui') locator (suspected Chinese character 'Hui' area) is C2, and the module size is, for example, the length of a3a2, so moudlesize=distance(a3a2), and count=1 is set. C2, moudlesize, and count=1 are saved in pattern_1, and pattern_1 is added to the array set all_patterns, which is initially an empty set. Next, the data of the next row is scanned. When the row and column scan successfully locates the Chinese character 'Hui' shaped locator (suspected Chinese character 'Hui' area), the center point of the located Chinese character 'Hui' shaped locator is Cn. Traverse the array set all_patterns, take a pattern from all_patterns each time, and calculate the distance between Cn and the center point center of the pattern. If the distance is less than moudlesize (that is, the difference threshold can be set equal to the module size), it means that the suspected locator area obtained by the current scan and the suspected locator area corresponding to the pattern correspond to the same Chinese character 'Hui' shaped locator. Then, the value of count in the pattern can be increased by 1. On the contrary, if the distance is greater than or equal to modulesize, a new array pattern_n is determined according to the coordinates of the center pixel of the current suspected positioning mark area and the module size, and pattern_n is added to the array set all_patterns. Continue to scan each row until all row data are scanned to obtain the final array set all_patterns. Subsequently, it can be determined whether the first image is a two-dimensional code image with a missing positioning mark area according to each pattern in the array set all_patterns, and when it is determined that the first image is a two-dimensional code image with a missing positioning mark area, two patterns corresponding to two intact positioning mark areas are determined from all_patterns. Specifically, the patterns in the data set all_patterns can be sorted. The sorting is based on the fact that the larger the count in the pattern, the higher it is ranked, and the largest pattern is ranked in the first position of all_patterns. The count values ​​of the first three patterns in the sorted all_patterns set are count1, count2, and count3 respectively. If count3 is less than (count1+count2)*0.5*0.7, the current QR code is a QR code that lacks a U-shaped positioning mark, and the first two patterns correspond to a complete U-shaped positioning mark respectively.

[0125] In the above scheme, when each suspected positioning mark area is located, by comparing the attributes of the suspected positioning mark area with the attributes of the divided area group, the area group to which the suspected positioning mark area belongs can be quickly and accurately determined, so that when the last suspected positioning mark area is located, the grouping of each suspected positioning mark area can be accurately determined, so that it can be quickly and accurately determined whether the first image is a two-dimensional code image with a missing positioning mark area, and when it is determined that the first image is a two-dimensional code image with a missing positioning mark area, the attributes of two intact positioning mark areas can be quickly obtained. The efficiency and accuracy of two-dimensional code analysis can be significantly improved, the amount of calculation can be reduced, subsequent processing can be facilitated, and the robustness of the system can be improved.

[0126] In one embodiment, the positioning mark of the two-dimensional code is a U-shaped positioning mark. Step S250 determines the position of the missing positioning mark area in the first image according to the attributes of the two intact positioning mark areas, including:

[0127] According to the first relative position relationship between the two intact positioning mark regions and the sizes of the two intact positioning mark regions, searching for a plurality of reference pixels satisfying a reference condition from the first positioning mark region;

[0128] The position of the missing positioning mark area in the first image is determined according to the second relative position relationship between the plurality of reference pixels.

[0129] Wherein, the first positioning mark area is any one of the two intact positioning mark areas, and the multiple reference pixels include at least two first reference pixels. The two first pixels are located on both sides of the first line, and the angles between the two first lines and the second line are equal. And the difference in distance between the two first reference pixels and the first center pixel is less than or equal to the first difference threshold. The first line is the line between the first reference pixel and the first center pixel of the first positioning mark area. The second line is the line between the center pixels of the two intact positioning mark areas. The first difference threshold can be arbitrarily set according to actual needs. For example, the first difference threshold is equal to 5px.

[0130] The first relative position relationship between the two intact positioning mark regions may be a relative position relationship between the same position of the two regions (e.g., the position of the center pixel of the region, the position of the upper left corner of the region). For example, it may be based on the distance between the center pixels of the two intact positioning mark regions.

[0131] The reference condition can be set according to actual needs. For example, the reference condition includes at least one of the following: the pixel value of the reference pixel is a preset pixel value; the distance between the reference pixel and the first central pixel is within a preset distance range; the reference pixel is located in a preset area (for example, in the straight line area where the second connecting line of the central pixels of the two intact positioning mark areas is located); the difference between the pixel value of the reference pixel and the pixel value of its adjacent pixel is greater than or equal to a pixel value threshold (for example, in the case where the first image is a binary image and the pixel value of each pixel is between 0 and 1, the pixel value threshold can be set to be greater than 0.5 and less than or equal to 1).

[0132] A variety of suitable methods may be used to screen out multiple reference pixels that meet the above reference conditions based on the first relative position relationship between the two intact positioning mark areas and the sizes of the two intact positioning mark areas in combination with the above reference conditions. Figure 3b and Figure 4a , the second connection can be Figure 3b O1O2 in Figure 4a O1 in can correspond to Figure 3b O1 in, so Figure 4a O1P0 and O1O2 are on the same straight line, or in the same straight line area. The multiple reference pixels include at least two first reference pixels. As mentioned above, the two first pixels are located on both sides of the first line, and the angles between the two first lines and the second line are equal. Let the angle be θ. For example, θ∈[π / 6,11π / 6]. The difference in distance between the two first reference pixels and the first center pixel is less than or equal to the first difference threshold. Taking the first difference threshold equal to 5px and θ=π / 4 as an example, combined with the above reference conditions, multiple schemes for the two first reference pixels can be determined. For example, the two first reference pixels are Figure 4a The P1 and P2 in the figure may also be P11 and P21, or P12 and P22. Of course, the multiple reference pixels may also include other reference pixels, such as Figure 4a P0, P01, and P02 in the table.

[0133] After determining the multiple reference pixels, various suitable logics may be used to further determine the position of the missing positioning mark region in the first image according to the second relative position relationship between the multiple reference pixels.

[0134] In one example, the plurality of reference pixels may include only two first reference pixels. A variety of suitable methods may be used to determine the position to which the missing positioning mark region should belong based on the relative position relationship between the two pixels. Figure 4a and Figure 4b, the two first reference pixels can be the pixel where point P1 is located and the pixel where point P2 is located in the two figures. Optionally, the orientation to which the missing positioning mark area should belong can be directly determined based on the difference between the horizontal coordinates and the vertical coordinates of the two first reference pixels. For example, if the horizontal coordinate difference and the vertical coordinate difference of the two are both large, it can be determined that the orientation to which the missing positioning mark area should belong is the upper left position; if the horizontal coordinate difference between the two is small but the vertical coordinate difference is large or the horizontal coordinate difference is large but the vertical coordinate difference is small, it can be determined that the orientation to which the missing positioning mark area should belong is the upper right position or the lower left position. Alternatively, the distance between points P1 and P2 can also be calculated, and the orientation to which the missing positioning mark area should belong can be determined based on the ratio of the distance to the size of the first positioning mark area.

[0135] For example, the ratio between P1P2 and the module size of the first positioning mark area is calculated. If the difference between the ratio and the first preset ratio is small, it can be determined that the position to which the missing positioning mark area should belong is the upper left position. Exemplarily, the first preset ratio and the angle θ may have the following functional relationship:

[0136]

[0137] Wherein, m represents the module size of the first positioning mark area.

[0138] For another example, if the difference between the ratio and the second preset ratio is small, it can be determined that the position of the missing positioning mark area should be the upper right position or the lower left position. Exemplarily, the second preset ratio and the angle θ may have the following functional relationship:

[0139]

[0140] Wherein, m represents the module size of the first positioning mark area.

[0141] In another example, the plurality of reference pixels further include other reference pixels. Exemplarily but not limitingly, the plurality of reference pixels further include a second reference pixel. Figure 4a and Figure 4b As shown, the second reference pixel is, for example, P0 in the figure. P0 can be the intersection of the straight line where the second connecting line of the center pixels of the two intact positioning mark areas is located and the edge of the positioning mark area. Exemplarily and non-restrictively, in this step, the direction to which the missing positioning mark area should belong can be determined based on the coordinate difference of the three pixels P0, P1, and P2. For example, for the case of π / 6≤θ≤π / 4, if the difference in the horizontal coordinates or the difference in the vertical coordinates of P0, P1, and P2 are small, it can be determined that the direction to which the missing positioning mark area should belong is the upper right or lower left; otherwise, it can be determined that the direction to which the missing positioning mark area should belong is the upper left.

[0142] In the above scheme, first, based on the first relative position relationship between the two intact positioning mark areas and the sizes of the two intact positioning mark areas, multiple reference pixels that meet the reference condition are searched from the first positioning mark area, and then, based on the second relative position relationship between the multiple reference pixels, the orientation to which the missing positioning mark area in the first image should belong can be quickly and accurately determined. This scheme can improve the accuracy of the determined orientation, and further ensure the accuracy of the fitted second position. Therefore, the efficiency and accuracy of QR code parsing can be further improved.

[0143] In one implementation, searching for a plurality of reference pixels satisfying a reference condition from the first image according to the first relative position relationship between the two intact positioning mark regions and the sizes of the two intact positioning mark regions includes:

[0144] Connect the center pixels of the two intact positioning mark areas to obtain a second connecting line;

[0145] Taking the first central pixel as the rotation center, the second connecting line is rotated 45° in a clockwise direction to obtain a first rotation straight line, and the second connecting line is rotated 45° in a counterclockwise direction to obtain a second rotation straight line;

[0146] Taking the first central pixel as the starting point, searching for a first pixel whose pixel value has a gradient change along the direction of the first rotation line, and searching for a second pixel whose pixel value has a gradient change along the direction of the second rotation line;

[0147] A first pixel satisfying a first reference condition is selected from each of the first pixels found, and a second pixel satisfying a reference condition is selected from each of the second pixels found, to obtain two first reference pixels.

[0148] Reference again Figure 3b , Figure 3c and Figure 3d The angle θ can be 45°. For example, the first central pixel is the pixel where the point O1 in the three figures is located, and O2O1 is the second connecting line. The straight line where O2O1 is located can be rotated 45° clockwise and counterclockwise around O1 to obtain the first rotation straight line and the second rotation straight line respectively. Specifically, the extension line of O2O1 can be rotated around O1. Figure 4a , point O1 can correspond to Figure 3b If O1 is the point in Figure 3b On the extension line of O2O1, the straight line where O1P0 is located can be rotated 45° clockwise and counterclockwise around point O1 to obtain the first rotated straight line (the straight line where O1P1 is located) and the second rotated straight line (the straight line where O1P2 is located). Figure 4b , point O1 can correspond to Figure 3dFor point O1 in the image, the straight line where O1P0 is located can also be rotated 45° clockwise and counterclockwise around point O1 to obtain the first rotated straight line (the straight line where O1P1 is located) and the second rotated straight line (the straight line where O1P2 is located). For both cases, we can start from point O1, search for the first pixel whose pixel value has a gradient change along the straight line where O1P1 is located, and search for the second pixel whose pixel value has a gradient change along the straight line where O1P2 is located. The pixel whose pixel value has a gradient change can be a pixel whose pixel value is greatly different from that of the previous pixel. For example, if the first image is a binary image with pixel values ​​of 0 and 1, the pixel whose pixel value has a gradient change can be a pixel whose absolute value of the difference with the pixel value of the previous pixel is equal to 1. For example, referring to Figure 4a , three first pixels P12, P11, and P1 can be found in sequence on the straight line where O1P1 is located, and three first pixels P22, P21, and P2 can be found in sequence on the straight line where O1P2 is located. Of course, when there are noise points in the first image, other first pixels and second pixels with gradient changes in pixel values ​​may also be found.

[0149] The reference conditions for screening the two first reference pixels can be set according to actual needs. Exemplarily, the reference conditions for screening the two first reference pixels include at least:

[0150] 1) The distance between the first reference pixel and the first center pixel is within a preset distance range;

[0151] 2) The pixel value of the first reference pixel is equal to the preset pixel value;

[0152] 3) There are at least two first pixels or second pixels with different pixel values ​​between the first reference pixel and the first central pixel.

[0153] Specifically, the preset distance range can be set according to the size of the intact positioning mark area. Figure 5 As shown, if the module size of the intact positioning mark area is equal to m. In a specific example, the preset distance range can be [3m, 6m]. The preset pixel value is, for example, equal to 1. Through the above method, two first reference pixels can be quickly and accurately selected, that is, the positioning Figure 4a and Figure 4b P1 and P2 in.

[0154] The above method for determining the first reference pixel can improve the accuracy of the determined position, and further ensure the accuracy of the fitted second position. Therefore, the efficiency and accuracy of the two-dimensional code analysis can be further improved.

[0155] In one implementation, determining the position of the missing positioning mark region in the first image according to the second relative position relationship between the plurality of reference pixels includes:

[0156] Calculating a value of at least one determination variable based on positions of the plurality of reference pixels in the first image;

[0157] Determine the position to which the missing positioning mark area in the first image should belong according to the value of at least one determination variable and the variable threshold value corresponding to each determination variable;

[0158] The determination variable includes at least one of the following:

[0159] a coordinate difference between the coordinates of the two first reference pixels;

[0160] a first distance between two first reference pixels;

[0161] A second distance from the first central pixel to a third line, wherein the third line is a line between two first reference pixels.

[0162] refer to Figure 4a and Figure 4b , the two first reference pixels are the pixels where the points P1 and P2 are located, and the determination variable may include the coordinate difference between the horizontal coordinates and the vertical coordinates of P1 and P2. The determination variable may also include the distance between P1 and P2, that is, the length of P1P2 shown in the figure. The third connecting line may be the straight line where P1P2 is located, and the determination variable may also include the vertical distance from the point O1 to the straight line where P1P2 is located.

[0163] Specifically, in one example, determining the position of the missing positioning mark area in the first image according to the second relative position relationship between the plurality of reference pixels includes:

[0164] determining a first coordinate difference between the abscissas of the two first reference pixels and a second coordinate difference between the ordinates of the two first reference pixels;

[0165] Determine whether the first coordinate difference and the second coordinate difference are both greater than a coordinate difference threshold;

[0166] If yes, then determine that the position to which the missing positioning mark area in the first image should belong is the upper left position;

[0167] If not, it is determined that the position to which the missing positioning mark area in the first image belongs is the upper right position or the lower left position.

[0168] The first coordinate difference and the second coordinate difference can be the absolute value of the difference in coordinates. The coordinate difference threshold is, for example, equal to the module size of the first positioning mark area. If the absolute value of the difference between the horizontal coordinates of P1 and P2 and the absolute value of the difference between the vertical coordinates are both greater than the module size, it can be determined that the position to which the missing positioning mark area in the first image belongs is the upper left position; if any one of the absolute value of the difference between the horizontal coordinates of P1 and P2 and the absolute value of the difference between the vertical coordinates is less than or equal to the module size, it can be determined that the position to which the missing positioning mark area in the first image belongs is the upper right position or the lower left position.

[0169] In another example, determining the position of the missing positioning mark area in the first image according to the second relative position relationship between the plurality of reference pixels includes:

[0170] Calculating a first distance between two first reference pixels;

[0171] Calculating a first preset ratio of the first distance to the sizes of the two intact positioning mark areas;

[0172] Determining whether the first preset ratio is greater than a first preset ratio threshold;

[0173] If yes, determine that the position of the missing positioning mark area in the first image should be the upper right position or the lower left position;

[0174] If not, it is determined that the position to which the missing positioning mark area in the first image should belong is the upper left position.

[0175] For example, refer to Figure 4a and Figure 4b , taking the length of P1P2 as the first distance, calculating the ratio of P1P2 to the module size of the first positioning mark area, and obtaining a first preset ratio. The first preset ratio threshold is, for example, 5. Therefore, for Figure 4a In the case where the first preset ratio is less than 5, it can be determined that the position to which the missing positioning mark area in the image belongs is the upper left position; Figure 4b In the case where the first preset ratio is greater than 5, it can be determined that the position to which the missing positioning mark area in the image should belong is the upper right position or the lower left position.

[0176] In yet another example, determining the position of the missing positioning mark region in the first image according to the second relative position relationship between the plurality of reference pixels includes:

[0177] Calculate the vertical distance between the first central pixel and the line connecting the two first reference pixels;

[0178] calculating a second predetermined ratio of the vertical distance to the size of the two intact positioning mark areas;

[0179] Determining whether the second preset ratio is greater than a second preset ratio threshold;

[0180] If yes, determine that the position of the missing positioning mark area in the first image should be the upper right position or the lower left position;

[0181] If not, it is determined that the position to which the missing positioning mark area in the first image should belong is the upper left position.

[0182] For example, continue to refer to Figure 4a and Figure 4b , the vertical distance from point O1 to the straight line where point P1P2 is located can be calculated, and then the ratio of the vertical distance to the module size of the first positioning mark area can be calculated to obtain a second preset ratio. The second preset ratio threshold is, for example, 2.6. Therefore, for Figure 4a In the case where the second preset ratio is less than 2.6, it can be determined that the position to which the missing positioning mark area in the image belongs is the upper left position; Figure 4b In the case where the first preset ratio is greater than 2.6, it can be determined that the position to which the missing positioning mark area in the image should belong is the upper right position or the lower left position.

[0183] The above method for determining the position of the missing positioning mark area in the first image is more accurate and requires less calculation. Thus, the position of the missing positioning mark area in the first image can be determined in real time and accurately. Therefore, the efficiency and accuracy of QR code analysis can be further improved.

[0184] In one implementation, the plurality of reference pixels further include a second reference pixel, and searching the first image for a plurality of reference pixels satisfying a reference condition according to the first relative position relationship between the two intact positioning mark regions and the sizes of the two intact positioning mark regions, further includes:

[0185] Taking the first central pixel as the starting point, searching for a third pixel whose pixel value has a gradient change along the direction of the second connecting line;

[0186] Selecting a third pixel that meets a reference condition from the found third pixels as a second reference pixel;

[0187] Determining the position of the missing positioning mark area in the first image according to the second relative position relationship between the plurality of reference pixels includes:

[0188] Determining the position of the missing positioning mark area in the first image according to the angle between two fourth connecting lines and a preset angle threshold, wherein the two fourth connecting lines are connecting lines between the second reference pixel and the two first reference pixels respectively; and / or

[0189] The orientation of the missing positioning mark area in the first image is determined based on the second distance from the first central pixel to the third line and two third distances, wherein the third line is the line between the two first reference pixels, and the two third distances are the distances from the first central pixel to the two fourth lines respectively.

[0190] The method for determining the second reference pixel is similar to the principle of determining the first reference pixel described above, except that the search for the third pixel is performed along the straight line where the second line between the center pixels of the two intact positioning mark areas is located. Taking the first center pixel as the starting point, search for the third pixel whose pixel value has a gradient change along the direction of the second line, specifically along the direction away from the center pixels of the two intact positioning mark areas. For example, in the aforementioned example, the count values ​​of the first three patterns in the sorted all_patterns set are count1, count2, and count3, respectively. If count3 is less than (count1+count2)*0.5*0.7, the current two-dimensional code is a two-dimensional code that lacks a positioning mark area, and the first two patterns correspond to a complete positioning mark area, respectively. Taking the two center pixels of the positioning mark areas as O1 and O2, respectively, O1 can be used as the starting point, and on the straight line where O1O2 is located, along the direction away from O2, the pixel points where the black and white pixels change in sequence are searched, and the changed pixel points are stored in the pixel set P. And the second reference pixel can be screened out from the data set according to the following conditions:

[0191] a. The number of pixels in the pixel set P is greater than or equal to 3;

[0192] b. The distance from the point where the color changes to O1 is greater than moduleSize*3 and less than moduleSize*6, where moduleSize is the module size of the positioning mark area;

[0193] c. The point position where the current color change is recorded is i, and the color of the pixels from the current point P[i] to the center point of the previous point P[i-1] is black.

[0194] If a pixel in the pixel sets P and P satisfies the above three conditions at the same time, then the pixel is used as the second reference pixel (i.e. Figure 4a and Figure 4b P0 in .

[0195] Reference again Figure 4a and Figure 4b After determining P0, P1 and P2 in the figure, the position of the missing positioning mark area in the first image can be determined according to the relative position relationship of these three pixels.

[0196] In one example, two fourth connecting lines may be obtained as the straight line where P0P1 is located and the straight line where P0P2 is located. Then, the angle α between P0P1 and P0P2 may be calculated. The preset angle threshold is, for example, 100°. Exemplarily, if α≤100°, it may be determined that the position to which the missing positioning mark area in the first image should belong is the upper left position, and if α>100°, it may be determined that the position to which the missing positioning mark area in the first image should belong is the upper right position or the lower left position. Figure 4a In the case of , we can determine that the position of the missing positioning mark area in the image should be the upper left position according to α being close to 90° and less than 100°; Figure 4b In the case of α being close to 180° and greater than 100°, it can be determined that the position of the missing positioning mark area in the image should be the upper right position or the lower left position.

[0197] In another example, the straight line where P0P1 is located, the straight line where P0P2 is located, and the straight line where P1P2 is located can be obtained first. Then, the distances from O1 to the three straight lines can be calculated respectively. The values ​​of these three distances can be used to determine the position of the missing positioning mark area in the first image. Figure 6a and Figure 6b As shown, the second distance L3 and the two third distances L1 and L2 can be obtained respectively. Then, various suitable methods can be used to determine the position of the missing positioning mark area in the first image according to these three.

[0198] In one embodiment, the absolute value of the difference between L3 and L1 and the absolute value of the difference between L3 and L1 can be calculated. It is determined whether both are less than a length threshold. The length threshold is, for example, 0.8*moudleSize. If so, it can be determined that the position to which the missing positioning mark area in the image should belong is the upper right position or the lower left position; if not, it can be determined that the position to which the missing positioning mark area in the image should belong is the upper left position.

[0199] In another embodiment, determining the position of the missing positioning mark area in the first image according to the second distance from the first central pixel to the third connecting line and the two third distances includes:

[0200] Calculate the sum of the two third distances to obtain the fifth distance;

[0201] calculating a first ratio between the second distance and the fifth distance;

[0202] Determining whether the first ratio is less than or equal to a first ratio threshold;

[0203] If yes, determine that the position of the missing positioning mark area in the first image should be the upper left position;

[0204] If not, it is determined that the position to which the missing positioning mark area in the first image belongs is the upper right position or the lower left position.

[0205] The second distance L3 and the two third distances L1 and L2 can be obtained respectively. The first ratio threshold can be set according to actual needs. For example, the first ratio threshold can be 0.4. The position of the missing positioning mark can be determined based on the first ratio obtained by L3 / (L2+L1) and the first ratio threshold 0.4. Figure 6b As shown in the figure, when the U-shaped positioning mark in the lower left position or the U-shaped positioning mark in the upper right position is missing, the three points P0, P1, and P2 are almost collinear, so the lengths of L1, L2, and L3 are basically the same. Therefore, L3 / (L2+L1)≈0.5, and according to L3 / (L2+L1)>0.4, it can be determined that the position of the missing positioning mark area in the first image should be the upper left position. Figure 6a As shown, when the U-shaped positioning mark in the upper left position is missing, the three points P0, P1, and P2 are not collinear, and L3 / (L2+L1)≈0.35. Therefore, according to L3 / (L2+L1)≤0.4, it can be determined that the position of the missing positioning mark area in the first image should be the upper right or lower left position.

[0206] This method for determining the missing positioning mark area is more accurate, less susceptible to interference from other factors, and requires less calculation, thereby further improving the accuracy and efficiency of QR code parsing.

[0207] In one embodiment, the orientation includes an upper left orientation, an upper right orientation, and a lower left orientation, and fitting the missing positioning mark region to a second position in the first image according to the orientation and the first positions of the two intact positioning mark regions includes:

[0208] When it is determined that the position to which the missing positioning mark area belongs is the upper left position, the second connecting line is rotated 45° in the clockwise direction and the counterclockwise direction respectively with the first central pixel as the rotation center, and the second connecting line is rotated 45° in the clockwise direction and the counterclockwise direction respectively with the third central pixel as the rotation center, to obtain four third rotation straight lines, wherein the first central pixel and the third central pixel are the central pixels of two intact positioning mark areas respectively, and the second connecting line is the connecting line of the first central pixel and the fourth central pixel; the second position is determined according to the positions of the intersections of the four third rotation straight lines;

[0209] and / or

[0210] When it is determined that the orientation of the missing positioning mark area is the upper right or lower left position, the third center pixel is rotated 90° in the clockwise and counterclockwise directions respectively with the first center pixel as the rotation center, and the first center pixel is rotated 90° in the clockwise and counterclockwise directions respectively with the third center pixel as the rotation center; the second position is determined according to the position of the rotated first center pixel or the position of the rotated third center pixel.

[0211] refer to Figure 7a For the case where the upper left positioning mark area is missing, the first central pixel O1 can be used as the rotation center, and the second line O1O2 can be rotated 45° in the clockwise direction and counterclockwise direction respectively to obtain two third rotation straight lines O1O2' and O1O2". And the third central pixel O2 can be used as the rotation center, and the second line O1O2 can be rotated 45° in the clockwise direction and counterclockwise direction respectively to obtain another two third rotation straight lines O2O1' and O2O1". Afterwards, the second position can be determined according to the intersection of O1O2' and O2O1' and the intersection of O1O2" and O2O1". For example, these two intersections can be directly used as two possible solutions for the position of the center point of the missing positioning mark area. Then, the two-dimensional code can be parsed according to these two possible solutions combined with the positions of the center points of the two intact positioning mark areas. If the parsing is successful, it means that the possible solution is the correct solution. If the parsing is unsuccessful, it means that the possible solution is not the correct solution.

[0212] refer to Figure 7b and Figure 7c For the case where the upper right positioning mark area and the lower left positioning mark area are missing, the first central pixel O1 can be used as the rotation center, and the third central pixel O2 can be rotated 90° in the clockwise direction and counterclockwise direction respectively to obtain rotated O2' and O2", and the first central pixel O1 can be used as the rotation center to rotate 90° in the clockwise direction and counterclockwise direction respectively to obtain rotated O1' and O1". Afterwards, the second position can be determined according to the coordinates of these four points. For example, these four points can be directly used as four possible solutions for the position of the center point of the missing positioning mark area. Afterwards, the QR code can be parsed according to these four possible solutions combined with the positions of the center points of the two intact positioning mark areas. If the parsing is successful, it means that the possible solution is the correct solution. If the parsing is unsuccessful, it means that the possible solution is not the correct solution.

[0213] The above-mentioned solution for fitting the second position has simpler execution logic, more comprehensive considerations, and less calculation, which can further improve the accuracy and efficiency of QR code parsing.

[0214] The present application also provides a two-dimensional code image processing device, such as Figure 8As shown, the processing device 800 includes:

[0215] An acquisition module 810 is used to acquire a first image of a QR code;

[0216] A first determination module 820 is used to determine the attributes of each suspected positioning mark region in the first image according to the pixel value of each pixel in the first image, wherein the attributes of the suspected positioning mark region include the first position of the suspected positioning mark region, or also include the size of the suspected positioning mark region;

[0217] A determination module 830, configured to determine whether the first image is a two-dimensional code image that lacks a positioning mark region according to the attributes of each suspected positioning mark region;

[0218] A screening module 840 is configured to screen out two intact positioning marker regions from each suspected positioning marker region if yes;

[0219] A second determination module 850 is used to determine the position of the missing positioning mark area in the first image according to the attributes of the two intact positioning mark areas;

[0220] The fitting module 860 is used to fit the missing positioning mark area to the second position in the first image according to the orientation and the first position of the two intact positioning mark areas, so as to perform a QR code parsing operation on the first image according to the second position and the first position of the two intact positioning mark areas.

[0221] like Fig. 9 As shown, the embodiment of the present application further provides a terminal device 900, including: at least one processor 910 ( Fig. 9 Only one processor is shown in the figure), a memory 920, and a computer program 930 stored in the memory 920 and executable on at least one processor 910. When the processor 910 executes the computer program 930, the steps of the above-mentioned two-dimensional code image processing method are implemented.

[0222] The terminal device may include but is not limited to a processor and a memory. Fig. 9It is only an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown in the figure, or combine certain components, or different components. The processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0223] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0224] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned function allocation can be completed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The functional modules in the embodiment can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules. In addition, the specific names of the functional modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0225] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned two-dimensional code image processing method can be implemented.

[0226] An embodiment of the present application provides a computer program product. When the computer program product is executed on a terminal device, the terminal device can implement the steps in the above-mentioned two-dimensional code image processing method.

[0227] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for processing a two-dimensional code image, characterized in that: include: Obtaining a first image of the QR code; Determining the attributes of each suspected positioning mark region in the first image according to the pixel value of each pixel in the first image, wherein the attributes of the suspected positioning mark region include the first position of the suspected positioning mark region, or further include the size of the suspected positioning mark region; According to the attributes of each of the suspected positioning mark areas, determining whether the first image is a two-dimensional code image that lacks a positioning mark area; If yes, two intact positioning marker regions are selected from the suspected positioning marker regions; Determining the position of the missing positioning mark region in the first image according to the attributes of the two intact positioning mark regions; According to the orientation and the first positions of the two intact positioning mark areas, the second position of the missing positioning mark area in the first image is fitted, so as to perform a QR code parsing operation on the first image according to the second position and the first positions of the two intact positioning mark areas.

2. The method for processing a two-dimensional code image according to claim 1, characterized in that: The positioning mark of the two-dimensional code is a U-shaped positioning mark, and the determining, according to the attributes of the two intact positioning mark areas, the position to which the missing positioning mark area in the first image should belong includes: According to the first relative position relationship between the two intact positioning mark areas and the sizes of the two intact positioning mark areas, searching for a plurality of reference pixels satisfying a reference condition from the first positioning mark area; Determine the position of the missing positioning mark area in the first image according to the second relative position relationship between the plurality of reference pixels; Among them, the first positioning mark area is any one of the two intact positioning mark areas, the multiple reference pixels include at least two first reference pixels, the angles between the two first reference pixels and the first center pixel of the first positioning mark area are equal to the second line, and the difference in distance between the two first reference pixels and the first center pixel is less than or equal to a first difference threshold, the first line is the line between the first reference pixel and the first center pixel of the first positioning mark area, and the second line is the line between the center pixels of the two intact positioning mark areas.

3. The method for processing a two-dimensional code image according to claim 2, wherein: The searching for a plurality of reference pixels satisfying a reference condition from the first positioning mark region according to the first relative position relationship between the two intact positioning mark regions and the sizes of the two intact positioning mark regions comprises: Taking the first central pixel as the rotation center, the second connecting line is rotated 45° in a clockwise direction to obtain a first rotation straight line, and the second connecting line is rotated 45° in a counterclockwise direction to obtain a second rotation straight line; Taking the first central pixel as a starting point, searching for a first pixel whose pixel value has a gradient change along the direction of the first rotation line, and searching for a second pixel whose pixel value has a gradient change along the direction of the second rotation line; A first pixel satisfying the reference condition is selected from each of the first pixels found, and a second pixel satisfying the reference condition is selected from each of the second pixels found, to obtain the two first reference pixels.

4. The method for processing a two-dimensional code image according to claim 3, wherein: The determining, according to the second relative position relationship between the plurality of reference pixels, the position to which the missing positioning mark area in the first image should belong includes: Calculating a value of at least one determination variable according to positions of the plurality of reference pixels in the first image; Determine the position to which the missing positioning mark area in the first image should belong according to the value of the at least one determination variable and the variable threshold value corresponding to each determination variable; The determination variable includes at least one of the following: a coordinate difference between the coordinates of the two first reference pixels; a first distance between the two first reference pixels; A second distance from the first central pixel to a third line, wherein the third line is a line between the two first reference pixels.

5. The method for processing a two-dimensional code image according to claim 3, wherein: The multiple reference pixels also include a second reference pixel, and searching for multiple reference pixels that meet the reference condition from the first positioning mark area according to the first relative position relationship between the two intact positioning mark areas and the sizes of the two intact positioning mark areas also includes: Taking the first central pixel as a starting point, searching for a third pixel whose pixel value has a gradient change along the direction of the second connecting line; Selecting a third pixel satisfying the reference condition from the found third pixels as the second reference pixel; The determining, according to the second relative position relationship between the plurality of reference pixels, the position to which the missing positioning mark area in the first image should belong includes: Determining the position to which the missing positioning mark area in the first image should belong according to an angle between two fourth connecting lines and a preset angle threshold, wherein the two fourth connecting lines are connecting lines between the second reference pixel and the two first reference pixels respectively; and / or The position of the missing positioning mark area in the first image is determined based on the second distance from the first central pixel to the third line and the two third distances, wherein the third line is the line between the two first reference pixels, and the two third distances are the distances from the first central pixel to the two fourth lines respectively.

6. The method for processing a two-dimensional code image according to claim 5, characterized in that: The determining, based on the second distance between the first central pixel and the third connecting line and the two third distances, the position to which the missing positioning mark area in the first image should belong includes: Calculating the sum of the two third distances to obtain a fifth distance; calculating a first ratio between the second distance and the fifth distance; Determining whether the first ratio is less than or equal to a first ratio threshold; If yes, determine that the position of the missing positioning mark area in the first image should be the upper left position; If not, it is determined that the position of the missing positioning mark area in the first image should be the upper right position or the lower left position.

7. The method for processing a two-dimensional code image according to any one of claims 1 to 6, characterized in that: Determining the attributes of each suspected positioning mark area in the first image according to the pixel value of each pixel in the first image includes: For each row area of ​​the first image, Determining, according to the pixel values ​​of each pixel in the row area, whether there is at least one positioning row sub-area in the row area, wherein pixels with different pixel values ​​in the positioning row sub-area meet a preset distribution requirement; If yes, determining the second center pixel of each positioning row sub-region; Determine whether there is a positioning column sub-region including the second central pixel in the column region where the second central pixel is located, wherein pixels with different pixel values ​​in the positioning column sub-region meet the preset distribution requirement; If yes, it is determined that the row area corresponds to a suspected positioning mark area, and the attributes of the suspected positioning mark area are determined according to the attributes of the positioning column sub-area; or, Determining the attributes of each suspected positioning mark area in the first image according to the pixel value of each pixel in the first image includes: For each column region of the first image, Determining whether there is at least one positioning column sub-region in the column region according to the pixel value of each pixel in the column region, wherein pixels with different pixel values ​​in the positioning column sub-region meet a preset distribution requirement; If yes, determine the second center pixel of each positioning column sub-region; Determine whether there is a positioning row sub-region including the second central pixel in the row region where the second central pixel is located, wherein pixels with different pixel values ​​in the positioning row sub-region meet the preset distribution requirement; If so, it is determined that the column area corresponds to a suspected positioning mark area, and the attributes of the suspected positioning mark area are determined according to the attributes of the positioning row sub-area.

8. The method for processing a two-dimensional code image according to claim 7, wherein: The determining, based on the attributes of each of the suspected positioning mark areas, whether the first image is a two-dimensional code image lacking a positioning mark area includes: According to the attributes of the respective suspected positioning mark regions, the respective suspected positioning mark regions are grouped to obtain at least one region group, wherein a difference between corresponding attributes of any two suspected positioning mark regions in each region group is less than or equal to a third difference threshold; At least according to the situation that the number of divided area groups is greater than or equal to 2, determining that the first image is a two-dimensional code image that lacks a positioning mark area; The step of selecting two intact positioning marker regions from the respective suspected positioning marker regions comprises: One suspected positioning marker region is selected from each of the two region groups to obtain the two intact positioning marker regions.

9. The method for processing a two-dimensional code image according to claim 8, wherein: The number of the area groups is greater than or equal to 3, and the determining that the first image is a two-dimensional code image lacking a positioning mark area at least based on the situation that the number of the divided area groups is greater than or equal to 2 includes: When the number of divided regional groups is greater than or equal to 3, three first regional groups are determined from the at least one regional group according to the number corresponding to each regional group, wherein the number corresponding to each of the three first regional groups is greater than the number corresponding to other regional groups; Determining whether the relationship between the quantities corresponding to the three first area groups satisfies a preset relationship; If so, it is determined that the first image is a two-dimensional code image that lacks a positioning mark area.

10. The method for processing a two-dimensional code image according to claim 9, wherein: The determining whether the relationship between the quantities corresponding to the three first area groups satisfies a preset relationship includes: Calculate the sum of the first quantity and the second quantity to obtain a fourth quantity; calculating a second ratio of the third quantity to the fourth quantity; Determining whether the second ratio is less than a second ratio threshold; If yes, determining that the relationship between the quantities corresponding to the three first area groups satisfies the preset relationship; If not, determining that the relationship between the quantities corresponding to the three first area groups does not satisfy the preset relationship; The first number, the second number and the third number are numbers corresponding to the three first area groups respectively, and the first number and the second number are both greater than the third number, and the second ratio threshold is less than or equal to 0.

5.

11. The method for processing a two-dimensional code image according to claim 8, wherein: The grouping of the suspected positioning mark areas according to the attributes of the suspected positioning mark areas includes: At the first moment when the first suspected positioning mark area is determined, the first suspected positioning mark area is used as the first area group, and the attribute array of the first area group is added to the array set, wherein the attribute array includes a representative position of the first area group, a representative size of the first area group, and a quantity corresponding to the first area group, the representative position is equal to the first position of the first suspected positioning mark area, the representative size is equal to the size of the first suspected positioning mark area, and the initial value of the quantity corresponding to the first area group is 1; At the second moment when the i-th suspected positioning mark area is determined, the attributes of the i-th suspected positioning mark area are respectively compared with the attribute arrays of each area group in the array set at the moment, and according to the comparison result, it is determined whether the i-th suspected positioning mark area matches any second area group, wherein i≥2, and the second area group is any one of the various area groups; If yes, then add the i-th suspected positioning mark area to the second area group, and update the number corresponding to the second area group in the array set; If not, the i-th suspected positioning mark area is taken as a new third area group, and based on the attributes of the i-th suspected positioning mark area, the attribute array of the third area group to which the i-th suspected positioning mark area belongs is determined, and the attribute array of the third area group is added to the array set.

12. The method for processing a two-dimensional code image according to any one of claims 1 to 6, characterized in that: The positions include an upper left position, an upper right position, and a lower left position, and fitting the second position of the missing positioning mark area in the first image according to the positions and the first positions of the two intact positioning mark areas includes: When it is determined that the position to which the missing positioning mark area belongs is the upper left position, the second connecting line is rotated 45° in the clockwise direction and the counterclockwise direction respectively with the first central pixel as the rotation center, and the second connecting line is rotated 45° in the clockwise direction and the counterclockwise direction respectively with the third central pixel as the rotation center to obtain four third rotation straight lines, wherein the first central pixel and the third central pixel are the central pixels of the two intact positioning mark areas respectively, and the second connecting line is the connecting line of the first central pixel and the third central pixel; the second position is determined according to the positions of the intersections of the four third rotation straight lines; and / or When it is determined that the orientation of the missing positioning mark area is the upper right or lower left position, the third center pixel is rotated 90° in a clockwise and counterclockwise direction respectively with the first center pixel as the rotation center, and the first center pixel is rotated 90° in a clockwise and counterclockwise direction respectively with the third center pixel as the rotation center; the second position is determined according to the position of the rotated first center pixel or the position of the rotated third center pixel.

13. A two-dimensional code image processing device, characterized in that: include: An acquisition module, used for acquiring a first image of the QR code; A first determination module, configured to determine the attributes of each suspected positioning mark region in the first image according to the pixel value of each pixel in the first image, wherein the attributes of the suspected positioning mark region include the first position of the suspected positioning mark region, or further include the size of the suspected positioning mark region; A judgment module, used for judging whether the first image is a two-dimensional code image lacking a positioning mark area according to the attributes of each suspected positioning mark area; a screening module, configured to screen out two intact positioning marker regions from the suspected positioning marker regions if yes; A second determination module, configured to determine the position of the missing positioning mark region in the first image according to the attributes of the two intact positioning mark regions; A fitting module is used to fit the second position of the missing positioning mark area in the first image according to the orientation and the first positions of the two intact positioning mark areas, so as to perform a QR code parsing operation on the first image according to the second position and the first positions of the two intact positioning mark areas.

14. A terminal device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for processing a two-dimensional code image as described in any one of claims 1 to 12 when executing the computer program.