Barcode image correction method, device, equipment, medium and program
Through Fourier transform and spectrogram analysis, the rotation angle of the barcode image is determined and corrected, and the recognition efficiency and accuracy of traditional methods in complex scenarios is solved, and the efficient identification and unified recognition effect of multiple barcodes is achieved.
Patent Information
- Application Number
- CN202411357232.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2024-12-27
AI Technical Summary
Traditional barcode positioning methods are difficult to achieve efficient and accurate recognition in complex scenarios, especially in the case of image blurring, contrast reduction, feature occlusion or rotation, which affects the recognition efficiency and accuracy.
The spectrum map is generated by Fourier transform, the rotation angle of the barcode image is determined, and the image is corrected to the target reference angle based on this angle, and the common structural features are analyzed by frequency domain to achieve unified and efficient identification of multiple barcodes.
Improves the efficiency and accuracy of barcode recognition, and is suitable for a variety of barcodes, without the need to optimize individually for each code system, which enhances robustness and adaptability.
Smart Images

Figure CN119205591A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing and recognition technology, and in particular to a barcode image correction method, device, equipment, medium and program. Background Art
[0002] With the rapid development of applications such as mobile payment, Internet of Things and information traceability, barcodes have become a bridge connecting the physical world and the digital world. However, in complex scenarios such as dynamically changing lighting conditions, angle tilt, partial occlusion or image blur, traditional barcode positioning methods often have difficulty in achieving efficient and accurate recognition, which limits their application scope and user experience.
[0003] At present, most barcode positioning technologies are based on classical computer vision methods such as edge detection, feature matching or template matching. Although these methods can work effectively under certain conditions, they are susceptible to false detection and missed detection in complex backgrounds, especially when the barcode pattern is damaged or incomplete. In addition, with the diversity of barcode sizes and the expansion of application scenarios, higher requirements are placed on the adaptability and robustness of positioning algorithms.
[0004] Traditional barcode detection methods usually rely on template matching or feature extraction. These methods work well under ideal conditions (such as clear barcodes, no obstructions, and uniform lighting). However, in actual applications, barcodes often encounter a variety of unfavorable factors, such as tilt, deformation, and uneven lighting, which lead to a decrease in recognition rate. Especially when the barcode is rotated, traditional detection methods are difficult to accurately identify the real information of the barcode, affecting recognition efficiency and accuracy. Summary of the invention
[0005] The present application provides a barcode image correction method, device, equipment, medium and program to solve the problems in the related art that the recognition efficiency and accuracy are affected when the image is blurred, the contrast is reduced, the features are blocked or damaged, etc.
[0006] The first aspect of the present application provides a method for correcting a barcode image, comprising the following steps: step S101, acquiring a barcode image; step S102, performing Fourier transform on the barcode image to generate a corresponding spectrum diagram; step S103, determining a rotation angle of the barcode image according to the spectrum diagram; step S104, correcting the barcode image to a target reference angle according to the rotation angle.
[0007] Preferably, determining the rotation angle of the barcode image according to the spectrum graph includes: identifying the frequency range of a bandpass filter; screening key features of the barcode in the spectrum graph using the frequency range of the bandpass filter; and calculating the rotation angle of the barcode image according to the key features of the barcode.
[0008] Preferably, the identifying the frequency range of the bandpass filter comprises: acquiring the width of the barcode image; and determining the frequency range of the bandpass filter according to the width of the barcode image.
[0009] Preferably, determining the frequency range of the bandpass filter according to the width of the barcode image comprises: calculating a reference inner radius and a reference outer radius according to the width of the barcode image; and determining the frequency range of the bandpass filter according to the reference inner radius and the reference outer radius.
[0010] Preferably, calculating the rotation angle of the barcode image according to the key features of the barcode includes: identifying the origin of the barcode; integrating a straight line passing through the origin at intervals of a preset angle to generate an integral value; and determining the rotation angle of the barcode image according to the integral value.
[0011] Preferably, the calculation formula for generating the integral value by integrating all the straight lines passing through the origin is:
[0012]
[0013] Where i is the pixel value, i∈[R1,R2], θ is the current angle of the line; x o and o is the image center coordinate.
[0014] Preferably, determining the rotation angle of the barcode image according to the integral value includes: screening the maximum integral value among all integral values; calculating the corresponding angle according to the maximum integral value; and determining the rotation angle of the barcode image according to the angle corresponding to the maximum integral value among all integral values.
[0015] Preferably, the calculation formula for calculating the corresponding angle according to the maximum integral value is:
[0016] θ=arg(max(I)),
[0017] Where I is the integral value and θ is the rotation angle of the barcode image.
[0018] The second aspect of the present application provides a barcode image correction device, including: an acquisition module for acquiring a barcode image; a generation module for performing Fourier transform on the barcode image to generate a corresponding spectrum diagram; a calculation module for determining the rotation angle of the barcode image according to the spectrum diagram; and a correction module for correcting the barcode image to a target reference angle according to the rotation angle.
[0019] A third aspect of the present application provides a vehicle, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to perform the barcode image correction method as described in the above embodiment.
[0020] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to perform the barcode image correction method as described in the above embodiment.
[0021] The fifth aspect of the present application provides a computer program product, including a computer program or instructions, characterized in that when the computer program or instructions are executed, the barcode image correction method described in the above embodiment is implemented.
[0022] Therefore, this application has at least the following beneficial effects:
[0023] The embodiment of the present application can perform Fourier transform on the barcode image to generate a corresponding spectrum diagram, calculate the rotation angle of the barcode image based on the spectrum diagram, correct the barcode image to the target reference angle based on the rotation angle, and use frequency domain analysis to identify structural features common to various code systems that are crucial to their stored information. There is no need to optimize each code system separately, thereby achieving unified and efficient recognition of various barcodes and improving recognition efficiency and accuracy.
[0024] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0026] Figure 1 A flowchart of a barcode image correction method provided according to an embodiment of the present application;
[0027] Figure 2 A schematic diagram of a one-dimensional code image after Fourier transformation according to an embodiment of the present application;
[0028] Figure 3 A schematic diagram of a two-dimensional code image after Fourier transformation according to an embodiment of the present application;
[0029] Figure 4 A schematic diagram of adding a mask according to an embodiment of the present application;
[0030] Figure 5 A flowchart corresponding to a blurred image of a one-dimensional code provided in an embodiment of the present application;
[0031] Figure 6 A flowchart corresponding to a blurred image of a one-dimensional code provided in an embodiment of the present application;
[0032] Figure 7A flowchart of a barcode image correction device provided according to an embodiment of the present application;
[0033] Figure 8 A schematic diagram of an electronic device provided according to an embodiment of the present application.
[0034] Description of the drawings: a barcode image correction device 10, an acquisition module 100, a generation module 200, a calculation module 300, and a correction module 400. DETAILED DESCRIPTION
[0035] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0036] The following describes the barcode image correction method of the embodiment of the present application with reference to the accompanying drawings. Specifically, Figure 1 A schematic flow chart of a barcode image correction method provided in an embodiment of the present application.
[0037] like Figure 1 As shown, the barcode image correction method includes the following steps:
[0038] In step S101, a barcode image is acquired.
[0039] Among them, the barcode image includes a two-dimensional code image and a one-dimensional code image, which can be selected according to actual needs without specific limitation.
[0040] It is understandable that the embodiment of the present application can obtain a barcode image so as to subsequently perform Fourier transform on the barcode image to generate a corresponding spectrum diagram.
[0041] In step S102, Fourier transform is performed on the barcode image to generate a corresponding spectrum diagram.
[0042] It can be understood that the embodiments of the present application can perform Fourier transform on the barcode image to generate a corresponding spectrum diagram, and can analyze the structural characteristics of the image from the perspective of the frequency domain, which helps to improve the robustness of the algorithm in the face of complex background or noise conditions, and can more effectively identify the key features of the barcode.
[0043] In step S103, the rotation angle of the barcode image is determined according to the spectrum diagram.
[0044] It can be understood that the embodiments of the present application can determine the rotation angle of the barcode image based on the spectrum diagram, and use frequency domain analysis to identify structural features common to various code systems that are critical to their stored information; there is no need to optimize each code system separately, thereby achieving unified and efficient recognition of various barcodes, improving recognition efficiency and accuracy, and facilitating subsequent correction of the barcode image to the target reference angle based on the rotation angle.
[0045] Specifically, the rotation angle of the barcode image is detected by Fourier transform. This method is not only applicable to two-dimensional codes, but also to one-dimensional code images. Specifically:
[0046] like Figure 2 As shown in the figure, in the Fourier spectrum of the one-dimensional code image, the brightest line represents the spacing between the bars. These periodic features appear as bright lines in the Fourier transformed spectrum diagram due to the periodic arrangement between the bars and spaces of the one-dimensional code. Because the spacing between these bars and spaces is dense and numerous, they appear particularly prominent in the frequency domain. When the Fourier transform is applied to such an image, a spectrum diagram is obtained, which shows the different frequency components of the image. The brightest line represents the most important periodic feature in the image, that is, the spacing between the bars. Because the number of bars and spaces in the one-dimensional code is large and the spacing is consistent, these periodic features appear as very obvious lines in the spectrum. In addition, there is a slightly darker line in the vertical direction of the most obvious bright line. This line represents the wider frequency information in the image, which is usually caused by the contrast change between the one-dimensional code and its background. Although this information is not as strong as the main periodic features, it is still visible in the spectrum, reflecting the width of the code and its change relative to the background.
[0047] like Figure 3 As shown in the figure, in the Fourier spectrum of the two-dimensional code image, due to the uniformity and periodicity of the code element distribution, the spectrum diagram usually shows a central bright spot surrounded by rings or spots with uniform intensity distribution; these spots represent different frequency components in the image. However, due to the square distribution of the code elements, the frequency information in the two directions in the spectrum diagram after Fourier transformation is not much different, so the distribution of these spots in the horizontal and vertical directions is similar, making it difficult to judge the rotation angle of the image by simple visual observation; therefore, a ring mask needs to be introduced for processing.
[0048] In an embodiment of the present application, determining the rotation angle of a barcode image based on a spectrum graph includes: identifying a frequency range of a bandpass filter; using the frequency range of the bandpass filter to filter key features of the barcode in the spectrum graph; and calculating the rotation angle of the barcode image based on the key features of the barcode.
[0049] It can be understood that the embodiments of the present application can identify the frequency range of the bandpass filter; use the frequency range of the bandpass filter to screen the key features of the barcode in the spectrum diagram; calculate the rotation angle of the barcode image based on the key features of the barcode, so as to take into account the influence of noise and complex situations in the image, eliminate the influence of noise in the image on recognition, and improve the recognition accuracy.
[0050] It should be noted that if Figure 4 As shown, the frequency range of the bandpass filter is a circular mask composed of radii R1 and R2, and only pixels with frequencies between R1 and R2 are retained; it helps to retain the information of the minimum pixel point (code element) and the maximum pixel point (rectangular boundary of the QR code) of the QR code, and eliminate the influence of noise in the image on recognition.
[0051] In an embodiment of the present application, identifying the frequency range of the bandpass filter includes: acquiring the width of the barcode image; and determining the frequency range of the bandpass filter according to the width of the barcode image.
[0052] It can be understood that the embodiments of the present application can obtain the width of the barcode image; determine the frequency range of the bandpass filter based on the width of the barcode image, thereby retaining pixels with frequencies between the frequency range, taking into account the influence of noise and complex situations in the image, eliminating the influence of noise in the image on recognition, and improving the recognition accuracy.
[0053] In an embodiment of the present application, the frequency range of the bandpass filter is determined according to the width of the barcode image, including: calculating a reference inner radius and a reference outer radius according to the width of the barcode image; and determining the frequency range of the bandpass filter according to the reference inner radius and the reference outer radius.
[0054] It can be understood that the embodiments of the present application can calculate the reference inner radius and the reference outer radius according to the width of the barcode image; determine the frequency range of the bandpass filter according to the reference inner radius and the reference outer radius, thereby retaining the pixels with frequencies between the frequency range, taking into account the influence of noise and complex situations in the image, eliminating the influence of noise in the image on recognition, and improving the recognition accuracy.
[0055] Specifically, the determination of R1: Considering the influence of noise and complex situations in the image, a code element needs at least 3 pixels to be effectively recognized. Therefore, the value of R1 should be able to filter out noise less than 3 pixels, and it is recommended to take R1 = image width / 2×0.2; the determination of R2: In theory, the QR code may cover the entire image, but in reality the code element will not be completely filled (that is, it is not a pure black or pure white rectangle), so R2 can be taken as 90% of the image width, that is, R2 = image width / 2×0.9, which can reduce the amount of calculation and ensure that the main features of the QR code are retained.
[0056] In an embodiment of the present application, the rotation angle of the barcode image is calculated based on the key features of the barcode, including: identifying the origin of the barcode; integrating the straight line passing through the origin at each preset angle interval to generate an integral value; and determining the rotation angle of the barcode image based on the integral value.
[0057] Among them, the preset angle can be 0.1°, which can be set according to actual needs without specific limitation.
[0058] The calculation formula for integrating all straight lines passing through the origin to generate the integral value is:
[0059]
[0060] Where i is the pixel value, i∈[R1,R2], θ is the current angle of the line; x o and o is the image center coordinate.
[0061] It can be understood that the embodiments of the present application can identify the origin of the barcode; integrate the straight line passing through the origin at each preset angle interval to generate an integral value; determine the rotation angle of the barcode image based on the integral value, so as to facilitate the subsequent correction of the barcode image to the target reference angle based on the rotation angle.
[0062] Specifically, the present application adopts a method of performing an integral operation on a straight line passing through the origin at each angle from 0 to 180 degrees in steps of 0.1 degrees to generate an angle-integral graph, such as Figure 4 shown.
[0063] In an embodiment of the present application, the rotation angle of the barcode image is determined according to the integral value, including: screening the maximum integral value among all integral values; calculating the corresponding angle according to the maximum integral value; and determining the rotation angle of the barcode image according to the angle corresponding to the maximum integral value among all integral values.
[0064] Among them, the calculation formula for calculating the corresponding angle according to the maximum integral value is:
[0065] θ=arg(max(I)),
[0066] Where I is the integral value and θ is the rotation angle of the barcode image.
[0067] It can be understood that the embodiments of the present application can filter out the maximum integral value among all integral values; calculate the corresponding angle based on the maximum integral value; determine the rotation angle of the barcode image based on the angle corresponding to the maximum integral value among all integral values, so as to facilitate the subsequent correction of the barcode image to the target reference angle based on the rotation angle.
[0068] In step S104, the barcode image is corrected to a target reference angle according to the rotation angle.
[0069] The target reference angle may be that the boundaries of the barcode image are located on the same horizontal line, and is not specifically limited.
[0070] It can be understood that by correcting the barcode image to the target reference angle according to the rotation angle, the frequency domain is used to analyze the structural features common to various code systems and crucial to their stored information; there is no need to optimize each code system separately, thus achieving unified and efficient recognition of various barcodes, improving recognition efficiency and accuracy.
[0071] According to the barcode image correction method proposed in the embodiment of the present application, the barcode image is subjected to Fourier transform to generate a corresponding spectrum diagram, the rotation angle of the barcode image is calculated based on the spectrum diagram, and the barcode image is corrected to the target reference angle based on the rotation angle. The frequency domain is used to analyze the structural features common to various code systems and crucial to their storage of information. There is no need to optimize each code system separately, which achieves unified and efficient recognition of diverse barcodes, thereby improving recognition efficiency and accuracy.
[0072] The following will be Figure 5 and Figure 6 As shown, the present application is described with two specific embodiments, as follows:
[0073] Embodiment 1, as Figure 5 As shown, a one-dimensional code blurred image is obtained, and a Fourier transform is performed on the one-dimensional code blurred image to obtain a spectrum diagram. The brightest line represents the spacing between bars. There is a slightly darker line in the vertical direction of the most obvious bright line, which indicates the wider frequency information formed by the one-dimensional code and the background. An annular mask composed of radii R1 and R2 is introduced to form a bandpass filter, and only pixels with frequencies between R1 and R2 are retained. The angle is from 0 to 180 degrees, and the step is 0.1 degree. The straight line passing through the origin at each angle is integrated to generate an angle-integral diagram. The angle corresponding to the maximum integral value is the rotation angle of the one-dimensional code image, and the barcode image is corrected according to the rotation angle of the one-dimensional code image.
[0074] Embodiment 2, as Figure 6As shown in the figure, a fuzzy image of a two-dimensional code is obtained, and a Fourier transform is performed on the fuzzy image of the two-dimensional code to obtain a spectrum diagram. Since the code element distribution is a square, the frequency information in the two directions is not much different, making it difficult to distinguish the two mutually perpendicular bright lines. The reason is that no matter whether it is qrcode or datamatrix, the distribution of their code elements is a square, so the frequency information in the two directions is not much different; an annular mask composed of radii R1 and R2 is introduced to form a bandpass filter, and only pixels with frequencies between R1 and R2 are retained; the angle is from 0 to 180 degrees, and the step is 0.1 degrees. The straight line passing through the origin at each angle is integrated to generate an angle-integral diagram; the angle corresponding to the maximum integral value is the rotation angle of the one-dimensional code image, and the barcode image is corrected according to the rotation angle of the one-dimensional code image.
[0075] In summary, the present application does not rely on the specific features of the QR code for the QR code rotation angle detection algorithm, and does not need to be optimized separately for each code system, thereby achieving unified and efficient recognition of diverse barcodes; it uses frequency domain analysis to analyze the structural features common to various code systems that are crucial to their storage of information.
[0076] Next, a barcode image correction device according to an embodiment of the present application is described with reference to the accompanying drawings.
[0077] Figure 7 It is a block diagram of a barcode image correction device according to an embodiment of the present application.
[0078] like Figure 7 As shown, the barcode image correction device 10 includes: an acquisition module 100 , a generation module 200 , a calculation module 300 and a correction module 400 .
[0079] Among them, the acquisition module 100 is used to acquire the barcode image; the generation module 200 is used to perform Fourier transform on the barcode image to generate a corresponding spectrum diagram; the calculation module 300 is used to determine the rotation angle of the barcode image according to the spectrum diagram; the correction module 400 is used to correct the barcode image to the target reference angle according to the rotation angle.
[0080] It should be noted that the above explanation of the embodiment of the barcode image correction method is also applicable to the barcode image correction device of this embodiment, and will not be repeated here.
[0081] According to the barcode image correction device proposed in the embodiment of the present application, the barcode image is subjected to Fourier transform to generate a corresponding spectrum diagram, the rotation angle of the barcode image is calculated based on the spectrum diagram, and the barcode image is corrected to the target reference angle based on the rotation angle, and the structural features common to various code systems and crucial to their storage of information are analyzed by frequency domain. There is no need to optimize each code system separately, which achieves unified and efficient recognition of various barcodes, thereby improving recognition efficiency and accuracy.
[0082] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:
[0083] A memory 801 , a processor 802 , and a computer program stored in the memory 801 and executable on the processor 802 .
[0084] When the processor 802 executes the program, the barcode image correction method provided in the above embodiment is implemented.
[0085] Furthermore, the electronic device further comprises:
[0086] The communication interface 803 is used for communication between the memory 801 and the processor 802 .
[0087] The memory 801 is used to store computer programs that can be executed on the processor 802 .
[0088] The memory 801 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0089] If the memory 801, the processor 802 and the communication interface 803 are implemented independently, the communication interface 803, the memory 801 and the processor 802 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0090] Optionally, in a specific implementation, if the memory 801, the processor 802 and the communication interface 803 are integrated on a chip, the memory 801, the processor 802 and the communication interface 803 can communicate with each other through an internal interface.
[0091] The processor 802 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0092] The embodiment of the present application further provides a computer-readable storage medium on which a computer program or instruction is stored. When the computer program or instruction is executed by a processor, the barcode image correction method as described above is implemented.
[0093] The embodiment of the present application further provides a computer program product, including a computer program or instructions, characterized in that when the computer program or instructions are executed, the above-mentioned barcode image correction method is implemented.
[0094] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0095] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0096] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0097] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of multiple of the following technologies known in the art: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0098] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
Claims
1. A method for correcting a barcode image, characterized in that: The following steps are involved: Step S101, obtaining a barcode image, wherein the barcode image includes a one-dimensional code image and a two-dimensional code image; Step S102, performing Fourier transform on the barcode image to generate a corresponding spectrum diagram; Step S103, determining the rotation angle of the barcode image according to the spectrum diagram; Step S104, correcting the barcode image to a target reference angle according to the rotation angle.
2. The barcode image correction method according to claim 1, characterized in that: The step of determining the rotation angle of the barcode image according to the spectrum diagram comprises: Identify the frequency range of the bandpass filter; Using the frequency range of the bandpass filter to filter the key features of the barcode in the spectrum graph; The rotation angle of the barcode image is calculated according to the key features of the barcode.
3. The barcode image correction method according to claim 2, characterized in that In, the frequency range of the identified bandpass filter includes: Obtaining the width of the barcode image; The frequency range of the bandpass filter is determined according to the width of the barcode image.
4. The barcode image correction method according to claim 3, characterized in that: Determining the frequency range of the bandpass filter according to the width of the barcode image includes: Calculating a reference inner radius and a reference outer radius according to the width of the barcode image; The frequency range of the bandpass filter is determined according to the reference inner radius and the reference outer radius.
5. The barcode image correction method according to claim 4, characterized in that: Calculating the rotation angle of the barcode image according to the key features of the barcode, including: identifying an origin of the barcode; Integrate the straight line passing through the origin at every preset angle to generate an integral value; The rotation angle of the barcode image is determined according to the integral value.
6. The barcode image correction method according to claim 5, characterized in that: The calculation formula for integrating all straight lines passing through the origin to generate the integral value is: Where i is the pixel value, i∈[R1,R2], θ is the current angle of the line; x o and o is the image center coordinate.
7. The barcode image correction method according to claim 5, characterized in that: Determining the rotation angle of the barcode image according to the integral value includes: Filter the maximum integral value among all integral values; Calculate the corresponding angle according to the maximum integral value; The rotation angle of the barcode image is determined according to the angle corresponding to the maximum integral value among all the integral values.
8. The barcode image correction method according to claim 5, characterized in that: The calculation formula for calculating the corresponding angle according to the maximum integral value is: θ=arg(max(I)), Where I is the integral value and θ is the rotation angle of the barcode image.
9. A barcode image correction device, characterized in that: include: An acquisition module, used for acquiring a barcode image; A generating module, used for performing Fourier transform on the barcode image to generate a corresponding spectrum diagram; A calculation module, used for determining the rotation angle of the barcode image according to the spectrum diagram; A correction module is used to correct the barcode image to a target reference angle according to the rotation angle.
10. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the barcode image correction method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: The computer program or instruction is executed by a processor to implement the barcode image correction method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed, the barcode image correction method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Barcode completion correction method based on opencv
CN114862660A
Open channel flow measurement method and device based on space-time image texture feature extraction
CN117889923A
Rotating speed measuring method based on rotary blurred image
CN1888913A
