A two-dimensional code repairing method, device, equipment and medium
Patent Information
- Application Number
- CN202310281612.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-21
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-03-21
AI Technical Summary
[0005]因此,本发明要解决的技术问题在于克服现有技术中由于采集的二维码图像出现缺陷,而导致无法正确解析二维码的缺陷,从而提供一种二维码修复方法、装置、设备及介质
[0005] Therefore, the technical problem to be solved by the present invention is to overcome the defect in the prior art that the QR code cannot be correctly parsed due to defects in the acquired QR code image, thereby providing a QR code repair method, device, equipment and medium.
Smart Images

Figure CN116306734B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, specifically to a QR code repair method, apparatus, device, and medium. Background Technology
[0002] QR code technology has been widely used in all aspects of production and daily life. For example, in industrial production, in order to achieve automated product identification and traceability, QR codes are often set on the surface of products as product identifiers. As products pass continuously on the production line, industrial cameras installed at preset image acquisition points capture the QR code image on each product one by one. The relevant business system then parses the QR code for subsequent data processing.
[0003] Because the opportunity to capture product QR code images is extremely brief during the high-speed operation of the production line, defects in the captured image can prevent the QR code from being correctly parsed, thus affecting subsequent production. Common defects include glare, blurriness, and skewness.
[0004] Therefore, how to repair defective QR code images has become a problem that needs to be solved. Summary of the Invention
[0005] Therefore, the technical problem to be solved by the present invention is to overcome the defect in the prior art that the QR code cannot be correctly parsed due to defects in the acquired QR code image, thereby providing a QR code repair method, device, equipment and medium.
[0006] In a first aspect, the present invention provides a QR code repair method, comprising:
[0007] Acquire at least two original images, which are images generated after shooting the target object from different shooting angles, and the target object carries a QR code image; extract the QR code image from each original image; adjust each QR code image to a first image to be corrected that meets preset conditions according to a preset conversion relationship; filter the first image to be corrected based on a preset first grayscale threshold and the first grayscale value corresponding to each pixel in the first image to be corrected to generate a second image to be corrected; fuse all the second images to be corrected to generate a QR code corrected image.
[0008] This invention, after acquiring original images corresponding to different shooting angles, extracts QR code images from each frame of the original image and adjusts all QR code images to meet preset conditions for a first image to be corrected. Based on a first grayscale threshold, the grayscale value corresponding to each pixel in the first image to be corrected is adjusted to generate a second image to be corrected. Finally, all the second images to be corrected are fused to generate a corrected QR code image. By adjusting the QR code images to the first image to be corrected, all QR code images meet the preset conditions, facilitating subsequent image fusion processing. Since the location of defects differs in each frame of the second image to be corrected, fusing all the second images to be corrected is equivalent to superimposing them, thereby determining the target grayscale value corresponding to each pixel in the second image to be corrected, and thus determining the target grayscale value of the defect location in each frame of the second image to be corrected, thereby completing the correction of the QR code image.
[0009] In conjunction with the first aspect, in the first embodiment of the first aspect, extracting a QR code image from each frame of the original image includes:
[0010] Each frame of the original image is processed into grayscale to generate a grayscale image corresponding to the original image; a QR code image corresponding to the grayscale image is extracted from each frame of the grayscale image.
[0011] In conjunction with the first aspect, in the second embodiment of the first aspect, extracting the QR code image corresponding to the grayscale image from each grayscale image frame includes:
[0012] The grayscale values of all pixels in the grayscale image are compared with a second grayscale threshold. The coordinates of pixels whose grayscale values are greater than or equal to the second grayscale threshold are extracted. From all the pixel coordinates greater than or equal to the second grayscale threshold, the first coordinate to which the maximum horizontal coordinate belongs, the second coordinate to which the minimum horizontal coordinate belongs, the third coordinate to which the maximum vertical coordinate belongs, and the fourth coordinate to which the minimum vertical coordinate belongs are selected. The QR code region is determined based on the first, second, third, and fourth coordinates. The image in the QR code region is extracted from the grayscale image as the QR code image.
[0013] In conjunction with the first aspect, in the third embodiment of the first aspect, adjusting each frame of the QR code image to a first image to be corrected that meets preset conditions according to a preset conversion relationship includes:
[0014] Obtain the pixel coordinates corresponding to each pixel in the QR code image; select the vertex coordinates corresponding to the vertices of the QR code image from the pixel coordinates corresponding to each pixel in the QR code image; determine the conversion coefficients based on the vertex coordinates, the preset target vertex coordinates, and the preset conversion relationship; adjust the QR code image to the first image to be corrected based on the conversion coefficients, the preset conversion relationship, and the pixel coordinates corresponding to each pixel in the QR code image.
[0015] In conjunction with the first aspect, in the fourth embodiment of the first aspect, based on a preset first grayscale threshold and the first grayscale value corresponding to each pixel in the first image to be corrected, the first image to be corrected is filtered to generate a second image to be corrected, including:
[0016] The first gray value corresponding to each pixel in the first image to be corrected is compared with the first gray value threshold to generate a comparison result; based on the comparison result, the first gray value corresponding to each pixel in the first image to be corrected is adjusted to the second gray value corresponding to the comparison result; and a second image to be corrected is generated based on the second gray value corresponding to each pixel.
[0017] In conjunction with the first aspect, in the fifth embodiment of the first aspect, all the second images to be corrected are fused to generate a QR code corrected image, including:
[0018] Obtain the second grayscale value corresponding to the first pixel in all second images to be corrected, where the first pixel is any pixel among multiple pixels contained in the second image to be corrected; determine the target grayscale value corresponding to the first pixel based on the second grayscale value corresponding to the first pixel in each frame of the second image to be corrected; generate a QR code correction image based on the target grayscale value corresponding to each pixel in the second image to be corrected.
[0019] In conjunction with the first aspect, in the sixth embodiment of the first aspect, determining the target grayscale value corresponding to the first pixel based on the second grayscale value corresponding to the first pixel in each frame of the second image to be corrected includes:
[0020] When all second grayscale values are consistent, the second grayscale value is used as the target grayscale value; when the second grayscale values are inconsistent, the preset grayscale value is determined as the target grayscale value.
[0021] In a second aspect, the present invention provides a QR code repair device, comprising:
[0022] The acquisition module is used to acquire at least two original images, which are images generated after shooting the target object from different shooting angles, and the target object carries a QR code image; the extraction module is used to extract the QR code image from each original image; the adjustment module is used to adjust each QR code image to a first image to be corrected that meets preset conditions according to a preset conversion relationship; the first processing module is used to filter the first image to be corrected based on a preset first grayscale threshold and the first grayscale value corresponding to each pixel in the first image to be corrected, to generate a second image to be corrected; the second processing module is used to fuse all the second images to be corrected to generate a QR code corrected image.
[0023] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory is used to store a computer program, and when the computer program is executed by the processor, the processor performs any of the QR code repair methods described in the present invention.
[0024] Fourthly, the present invention provides a computer-readable storage medium for storing computer instructions that, when executed by a processor, implement the QR code repair method as described in any of the claims of the present invention. Attached Figure Description
[0025] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0026] Figure 1 A flowchart of a QR code repair method provided in an embodiment of the present invention;
[0027] Figure 2 This is an example diagram corresponding to the application scenario of acquiring raw images provided in the embodiments of the present invention;
[0028] Figure 3 A schematic diagram of a grayscale image provided in an embodiment of the present invention;
[0029] Figure 4 This is a schematic diagram of the first placement of a QR code image in a grayscale image, as provided in an embodiment of the present invention.
[0030] Figure 5 This is a schematic diagram illustrating the second arrangement of a QR code image in a grayscale image, as provided in an embodiment of the present invention.
[0031] Figure 6This is a schematic diagram of the first image to be corrected provided in an embodiment of the present invention;
[0032] Figure 7 This is a schematic diagram of the second image to be corrected provided in an embodiment of the present invention;
[0033] Figure 8 This is a schematic diagram of a corrected QR code image provided in an embodiment of the present invention;
[0034] Figure 9 A connection diagram of the QR code repair device provided in an embodiment of the present invention;
[0035] Figure 10 This is a computer device connection diagram provided for an embodiment of the present invention. Detailed Implementation
[0036] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0037] This invention discloses a QR code repair method, such as... Figure 1 As shown, the specific steps include the following:
[0038] S1: Acquire at least two original images.
[0039] Specifically, at least two original images are generated by shooting the target object from different shooting angles, and the target object carries a QR code image.
[0040] For example, in a practical application scenario, the number of frames in the original image is consistent with the number of cameras. The cameras are installed in different locations to capture images of the target object from different shooting angles. Therefore, one frame of the original image is acquired at each shooting angle. The original image includes a QR code image and a background image. It should be noted that the QR code in each frame of the original image provided in this embodiment has defects; therefore, it is impossible to parse the QR code content solely from the QR code image in any single frame of the original image. These image defects include, but are not limited to, reflections, blurring, and skewness.
[0041] For example, when a product carrying a QR code is conveyed on a conveyor belt, at least two cameras installed on one side of the conveyor belt capture images of the QR code on the product to obtain the original image. Figure 2This is an example diagram corresponding to the application scenario of this embodiment. A QR code 4 is set on the surface of the product 3. The product 3 moves from left to right on the conveyor belt 1 in the direction shown by the arrow. When the trigger 6 installed above the conveyor belt senses that the product 3 has entered the radiation range of the trigger 6, the trigger 6 sends a trigger signal. When the camera 2 and camera 5 installed on one side of the conveyor belt receive the trigger signal sent by the trigger 6, they simultaneously take pictures of the QR code, thereby obtaining the original images corresponding to different shooting angles. The QR code type in this embodiment includes, but is not limited to, QR codes.
[0042] S2: Extract the QR code image from each frame of the original image.
[0043] Specifically, after obtaining at least two original images, it is necessary to extract the corresponding QR code image from each original image.
[0044] For example, in an optional embodiment, the process of extracting the QR code image from each frame of the original image is as follows: perform grayscale processing on each frame of the original image to generate a grayscale image corresponding to the original image; and extract the QR code image corresponding to the grayscale image from each frame of the grayscale image.
[0045] S3: According to the preset conversion relationship, adjust each frame of QR code image to the first image to be corrected that meets the preset conditions.
[0046] Specifically, the preset conditions include, but are not limited to, preset size and preset orientation. That is, the size of each frame of the QR code image is adjusted to the preset size, and the orientation of each frame of the QR code image is adjusted to the preset orientation.
[0047] For example, each frame of the QR code image contains three positioning blocks. Adjusting the placement of the QR code image to a preset orientation means rotating the QR code image so that the positions of the three positioning blocks in the QR code image are consistent with the preset positions. At this time, the orientation of the QR code image is the preset orientation. For example, if the preset positions are upper left, upper right, and lower right, the QR code image is rotated so that the three positioning blocks are located at the upper left, upper right, and lower right corners of the QR code image, respectively.
[0048] S4: Based on the preset first grayscale threshold and the first grayscale value corresponding to each pixel in the first image to be corrected, the first image to be corrected is filtered to generate the second image to be corrected.
[0049] Specifically, the first grayscale value corresponding to each pixel in the first image to be corrected is compared with a first grayscale threshold to generate a comparison result. Based on the comparison result, the grayscale values corresponding to all pixels in the first image to be corrected are readjusted to the grayscale values corresponding to the comparison result. In this way, the grayscale values of all white blocks in the first image to be corrected can be adjusted to value A, and the grayscale values of all black blocks can be adjusted to value B. The first grayscale threshold is a grayscale value that can distinguish between white and black blocks in the first image to be corrected.
[0050] S5: Perform fusion processing on all the second images to be corrected to generate a QR code corrected image.
[0051] Specifically, the second grayscale values corresponding to the same pixel in all the second images to be corrected are fused, and a QR code corrected image is generated based on the result of the fusion processing of each pixel in the second images to be corrected.
[0052] This invention, after acquiring original images corresponding to different shooting angles, extracts QR code images from each frame of the original image and adjusts all QR code images to a first image to be corrected that meets preset conditions. Based on a first grayscale threshold, the grayscale value corresponding to each pixel in the first image to be corrected is adjusted to generate a second image to be corrected. Finally, all the second images to be corrected are fused to generate a corrected QR code image. By adjusting the QR code images to the first image to be corrected, all QR code images meet the preset conditions, facilitating subsequent image fusion processing. Since the location of defects differs in each frame of the second image to be corrected, fusing all the second images to be corrected is equivalent to superimposing them, thereby determining the target grayscale value corresponding to each pixel in the second image to be corrected, thus determining the target grayscale value of the defect location in each frame of the second image to be corrected, ultimately completing the correction of the QR code image.
[0053] In an optional embodiment, extracting a QR code image from each frame of the original image includes:
[0054] Each frame of the original image is processed into grayscale to generate a grayscale image corresponding to the original image; a QR code image corresponding to the grayscale image is extracted from each frame of the grayscale image.
[0055] For example, in order to eliminate the interference of the background image (i.e., the packaging pattern on the side of the product packaging where the QR code image is located) on the QR code image in the original image during the recognition process, it is necessary to first perform grayscale processing on the original image. Methods for grayscale processing include, but are not limited to, weighted average, maximum value method, and average value method. In this embodiment, the weighted average method is used to perform grayscale processing on the original image, thereby obtaining the following result: Figure 3The grayscale image shown is due to reflections from the object's surface during the acquisition process; therefore, reflective areas still exist in the grayscale image.
[0056] The weighted average method is used to process the grayscale of each pixel in the original image. The specific implementation method is as follows:
[0057] W i =R i 0.30+G i 0.59+B i 0.11
[0058] Where i is the i-th pixel in the original image, W i Let R be the gray value of the i-th pixel in the grayscale image. i G represents the grayscale value of the red component in the i-th pixel of the original image. i B is the gray value corresponding to the green component in the i-th pixel of the original image. i is the grayscale value corresponding to the blue component in the i-th pixel of the original image.
[0059] By using the above implementation method, the gray value corresponding to each pixel in the original image after grayscale processing can be obtained, and a grayscale image corresponding to the original image can be generated based on the grayscale value corresponding to each pixel after grayscale processing.
[0060] After grayscale processing, a Cartesian coordinate system is established on the grayscale image. For example, in Figure 3 In the grayscale image shown, a Cartesian coordinate system is established with the lower left corner of the grayscale image as the origin, the line containing the lower boundary of the grayscale image as the x-coordinate, and the line containing the left boundary of the grayscale image as the y-coordinate.
[0061] For example, in an optional embodiment, after the Cartesian coordinate system is established, the corresponding QR code image is extracted from each frame of grayscale image. The specific extraction steps are as follows:
[0062] S31: Compare the gray values of all pixels in the grayscale image with the second grayscale threshold respectively.
[0063] For example, the grayscale value of each pixel in the grayscale image is obtained, and the grayscale value of each pixel is compared with a second grayscale threshold B to obtain a comparison result corresponding to each pixel. In this embodiment, the second grayscale threshold B is set to 235. It should be noted that the range of pixel grayscale values is 0-255. When the grayscale value is 0, the color is the darkest, displayed as black; when the grayscale value is 255, the color is the lightest, displayed as white. The second grayscale threshold is the grayscale value that clearly distinguishes black from white in the grayscale image; its specific value can be determined depending on the situation.
[0064] S32: Extract the coordinates of pixels whose grayscale values are greater than or equal to the second grayscale threshold.
[0065] For example, from all the comparison results, pixels with grayscale values greater than or equal to the second grayscale threshold are selected and identified as white pixels. The pixel coordinates corresponding to all white pixels are then obtained.
[0066] S33: From all pixel coordinates that are greater than or equal to the second grayscale threshold, filter out the first coordinate to which the maximum horizontal coordinate belongs, the second coordinate to which the minimum horizontal coordinate belongs, the third coordinate to which the maximum vertical coordinate belongs, and the fourth coordinate to which the minimum vertical coordinate belongs.
[0067] Specifically, the number of first, second, third, and fourth pixel coordinates can be one or more. The number of pixel coordinates depends on the arrangement of the QR code image in the grayscale image.
[0068] For example, there are two ways in which the QR code image can be placed in a grayscale image, as shown in case one. Figure 4 As shown, case two is as follows Figure 5 As shown. Figure 4 The square frame formed by squares ABCD and A'B'C'D' and Figure 5 The square frame formed by squares MNPQ and M'N'P'Q' is the white frame surrounding the QR code image. The pixel coordinates corresponding to all white pixels extracted in S32 include not only the coordinates of the white pixels carrying image information inside the QR code image, but also the coordinates of the white pixels contained within the white frame surrounding the QR code image.
[0069] When the QR code image is arranged in a grayscale image as follows Figure 4 As shown, the first, second, third, and fourth coordinates each have one result. Corresponding to... Figure 4 In the diagram, the x-coordinate of pixel A is the maximum value among all white pixel coordinates, the y-coordinate of pixel B is the minimum value among all white pixel coordinates, the x-coordinate of pixel C is the maximum value among all white pixel coordinates, and the y-coordinate of pixel D is the maximum value among all white pixel coordinates.
[0070] When the QR code image is arranged in a grayscale image as follows Figure 5As shown, since the two adjacent sides of the square frame are parallel to the two coordinate axes in the coordinate system, there are multiple first, second, third, and fourth coordinates. For example, the ordinates of all white pixels contained between MN and M'N' are the maximum values among all white pixel coordinates; similarly, the x-coordinates of all white pixels contained between MQ and M'Q' are the minimum values among all white pixel coordinates. Likewise, the ordinates of all white pixels contained between PQ and P'Q' are the minimum values among all white pixel coordinates, and the x-coordinates of all white pixels contained between PN and P'N' are the maximum values among all white pixel coordinates.
[0071] S34: Determine the QR code region based on the first coordinate, second coordinate, third coordinate, and fourth coordinate; extract the image in the QR code region from the grayscale image as the QR code image.
[0072] Exemplarily, in an optional embodiment, the placement of the QR code image in the grayscale image is as follows: Figure 4 As shown, there is one coordinate each for the first, second, third, and fourth coordinates. In this case, the first, second, third, and fourth coordinates can be connected to form a region that is defined as the QR code region. The image within the QR code region is extracted from the grayscale image, and this extracted image is then used as the QR code image.
[0073] In another alternative embodiment, the QR code image is arranged in the grayscale image as follows: Figure 5 As shown, there are multiple first, second, third, and fourth coordinates. The process involves connecting all the first coordinates to form a straight line, then connecting all the second coordinates to form a straight line, then connecting all the third coordinates to form a straight line, and finally connecting all the fourth coordinates to form a straight line. These four straight lines are then connected to form the QR code area. The image within the QR code area is then extracted from the grayscale image, and this extracted image is identified as the QR code image.
[0074] In an optional embodiment, each frame of the QR code image is adjusted to a first image to be corrected that meets preset conditions according to a preset conversion relationship, including:
[0075] Obtain the pixel coordinates corresponding to each pixel in the QR code image; select the vertex coordinates corresponding to the vertices of the QR code image from the pixel coordinates corresponding to each pixel in the QR code image; determine the conversion coefficients based on the vertex coordinates, the preset target vertex coordinates, and the preset conversion relationship; adjust the QR code image to the first image to be corrected based on the conversion coefficients, the preset conversion relationship, and the pixel coordinates corresponding to each pixel in the QR code image.
[0076] For example, the preset conditions include a preset size and a preset orientation. In this embodiment, the pixel coordinates of each pixel in the QR code image are transformed according to a preset transformation relationship, thereby adjusting the QR code image into a first image to be corrected with a preset size and preset orientation.
[0077] The process of adjusting a QR code image to a first image to be corrected that meets preset conditions is the process of pixel coordinate transformation. The transformation of pixel coordinates depends on the following transformation relationship.
[0078]
[0079] Where x and y are the horizontal and vertical coordinates of pixel A in the QR code image, respectively, and pixel A is any one of the multiple pixels contained in the QR code image; X ′ Y is the x-coordinate of pixel A' in the first image to be corrected, corresponding to pixel A in the QR code image. ′ It is the ordinate of pixel A' in the first image to be corrected, corresponding to pixel A in the QR code image; a 11 a 12 a 13 a 21 a 22 a 23 a 31 a 32 These are predetermined conversion coefficients.
[0080] The transformation coefficients are determined based on vertex coordinates, preset target vertex coordinates, and preset transformation relationships. The preset target vertex coordinates are the vertex coordinates corresponding to the vertices of the first image to be corrected that meet preset conditions, and these preset target vertex coordinates correspond to the vertex coordinates of the QR code image. The specific determination process is as follows:
[0081] For example, the pixel coordinates corresponding to each pixel in the QR code image are obtained (these pixel coordinates correspond to the coordinates established on the grayscale image), and the vertex coordinates corresponding to the four vertex pixels of the QR code are extracted from all the pixel coordinates. For example, in this embodiment, the vertex coordinates are A(x... A y A ), B(x) B y B ), C(x) C y C ), D(x D y D Obtain the coordinates (i.e., preset target vertex coordinates) of A', B', C', and D' in the first image to be corrected, corresponding to A, B, C, and D respectively, such as A'(X... A ′, Y A ′), B'(X) B ′, YB ′), C'(X) C ′, Y C ′), D'(X) D ′, Y D Substitute the coordinates of the eight vertices into the above transformation relationship to calculate the transformation coefficient 'a'. 11 a 12 a 13 a 21 a 22 a 23 a 31 a 32 The value of . It should be noted that since the vertex coordinates of each frame of the QR code image are not the same, each frame of the QR code image corresponds to a set of transformation coefficients.
[0082] Once the transformation coefficients are determined, their values are substituted into the transformation relation to determine the target transformation relation. The pixel coordinates of each pixel in the QR code image are then substituted into the target transformation relation to obtain the target pixel coordinates. Each pixel in the QR code image is then moved to its corresponding target pixel coordinate, thus generating the first image to be corrected. The first image to be corrected is shown below. Figure 6 As shown.
[0083] In an optional embodiment, based on a preset first grayscale threshold and a first grayscale value corresponding to each pixel in the first image to be corrected, the first image to be corrected is filtered to generate a second image to be corrected, including:
[0084] The first gray value corresponding to each pixel in the first image to be corrected is compared with the first gray value threshold to generate a comparison result; based on the comparison result, the first gray value corresponding to each pixel in the first image to be corrected is adjusted to the second gray value corresponding to the comparison result; and a second image to be corrected is generated based on the second gray value corresponding to each pixel.
[0085] For example, when the comparison result is that the first grayscale value is greater than or equal to the first grayscale threshold, the second grayscale value corresponding to the comparison result is the maximum grayscale value; when the comparison result is that the first grayscale value is less than the first grayscale threshold, the second grayscale value corresponding to the comparison result is the minimum grayscale value. In this embodiment, the maximum grayscale value is 255, and the minimum grayscale value is 0.
[0086] For example, the first grayscale value corresponding to each pixel in the first image to be corrected is obtained. Each first grayscale value is compared with a first grayscale threshold. When the comparison result is that the first grayscale value is greater than or equal to the first grayscale threshold, the grayscale value corresponding to that pixel is adjusted to 255 (i.e., the second grayscale value); when the comparison result is that the first grayscale value is less than the first grayscale threshold, the grayscale value corresponding to that pixel is adjusted to 0 (i.e., the second grayscale value). This invention adjusts the grayscale value corresponding to each pixel in the first corrected image in this way, thereby generating a second image to be corrected based on the adjusted result. Figure 7 In the second image to be corrected shown, the grayscale values corresponding to all pixels have only two possible outcomes: 0 / 255.
[0087] In an optional embodiment, all the second images to be corrected are fused to generate a QR code corrected image, including:
[0088] Obtain the second grayscale value corresponding to the first pixel in all second images to be corrected, where the first pixel is any pixel among multiple pixels contained in the second image to be corrected; determine the target grayscale value corresponding to the first pixel based on the second grayscale value corresponding to the first pixel in each frame of the second image to be corrected; generate a QR code correction image based on the target grayscale value corresponding to each pixel in the second image to be corrected.
[0089] For example, the second grayscale value corresponding to pixel A in each frame of the second image to be corrected is obtained. When all the second grayscale values corresponding to pixel A are consistent, the second grayscale value is determined as the target grayscale value; when all the second grayscale values corresponding to pixel A are inconsistent, a preset grayscale value is determined as the target grayscale value. Based on the target grayscale value corresponding to each pixel in the second image to be corrected, a process is generated as follows: Figure 8 The QR code image shown is a corrected version. The preset grayscale value can be set according to the actual situation.
[0090] For example, in one embodiment, the preset grayscale value is 0. In this embodiment, there are 5 frames of second images to be corrected, and the second grayscale values corresponding to pixel A in each frame are 255, 255, 0, 255, and 0, respectively. Since all the second grayscale values corresponding to pixel A are inconsistent, the preset grayscale value of 0 can be determined as the target grayscale value corresponding to pixel A. The target grayscale value is the grayscale value corresponding to pixel A in the QR code correction image.
[0091] For example, in another embodiment, there are 5 frames of second images to be corrected, and the second grayscale value corresponding to pixel A in each frame of the second images to be corrected is 255, 255, 255, 255, 255, respectively. In all the second images to be corrected, all the second grayscale values corresponding to pixel A are the same, therefore, 255 is used as the target grayscale value of pixel A.
[0092] Secondly, the present invention provides a QR code repair device, such as... Figure 9 As shown, it includes the following modules:
[0093] The acquisition module 91 is used to acquire at least two original images, which are images generated after shooting the target object from different shooting angles, and the target object carries a QR code image.
[0094] Extraction module 92 is used to extract QR code images from each frame of the original image.
[0095] The adjustment module 93 is used to adjust each frame of QR code image to the first image to be corrected that meets the preset conditions according to the preset conversion relationship.
[0096] The first processing module 94 is used to perform filtering processing on the first image to be corrected based on a preset first grayscale threshold and the first grayscale value corresponding to each pixel in the first image to be corrected, to generate a second image to be corrected.
[0097] The second processing module 95 is used to perform fusion processing on all the second images to be corrected to generate a QR code corrected image.
[0098] In an optional embodiment, the extraction module 92 includes:
[0099] The processing submodule is used to perform grayscale processing on each frame of the original image to generate a grayscale image corresponding to the original image; the extraction submodule is used to extract the QR code image corresponding to the grayscale image from each frame of the grayscale image.
[0100] In an optional embodiment, the extraction submodule includes:
[0101] The comparison unit is used to compare the gray values of all pixels in the grayscale image with a second grayscale threshold; the first extraction unit is used to extract the coordinates of pixels whose gray values are greater than or equal to the second grayscale threshold; the filtering unit is used to filter out the first coordinate to which the maximum horizontal coordinate belongs, the second coordinate to which the minimum horizontal coordinate belongs, the third coordinate to which the maximum vertical coordinate belongs, and the fourth coordinate to which the minimum vertical coordinate belongs from all pixel coordinates greater than or equal to the second grayscale threshold; the determination unit is used to determine the QR code region based on the first, second, third, and fourth coordinates; and the first extraction unit is used to extract the image in the QR code region from the grayscale image as the QR code image.
[0102] In an optional embodiment, the adjustment module 93 includes:
[0103] The module is divided into three parts: an acquisition submodule, a selection submodule, and a determination submodule. The acquisition submodule is used to acquire the pixel coordinates corresponding to each pixel in the QR code image; the selection submodule is used to select the vertex coordinates corresponding to the vertices of the QR code image from the pixel coordinates corresponding to each pixel in the QR code image; the determination submodule is used to determine the transformation coefficients based on the vertex coordinates, the preset target vertex coordinates, and the preset transformation relationship; and the adjustment submodule is used to adjust the QR code image into the first image to be corrected based on the transformation coefficients, the preset transformation relationship, and the pixel coordinates corresponding to each pixel in the QR code image.
[0104] In an optional embodiment, the second processing module 95 includes:
[0105] The first generation submodule is used to compare the first gray value corresponding to each pixel in the first image to be corrected with the first gray value threshold and generate a comparison result; the adjustment submodule is used to adjust the first gray value corresponding to each pixel in the first image to be corrected to the second gray value corresponding to the comparison result based on the comparison result; the second generation submodule is used to generate a second image to be corrected based on the second gray value corresponding to each pixel.
[0106] In an optional embodiment, the second processing module 95 includes:
[0107] The module is divided into three parts: an acquisition submodule, which is used to acquire the second grayscale value corresponding to the first pixel in all second images to be corrected, wherein the first pixel is any pixel among multiple pixels contained in the second image to be corrected; a determination submodule, which is used to determine the target grayscale value corresponding to the first pixel based on the second grayscale value corresponding to the first pixel in each frame of the second image to be corrected; and a generation submodule, which is used to generate a QR code correction image based on the target grayscale value corresponding to each pixel in the second image to be corrected.
[0108] In an alternative embodiment, determining a submodule includes:
[0109] The first determining unit is used to take the second gray value as the target gray value when all the second gray values are consistent; the second determining unit is used to determine a preset gray value as the target gray value when the second gray values are inconsistent.
[0110] This embodiment provides a computer device, such as... Figure 10As shown, the computer device may include at least one processor 101, at least one communication interface 102, at least one communication bus 103, and at least one memory 104. The communication interface 102 may include a display screen and a keyboard; optionally, the communication interface 102 may also include a standard wired interface or a wireless interface. The memory 104 may be high-speed RAM (Random Access Memory) or non-volatile memory, such as at least one disk drive. Optionally, the memory 104 may also be at least one storage device located remotely from the aforementioned processor 101. The processor 101 may be combined with... Figure 10 The described apparatus stores an application program in memory 104, and the processor 101 calls the program code stored in memory 104 to execute the QR code repair method of any of the above method embodiments.
[0111] The communication bus 103 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus 103 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 10 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0112] The memory 104 may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory 104 may also include a combination of the above types of memory.
[0113] The processor 101 can be a central processing unit (CPU), a network processor (NP), or a combination of CPU and NP.
[0114] The processor 101 may further include a hardware chip. This hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. Optionally, the memory 104 is also used to store program instructions. The processor 101 can invoke the program instructions to implement the QR code repair method in any embodiment of the present invention.
[0115] This embodiment provides a computer-readable storage medium storing computer-executable instructions that can execute the QR code repair method in any of the above method embodiments. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium may also include combinations of the above types of memory.
[0116] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A QR code repair method, characterized in that, include: Acquire at least two original images, which are images generated after shooting the target object from different shooting angles, and the target object carries a QR code image; extract the QR code image from each of the original images; According to the preset conversion relationship, each frame of the QR code image is adjusted to a first image to be corrected that meets the preset conditions. The preset conditions include a preset direction, which is the direction that makes the positions of the three positioning blocks in the QR code image consistent with the preset positions. Based on a preset first grayscale threshold and a first grayscale value corresponding to each pixel in the first image to be corrected, the first image to be corrected is filtered to generate a second image to be corrected. This includes: comparing the first grayscale value corresponding to each pixel in the first image to be corrected with the first grayscale threshold to generate a comparison result; adjusting the first grayscale value corresponding to each pixel in the first image to be corrected to a second grayscale value corresponding to the comparison result based on the comparison result; and generating the second image to be corrected based on the second grayscale value corresponding to each pixel. The process of fusing all the second images to be corrected to generate a QR code corrected image includes: obtaining the second grayscale value corresponding to the first pixel in all the second images to be corrected, wherein the first pixel is any pixel among the plurality of pixels contained in the second image to be corrected; determining the target grayscale value corresponding to the first pixel based on the second grayscale value corresponding to the first pixel in each frame of the second image to be corrected, including: when all the second grayscale values are consistent, using the second grayscale value as the target grayscale value; when the second grayscale values are inconsistent, determining a preset grayscale value as the target grayscale value; and generating the QR code corrected image based on the target grayscale value corresponding to each pixel in the second image to be corrected.
2. The QR code repair method according to claim 1, characterized in that, Extracting QR code images from each frame of the original image includes: Each frame of the original image is processed to produce a grayscale image corresponding to the original image; Extract the QR code image corresponding to each grayscale image from each frame of the grayscale image.
3. The QR code repair method according to claim 2, characterized in that, The step of extracting the QR code image corresponding to each grayscale image from each frame of the grayscale image includes: The grayscale values of all pixels in the grayscale image are compared with the second grayscale threshold respectively; Extract the pixel coordinates whose grayscale value is greater than or equal to the second grayscale threshold; From all pixel coordinates that are greater than or equal to the second grayscale threshold, filter out the first coordinate to which the maximum horizontal coordinate belongs, the second coordinate to which the minimum horizontal coordinate belongs, the third coordinate to which the maximum vertical coordinate belongs, and the fourth coordinate to which the minimum vertical coordinate belongs. The QR code area is determined based on the first coordinate, the second coordinate, the third coordinate, and the fourth coordinate; The image in the QR code region is extracted from the grayscale image and used as the QR code image.
4. The QR code repair method according to any one of claims 1-3, characterized in that, The step of adjusting each frame of the QR code image to a first image to be corrected that meets preset conditions according to a preset conversion relationship includes: Obtain the pixel coordinates corresponding to each pixel in the QR code image; From the pixel coordinates corresponding to each pixel in the QR code image, select the vertex coordinates corresponding to the vertices of the QR code image; The transformation coefficients are determined based on the vertex coordinates, the preset target vertex coordinates, and the preset transformation relationship. Based on the conversion coefficient, the preset conversion relationship, and the pixel coordinates corresponding to each pixel in the QR code image, the QR code image is adjusted to the first image to be corrected.
5. A QR code repair device, characterized in that, include: The acquisition module is used to acquire at least two original images, which are images generated after shooting the target object from different shooting angles, and the target object carries a QR code image; The extraction module is used to extract QR code images from each frame of the original image; The adjustment module is used to adjust each frame of the QR code image to a first image to be corrected that meets preset conditions according to a preset conversion relationship. The preset conditions include a preset direction, which is the direction that makes the positions of the three positioning blocks in the QR code image consistent with the preset positions. A first processing module is configured to perform filtering processing on the first image to be corrected based on a preset first grayscale threshold and a first grayscale value corresponding to each pixel in the first image to be corrected, to generate a second image to be corrected. The processing module includes: comparing the first grayscale value corresponding to each pixel in the first image to be corrected with the first grayscale threshold to generate a comparison result; adjusting the first grayscale value corresponding to each pixel in the first image to be corrected to a second grayscale value corresponding to the comparison result based on the comparison result; and generating the second image to be corrected based on the second grayscale value corresponding to each pixel. The second processing module is used to perform fusion processing on all the second images to be corrected to generate a QR code corrected image, including: obtaining the second grayscale value corresponding to the first pixel in all the second images to be corrected, wherein the first pixel is any pixel among the multiple pixels contained in the second image to be corrected; determining the target grayscale value corresponding to the first pixel based on the second grayscale value corresponding to the first pixel in each frame of the second image to be corrected, including: when all the second grayscale values are consistent, using the second grayscale value as the target grayscale value; when the second grayscale values are inconsistent, determining a preset grayscale value as the target grayscale value; and generating the QR code corrected image based on the target grayscale value corresponding to each pixel in the second image to be corrected.
6. A computer device, characterized in that, include: The device includes a memory and a processor, which are communicatively connected to each other. The memory is used to store a computer program, which, when executed by the processor, causes the processor to perform the QR code repair method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store computer instructions, which, when executed by a processor, implement the QR code repair method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Image registration method and device, electronic equipment and storage medium
CN112017218A
Image processing method and device, computer equipment and storage medium
CN113379705A
Two-dimensional code imaging and identification method based on multi-frame fusion, electronic equipment and medium
CN115760660A