Code reader distortion image correcting and decoding method and system based on machine vision

The method and system for barcode reader image correction using machine vision address distortion issues by accurately identifying and correcting radial and perspective distortions, enhancing accuracy and reliability in barcode recognition.

CN120318130AActive Publication Date: 2025-07-15SHANGHAI BOTRONG ELECTRIC

Patent Information

Application Number
CN202510777094.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2025-07-15
Estimated Expiration
2045-06-11

AI Technical Summary

Technical Problem

Existing barcode reading equipment has problems with radial distortion and perspective distortion, resulting in insufficient accuracy and reliability of barcode identification. The traditional correction methods have high computational complexity and cannot meet real-time requirements, and lack an effective quality evaluation mechanism.

Method used

The machine vision-based code reader distortion image correction method is used to accurately judge the distortion type and use the radial distortion correction model and perspective transformation matrix to correct it, and at the same time, quality evaluation is carried out, including contrast, clarity, uniformity and noise evaluation, to ensure that the image quality meets the decoding requirements.

Benefits of technology

It significantly improves the accuracy and success rate of barcode recognition, improves correction accuracy by more than 10%, and is suitable for various types of barcodes and application scenarios, meeting the high accuracy and high reliability needs of industrial applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120318130A_ABST
    Figure CN120318130A_ABST
Patent Text Reader

Abstract

The invention discloses a code reader distorted image correcting and decoding method and system based on machine vision. The method comprises the following steps: acquiring an original image containing a bar code through image acquisition equipment, preprocessing the original image, and extracting feature parameters; image distortion types including radial distortion and perspective distortion are judged according to the extracted features, and distortion correction is carried out by adopting a corresponding correction model; performing quality evaluation on the corrected image, and when a quality threshold value is met, repositioning a bar code area and performing decoding processing; the method can effectively solve the problem of image distortion caused by inherent defects of an optical system and a shooting angle in the bar code reading process, remarkably improves the accuracy and success rate of bar code recognition, and is suitable for bar code recognition application in the fields of industrial automation, logistics management and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image distortion correction, and particularly relates to a method and system for correcting and decoding distorted images of a barcode reader based on machine vision. Background Art

[0002] Traditional barcode reading devices often face image distortion problems in practical applications, which affect the accuracy and reliability of barcode recognition; in the existing barcode reading systems, there are radial distortion problems caused by inherent defects of the optical system; due to the limitations of lens manufacturing processes and optical principle constraints, barrel distortion or pincushion distortion generally exists in the imaging systems of barcode readers, causing the straight lines in barcode images to bend, resulting in the distortion of barcode width information and affecting the decoding accuracy.

[0003] In practical application scenarios, barcodes often cannot be vertically aligned with the camera optical axis, forming perspective distortion, making the barcodes present trapezoids or parallelograms, which affects the geometric features of the barcodes and the effectiveness of decoding algorithms. Traditional image correction techniques are mostly general methods and 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 the real-time requirements; in addition, existing technologies often ignore the quantitative evaluation of the quality of the corrected images and cannot ensure that the correction effect meets the subsequent decoding requirements, resulting in a relatively high decoding failure rate.

[0004] Therefore, there is an urgent need to develop a distortion correction method specifically for barcode images, which can accurately identify and correct radial distortion and perspective distortion, and has a perfect quality evaluation 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 deficiencies of the prior art, and provide a method and system for correcting and decoding distorted images of a barcode reader based on machine vision, so as to solve the image distortion problems caused by optical system defects and shooting angle changes during the barcode reading process. Through accurate distortion type judgment, targeted correction algorithms, and a perfect quality evaluation mechanism, the accuracy and success rate of barcode recognition are significantly improved, meeting the requirements of industrial applications for high-precision and high-reliability barcode recognition.

[0006] In a first aspect, the present invention provides a method for correcting and decoding distorted images of a barcode reader based on machine vision, which is used to correct the distortion of the images read by a barcode reader. The method includes the following steps: Step S1, obtain the original image containing the barcode through an image acquisition device, preprocess the original image, including grayscale conversion, noise reduction, and edge detection, perform barcode area localization and feature extraction on the preprocessed image, and extract the pixel coordinates, image principal point coordinates, coordinates of points on the barcode straight line, radial distance from the pixel point to the image principal point, and interior angles of the outer rectangular contour of the image.

[0007] Step S2: Determine the distortion type of the image according to the extracted features. The distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a fourth-order radial distortion correction model is used to correct the radial distortion of the image. When it is determined that the image has perspective distortion, a perspective transformation matrix is used to perform a perspective transformation on the image to achieve perspective distortion correction.

[0008] Step S3: Calculate the contrast, sharpness, uniformity, and noise of the corrected image, and perform a quality assessment on the corrected image. When the quality threshold is met, re-locate and segment the barcode area of the corrected image, and perform a decoding process on the segmented barcode image to output barcode information.

[0009] Further, calculate the average curvature of the straight line based on the point coordinates on the barcode straight line to determine whether the image has radial distortion: , where N is the total number of detection points on the straight line, ; is the coordinate of the th detection point on the straight line, ; is the average curvature of the straight line. When , it is determined that there is radial distortion; is the curvature threshold, taking 0.005.

[0010] Further, when it is determined that the image has radial distortion, a fourth-order radial distortion correction model is used to correct the radial distortion of the image. The radial distortion correction model uses the following formula: ; where the radial distance from the pixel point to the principal point of the image is: ; is the pixel coordinate in the distorted image, is the corrected pixel coordinate; is the principal point coordinate of the image, that is, the intersection of the optical axis and the imaging plane; , , , are the distortion coefficients of the radial distortion correction model; is the tangential distortion coefficient, which corrects the distortion caused by lens assembly errors, and its value range is [-0.01, 0.01].

[0011] Further, the radial distortion correction model uses fourth-order radial distortion correction, is the first-order radial distortion coefficient, and its value range is [-0.5, 0.5], which is used to control barrel or pincushion distortion; is the second-order radial distortion coefficient, with a value range of [-0.1, 0.1], used to correct the second-order distortion component; is the third-order radial distortion coefficient, with a value range of [-0.01, 0.01], used to supplement and correct the second-order distortion component; is the fourth-order radial distortion coefficient, with a value range of [-0.001, 0.001], used for fine correction of residual distortion.

[0012] Furthermore, calculate the angular deviation of the rectangle based on the interior angles of the outer rectangular contour of the image. When the average value of the angular deviation is greater than the preset angular deviation threshold, it is determined that the image has perspective distortion. The angular deviation threshold is 5°; the calculation formula for the angular deviation is: ; where is the th interior angle of the rectangle, ; is the average value of the angular deviation.

[0013] Furthermore, when perspective distortion is detected, use the perspective transformation matrix for correction. The transformation matrix is expressed as: ; where is the axis and axis direction scaling coefficient, with a value range of [0.5, 2.0], is the shear transformation coefficient, controlling the inclination degree of the image, with a value range of [-0.5, 0.5]; is the axis and axis direction translation amount; is the perspective transformation coefficient, controlling the trapezoid correction degree, with a value range of [-0.001, 0.001]; is the normalization coefficient, set to 1; is the transformation redundant term.

[0014] The constraint condition is satisfied: , ensuring the effectiveness of the transformation.

[0015] Furthermore, calculate the contrast, sharpness, uniformity, and noise of the corrected image, and perform quality assessment on the corrected image. The quality assessment formula is: ; where is the quality assessment value, is the contrast quality, , are the average gray values of the white and black areas of the barcode respectively; is a small constant to prevent division by zero, taking ; is the sharpness quality, ; are the width and height of the image respectively, is the Laplacian operator at the position (x, y) for detecting edge sharpness; is the uniformity quality, ; is the standard deviation of the gray level in the local area; is the global average gray level value; is the noise quality, , ; are the signal mean and the noise standard deviation respectively; is the weight coefficient, satisfying .

[0016] Further, when , it indicates that the quality threshold is met. At this time, the barcode area in the corrected image is located and segmented.

[0017] Further, when locating and segmenting the barcode area in the corrected image, the barcode area location adopts gradient direction consistency detection: , where the gradient direction is calculated as: ; R is the candidate barcode area, including the set of all pixels to be detected; |R| is the total number of pixels in the area R, are the x-direction and y-direction gradient components at the position (x, y) respectively; is the dominant gradient direction in the area, obtained through histogram statistics.

[0018] When , it is considered that the candidate barcode area R is the barcode area; the decoder segments the barcode area based on the white and black pixels in the barcode area, identifies and outputs the barcode information.

[0019] In the second aspect, based on the same inventive concept, the present invention provides a distortion image correction and decoding system for a machine vision-based barcode reader, and the system includes: an image preprocessing module, a distortion correction module, and a correction evaluation and decoding module.

[0020] Further, the image preprocessing module is used to obtain the original image containing the barcode through an image acquisition device, preprocess the original image, including graying, noise reduction, and edge detection, perform barcode area location and feature extraction on the preprocessed image, and extract the pixel coordinates, the coordinates of the principal point of the image, the coordinates of the points on the barcode line, the radial distance from the pixel point to the principal point of the image, and the interior angles of the outer rectangular contour of the image.

[0021] Further, the distortion correction module is used to determine the distortion type of the image according to the extracted features. The distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a fourth-order radial distortion correction model is used to correct the radial distortion of 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.

[0022] Further, the correction evaluation and decoding module is used to calculate the contrast, sharpness, uniformity, and noise of the corrected image, evaluate the quality of the corrected image. When the quality threshold is met, the barcode area of the corrected image is repositioned and segmented again, and the segmented barcode image is decoded to output barcode information.

[0023] Further, 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 according to the average curvature of the straight line calculated from the point coordinates on the barcode straight line and the rectangular angle deviation calculated from the inner angles of the outer rectangular contour of the image.

[0024] 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.

[0025] 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.

[0026] The parameter storage unit stores and manages the correction parameters of various distortions, and supports real-time update of parameters and historical version management.

[0027] The parallel processing unit supports multi-core CPU and GPU acceleration to achieve simultaneous radial distortion correction and perspective distortion of the image.

[0028] Compared with the prior art, the beneficial effects of the present invention are as follows: By analyzing the average curvature of the barcode straight line and the angle deviation of the outer rectangular contour of the image, the present invention can accurately distinguish between radial distortion and perspective distortion, providing an accurate basis for subsequent correction, and avoiding the problem of correction failure caused by misjudgment of the distortion type in the traditional method. Compared with the traditional general correction method, the correction accuracy of the present invention is increased 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 generality and practicability. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1Flowchart of the distortion image correction and decoding method of the barcode reader based on machine vision according to the present invention; Figure 2 Schematic diagram of the composition of the distortion image correction and decoding system of the barcode reader based on machine vision according to the present invention. Specific implementation manners

[0030] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below. Apparently, the described implementation manners are some but not all of the implementation manners of the present invention. All other implementation manners obtained by those of ordinary skill in the art without creative efforts based on the implementation manners in the present invention belong to the scope of protection of the present invention.

[0031] Example 1: As Figure 1 shown, it is a flowchart of the distortion image correction and decoding method of the barcode reader based on machine vision according to the present invention. The method is used for performing distortion correction on the image read by the barcode reader, and includes the following steps: Step S1, obtain the original image containing the barcode through an image acquisition device, perform preprocessing on the original image, including grayscale conversion, noise reduction and edge detection, perform barcode area positioning and feature extraction on the preprocessed image, and extract the pixel coordinates, the coordinates of the principal point of the image, the coordinates of the points on the barcode straight line, the radial distance from the pixel point to the principal point of the image, and the interior angles of the outer rectangular contour of the image.

[0032] The grayscale conversion process uses the weighted average method, and 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, first calculate the noise variance of the image, and then determine the filter kernel size: .

[0033] The edge detection uses an improved Canny operator, and edge extraction is performed through a double-threshold strategy. The low threshold is set to 0.5 times the average value of the image gradient magnitude, 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, typical threshold settings are: low threshold = 50, high threshold = 120; the barcode area positioning uses gradient direction consistency detection: , where the gradient direction is calculated as: ; R is the candidate barcode area, which contains all the pixel point sets to be detected; |R| is the total number of pixel points in the area R, are the x-direction and y-direction gradient components at the position (x, y) respectively; is the dominant gradient direction within the region, obtained through histogram statistics; when holds, it is considered that the candidate barcode region R is a barcode region.

[0034] 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 fourth-order radial distortion correction model is used to correct the radial distortion of the image. When it is determined that the image has perspective distortion, a perspective transformation matrix is used to perform a perspective transformation on the image to achieve perspective distortion correction.

[0035] Calculate the average curvature of the straight line based on the point coordinates on the barcode straight line to determine whether the image has radial distortion: , where N is the total number of detection points on the straight line, ; when the number of detection points N is small (e.g., N < 10), the accuracy of curvature calculation will decrease significantly, and the system will automatically increase the sampling density of detection points to ensure that the condition N ≥ 10 is met; for example, for a barcode straight line with a length of 200 pixels, usually 15 - 20 detection points are sampled. is the coordinate of the th detection point on the straight line, ; is the average curvature of the straight line. When holds, it is determined that there is radial distortion; is the curvature threshold, taking 0.005.

[0036] When it is determined that the image has radial distortion, a fourth-order radial distortion correction model is used to correct the radial distortion of the image. The radial distortion correction model uses the following formula: ; where the radial distance from the pixel point to the principal point of the image is: ; are the pixel coordinates in the distorted image, are the corrected pixel coordinates; are the coordinates of the principal point of the image, that is, the intersection of the optical axis and the imaging plane; , , , are the distortion coefficients of the radial distortion correction model; is the tangential distortion coefficient, which corrects the distortion caused by lens assembly errors, and its value range is [-0.01, 0.01].

[0037] The radial distortion correction model uses 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 pillow distortion; is the second-order radial distortion coefficient, with a value range of [-0.1, 0.1], used to correct the second-order distortion component; is the third-order radial distortion coefficient, with a value range of [-0.01, 0.01], used to supplement and correct the second-order distortion component; is the fourth-order radial distortion coefficient, with a value range of [-0.001, 0.001], used for fine correction of residual distortion; the curvature calculation for radial distortion judgment is based on the second-order difference principle of the barcode straight line. For an ideal straight line, its second-order difference should be zero; when there is radial distortion, the straight line will show curvature and the second-order difference value increases.

[0038] Calculate the angle deviation of the rectangle based on the interior angles of the outer rectangle contour of the image. When the average value of the angle deviation is greater than the preset angle deviation threshold, it is determined that the image has 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 calculation formula for the angle deviation is: ; where is the th interior angle of the rectangle, ; is the average value of the angle deviation.

[0039] When perspective distortion is detected, a perspective transformation matrix is used for correction. The transformation matrix is expressed as: ; Convert the actual coordinates to: .

[0040] is the scaling coefficient in the axis and axis directions, with a value range of [0.5, 2.0], is the shear transformation coefficient, controlling the inclination degree of the image, with a value range of [-0.5, 0.5]; is the axis and axis direction translation amount; is the perspective transformation coefficient, controlling the trapezoid correction degree, with a value range of [-0.001, 0.001]; is the pixel coordinates transformed through the transformation matrix; is the transformation redundant term; The constraint condition is satisfied: , ensuring the effectiveness 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. When it is close to zero (such as the absolute value is less than 10⁻6 ), the transformation parameters will be fine-tuned.

[0041] Step S3: Calculate the contrast, sharpness, uniformity, and noise of the corrected image, evaluate the quality of 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 barcode information.

[0042] Calculate the contrast, sharpness, uniformity, and noise of the corrected image, and evaluate the quality of the corrected image. The quality evaluation formula is: ; where is the quality evaluation value, is the contrast quality, , are the average gray values of the white and black areas of the barcode respectively; is a small constant to prevent division by zero, take ; is the sharpness quality, ; are the width and height of the image respectively, is the Laplacian operator at position (x,y) for detecting edge sharpness; is the uniformity quality, ; is the standard deviation of gray values in 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 , it indicates that the quality threshold is met. At this time, locate and segment the barcode area of the corrected image.

[0043] It should be noted that the contrast calculation Qc in the quality evaluation reflects the separation degree of the barcode black and white areas; and are the average gray values 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 , (in the gray range of 0 - 255), at this time .

[0044] The clarity quality Qs is calculated based on the variance of the Laplacian operator, reflecting the sharpness of the image edges. The Laplacian operator kernel is: [-1 -1 -1], [-1 8 -1], [-1 -1 -1]; for a clear barcode image, the Qs value is usually between 50 and 200.

[0045] When positioning and segmenting the barcode area of the corrected image, the barcode area positioning uses gradient direction consistency detection: , where the gradient direction is calculated as: ; R is the candidate barcode area, containing all the pixel point sets to be detected; |R| is the total number of pixel points in area R, are the x-direction and y-direction gradient components at position (x, y) respectively; is the dominant gradient direction within the area, obtained through histogram statistics; When , it is considered that the candidate barcode area R is the barcode area; the decoder segments the barcode area based on the white and black pixel points of the barcode area, identifies and outputs the barcode information.

[0046] The decoding process adopts an adaptive sampling strategy: Decoding confidence calculation: ; is the basic sampling rate, with a value of 8 - 16 sampling points per module; is the adaptive adjustment coefficient, in the range [0.2, 0.8], controlling the variation amplitude of the sampling density; is the local quality score of the th 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; is the probability of the th bit for a given observation value; is the probability of is the th module's observed gray value; , is the theoretical mean and the square of the standard deviation of the module value ; when > 0.95, it indicates successful decoding.

[0047] An adaptive parameter optimization algorithm is adopted: ; the loss function is defined as: ; where each loss component is: ; is the parameter vector for the t-th iteration, containing all distortion correction parameters; is the learning rate, in the range [0.001, 0.1], controlling the parameter update step size; is the momentum coefficient, in the range [0.8, 0.95], accelerating convergence and reducing oscillations.

[0048] B1 is the batch size, i.e., the number of images processed simultaneously, with values ranging from 16 to 64; is the loss weight, taking values (0.5, 0.3, 0.2) in sequence; is the decoding loss of the j-th sample, based on the decoding success probability; is the distortion residual loss of the j-th sample; is the quality loss of the j-th sample; is the residual distortion vector of the j-th sample after correction; is the quality threshold, with a value of 0.75.

[0049] On the production line of a certain automobile manufacturing enterprise, the barcode recognition system of the present invention is applied to trace and manage engine parts; the following challenges exist in the production environment: Due to cost considerations, there is obvious barrel distortion in the camera lens, and the k1 coefficient is about -0.15; due to limited installation space, the angle between the camera and the barcode plane is about 15°, resulting in obvious perspective distortion; the vibration of the production line and the change of light cause unstable image quality.

[0050] Using the traditional recognition method, the recognition success rate is only 78.5%, seriously affecting 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 enables 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 that: 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, meeting the decoding requirements.

[0051] Finally, the recognition success rate is increased to 95.8%, an increase of 17.3 percentage points compared with the traditional method, effectively solving the problem of barcode recognition on the production line, and significantly improving the production efficiency and the reliability of product quality traceability.

[0052] Example 2: As Figure 2As shown in the figure, a distortion image correction and decoding system of a barcode reader based on machine vision according to the present invention includes an image preprocessing module, a distortion correction module, and a correction evaluation and decoding module.

[0053] The image preprocessing module is used to obtain the original image containing the barcode through an image acquisition device, preprocess the original image, including grayscale conversion, noise reduction, and edge detection, perform barcode area positioning and feature extraction on the preprocessed image, and extract the pixel coordinates, the coordinates of the principal point of the image, the coordinates of the points on the barcode straight line, the radial distance from the pixel point to the principal point of the image, and the interior angles of the outer rectangular contour of the image; the image preprocessing module adopts a multi-threaded parallel processing architecture, which can process multiple images simultaneously to improve the system throughput; an image cache manager is included inside this module, supporting the concurrent processing of up to 32 images.

[0054] The distortion correction module is used to determine the distortion type of the image according to the extracted features. The distortion types include radial distortion and perspective distortion. When it is determined that the image has radial distortion, a fourth-order radial distortion correction model is used to correct the radial distortion of 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.

[0055] 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 calculate the average curvature of the straight line according to the coordinates of the points on the barcode straight line and the rectangular angle deviation calculated from the interior angles of the outer rectangular contour of the image to determine the distortion type of the image; the radial distortion correction unit is used to, when it is determined that the image has radial distortion, correct the fourth-order radial distortion of the image using a radial distortion correction model; the perspective distortion correction unit is used to, when it is determined that the image has perspective distortion, perform perspective transformation on the image using a perspective transformation matrix to achieve perspective distortion correction; the parameter storage unit stores and manages the correction parameters of various distortions, supporting real-time update of parameters and historical version management; the parallel processing unit supports multi-core CPU and GPU acceleration to achieve simultaneous radial distortion correction and perspective distortion correction of the image.

[0056] The correction evaluation and decoding module is used to calculate the contrast, sharpness, uniformity, and noise of the corrected image, evaluate the quality of the corrected image. When the quality threshold is met, the barcode area of the corrected image is re-positioned and segmented, and the segmented barcode image is decoded to output barcode information.

[0057] The calibration and evaluation decoding module adopts a multi-level evaluation strategy. The first level is a quick evaluation, which calculates the basic quality indicators of the image and takes about 1-2 milliseconds. The second level is a detailed evaluation, which calculates all quality indicators and takes about 5-10 milliseconds. The third level is a precise evaluation, which includes additional statistical analysis and takes about 20-30 milliseconds. The decoding module supports multiple barcode types, including Code128, Code 39, EAN-13, QR code, etc. For different barcode types, corresponding decoding algorithms and parameter settings are adopted. The system has a built-in barcode type recognition function, which can automatically judge the barcode type and select a suitable decoder.

[0058] 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 two-dimensional codes that support error correction, the system will use the Reed-Solomon error correction algorithm to repair minor data errors.

[0059] In a large logistics distribution center, an intelligent sorting system based on the present invention is deployed. The system needs to handle the sorting tasks of 10,000 packages per hour, and the barcodes on each package may have different degrees of distortion.

[0060] The system is configured as an 8-core CPU server, equipped with 2 NVIDIA RTX 3080 GPUs and 64GB of memory. By adopting the parallel processing architecture of the present invention, the following performance indicators are achieved: image preprocessing speed: 250fps (frames per second); distortion correction speed: 200fps; quality evaluation and decoding speed: 300fps; overall system latency is less than 20 milliseconds.

[0061] During the actual operation for 3 months, the system processed more than 2 million packages, and the barcode recognition success rate reached 96.2%. Compared with the original system (success rate of 90.5%), it increased by 5.7 percentage points. Especially for barcodes with obvious distortion, the success rate increased from 62.3% to 84.8%, significantly improving the sorting efficiency.

[0062] The specific embodiments described above further elaborate on the purpose, technical solutions, and beneficial effects of the present invention. It should be understood that the above description is only the specific embodiments of the present invention and is not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A distortion image correction and decoding method for a barcode reader based on machine vision, which is used to correct the distortion of the image read by the barcode reader, and is characterized in that, The method includes the following steps: Step S1: Obtain the original image containing the barcode through an image acquisition device, preprocess the original image, including grayscale conversion, noise reduction, and edge detection, perform barcode area positioning and feature extraction on the preprocessed image, and extract the pixel coordinates in the image, the principal point coordinates of the image, the point coordinates on the barcode straight line, the radial distance from the pixel point to the principal point of the image, and the interior angles of the outer rectangular contour of the image; Step S2: Judge the distortion type of the image according to the extracted features. The distortion types include radial distortion and perspective distortion. When it is judged that the image has radial distortion, use the radial distortion correction model to perform fourth-order radial distortion correction on the image. When it is judged that the image has perspective distortion, use the perspective transformation matrix to perform perspective transformation on the image to achieve perspective distortion correction; Step S3: Calculate the contrast, sharpness, uniformity, and noise of the corrected image, perform quality evaluation on the corrected image. When the quality threshold is met, re-position and segment the barcode area of the corrected image, and perform decoding processing on the segmented barcode image to output barcode information.

2. The method according to claim 1, characterized in that Calculate the average curvature of a straight line based on the point coordinates on the barcode straight line to determine whether there is radial distortion in the image: , where N is the total number of detected points on the straight line, ; is the coordinate of the th detected point on the straight line, ; is the average curvature of the straight line. When , it is determined that there is radial distortion; is the curvature threshold, taking 0.

005.

3. The method according to claim 2, wherein When it is judged that the image has radial distortion, use the radial distortion correction model 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 point to the principal point of the image is: ; is the pixel coordinate in the distorted image, is the pixel coordinate after correction; is the principal point coordinate of the image, that is, the intersection point of the optical axis and the imaging plane; 、 、 、 are the distortion coefficients of the radial distortion correction model; is the tangential distortion coefficient, which corrects the distortion caused by the lens assembly error, and the value range is [-0.01, 0.01].

4. The method according to claim 2, wherein The radial distortion correction model adopts fourth-order radial distortion correction. is the first-order radial distortion coefficient, and its value range is [-0.5, 0.5], which is used to control barrel or pincushion distortion. is the second-order radial distortion coefficient, and its value range is [-0.1, 0.1], which is used to correct the second-order distortion component. is the third-order radial distortion coefficient, and its value range is [-0.01, 0.01], which is used to supplement and correct the second-order distortion component. is the fourth-order radial distortion coefficient, and its value range is [-0.001, 0.001], which is used for fine correction of residual distortion.

5. The method according to claim 4, characterized in that, Calculate the angular deviation of the rectangle according to the interior angles of the outer rectangular contour of the image. When the mean value of the angular deviation is greater than the preset angular deviation threshold, it is determined that there is perspective distortion in the image. The angular deviation threshold is 5°; the calculation formula for the angular deviation is: ; where is the th interior angle of the rectangle, ; is the mean value of the angular deviation.

6. The method according to claim 5, wherein When perspective distortion is detected, perspective transformation matrix is used for correction, and the transformation matrix is expressed as: ; where is the scaling factor in the axis and axis directions, and its value range is [0.5, 2.0], is the shear transformation coefficient, which controls the inclination degree of the image, and its value range is [-0.5, 0.5]; is the translation amount in the axis and axis directions; is the perspective transformation coefficient, which controls the trapezoid correction degree, and its value range is [-0.001, 0.001]; is the normalization coefficient, which is set to 1; is the pixel coordinates transformed by the transformation matrix; is the transformation redundancy term; Constraint satisfaction: , ensuring the effectiveness of the transformation.

7. The method according to claim 6, wherein Calculate the contrast, sharpness, uniformity, and noise of the corrected image, perform quality evaluation on the corrected image. The quality evaluation formula is: ; where, is the quality assessment value, is the contrast quality, , are the average gray values of the white and black areas of the barcode respectively; is a small constant to prevent division by zero, taking ; is the sharpness quality, ; are the width and height of the image respectively, is the Laplacian operator at the position (x, y) for detecting edge sharpness; is the uniformity quality, ; is the standard deviation of gray values in the local area; is the global average gray value; is the noise quality, , ; are the signal mean and the noise standard deviation respectively; is the weight coefficient, satisfying ; When it indicates that the quality threshold is met. At this time, the corrected image barcode area is located and segmented.

8. The method according to claim 7, wherein When positioning and segmenting the barcode area of the corrected image, the barcode area positioning uses gradient direction consistency detection: , where the gradient direction is calculated as: ; R is the candidate barcode region, which contains the set of all pixels to be detected; |R| is the total number of pixels in region R, are the gradient components in the x - direction and y - direction at the position (x, y) respectively; is the dominant gradient direction within the region, obtained through histogram statistics; When it is considered that the candidate barcode area R is the barcode area; the decoder divides the barcode area based on the white and black pixel points of the barcode area, identifies and outputs the barcode information.

9. A distortion image correction and decoding system of a code reader based on machine vision, which is used to execute the method described in any one of claims 1-8, characterized in that, The system includes: an image preprocessing module, a distortion correction module, and a correction evaluation and decoding module; The image preprocessing module is used to obtain the original image containing the barcode through an image acquisition device, preprocess the original image, including grayscale conversion, noise reduction, and edge detection, perform barcode area positioning and feature extraction on the preprocessed image, and extract the pixel coordinates in the image, the principal point coordinates of the image, the point coordinates on the barcode straight line, the radial distance from the pixel point to the principal point of the image, and the interior angles of the outer rectangular contour of the image; The distortion correction module is used to judge the distortion type of the image according to the extracted features. The distortion types include radial distortion and perspective distortion. When it is judged that the image has radial distortion, use the radial distortion correction model to perform fourth-order radial distortion correction on the image. When it is judged that the image has perspective distortion, use the perspective transformation matrix to perform perspective transformation on the image to achieve perspective distortion correction; The correction evaluation and decoding module is used to calculate the contrast, sharpness, uniformity, and noise of the corrected image, perform quality evaluation on the corrected image. When the quality threshold is met, re-position and segment the barcode area of the corrected image, and perform decoding processing on the segmented barcode image to output barcode information.

10. The system according to claim 9, wherein 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 judge the distortion type of the image according to the average straightness of the straight line calculated from the point coordinates on the barcode straight line and the rectangular angle deviation calculated from the interior angles of the outer rectangular contour of the image; The radial distortion correction unit is used to perform fourth-order radial distortion correction on the image using the radial distortion correction model when it is judged that the image has radial distortion; The perspective distortion correction unit is used to perform perspective transformation on an 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 update of parameters and historical version management; The parallel processing unit supports multi-core CPU and GPU acceleration to simultaneously perform radial distortion correction and perspective distortion correction on an image.

Citation Information

Patent Citations

  • Complicated background bar code image automatic partitioning method based on gradient direction consistency

    CN104636706A

  • Two-dimensional code identification method, device and equipment

    CN110046529A

  • Camera parameter accuracy determination method and device, storage medium and terminal

    CN111145271A

  • Camera lens distortion correction method based on sparse dimension reduction

    CN118195970A

  • Multi-lens iris recognition module and recognition method

    CN119445646A

Cited By

  • Code scanning image optimization method for flat panel camera

    CN120976058A

  • A code scanning image optimization method for a flat camera

    CN120976058B

  • Liquid level indicating instrument reading recognition method based on image recognition

    CN121527748A

  • A liquid level indicating instrument reading recognition method based on image recognition

    CN121527748B

  • Skin prick test image data processing and wind mass feature extraction method and system

    CN122453806A