Machine vision-based code reader distortion image correction and decoding method and system
The machine vision-based barcode reader distortion image correction method solves the image distortion problem caused by optical system defects and shooting angle changes in barcode reading equipment, achieving high-precision and high-reliability barcode recognition, which is suitable for industrial automation, logistics management, retail and other fields.
Patent Information
- Application Number
- CN202510777094.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-06-11
AI Technical Summary
Traditional barcode reading devices suffer from image distortion problems caused by optical system defects and changes in shooting angles, which affect the accuracy and reliability of barcode recognition. The image correction methods in existing technologies have high computational complexity and cannot meet real-time requirements, resulting in a high decoding failure rate.
Through a machine vision-based code reader distortion image correction method, accurate distortion type judgment and targeted correction algorithms are used, combined with a quality assessment mechanism, including a radial distortion correction model and perspective transformation matrix, to perform image distortion correction. The barcode recognition accuracy is improved through image preprocessing, distortion type judgment, correction and quality assessment processes.
It significantly improves the accuracy and success rate of barcode recognition, is suitable for various types of barcodes and application scenarios, improves the correction accuracy by more than 10%, and meets the needs of industrial applications for high precision and high reliability.
Smart Images

Figure CN120318130B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image distortion correction, and in particular relates to a machine vision-based code reader distortion image correction and decoding method and system. Background Art
[0002] Traditional barcode reading devices often face image distortion problems in practical applications, affecting the accuracy and reliability of barcode recognition. Barcode reading systems in existing technologies suffer from radial distortion caused by inherent defects in their optical systems. Due to limitations in lens manufacturing processes and constraints in optical principles, the imaging systems of barcode readers generally suffer from barrel distortion or pincushion distortion, which causes straight lines in barcode images to appear curved, resulting in distortion of barcode width information and affecting decoding accuracy.
[0003] In actual application scenarios, barcodes often cannot be aligned perpendicularly to the camera's optical axis, resulting in perspective deformation, making the barcode appear trapezoidal or parallelogram, affecting the barcode's geometric characteristics and the effectiveness of the decoding algorithm. Traditional image correction technologies are mostly general methods that are not optimized for the special properties of barcode images. The correction effect is limited, and the computational complexity is high, making it difficult to meet real-time requirements. In addition, existing technologies often ignore the quantitative evaluation of the quality of the corrected image, and cannot ensure that the correction effect meets the subsequent decoding requirements, resulting in a high decoding failure rate.
[0004] Therefore, there is an urgent need to develop a distortion correction method specifically for barcode images that can accurately identify and correct radial distortion and perspective distortion, and has a complete quality assessment mechanism to improve the accuracy and robustness of barcode recognition. Summary of the Invention
[0005] The purpose of the present invention is to overcome the shortcomings of the existing technology and provide a machine vision-based code reader distortion image correction and decoding method and system to solve the image distortion problem caused by optical system defects and shooting angle changes during the barcode reading process. Through precise distortion type judgment, targeted correction algorithm and perfect quality assessment mechanism, the accuracy and success rate of barcode recognition are significantly improved, meeting the needs of industrial applications for high-precision and high-reliability barcode recognition.
[0006] In a first aspect, the present invention provides a machine vision-based barcode reader distortion image correction and decoding method for performing distortion correction on an image read by a barcode reader. The method comprises the following steps:
[0007] Step S1, obtain the original image containing the barcode through the image acquisition device, preprocess the original image, including grayscale, noise reduction and edge detection, locate the barcode area and extract features of the preprocessed image, and extract the pixel coordinates in the image, the coordinates of the main point of the image, the coordinates of the points on the barcode line, the radial distance from the pixel point to the main point of the image, and the inner angle of the outer rectangular outline of the image.
[0008] Step S2: Determine the distortion type of the image based on the extracted features. The distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. When it is determined that the image has perspective distortion, a perspective transformation matrix is used to perform perspective transformation on the image to achieve perspective distortion correction.
[0009] Step S3, calculate the contrast, clarity, uniformity and noise of the corrected image, and perform quality assessment on the corrected image. When the quality threshold is met, re-locate and segment the barcode area of the corrected image, and decode the segmented barcode image to output the barcode information.
[0010] Furthermore, the average curvature of the barcode line is calculated based on the coordinates of the points on the line to determine whether the image has radial distortion: , where N is the total number of detection points on the line, ; The first The coordinates of the detection points, ; is the average curvature of the straight line, when When , it is determined that radial distortion exists; is the curvature threshold, which is 0.005.
[0011] Furthermore, when it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. The radial distortion correction model uses the following formula:
[0012] ;
[0013] Among them, the radial distance from the pixel to the image principal point is for: ; are the pixel coordinates in the distorted image, is the pixel coordinate after correction; is the coordinate of the principal point of the image, that is, the intersection of the optical axis and the imaging plane; 、 、 、 is the distortion coefficient of the radial distortion correction model; is the tangential distortion coefficient, which corrects the distortion caused by lens assembly error and its value range is [-0.01, 0.01].
[0014] Furthermore, the radial distortion correction model adopts the fourth-order radial distortion correction. is the first-order radial distortion coefficient, with a value range of [-0.5, 0.5], used to control barrel or pincushion distortion; is the second-order radial distortion coefficient, with a value range of [-0.1, 0.1], which is used to correct the second-order distortion component; is the third-order radial distortion coefficient, with a value range of [-0.01, 0.01], which is used to supplement the correction of the second-order distortion component; is the fourth-order radial distortion coefficient, ranging from [-0.001, 0.001], used for fine correction of residual distortion.
[0015] Furthermore, the angle deviation of the rectangle is calculated based on the inner angle of the outer rectangular outline of the image. When the angle deviation is greater than the preset angle deviation threshold, the image is judged to have perspective distortion. The angle deviation threshold is 5°. The angle deviation calculation formula is: ;in, For the rectangular interior angles, ; is the mean angle deviation.
[0016] Furthermore, when perspective distortion is detected, the perspective transformation matrix is used for correction. The transformation matrix is expressed as: ;in, for Axis and The scaling factor in the axis direction is in the range of [0.5, 2.0]. is the shear transformation coefficient, which controls the tilt of the image and has a value range of [-0.5, 0.5]; for Axis and The amount of translation in the axis direction; is the perspective transformation coefficient, which controls the degree of trapezoidal correction and has a value range of [-0.001, 0.001]; is the normalization coefficient, set to 1; is the transformation redundancy term.
[0017] The constraints are satisfied: , to ensure the effectiveness of the transformation.
[0018] Furthermore, the contrast, clarity, uniformity and noise of the corrected image are calculated, and the quality of the corrected image is evaluated. The quality evaluation formula is:
[0019] ;in, is the quality assessment value, is the contrast quality, , are the average grayscale values of the white and black areas of the barcode, respectively; To prevent division by zero for small constants, take ; For clarity quality, ; are the width and height of the image, is the Laplace operator at position (x, y), used to detect edge sharpness; is the uniformity quality, ; is the grayscale standard deviation of the local area; is the global average gray value; is the noise quality, , ; are the signal mean and noise standard deviation, respectively; is the weight coefficient, satisfying .
[0020] Further, when , indicating that the quality threshold is met, at this time, the barcode area of the corrected image is located and segmented.
[0021] Furthermore, when locating and segmenting the barcode area of the corrected image, the barcode area positioning adopts gradient direction consistency detection: , where the gradient direction Calculated as:
[0022] ; R is the candidate barcode area, which contains all the pixel points to be detected; |R| is the total number of pixels in area R, are the x-direction and y-direction gradient components at position (x, y) respectively; is the dominant gradient direction in the region, obtained through histogram statistics.
[0023] when When , the candidate barcode region R is considered to be the barcode region; the decoder segments the barcode region based on the white pixels and black pixels in the barcode region, recognizes and outputs the barcode information.
[0024] In a second aspect, based on the same inventive concept, the present invention provides a code reader distortion image correction and decoding system based on machine vision, the system comprising: an image preprocessing module, a distortion correction module and a correction evaluation and decoding module.
[0025] Furthermore, the image preprocessing module is used to obtain the original image containing the barcode through the image acquisition device, preprocess the original image, including grayscale, noise reduction and edge detection, and perform barcode area positioning and feature extraction on the preprocessed image, extracting the pixel coordinates in the image, the coordinates of the main point of the image, the coordinates of the points on the barcode straight line, the radial distance from the pixel point to the main point of the image, and the inner angle of the outer rectangular outline of the image.
[0026] Furthermore, the distortion correction module is used to determine the distortion type of the image based on the extracted features, and the distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. When it is determined that the image has perspective distortion, a perspective transformation matrix is used to perform perspective transformation on the image to achieve perspective distortion correction.
[0027] Furthermore, the correction evaluation decoding module is used to calculate the contrast, clarity, uniformity and noise of the corrected image, perform quality evaluation on the corrected image, and when the quality threshold is met, re-locate and segment the barcode area of the corrected image, and decode the segmented barcode image to output the barcode information.
[0028] Furthermore, the distortion correction module includes: a distortion type determination unit, a radial distortion correction unit, a perspective distortion correction unit, and a parallel processing unit;
[0029] The distortion type determination unit is used to determine the distortion type of the image based on the average curvature of the straight line calculated from the coordinates of the points on the barcode straight line and the rectangular angle deviation calculated from the inner angle of the outer rectangular outline of the image.
[0030] The radial distortion correction unit is used to perform fourth-order radial distortion correction on the image using a radial distortion correction model when it is determined that the image has radial distortion.
[0031] The perspective distortion correction unit is used to perform perspective transformation on the image using a perspective transformation matrix to achieve perspective distortion correction when it is determined that the image has perspective distortion.
[0032] The parameter storage unit stores and manages correction parameters of various types of distortion, and supports real-time update and historical version management of parameters.
[0033] The parallel processing unit supports multi-core CPU and GPU acceleration to achieve simultaneous radial distortion correction and perspective distortion correction of images.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] By analyzing the average curvature of the barcode straight lines and the angular deviation of the outer rectangular outline of the image, the present invention can accurately distinguish between radial distortion and perspective distortion, providing an accurate basis for subsequent correction, avoiding the correction failure problem caused by misjudgment of the distortion type in traditional methods. Compared with traditional general correction methods, the correction accuracy of the present invention is improved by more than 10%; the present invention is applicable to various types of barcodes (one-dimensional codes, two-dimensional codes, etc.) and different application scenarios (industrial automation, logistics management, retail, etc.), and has good versatility and practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 This is a flow chart of the machine vision-based code reader distortion image correction and decoding method of the present invention;
[0037] Figure 2 The figure is a schematic diagram of the composition of the machine vision-based code reader distortion image correction and decoding system of the present invention. DETAILED DESCRIPTION
[0038] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention are described clearly and completely below. Obviously, the embodiments described are only part of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0039] Embodiment 1:
[0040] like Figure 1 FIG. 1 is a flow chart of a machine vision-based barcode reader distortion image correction and decoding method according to the present invention. The method is used to correct the distortion of an image read by a barcode reader, and includes the following steps:
[0041] Step S1, obtain the original image containing the barcode through the image acquisition device, preprocess the original image, including grayscale, noise reduction and edge detection, locate the barcode area and extract features of the preprocessed image, and extract the pixel coordinates in the image, the coordinates of the main point of the image, the coordinates of the points on the barcode line, the radial distance from the pixel point to the main point of the image, and the inner angle of the outer rectangular outline of the image.
[0042] Grayscale processing uses the weighted average method, the formula is: , where R, G, and B are the pixel values of the red, green, and blue color channels respectively; the noise reduction process uses an adaptive Gaussian filter, and the filter kernel size is dynamically adjusted according to the image noise level. Specifically, the noise variance of the image is first calculated , and then determine the filter kernel size: .
[0043] Edge detection uses an improved Canny operator and a dual-threshold strategy for edge extraction. The low threshold is set to 0.5 times the mean value of the image gradient amplitude, and the high threshold is set to 2-3 times the low threshold. For example, for a barcode image with a resolution of 1920×1080, the typical threshold settings are: low threshold = 50, high threshold = 120; barcode area positioning uses gradient direction consistency detection: , where the gradient direction Calculated as: ; R is the candidate barcode area, which contains all the pixel points to be detected; |R| is the total number of pixels in area R, are the x-direction and y-direction gradient components at position (x, y) respectively; is the dominant gradient direction in the region, obtained through histogram statistics; when When , the candidate barcode region R is considered to be a barcode region.
[0044] Step S2: Determine the distortion type of the image based on the extracted features. The distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. When it is determined that the image has perspective distortion, a perspective transformation matrix is used to perform perspective transformation on the image to achieve perspective distortion correction.
[0045] Calculate the average curvature of the barcode line based on the coordinates of the points on the line to determine whether the image has radial distortion: , where N is the total number of detection points on the line, When the number of detection points N is small (e.g. N<10), the accuracy of curvature calculation will drop significantly. The system will automatically increase the sampling density of detection points to ensure that the condition of N≥10 is met. For example, for a barcode straight line with a length of 200 pixels, 15-20 detection points are usually sampled. The first The coordinates of the detection points, ; is the average curvature of the straight line, when When , it is determined that radial distortion exists; is the curvature threshold, which is 0.005.
[0046] When it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. The radial distortion correction model uses the following formula:
[0047] ;
[0048] Among them, the radial distance from the pixel to the image principal point is for: ; are the pixel coordinates in the distorted image, is the pixel coordinate after correction; is the coordinate of the principal point of the image, that is, the intersection of the optical axis and the imaging plane; 、 、 、 is the distortion coefficient of the radial distortion correction model; is the tangential distortion coefficient, which corrects the distortion caused by lens assembly error and its value range is [-0.01, 0.01].
[0049] The radial distortion correction model adopts the fourth-order radial distortion correction. is the first-order radial distortion coefficient, with a value range of [-0.5, 0.5], used to control barrel or pincushion distortion; is the second-order radial distortion coefficient, with a value range of [-0.1, 0.1], which is used to correct the second-order distortion component; is the third-order radial distortion coefficient, with a value range of [-0.01, 0.01], which is used to supplement the correction of the second-order distortion component; This is the fourth-order radial distortion coefficient, with a value range of [-0.001, 0.001]. It is used to fine-tune residual distortion. The curvature calculation for radial distortion determination is based on the second-order difference principle of the barcode line. For an ideal straight line, its second-order difference should be zero. When radial distortion exists, the line will appear curved, and the second-order difference value will increase.
[0050] Calculate the angle deviation of the rectangle according to the inner angle of the rectangle outline outside the image. When the angle deviation is greater than the preset angle deviation threshold, the image is judged to have perspective distortion. The angle deviation threshold is 5°. When the angle deviation between the camera and the barcode is less than 5°, the impact on the decoding accuracy can be ignored. When the angle deviation exceeds 5°, the geometric shape of the barcode will change significantly, affecting the decoding success rate. The formula for calculating the angle deviation is: ;in, For the rectangular interior angles, ; is the mean angle deviation.
[0051] When perspective distortion is detected, the perspective transformation matrix is used for correction. The transformation matrix is expressed as: ; Convert the actual coordinates to: .
[0052] for Axis and The scaling factor in the axis direction is in the range of [0.5, 2.0]. is the shear transformation coefficient, which controls the tilt of the image and has a value range of [-0.5, 0.5]; for Axis and The amount of translation in the axis direction; is the perspective transformation coefficient, which controls the degree of trapezoidal correction and has a value range of [-0.001, 0.001]; is the normalization coefficient, set to 1; for Pixel coordinates after transformation by the transformation matrix; is the transformation redundancy term;
[0053] The constraints are satisfied: , to ensure the validity of the transformation; when this condition is not met, the transformation matrix will cause a division by zero error; in actual implementation, the system will check this condition, and when it is close to zero (such as the absolute value is less than 10⁻ 6 ), which will fine-tune the transformation parameters.
[0054] Step S3, calculate the contrast, clarity, uniformity and noise of the corrected image, and perform quality assessment on the corrected image. When the quality threshold is met, re-locate and segment the barcode area of the corrected image, and decode the segmented barcode image to output the barcode information.
[0055] Calculate the contrast, clarity, uniformity and noise of the corrected image and perform quality assessment on the corrected image. The quality assessment formula is:
[0056] ;in, is the quality assessment value, is the contrast quality, , are the average grayscale values of the white and black areas of the barcode, respectively; To prevent division by zero for small constants, take ; For clarity quality, ; are the width and height of the image, is the Laplace operator at position (x, y), used to detect edge sharpness; is the uniformity quality, ; is the grayscale standard deviation of the local area; is the global average gray value; is the noise quality, , ; are the signal mean and noise standard deviation, respectively; is the weight coefficient, satisfying ;
[0057] when , indicating that the quality threshold is met, at this time, the barcode area of the corrected image is located and segmented.
[0058] It should be noted that the contrast calculation Qc in quality assessment reflects the separation between the black and white areas of the barcode; and The average grayscale value of the white and black areas respectively, and the segmentation threshold is automatically determined by the Ot threshold segmentation method; for example, for a standard one-dimensional barcode, ideally , (within the grayscale range of 0-255), at this time .
[0059] The sharpness quality (Qs) is calculated based on the variance of the Laplacian operator and reflects the sharpness of image edges. The Laplacian operator kernel is [-1 -1 -1], [-1 8 -1], [-1 -1 -1]. For clear barcode images, the Qs value is typically between 50 and 200.
[0060] When locating and segmenting the barcode area of the rectified image, the barcode area positioning adopts gradient direction consistency detection: , where the gradient direction Calculated as:
[0061] ; R is the candidate barcode area, which contains all the pixel points to be detected; |R| is the total number of pixels in area R, are the x-direction and y-direction gradient components at position (x, y) respectively; is the dominant gradient direction in the region, obtained through histogram statistics;
[0062] when When , the candidate barcode region R is considered to be the barcode region; the decoder segments the barcode region based on the white pixels and black pixels in the barcode region, recognizes and outputs the barcode information.
[0063] The decoding process uses an adaptive sampling strategy:
[0064] Decoding confidence calculation:
[0065] ; The basic sampling rate is 8-16 sampling points per module; is the adaptive adjustment coefficient, ranging from [0.2, 0.8], which controls the variation of sampling density; For the The local quality score of each barcode module; , are the minimum and maximum values of the quality score respectively; L is the total length of the barcode, that is, the total number of barcode modules; For a given observation value Bit for probability; For the The observed gray value of each module; , The value of the module The theoretical mean and standard deviation of >0.95, indicating successful decoding.
[0066] Adopting adaptive parameter optimization algorithm: ;The loss function is defined as:
[0067] ; The loss components are:
[0068] ;
[0069] is the parameter vector of the tth iteration, containing all distortion correction parameters; is the learning rate, ranging from [0.001, 0.1], which controls the parameter update step size; is the momentum coefficient, ranging from [0.8, 0.95], which accelerates convergence and reduces oscillation.
[0070] B1 is the batch size, that is, the number of images processed simultaneously, ranging from 16 to 64; is the loss weight, which takes values (0.5, 0.3, 0.2) in sequence; is the decoding loss of the jth sample, based on the probability of successful decoding; is the distortion residual loss of the jth sample; is the mass loss of the jth sample; is the residual distortion vector after correction of the jth sample; is the quality threshold, which is 0.75.
[0071] On the production line of a certain automobile manufacturer, the barcode recognition system of the present invention is applied to trace engine parts. The production environment presents the following challenges: due to cost considerations, the camera lens has significant barrel distortion, with a k1 coefficient of approximately -0.15; due to installation space limitations, the angle between the camera and the barcode plane is approximately 15°, resulting in significant perspective distortion; and vibrations on the production line and changes in lighting lead to unstable image quality.
[0072] Using traditional recognition methods, the recognition success rate is only 78.5%, which seriously affects production efficiency. After applying the method of the present invention, the system first detects radial distortion (Cu=0.0087>0.005) and perspective distortion (An=12.3°>5°), and automatically activates the corresponding correction algorithm. After radial distortion correction, the curvature of the barcode straight line is reduced to 0.0021; after perspective distortion correction, the rectangular angle deviation is reduced to 2.1°. The quality assessment results show: Qc=0.62 (good contrast), Qs=85.3 (high clarity), Qu=0.89 (good uniformity), Qn=0.15 (low noise), and the comprehensive quality score Qt=0.78>0.75, which meets the decoding requirements.
[0073] The final recognition success rate increased to 95.8%, an increase of 17.3 percentage points compared to traditional methods, effectively solving the problem of production line barcode recognition and significantly improving production efficiency and the reliability of product quality traceability.
[0074] Example 2:
[0075] like Figure 2 As shown in the figure, a machine vision-based code reader distortion image correction and decoding system of the present invention includes: an image preprocessing module, a distortion correction module and a correction evaluation and decoding module.
[0076] The image preprocessing module is used to obtain an original image containing a barcode through an image acquisition device, preprocess the original image, including grayscale conversion, noise reduction and edge detection, and perform barcode area positioning and feature extraction on the preprocessed image, extracting pixel coordinates in the image, image principal point coordinates, point coordinates on the barcode line, radial distances from pixel points to image principal points, and inner angles of the outer rectangular outline of the image. The image preprocessing module adopts a multi-threaded parallel processing architecture and can process multiple images simultaneously, thereby improving system throughput. The module also includes an image cache manager that supports concurrent processing of up to 32 images.
[0077] The distortion correction module is used to determine the distortion type of the image based on the extracted features. The distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. When it is determined that the image has perspective distortion, a perspective transformation matrix is used to perform perspective transformation on the image to achieve perspective distortion correction.
[0078] The distortion correction module includes: a distortion type determination unit, a radial distortion correction unit, a perspective distortion correction unit and a parallel processing unit; the distortion type determination unit is used to determine the distortion type of the image by calculating the average curvature of the straight line based on the coordinates of the points on the barcode straight line and the rectangular angle deviation calculated from the inner angle of the outer rectangular outline of the image; the radial distortion correction unit is used to use a radial distortion correction model to perform fourth-order radial distortion correction on the image when it is determined that the image has radial distortion; the perspective distortion correction unit is used to use a perspective transformation matrix to perform perspective transformation on the image to achieve perspective distortion correction when it is determined that the image has perspective distortion; the parameter storage unit stores and manages correction parameters for various types of distortions, and supports real-time update and historical version management of parameters; the parallel processing unit supports multi-core CPU and GPU acceleration to achieve simultaneous radial distortion correction and perspective distortion of the image.
[0079] The correction evaluation decoding module is used to calculate the contrast, clarity, uniformity and noise of the corrected image, perform quality evaluation on the corrected image, and when the quality threshold is met, re-locate and segment the barcode area of the corrected image, and decode the segmented barcode image to output the barcode information.
[0080] The calibration, evaluation, and decoding module utilizes a multi-level evaluation strategy. The first level is a quick evaluation, calculating basic image quality metrics and taking approximately 1-2 milliseconds. The second level is a detailed evaluation, calculating all quality metrics and taking approximately 5-10 milliseconds. The third level is a precise evaluation, including additional statistical analysis and taking approximately 20-30 milliseconds. The decoding module supports a variety of barcode types, including Code 128, Code 39, EAN-13, and QR codes. Different barcode types require corresponding decoding algorithms and parameter settings. The system also includes a built-in barcode type recognition function that automatically determines the barcode type and selects the appropriate decoder.
[0081] The module also includes error detection and correction functions. For barcodes with check digits, the system will verify the correctness of the check digits; for QR codes that support error correction, the system will use the Reed-Solomon error correction algorithm to repair minor data errors.
[0082] In a large logistics distribution center, an intelligent sorting system based on the present invention is deployed; the system needs to handle the sorting task of 10,000 packages per hour, and the barcode on each package may have varying degrees of distortion.
[0083] The system is configured as an 8-core CPU server equipped with two NVIDIA RTX 3080 GPUs and 64GB of memory. Using the parallel processing architecture of this invention, the following performance indicators were achieved: image preprocessing speed: 250 frames per second; distortion correction speed: 200 fps; quality assessment and decoding speed: 300 fps; and overall system latency: less than 20 milliseconds.
[0084] During the three months of actual operation, the system processed more than 2 million parcels, with a barcode recognition success rate of 96.2%, an increase of 5.7 percentage points compared to the original system (success rate of 90.5%); in particular, for barcodes with obvious distortion, the success rate increased from 62.3% to 84.8%, significantly improving sorting efficiency.
[0085] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A machine vision-based barcode reader distortion image correction and decoding method for performing distortion correction on images read by a barcode reader, characterized in that: The method comprises the following steps: Step S1, acquiring an original image containing a barcode through an image acquisition device, preprocessing the original image, including grayscale conversion, noise reduction, and edge detection, and performing barcode region location and feature extraction on the preprocessed image, extracting pixel coordinates in the image, image principal point coordinates, point coordinates on the barcode line, radial distances from pixel points to the image principal point, and inner angles of the outer rectangular outline of the image; Step S2: determining the type of image distortion based on the extracted features, where the distortion types include radial distortion and perspective distortion. If radial distortion is detected, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. If perspective distortion is detected, a perspective transformation matrix is used to perform perspective distortion correction on the image. Calculate the average curvature of the barcode line based on the coordinates of the points on the line to determine whether the image has radial distortion: , where N is the total number of detection points on the line, ; The first The coordinates of the detection points, ; is the average curvature of the straight line, when When , it is determined that radial distortion exists; is the curvature threshold, which is 0.005; When it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. The radial distortion correction model uses the following formula: ; Among them, the radial distance from the pixel to the image principal point is for: ; are the pixel coordinates in the distorted image, is the pixel coordinate after correction; is the coordinate of the principal point of the image, that is, the intersection of the optical axis and the imaging plane; 、 、 、 is the distortion coefficient of the radial distortion correction model; is the tangential distortion coefficient, which corrects the distortion caused by lens assembly error and has a value range of [-0.01, 0.01]; Step S3, calculate the contrast, clarity, uniformity and noise of the corrected image, and perform quality assessment on the corrected image. When the quality threshold is met, re-locate and segment the barcode area of the corrected image, and decode the segmented barcode image to output the barcode information.
2. The method according to claim 1, characterized in that The radial distortion correction model adopts the fourth-order radial distortion correction. is the first-order radial distortion coefficient, with a value range of [-0.5, 0.5], used to control barrel or pincushion distortion; is the second-order radial distortion coefficient, with a value range of [-0.1, 0.1], which is used to correct the second-order distortion component; is the third-order radial distortion coefficient, with a value range of [-0.01, 0.01], which is used to supplement the correction of the second-order distortion component; is the fourth-order radial distortion coefficient, ranging from [-0.001, 0.001], used for fine correction of residual distortion.
3. The method according to claim 2, characterized in that Calculate the angle deviation of the rectangle according to the inner angle of the rectangle outline outside the image. When the angle deviation is greater than the preset angle deviation threshold, the image is judged to have perspective distortion. The angle deviation threshold is 5°. The angle deviation calculation formula is: ;in, For the rectangular interior angles, ; is the mean angle deviation.
4. The method according to claim 3, characterized in that When perspective distortion is detected, the perspective transformation matrix is used for correction. The transformation matrix is expressed as: ;in, for Axis and The scaling factor in the axis direction is in the range of [0.5, 2.0]. is the shear transformation coefficient, which controls the tilt of the image and has a value range of [-0.5, 0.5]; for Axis and The amount of translation in the axis direction; is the perspective transformation coefficient, which controls the degree of trapezoidal correction and has a value range of [-0.001, 0.001]; is the normalization coefficient, set to 1; for Pixel coordinates after transformation by the transformation matrix; is the transformation redundancy term; The constraints are satisfied: , to ensure the effectiveness of the transformation.
5. The method according to claim 4, characterized in that Calculate the contrast, clarity, uniformity and noise of the corrected image and perform quality assessment on the corrected image. The quality assessment formula is: ;in, is the quality assessment value, is the contrast quality, , are the average grayscale values of the white and black areas of the barcode, respectively; To prevent division by zero for small constants, take ; For clarity quality, ; are the width and height of the image, is the Laplace operator at position (x, y), used to detect edge sharpness; is the uniformity quality, ; is the grayscale standard deviation of the local area; is the global average gray value; is the noise quality, , ; are the signal mean and noise standard deviation, respectively; is the weight coefficient, satisfying ; when , indicating that the quality threshold is met, at this time, the barcode area of the corrected image is located and segmented.
6. The method according to claim 5, characterized in that When locating and segmenting the barcode area of the rectified image, the barcode area positioning adopts gradient direction consistency detection: , where the gradient direction Calculated as: ; R is the candidate barcode area, which contains all the pixel points to be detected; |R| is the total number of pixels in area R, are the x-direction and y-direction gradient components at position (x, y) respectively; is the dominant gradient direction in the region, obtained through histogram statistics; when When , the candidate barcode region R is considered to be the barcode region; the decoder segments the barcode region based on the white pixels and black pixels in the barcode region, recognizes and outputs the barcode information.
7. A machine vision-based code reader distortion image correction and decoding system, used to execute the method according to any one of claims 1 to 6, characterized in that: The system includes: an image preprocessing module, a distortion correction module and a correction evaluation decoding module; The image preprocessing module is used to obtain an original image containing a barcode through an image acquisition device, preprocess the original image, including grayscale conversion, noise reduction and edge detection, and perform barcode area positioning and feature extraction on the preprocessed image, extracting pixel coordinates in the image, image principal point coordinates, point coordinates on the barcode line, radial distances from pixel points to image principal points, and inner angles of the outer rectangular outline of the image; The distortion correction module is used to determine the type of image distortion based on the extracted features. The distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a radial distortion correction model is used to perform fourth-order radial distortion correction on the image. When it is determined that the image has perspective distortion, a perspective transformation matrix is used to perform perspective transformation on the image to achieve perspective distortion correction. The correction evaluation decoding module is used to calculate the contrast, clarity, uniformity and noise of the corrected image, perform quality evaluation on the corrected image, and when the quality threshold is met, re-locate and segment the barcode area of the corrected image, and decode the segmented barcode image to output the barcode information.
8. The system according to claim 7, characterized in that The distortion correction module includes: a distortion type determination unit, a radial distortion correction unit, a perspective distortion correction unit and a parallel processing unit; The distortion type determination unit is used to determine the distortion type of the image based on the average curvature of the straight line calculated from the coordinates of the points on the barcode straight line and the rectangular angle deviation calculated from the inner angle of the rectangular outline outside the image; The radial distortion correction unit is used to perform fourth-order radial distortion correction on the image using a radial distortion correction model when it is determined that the image has radial distortion; The perspective distortion correction unit is used to perform perspective transformation on the image using a perspective transformation matrix to achieve perspective distortion correction when it is determined that the image has perspective distortion; The parameter storage unit stores and manages correction parameters for various types of distortion, and supports real-time parameter updates and historical version management; The parallel processing unit supports multi-core CPU and GPU acceleration, and realizes radial distortion correction and perspective distortion correction of images at the same time.
Citation Information
Patent Citations
Complicated background bar code image automatic partitioning method based on gradient direction consistency
CN104636706A
Camera parameter accuracy determination method and device, storage medium and terminal
CN111145271A
Multi-lens iris recognition module and recognition method
CN119445646A