Detection method and device of identification code, terminal and computer readable storage medium

CN120597911BActive Publication Date: 2026-10-23ZHEJIANG HUARAY TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510668580.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2026-10-23
Estimated Expiration
2045-05-21

AI Technical Summary

Technical Problem

[0004]本发明主要解决的技术问题是提供一种识别码的检测方法、装置、电子终端及计算机可读存储介质,解决现有技术中由于静音区范围过小导致条码误读的问题

Benefits of technology

[0056] The beneficial effects of this invention are as follows: Unlike existing technologies, this invention provides a method, apparatus, electronic terminal, and computer-readable storage medium for detecting identification codes. The method includes: acquiring an image of an identification code to be detected; the image includes an identification code region containing the identification code and a silent region disposed on the side of the identification code region; detecting the image to be detected to obtain detection edge information of the silent region; searching the side of the identification code region based on the detection edge information of the silent region to obtain search edge information of the silent region; and determining the detection result of the silent region based on the detection edge information and search edge information corresponding to the silent region. This application uses the detection edge information of the identification code region in the image to be detected as the inner edge of the silent region; and searches based on the inner edge of the silent region to obtain the outer edge of the silent region. This facilitates accurate determination of the detection result of the silent region based on the inner and outer edges of the silent region, thereby reducing misreading of the identification code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120597911B_ABST
    Figure CN120597911B_ABST
Patent Text Reader

Abstract

The application provides a kind of identification code detection method, device, electronic terminal and computer readable storage medium, identification code detection method includes: obtaining the image of identification code to be detected;The image of identification code to be detected includes the identification code area including identification code and the mute area arranged at the side of identification code area;The detection edge information of mute area is obtained by detecting the image of identification code to be detected;Search is carried out based on the detection edge information of mute area at the side of identification code area, and the search edge information of mute area is obtained;The detection result of mute area is determined based on the detection edge information and search edge information corresponding to mute area.This application detects the detection edge information of identification code area in the image of identification code to be detected as the inner side edge of mute area;The outer side edge of mute area is obtained by searching according to the inner side edge of mute area, so that the detection result of mute area can be accurately obtained according to the inner side edge and outer side edge of mute area, and then the misreading of identification code is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image technology, and in particular to a method, apparatus, electronic terminal, and computer-readable storage medium for detecting identification codes. Background Technology

[0002] A barcode is a machine-readable pattern on a product, packaging, or component. Barcodes record essential information about the production and distribution process of various products. Barcodes are mainly divided into one-dimensional barcodes and two-dimensional barcodes. One-dimensional barcodes contain data only in the horizontal direction, while two-dimensional barcodes contain information in both the vertical and horizontal directions.

[0003] A barcode silence zone is a blank, uncoded area within a barcode used to separate different barcodes. The silence zone helps scanning devices determine the start and end positions of the barcode, ensuring accurate reading of the information. If the silence zone is too small, it can easily lead to misreading. Summary of the Invention

[0004] The main technical problem solved by this invention is to provide a method, device, electronic terminal and computer-readable storage medium for detecting identification codes, thereby solving the problem of barcode misreading caused by the small silent zone in the prior art.

[0005] To solve the above-mentioned technical problems, the first technical solution adopted by the present invention is: to provide a method for detecting an identification code, the method comprising:

[0006] Acquire the image of the identification code to be detected; the image of the identification code to be detected includes the identification code area containing the identification code and a silent area set on the side of the identification code area;

[0007] The image of the identification code to be detected is inspected to obtain the detection edge information of the silent area;

[0008] Based on the detection edge information of the silent zone, a search is performed on the side of the area to be detected identification code to obtain the search edge information of the silent zone.

[0009] The detection result of the silent area is determined based on the detection edge information and search edge information corresponding to the silent area.

[0010] The process involves detecting the image of the identification code to be detected, obtaining the detection edge information of the silent area, including:

[0011] The image of the identification code to be detected is inspected to obtain the detection category of the identification code and the initial detection edge information of the identification code region;

[0012] The initial detection edge information of the identification code region is corrected based on the preset rules corresponding to the detection category of the identification code, so as to obtain the corrected detection edge information of the identification code region.

[0013] The correction detection edge information of the identification code area is used as the detection edge information of the silent area.

[0014] The step of obtaining the initial detection edge information of the identification code region includes:

[0015] The grayscale difference of a pixel is determined based on the difference between the grayscale value of each pixel in the image of the identification code to be detected and the grayscale value of its neighboring pixels.

[0016] If the grayscale difference of a pixel exceeds the first grayscale threshold, the pixel is taken as the first edge point of the identification code region.

[0017] Fit the first edge point on the same side of the identification code region to obtain the initial detection edge of the identification code region on the side.

[0018] Specifically, the initial detection edge information of the identification code region is corrected based on the preset rules corresponding to the detection category of the identification code, resulting in corrected detection edge information of the identification code region, including:

[0019] In response to the detection category of the identification code being a barcode, the initial detection edge information of the identification code region is determined to include the first detection edge and the second detection edge at opposite ends of the identification code region;

[0020] The first and second detection edges at opposite ends of the identification code area are corrected to make the first and second detection edges parallel to each other.

[0021] The first and second detection edges, which are parallel to each other, are used as the correction detection edge information of the identification code region.

[0022] Specifically, the initial detection edge information of the identification code region is corrected based on the preset rules corresponding to the detection category of the identification code, resulting in corrected detection edge information of the identification code region, including:

[0023] In response to the detection category of the identification code being a QR code, the initial detection edge information of the identification code area is determined to include the first detection edge, the second detection edge, the third detection edge, and the fourth detection edge around the identification code area;

[0024] The first, second, third, and fourth detection edges around the identification code area are corrected so that the first, second, third, and fourth detection edges are connected in sequence and enclosed to form a rectangle;

[0025] The first, second, third, and fourth detection edges, which are connected in sequence and enclose a rectangle, are used as the correction detection edge information of the identification code area.

[0026] The detection edge information of the silent zone includes the first detection edge located in the first preset direction;

[0027] Based on the detection edge information of the silent region, a search is performed on the side of the region to be detected for the identification code to obtain the search edge information of the silent region, including:

[0028] Starting from the first detection edge of the silent zone, the search is performed on each pixel point on the side of the identification code area to be detected along the second preset direction; the second preset direction is perpendicular to the first preset direction and the second preset direction is oriented away from the identification code area.

[0029] Based on the difference between the gray value of a pixel in the second preset direction and the gray value of its neighboring pixels, the second edge points corresponding to each pixel on the first detection edge are obtained.

[0030] The second edge points corresponding to each pixel on the first detection edge are fitted to obtain the first search edge corresponding to the first detection edge; the first search edge is located on the side of the first detection edge that is far away from the recognition code area.

[0031] The first search edge is used as the search edge information for the silent zone.

[0032] The detection methods for the identification code also include:

[0033] Set the preset width of the silent zone;

[0034] Based on the difference between the grayscale value of a pixel in the second preset direction and the grayscale value of its adjacent pixels, the second edge points corresponding to each pixel on the first detection edge are obtained, including:

[0035] The grayscale difference of a pixel is obtained based on the difference between the grayscale value of a pixel in the second preset direction and the grayscale value of its neighboring pixels.

[0036] If the grayscale difference of a pixel exceeds a second grayscale threshold and the shortest distance between the pixel and the first detection edge is not greater than the preset width of the silent area, then the pixel is designated as a second edge point; and / or, if the grayscale difference of a pixel exceeds a second grayscale threshold and the shortest distance between the pixel and the first detection edge is greater than the width threshold of the silent area, then the pixel corresponding to the shortest distance between the pixel and the first detection edge in the second preset direction being the preset width is designated as a second edge point.

[0037] Before the step of determining the detection result of the silent region based on the detection edge information and search edge information corresponding to the silent region, the following steps are also included:

[0038] Based on the number of second edge points on the first search edge and the total number of pixels on the first search edge, determine whether to retain the first search edge;

[0039] If the proportion of the number of second edge points on the first search edge to the total number of pixels on the first search edge exceeds a preset proportion, then the first search edge is retained.

[0040] The detection edge information includes the first detection edge; the search edge information includes the first search edge;

[0041] Before determining the detection result of the silent region based on the detection edge information and search edge information corresponding to the silent region, the following steps are also included:

[0042] Based on the angle between the first search edge and the first detection edge on the same side of the identification code area, determine whether to retain the first search edge;

[0043] If the angle between the first search edge and the first detection edge on the same side of the identification code area is within a preset angle range, then the first search edge is retained.

[0044] The detection edge information includes the first detection edge; the search edge information includes the first search edge;

[0045] Based on the detection edge information and search edge information corresponding to the silent region, the detection result of the silent region is determined, including:

[0046] The shortest distance between the first and second detection edges on the same side of the identification code area is taken as the detection distance of the silent zone.

[0047] If the detection distance of the silent zone corresponding to each side of the identification code area is not less than the preset width of the silent zone, then the silent zone is determined to be valid.

[0048] If the detection distance of the silent zone corresponding to any side of the identification code area is less than the preset width of the silent zone, then the silent zone is determined to be invalid.

[0049] To solve the above-mentioned technical problems, the second technical solution adopted by the present invention is: to provide a device for detecting identification codes, the device comprising:

[0050] The acquisition module is used to acquire the image of the identification code to be detected; the image of the identification code to be detected includes an identification code area containing the identification code and a silent area set on the side of the identification code area;

[0051] The detection module is used to detect the image of the identification code to be detected and obtain the detection edge information of the silent area;

[0052] The search module is used to search the side of the identification code area to be detected based on the detection edge information of the silent area, so as to obtain the search edge information of the silent area.

[0053] The determination module is used to determine the detection result of the silent area based on the detection edge information and search edge information corresponding to the silent area.

[0054] To solve the above-mentioned technical problems, the third technical solution adopted by the present invention is to provide an electronic terminal, which includes a memory, a processor, and a computer program stored in the memory and running on the processor. The processor is used to execute program data to implement the steps in the identification code detection method described above.

[0055] To solve the above-mentioned technical problems, the fourth technical solution adopted by the present invention is to provide a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps in the identification code detection method described above.

[0056] The beneficial effects of this invention are as follows: Unlike existing technologies, this invention provides a method, apparatus, electronic terminal, and computer-readable storage medium for detecting identification codes. The method includes: acquiring an image of an identification code to be detected; the image includes an identification code region containing the identification code and a silent region disposed on the side of the identification code region; detecting the image to be detected to obtain detection edge information of the silent region; searching the side of the identification code region based on the detection edge information of the silent region to obtain search edge information of the silent region; and determining the detection result of the silent region based on the detection edge information and search edge information corresponding to the silent region. This application uses the detection edge information of the identification code region in the image to be detected as the inner edge of the silent region; and searches based on the inner edge of the silent region to obtain the outer edge of the silent region. This facilitates accurate determination of the detection result of the silent region based on the inner and outer edges of the silent region, thereby reducing misreading of the identification code. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0058] Figure 1 This is a flowchart illustrating the identification code detection method provided by the present invention;

[0059] Figure 2 yes Figure 1 A flowchart illustrating a specific embodiment of step S2 in the provided identification code detection method;

[0060] Figure 3 yes Figure 1 A flowchart illustrating a specific embodiment of step S3 in the provided identification code detection method;

[0061] Figure 4This is a schematic diagram of the framework of an embodiment of the identification code detection device provided by the present invention;

[0062] Figure 5 This is a schematic diagram of the framework of an embodiment of the electronic terminal provided by the present invention;

[0063] Figure 6 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium provided by the present invention. Detailed Implementation

[0064] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0065] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.

[0066] In this article, the term "and / or" simply describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "more" in this article means two or more objects.

[0067] To enable those skilled in the art to better understand the technical solution of the present invention, the following describes in further detail a method for detecting an identification code provided by the present invention, in conjunction with the accompanying drawings and specific embodiments.

[0068] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0069] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0070] A silent area in a barcode refers to a blank, uncoded region used to separate different barcodes. The silent area helps scanning devices determine the start and end positions of the barcode, ensuring accurate reading of the information. The length of the silent area is defined in the barcode encoding specifications, typically the width of a barcode module. The presence of the silent area ensures that scanning devices can accurately identify the boundaries of barcode characters, preventing misreading or omissions. The scanning device decodes the barcode based on the width of the silent area, accurately converting it into the corresponding characters, thus improving reading accuracy and speed.

[0071] Barcodes are mainly divided into one-dimensional barcodes and two-dimensional barcodes. One-dimensional barcodes contain data only in the horizontal direction, while two-dimensional barcodes contain information in both the vertical and horizontal directions.

[0072] A one-dimensional barcode consists of a series of bars. The width and spacing of these bars represent specific characters within the barcode. In most cases, one-dimensional barcodes are read from left to right. The silent area is the white region on the left and right sides of the barcode, used for positioning the barcode during decoding and improving decoding accuracy. The silent area is at least seven to ten times the width of the narrowest bar in the barcode. In short, the silent area plays a crucial role in one-dimensional barcodes, identifying the start and end positions of the barcode to ensure accurate reading of the information. One-dimensional barcodes are also known as barcodes.

[0073] QR codes contain information in both horizontal and vertical directions. To ensure successful and accurate QR code decoding, QR codes also have a silent area, which is the blank area around the QR code.

[0074] To ensure decoding accuracy, a certain quiet zone for the barcode is necessary. In actual production, barcode misreading can occur due to factors such as barcode printing position deviations leading to incomplete barcodes, quiet zone contamination, and excessively small quiet zone areas. Since an incomplete quiet zone can cause barcode misreading, the measurement results of the quiet zone can serve as a filtering criterion for reading results, thereby improving the accuracy of barcode reading. Therefore, measuring the quiet zone of a barcode can alert to barcode printing position errors, and filtering decoding results based on whether the quiet zone meets decoding requirements is of great significance for improving the accuracy and stability of decoding.

[0075] The identification code detection method provided in this application embodiment can be implemented by a server or terminal alone, or by a server and terminal working together. In some embodiments, the terminal or server can implement the identification code detection method provided in this application embodiment by running a computer program. For example, the computer program can be a native program or software module in an operating system; it can be a native application (APP), that is, a program that needs to be installed in the operating system to run, such as a client that supports virtual scenes, such as a game APP; it can also be a mini-program, that is, a program that only needs to be downloaded into a browser environment to run; or it can be a mini-program that can be embedded in any APP. In short, the above-mentioned computer program can be any form of application, module or plugin.

[0076] The following uses a server implementation as an example to illustrate the identification code detection method provided in this application embodiment.

[0077] Please see Figure 1 , Figure 1 This is a flowchart illustrating the identification code detection method provided by the present invention.

[0078] This embodiment provides a method for detecting an identification code, which includes the following steps.

[0079] S1: Obtain the image of the identification code to be detected; the image of the identification code to be detected includes the identification code area containing the identification code and a silent area set on the side of the identification code area.

[0080] S2: Detect the image of the identification code to be detected and obtain the detection edge information of the silent area.

[0081] S3: Based on the detection edge information of the silent area, search the side of the identification code area to be detected to obtain the search edge information of the silent area.

[0082] S4: Determine the detection result of the silent area based on the detection edge information and search edge information corresponding to the silent area.

[0083] In the identification code detection method provided in this embodiment, the detection edge information of the identification code region in the identification code image to be detected is used as the inner edge of the silent region; the outer edge of the silent region is obtained by searching based on the inner edge of the silent region, so that the detection result of the silent region can be accurately obtained based on the inner edge and the outer edge of the silent region, thereby reducing the misreading of the identification code.

[0084] In one embodiment, the method for detecting the identification code further includes setting a preset width for the silent zone.

[0085] Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for determining evaluation parameters corresponding to a target location in a specific embodiment of the present invention.

[0086] Specifically, the specific implementation method for obtaining the image of the identification code to be detected in step S1 is as follows.

[0087] In one specific embodiment, an image of the identification code to be detected is obtained by acquiring an image of the identification code using an image acquisition device. The image of the identification code to be detected includes an identification code area containing the identification code and a silent area disposed on the side of the identification code area. The identification code can be a QR code or a one-dimensional barcode.

[0088] When the identification code is a one-dimensional barcode, the line connecting the center points of the silent zones located on the sides of the identification code area is parallel to the printing direction of the one-dimensional barcode. For example, when the one-dimensional barcode is printed horizontally, the silent zones are located on the left and right sides of the identification code area; when the one-dimensional barcode is printed vertically, the silent zones are located on the top and bottom sides of the identification code area.

[0089] When the identification code is a QR code, a silent zone is set on the side of the identification code area, surrounding the entire identification code area. That is, the silent zone is set on the top, bottom, left, and bottom sides of the identification code area.

[0090] Specifically, the specific implementation method for detecting the image of the identification code to be detected in step S2 to obtain the detection edge information of the silent area is as follows.

[0091] Please see Figure 2 , Figure 2 yes Figure 1 A flowchart illustrating a specific embodiment of step S2 in the provided identification code detection method.

[0092] S21: Detect the image of the identification code to be detected, and obtain the detection category of the identification code and the initial detection edge information of the identification code region.

[0093] In one embodiment, target detection is performed on the image of the identification code to be detected, obtaining the detection category of the identification code and the coordinate position of the identification code region. For example, the coordinate positions of the four vertices of the identification code region are detected. The line connecting two adjacent vertices of the identification code region is used as the initial detection edge. The detection categories include barcodes and QR codes.

[0094] In one embodiment, the initial detection edges corresponding to each side of the identification code region are determined based on an edge-finding algorithm. The edge-finding algorithm can be a caliper algorithm.

[0095] In one embodiment, when the detection category of the identification code is a barcode, a caliper algorithm is used to detect the side of the identification code area near the silent area to obtain the initial detection edge of the identification code area on the side. Specifically, by placing a series of calipers on the side of the identification code area near the silent area, the caliper algorithm can obtain a series of edge points.

[0096] In one specific embodiment, the grayscale difference of a pixel is determined based on the difference between the grayscale value of each pixel in the image to be detected and the grayscale values ​​of its adjacent pixels. If the grayscale difference of a pixel exceeds a first grayscale threshold, the pixel is designated as the first edge point of the identification code region. The first edge points on the same side of the identification code region are fitted to obtain the initial detection edge of the identification code region on the side. Specifically, the RANSAC straight-line fitting algorithm can be used to fit the first edge points on the same side of the identification code region to obtain the initial detection edge of the identification code region on the side.

[0097] This embodiment uses an edge-finding algorithm to locate the edge of the identification code region and utilizes local region information to locate the edge of the identification code region, thereby improving the anti-interference capability of the initial detection edge of the identification code region.

[0098] S22: Correct the initial detection edge information of the identification code region based on the preset rules corresponding to the detection category of the identification code to obtain the corrected detection edge information of the identification code region.

[0099] In one specific embodiment, in response to the detection category of the identification code being a barcode, the initial detection edge information of the identification code region is determined to include a first detection edge and a second detection edge at opposite ends of the identification code region; the first detection edge and the second detection edge at opposite ends of the identification code region are corrected to make the first detection edge and the second detection edge parallel to each other; the parallel first detection edge and the second detection edge are used as the corrected detection edge information of the identification code region.

[0100] In one specific embodiment, in response to the detection category of the identification code being a QR code, the initial detection edge information of the identification code area is determined to include a first detection edge, a second detection edge, a third detection edge, and a fourth detection edge around the identification code area; the first detection edge, the second detection edge, the third detection edge, and the fourth detection edge around the identification code area are corrected so that the first detection edge, the second detection edge, the third detection edge, and the fourth detection edge are sequentially connected and enclosed to form a rectangle; the first detection edge, the second detection edge, the third detection edge, and the fourth detection edge that are sequentially connected and enclosed to form a rectangle are used as the corrected detection edge information of the identification code area.

[0101] S23: Use the correction detection edge information of the identification code area as the detection edge information of the silent area.

[0102] Specifically, when the detection category of the identification code is a barcode, the detection edge information of the silent area includes a first detection edge and a second detection edge that are parallel to each other.

[0103] Specifically, when the detection category of the identification code is a QR code, the detection edge information of the silent area includes a first detection edge, a second detection edge, a third detection edge, and a fourth detection edge that are connected in sequence and enclose a rectangle.

[0104] Specifically, the specific implementation of step S3, which involves searching the side of the identification code region based on the detection edge information of the silent region to obtain the search edge information of the silent region, is as follows.

[0105] Please see Figure 3 , Figure 3 yes Figure 1 A flowchart illustrating a specific embodiment of step S3 in the provided identification code detection method.

[0106] S31: Starting from the first detection edge of the silent area, search for each pixel on the side of the identification code area to be detected along the second preset direction; the second preset direction is perpendicular to the first preset direction and the second preset direction is oriented away from the identification code area.

[0107] S32: Based on the difference between the gray value of a pixel in the second preset direction and the gray value of its neighboring pixels, obtain the second edge points corresponding to each pixel on the first detection edge.

[0108] Specifically, taking the first detection edge of the silent zone as an example, based on the precise location of the first detection edge of the silent zone, the search proceeds in a direction away from the identification code area. Assume the preset width of the silent zone is L, i.e., the search range is L, and the search step size is S. The detection edge of the identification code area is the first detection edge of the silent zone. Starting from the first detection edge of the silent zone, the edge-finding tool is used every S distance, searching L / S times, until the entire search range is searched. The edge-finding results throughout the entire search process are recorded.

[0109] Specifically, the grayscale difference of a pixel is obtained based on the difference between the grayscale value of a pixel in the second preset direction and the grayscale value of its neighboring pixels.

[0110] In one specific embodiment, in response to a pixel's grayscale difference exceeding a second grayscale threshold and the shortest distance between the pixel and the first detection edge not being greater than a preset width of the silent area, the pixel is designated as a second edge point.

[0111] In one specific embodiment, in response to the grayscale difference of a pixel exceeding a second grayscale threshold and the shortest distance between the pixel and the first detection edge being greater than the width threshold of the silent area, the pixel corresponding to the shortest distance between the pixel and the first detection edge in the second preset direction being a preset width is designated as the second edge point.

[0112] S33: Fit the second edge points corresponding to each pixel on the first detection edge to obtain the first search edge corresponding to the first detection edge; the first search edge is located on the side of the first detection edge that is far away from the recognition code area.

[0113] In one embodiment, before determining the detection result of the silent area based on the detection edge information and search edge information corresponding to the silent area, the method further includes: determining whether to retain the first search edge based on the number of second edge points on the first search edge and the total number of pixels on the first search edge; and retaining the first search edge if the ratio of the number of second edge points on the first search edge to the total number of pixels on the first search edge exceeds a preset ratio.

[0114] In one embodiment, before determining the detection result of the silent area based on the detection edge information and search edge information corresponding to the silent area, the method further includes: determining whether to retain the first search edge based on the angle between the first search edge and the first detection edge corresponding to the same side of the identification code area; and retaining the first search edge in response to the angle between the first search edge and the first detection edge corresponding to the same side of the identification code area being within a preset angle range.

[0115] S34: Use the first search edge as the search edge information for the silent zone.

[0116] When the detection category of the identification code is a barcode, the detection edge information of the silent area includes a first detection edge and a second detection edge that are parallel to each other. Through the above steps, the first search edge corresponding to the first detection edge can be obtained, and the second detection edge has a corresponding second search edge.

[0117] Specifically, when the detection category of the identification code is a QR code, the detection edge information of the silent area includes a first detection edge, a second detection edge, a third detection edge, and a fourth detection edge that are connected sequentially and enclose a rectangle. Through the above steps, the first search edge corresponding to the first detection edge, the second search edge corresponding to the second detection edge, the third search edge corresponding to the third detection edge, and the fourth search edge corresponding to the fourth detection edge can be obtained.

[0118] Specifically, the specific implementation method for determining the detection result of the silent area based on the detection edge information and search edge information corresponding to the silent area in step S4 is as follows.

[0119] In one embodiment, the shortest distance between the first detection edge and the second detection edge corresponding to the same side of the identification code area is used as the detection distance of the silent area.

[0120] If the detection distance of the silent zone corresponding to each side of the identification code area is not less than the preset width of the silent zone, then the silent zone is determined to be valid.

[0121] If the detection distance of the silent zone corresponding to any side of the identification code area is less than the preset width of the silent zone, then the silent zone is determined to be invalid.

[0122] In the identification code detection method provided in this embodiment, the detection edge information of the identification code region in the identification code image to be detected is used as the inner edge of the silent region; the outer edge of the silent region is obtained by searching based on the inner edge of the silent region, so that the detection result of the silent region can be accurately obtained based on the inner edge and the outer edge of the silent region, thereby reducing the misreading of the identification code.

[0123] Please see Figure 4 , Figure 4 This is a schematic diagram of a framework of an embodiment of the identification code detection device provided by the present invention. This embodiment provides an identification code detection device 60, which includes an acquisition module 61, a detection module 62, a search module 63, and a determination module 64.

[0124] The acquisition module 61 is used to acquire the image of the identification code to be detected; the image of the identification code to be detected includes an identification code area containing the identification code and a silent area set on the side of the identification code area.

[0125] The detection module 62 is used to detect the image of the identification code to be detected and obtain the detection edge information of the silent area.

[0126] The search module 63 is used to search the side of the identification code area to be detected based on the detection side information of the silent area to obtain the search side information of the silent area.

[0127] The determination module 64 is used to determine the detection result of the silent area based on the detection edge information and search edge information corresponding to the silent area.

[0128] In the identification code detection device provided in this embodiment, the detection edge information of the identification code region in the identification code image to be detected is used as the inner edge of the silent region; the outer edge of the silent region is obtained by searching based on the inner edge of the silent region, so that the detection result of the silent region can be accurately obtained based on the inner edge and the outer edge of the silent region, thereby reducing the misreading of the identification code.

[0129] Please see Figure 5 , Figure 5 This is a schematic diagram of a framework of an embodiment of the electronic terminal provided by the present invention. The electronic terminal 80 includes a memory 81 and a processor 82 coupled to each other. The processor 82 is used to execute program instructions stored in the memory 81 to implement the steps of any of the above-described identification code detection method embodiments. In a specific implementation scenario, the electronic terminal 80 may include, but is not limited to, a microcomputer or a server. In addition, the electronic terminal 80 may also include mobile devices such as laptops and tablets, which are not limited here.

[0130] Specifically, processor 82 controls itself and memory 81 to implement the steps of any of the above-described identification code detection method embodiments. Processor 82 can also be referred to as a CPU (Central Processing Unit). Processor 82 may be an integrated circuit chip with signal processing capabilities. Processor 82 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 82 can be implemented using integrated circuit chips.

[0131] Please see Figure 6 , Figure 6 This is a schematic diagram of a framework of an embodiment of a computer-readable storage medium provided by the present invention. The computer-readable storage medium 90 stores program instructions 901 that can be executed by a processor. The program instructions 901 are used to implement the steps of any of the above-described identification code detection method embodiments.

[0132] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0133] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.

[0134] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0135] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0136] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0137] The above are merely embodiments of the present invention and do not limit the scope of patent protection of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for detecting an identification code, characterized in that, The method for detecting the identification code includes: Acquire an image of the identification code to be detected; the image of the identification code to be detected includes an identification code area containing the identification code and a silent area set on the side of the identification code area; The image of the identification code to be detected is inspected to obtain the detection edge information of the silent area; Based on the detection edge information of the silent zone, a search is performed on the side of the identification code area to be detected to obtain the search edge information of the silent zone; Based on the detection edge information and search edge information corresponding to the silent area, the detection result of the silent area is determined; The detection edge information of the silent zone includes a first detection edge located in a first preset direction; The search for the search edge information of the silent zone based on the detection edge information of the silent zone on the side of the identification code area to be detected, including: Starting from the first detection edge of the silent zone, the pixels on the side of the identification code area to be detected are searched along the second preset direction; the second preset direction is perpendicular to the first preset direction and the second preset direction is oriented away from the identification code area; Based on the difference between the gray value of the pixel point and the gray value of the adjacent pixel point in the second preset direction, the second edge point corresponding to each pixel point on the first detection edge is obtained; The second edge points corresponding to each pixel on the first detection edge are fitted to obtain the first search edge corresponding to the first detection edge; the first search edge is located on the side of the first detection edge that is far away from the identification code area. The first search edge is used as the search edge information of the silent zone.

2. The method for detecting the identification code according to claim 1, characterized in that, The step of detecting the image of the identification code to be detected to obtain the detection edge information of the silent area includes: The image of the identification code to be detected is inspected to obtain the detection category of the identification code and the initial detection edge information of the identification code region; The initial detection edge information of the identification code region is corrected based on the preset rule corresponding to the detection category of the identification code to obtain the corrected detection edge information of the identification code region. The correction detection edge information of the identification code area is used as the detection edge information of the silent area.

3. The method for detecting the identification code according to claim 2, characterized in that, The steps for obtaining the initial detection edge information of the identification code region include: The grayscale difference of the pixel is determined based on the difference between the grayscale value of each pixel in the image to be detected and the grayscale value of the adjacent pixel. If the grayscale difference of the pixel exceeds a first grayscale threshold, then the pixel is designated as the first edge point of the identification code region. Fit the first edge point on the same side of the identification code region to obtain the initial detection edge of the identification code region on the side.

4. The method for detecting the identification code according to claim 2, characterized in that, The initial detection edge information of the identification code region is corrected based on the preset rule corresponding to the detection category of the identification code to obtain the corrected detection edge information of the identification code region, including: In response to the detection category of the identification code being a barcode, the initial detection edge information of the identification code region is determined to include the first detection edge and the second detection edge at opposite ends of the identification code region; The first detection edge and the second detection edge at opposite ends of the identification code area are corrected to make the first detection edge and the second detection edge parallel to each other. The first and second detection edges, which are parallel to each other, are used as the correction detection edge information of the identification code region.

5. The method for detecting the identification code according to claim 2, characterized in that, The initial detection edge information of the identification code region is corrected based on the preset rule corresponding to the detection category of the identification code to obtain the corrected detection edge information of the identification code region, including: In response to the detection category of the identification code being a QR code, the initial detection edge information of the identification code area is determined to include the first detection edge, the second detection edge, the third detection edge, and the fourth detection edge around the identification code area; The first detection edge, the second detection edge, the third detection edge, and the fourth detection edge around the identification code area are corrected so that the first detection edge, the second detection edge, the third detection edge, and the fourth detection edge are connected in sequence and enclosed to form a rectangle; The first detection edge, the second detection edge, the third detection edge, and the fourth detection edge, which are connected in sequence and enclose a rectangle, are used as the correction detection edge information of the identification code area.

6. The method for detecting the identification code according to claim 1, characterized in that, The method for detecting the identification code further includes: Set the preset width of the silent zone; The step of obtaining the second edge points corresponding to each pixel on the first detection edge based on the difference between the gray value of the pixel and the gray value of the adjacent pixel in the second preset direction includes: The grayscale difference of the pixel is obtained based on the difference between the grayscale value of the pixel and the grayscale value of the adjacent pixel in the second preset direction; If the grayscale difference of the pixel exceeds a second grayscale threshold and the shortest distance between the pixel and the first detection edge is not greater than the preset width of the silent area, then the pixel is designated as the second edge point; and / or, if the grayscale difference of the pixel exceeds the second grayscale threshold and the shortest distance between the pixel and the first detection edge is greater than the width threshold of the silent area, then the pixel corresponding to the shortest distance between the pixel and the first detection edge in the second preset direction being the preset width is designated as the second edge point.

7. The method for detecting the identification code according to claim 1, characterized in that, Before the step of determining the detection result of the silent area based on the detection edge information and the search edge information corresponding to the silent area, the method further includes: Based on the number of the second edge points on the first search edge and the total number of all the pixels on the first search edge, determine whether to retain the first search edge; If the proportion of the number of the second edge points on the first search edge to the total number of all pixels on the first search edge exceeds a preset proportion, then the first search edge is retained.

8. The method for detecting the identification code according to claim 1, characterized in that, The detection edge information includes a first detection edge; the search edge information includes a first search edge; Before the step of determining the detection result of the silent area based on the detection edge information and the search edge information corresponding to the silent area, the method further includes: Based on the angle between the first search edge and the first detection edge on the same side of the identification code area, determine whether to retain the first search edge; If the angle between the first search edge and the first detection edge on the same side of the identification code area is within a preset angle range, then the first search edge is retained.

9. The method for detecting the identification code according to claim 1, characterized in that, The detection edge information includes a first detection edge; the search edge information includes a first search edge; The step of determining the detection result of the silent area based on the detection edge information and the search edge information corresponding to the silent area includes: The shortest distance between the first detection edge and the second detection edge corresponding to the same side of the identification code area is taken as the detection distance of the silent zone; If the detection distance of the silent zone corresponding to each side of the identification code area is not less than the preset width of the silent zone, then the silent zone is determined to be valid. If the detection distance of the silent zone corresponding to any side of the identification code area is less than the preset width of the silent zone, then the silent zone is determined to be invalid.

10. A device for detecting an identification code, characterized in that, The detection device for the identification code includes: An acquisition module is used to acquire an image of a code to be detected; the image of the code to be detected includes a code area containing the code and a silent area set on the side of the code area; The detection module is used to detect the image of the identification code to be detected and obtain the detection edge information of the silent area; The search module is used to search the side of the identification code area to be detected based on the detection edge information of the silent area to obtain the search edge information of the silent area; the detection edge information of the silent area includes a first detection edge in a first preset direction; it is also used to search each pixel point on the side of the identification code area to be detected along a second preset direction, starting from the first detection edge of the silent area; the second preset direction is perpendicular to the first preset direction and faces a direction away from the identification code area; based on the difference between the gray value of the pixel point and the gray value of the adjacent pixel point in the second preset direction, a second edge point corresponding to each pixel point on the first detection edge is obtained; the second edge points corresponding to each pixel point on the first detection edge are fitted to obtain a first search edge corresponding to the first detection edge; the first search edge is located on the side of the first detection edge away from the identification code area; the first search edge is used as the search edge information of the silent area. The determination module is used to determine the detection result of the silent area based on the detection edge information and the search edge information corresponding to the silent area.

11. An electronic terminal, characterized in that, The electronic terminal includes a memory, a processor, and a computer program stored in the memory and running on the processor, the processor being used to execute program data to implement the steps in the identification code detection method as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the identification code detection method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method and apparatus for decoding bar code symbols using independent bar and space analysis

    US5352878A