Image correction method, device, linear array camera and storage medium
By calculating the distortion coefficient in the online array camera to correct the image, the low imaging efficiency and distortion problems of the linear array camera when the object movement speed changes are solved, adaptive image correction is achieved, and image acquisition efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202411895693.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2044-12-20
AI Technical Summary
In the prior art, linear array cameras need to be recalibrated when the object's movement speed changes, resulting in low image acquisition efficiency and severe imaging distortion in non-uniform motion scenarios, making it difficult to adapt to variable speed motion scenarios.
By acquiring the object to be measured and the background code included in the image captured by the linear array camera, the distortion coefficient of the background code is calculated, and the image of the object to be measured is corrected using this coefficient to realize adaptive image correction and adapt to the speed change and uniform motion scenes.
There is no need to precalibrate the line array camera, which reduces the difficulty of matching and debugging between the line frequency and the object movement speed, expands the application scenario, improves image acquisition efficiency, reduces image distortion, and improves the accuracy of subsequent processing.
Smart Images

Figure CN119379567B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine vision technology, and in particular to an image correction method, device, linear array camera, and storage medium. Background Art
[0002] Scanning moving objects with a line scan camera is a common image acquisition method. For example, in smart logistics applications, a line scan camera is used to scan and identify barcodes on packages being transported on a conveyor belt. To obtain clearer images and more accurate recognition results, the object's motion speed should match the imaging speed of the line scan camera to reduce the likelihood of image distortion. In related technologies, most pre-calibrate the line scan camera using a moving calibration plate. The calibrated line scan camera is then used to scan objects moving at the same speed as the calibration plate. However, if the object's motion speed changes, the line scan camera needs to be recalibrated, resulting in lower image acquisition efficiency. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide an image correction method, device, line array camera, and storage medium to improve the efficiency of image acquisition. The specific technical solutions are as follows:
[0004] In a first aspect, an embodiment of the present application provides an image correction method, comprising:
[0005] Acquire a first image captured by a linear array camera, wherein the first image includes the object to be measured and a background code in the same motion state;
[0006] Determining the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image;
[0007] Comparing the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient;
[0008] The image to be corrected is corrected using the distortion coefficient to obtain a target image of the object to be measured.
[0009] In one possible implementation, the collection field of view of the linear array camera includes multiple background codes placed at equal distances. The background codes placed at each distance include at least two background codes with different sizes and contents, which are respectively adapted to the maximum line frequency and the minimum line frequency of the linear array camera. The scanning direction of the background code is consistent with the movement direction of the object to be measured.
[0010] In a possible implementation, determining the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image includes:
[0011] Identifying the object to be measured and the background code on the first image to obtain the image to be corrected of the object to be measured and the distorted coordinates of each vertex of the background code;
[0012] Based on the distorted coordinates of each vertex, the size information to be corrected of the background code is determined.
[0013] In a possible implementation, the standard information includes a standard size ratio, and comparing the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient includes:
[0014] Using the ratio of the size information to be corrected to the standard size, the information to be corrected is compared with the standard information to obtain the degree of distortion of the background code;
[0015] A current distortion coefficient is determined based on the distortion degree of the background code.
[0016] In one possible implementation, the size information to be corrected includes width and height information to be corrected, the standard size ratio includes a standard width and height ratio, and comparing the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient includes:
[0017] Calculating the projection of the background code's width and height to be corrected in the first direction without distortion according to the distortion coordinates and the width and height information to be corrected;
[0018] Correcting the to-be-corrected width-height projection using the standard width-height ratio to obtain the undistorted coordinates of the background code;
[0019] The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficient.
[0020] In one possible implementation, the object to be measured is a package including a barcode, the image to be corrected includes the barcode, and correcting the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured includes:
[0021] The barcode image in the image to be corrected is corrected using the distortion coefficient to obtain a target image of the barcode.
[0022] In a possible implementation, after obtaining the target image, the method further includes:
[0023] Obtaining the current line frequency of the linear array camera;
[0024] Correcting the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera;
[0025] The line frequency of the line array camera is adjusted to the target line frequency.
[0026] In a second aspect, an embodiment of the present application provides an image correction device, comprising:
[0027] An image acquisition module, configured to acquire a first image captured by the linear array camera, wherein the first image includes the object to be measured and the background code in the same motion state;
[0028] An information determination module, configured to determine the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image;
[0029] A distortion coefficient determination module, configured to compare the difference between the standard information of the background code and the information to be corrected to determine a current distortion coefficient;
[0030] The image correction module is used to correct the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured.
[0031] In a possible implementation, the information determination module is specifically configured to:
[0032] Identifying the object to be measured and the background code on the first image to obtain the image to be corrected of the object to be measured and the distorted coordinates of each vertex of the background code;
[0033] Based on the distorted coordinates of each vertex, the size information to be corrected of the background code is determined.
[0034] In a possible implementation, the standard information includes a standard size ratio, and the distortion coefficient determination module is specifically configured to:
[0035] Using the ratio of the size information to be corrected to the standard size, the information to be corrected is compared with the standard information to obtain the degree of distortion of the background code;
[0036] A current distortion coefficient is determined based on the distortion degree of the background code.
[0037] In a possible implementation, the size information to be corrected includes width and height information to be corrected, the standard size ratio includes a standard width and height ratio, and the distortion coefficient determination module is specifically configured to:
[0038] Calculating the to-be-corrected width and height projections of the background code in the first direction without distortion according to the distortion coordinates and the to-be-corrected width and height projections;
[0039] Correcting the to-be-corrected width-height projection using the standard width-height ratio to obtain the undistorted coordinates of the background code;
[0040] The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficient.
[0041] In a possible implementation, the object to be measured is a package including a barcode, the image to be corrected includes the barcode, and the image correction module is specifically configured to:
[0042] The barcode image in the image to be corrected is corrected using the distortion coefficient to obtain a target image of the barcode.
[0043] In a possible implementation, the apparatus further includes:
[0044] A line frequency acquisition module, used to acquire the current line frequency of the line array camera;
[0045] A line frequency correction module, configured to correct the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera;
[0046] A line frequency adjustment module is used to adjust the line frequency of the line array camera to the target line frequency.
[0047] In a third aspect, an embodiment of the present application provides a line scan camera, comprising:
[0048] An image collector, used for collecting images;
[0049] Memory for storing computer programs;
[0050] The processor is configured to implement any of the above-mentioned image correction methods when executing the program stored in the memory.
[0051] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements any of the above-mentioned image correction methods.
[0052] An embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-described image correction methods.
[0053] Beneficial effects of the embodiments of the present application:
[0054] The image correction method, device, line scan camera, and storage medium provided by the embodiments of the present application first obtain a first image captured by a line scan camera, the first image including an object to be measured and a background code in the same motion state; determine the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image; compare the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient; and correct the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured. After the line scan camera scans the image of the object to be measured, the current distortion coefficient is calculated using the background code, and the image of the object to be measured is directly corrected using the distortion coefficient to reduce the distortion of the image output by the line scan camera. This method achieves adaptive alignment between the line scan camera's line frequency and the speed of the object to be measured. Pre-calibration of the line scan camera is unnecessary, regardless of whether the scene is a variable-speed motion scene or a uniform-speed motion scene. This reduces the difficulty of matching and debugging the line scan camera's line frequency with the object's motion speed, expands the application scenarios of line scan cameras, and improves the efficiency of image acquisition using line scan cameras. Furthermore, the distortion of the output image is reduced, further improving the accuracy of subsequent processing of the output image of the line scan camera.
[0055] Of course, it is not necessary to achieve all the advantages described above at the same time when implementing any product or method of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0057] Figure 1-1 A schematic flow chart of the first image correction method provided in an embodiment of the present application;
[0058] Figure 1-2 This is a structural example diagram of a line scan camera provided in an embodiment of the present application;
[0059] Figure 1-3 An example diagram of a background code provided in an embodiment of the present application;
[0060] Figure 1-4 This is an example diagram of a background code under stretching distortion provided in an embodiment of the present application;
[0061] Figure 1-5 This is an example diagram of a background code under compression distortion provided by an embodiment of the present application;
[0062] Figure 1-6 A front view of a linear array camera and a conveyor belt in a parcel barcode recognition application scenario provided by an embodiment of the present application;
[0063] Figure 1-7 A top view of a linear array camera and a conveyor belt in a parcel barcode recognition application scenario provided by an embodiment of the present application;
[0064] Figure 1-8 This is an example diagram of placing background codes on a multi-segment conveyor belt provided in an embodiment of the present application;
[0065] Figure 1-9 This is an example diagram of a first image in a package barcode recognition application scenario provided by an embodiment of the present application;
[0066] Figure 2 A possible implementation of step S103 provided in an embodiment of the present application;
[0067] Figure 3-1 Another possible implementation of step S103 provided in the embodiment of the present application;
[0068] Figure 3-2 This is an example diagram of the distorted coordinates of each vertex of a background code provided in an embodiment of the present application;
[0069] Figure 3-3 This is an example diagram of calculating a distortion coefficient provided in an embodiment of the present application;
[0070] Figure 4 A schematic flow chart of a second image correction method provided in an embodiment of the present application;
[0071] Figure 5 A schematic structural diagram of an image correction device provided in an embodiment of the present application;
[0072] Figure 6 A schematic structural diagram of a line array camera provided in an embodiment of the present application. DETAILED DESCRIPTION
[0073] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field based on this application are within the scope of protection of this application.
[0074] Line scan cameras capture images of objects in their field of view by scanning them line by line. As objects in motion pass through the field of view at a constant or variable speed, the camera accumulates images line by line based on the length of the photoelectric signal. This is then fed to a processing algorithm, which then uses the image recognition and detection. For example, a line scan camera can capture and output images of packages on a conveyor belt to identify the package's barcode (either a QR code or a 1D code).
[0075] The cumulative imaging principle of line scan cameras makes the image quality extremely susceptible to the speed of the object's motion. If the object's speed does not match the line scan camera's line frequency (the number of exposures per unit time, or scans per second), the image is easily distorted. For example, if the object's speed exceeds the line scan camera's line frequency, the image appears compressed; if the object's speed is less than the line frequency, the image appears stretched.
[0076] To reduce the probability of image distortion, even in scenes with uniformly moving objects, it's necessary to pre-calibrate the line scan camera's line rate against the object's speed using a calibration board (such as a black and white board or a checkerboard board). This allows the camera to be calibrated at the current speed. However, in scenes with non-uniform motion, line scan cameras still face image distortion and distorted output images. Calibration based on each object's speed is inefficient.
[0077] In order to solve at least one of the above problems, embodiments of the present application provide an image correction method, device, line array camera, and storage medium.
[0078] The following is a detailed description of the image correction method provided in the embodiment of the present application. Figure 1-1 , Figure 1-1 A flowchart of a first image correction method is provided for an embodiment of the present application, including:
[0079] Step S101: Acquire a first image captured by a line array camera.
[0080] The first image includes the object to be detected and the background code in the same motion state.
[0081] A line scan camera is a camera that captures one line of image per exposure and outputs an image obtained by stitching multiple lines of images. Figure 1-2 As shown, including the centrally located camera.
[0082] The line scan camera always scans images toward its field of view. The background code is within the line scan camera's field of view. The first image represents the image of the object under test captured by the line scan camera as it passes through the camera's field of view, including the background code within the field of view. Exemplarily, the background code can be various one-dimensional codes (barcodes), such as EAN (European Article Number), Code 39, Interleaved 2 of 5, UPC (Universal Product Code), Code 128, Code 93, Codabar, and so on.
[0083] In one embodiment of the present application, the line scan camera's field of view includes multiple background codes placed at equal distances. The background codes placed at each distance include at least two background codes of different sizes and content, adapted to the maximum and minimum line frequencies of the line scan camera, respectively, and distinguishable after recognition. The background codes are scanned in a direction consistent with the direction of motion of the object to be detected.
[0084] To ensure that the first image output by the line scan camera each time includes the background code, multiple background codes are placed at equal distances within the acquisition field of view of the line scan camera. The spacing is determined according to the actual line frequency of the line scan camera, so that the first image output by the line scan camera each time includes at least one complete background code.
[0085] When the object's speed and the camera's line rate don't match, the image will be distorted by stretching or compression. To ensure that the first image includes at least one complete background code at any degree of distortion, at least two barcode sizes are placed at each distance to capture the complete background code image at both the maximum and minimum line rates of the linear array camera.
[0086] For example Figure 1-3 As shown in the figure, the background code includes bar codes of three ratio sizes (2:1, 3:1, and 4:1) placed at equal distances. Under the condition of high line frequency and low motion speed, the image stretching and distortion reaches the maximum, and only the background code with a ratio of 4:1 can be completely captured. Figure 1-4 As shown in the figure; in the case of low line frequency and high motion speed, the image compression distortion reaches the maximum. Although the three background codes can all capture complete images, the 4:1 background code is difficult to be fully recognized due to the reduction of vertical pixels after compression. Only the 2:1 background code can be recognized and further processed, as shown in the figure. Figure 1-5 shown.
[0087] The specific size of the background code is set according to the line frequency parameter of the line array camera in actual application.
[0088] The scanning direction of the background code is consistent with the direction of motion of the object to be measured to reduce distortion errors introduced by tilt factors. In this case, the image distortion usually only occurs in one direction, namely the direction of motion, and the direction of no distortion is perpendicular to the direction of motion.
[0089] For example, Figure 1-6 and Figure 1-7 As shown in the application scenario of package barcode recognition, the line scan camera scans the image toward the moving conveyor belt, and the background code is placed at an equal distance on the conveyor belt. The first image of the package captured by the line scan camera includes the background code. In one example, for a multi-section conveyor belt, the background code can be attached to the conveyor belt around a special tape loop, such as Figure 1-8As shown, the three background codes in the frame on the conveyor belt are enlarged as shown in Figure 1-3 shown.
[0090] Step S102 : determining the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image.
[0091] The first image includes the object to be measured and the background code. An image of the object to be measured is determined within the image. Because it may be distorted, this image is used as the image to be corrected for the object to be measured. The image of the background code is determined within the first image, and information to be corrected for the detected background code is identified. Exemplarily, the information to be corrected may include background code size information or content identification information of the background code.
[0092] Step S103 : comparing the standard information of the background code with the information to be corrected to determine the current distortion coefficient.
[0093] The standard information of the background code is the real information collected in advance, such as the real size information and real content identification information of the background code. The difference between the standard information of the background code and the information to be corrected is compared to determine the current distortion coefficient.
[0094] In one embodiment of the present application, the above step S102 determines the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image, including:
[0095] Step 1: Identify the object to be measured and the background code on the first image to obtain the image to be corrected of the object to be measured and the distorted coordinates of each vertex of the background code;
[0096] Step 2: Determine the size information to be corrected of the background code based on the distorted coordinates of each vertex.
[0097] In the first image, a coordinate system is established with a vertex of the background code as the origin, the direction of motion of the object to be measured as the Y-axis, and the direction perpendicular to the motion as the X-axis. The coordinates of each vertex of the background code are identified to obtain the distorted coordinates. Specifically, this can also be achieved using a code reading algorithm. In this case, the distortion of the background code is caused only by the motion along the Y-axis, while the X-axis is the first direction without distortion.
[0098] In the embodiment of the present application, the distortion coordinates of each vertex of the background code are obtained to determine the size information of the background code to be corrected, thereby providing a calculation basis for the subsequent calculation of the distortion coefficient.
[0099] In one embodiment of the present application, the above-mentioned standard information includes standard size ratios, such as Figure 2As shown, the above step S103 compares the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient, including:
[0100] Step S201, using the ratio of the size information to be corrected to the standard size, the information to be corrected is compared with the standard information to obtain the degree of distortion of the background code;
[0101] Step S202: determining a current distortion coefficient based on the distortion degree of the background code.
[0102] The size information to be corrected is compared with the standard size ratio to determine the current degree of distortion. Specifically, the degree of distortion includes the degree of tensile distortion and the degree of compressive distortion. The current distortion coefficient is determined based on the degree of distortion. Specifically, the distortion coefficient can be directly calculated to obtain coefficients in both positive and negative directions, corresponding to the degree of tensile distortion and the degree of compressive distortion, respectively. Alternatively, it can be determined in advance whether the distortion is in the tensile or compressive direction, and then a non-directional coefficient is determined for each direction.
[0103] The embodiment of the present application uses size information as a detection benchmark to identify and compare the degree of distortion of the background code. The collection of size information is relatively simple, and the calculation of the distortion coefficient based on this benchmark is also relatively easy, which can effectively improve the efficiency of image correction.
[0104] Step S104: Correcting the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured.
[0105] The distortion coefficient is used to correct the image of the object to be measured to obtain a target image of the object to be measured without distortion.
[0106] For example, the line scan camera can be embedded with a code reading algorithm to realize the correction information of the background code recognition, calculate the distortion coefficient, and use the distortion coefficient to correct the image of the object to be measured. The output of the line scan camera can be the target image after correction.
[0107] In one embodiment of the present application, the object to be measured is a package including a barcode, and the image to be corrected includes the barcode. Step S104 corrects the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured, including:
[0108] The barcode image in the image to be corrected is corrected using the distortion coefficient to obtain a target image of the barcode.
[0109] In the application scenario of package barcode recognition, such as Figure 1-9As shown, the first image includes a package and a barcode. The distortion coefficient is used to correct the package image, and the distortion coefficient is also used to correct the barcode image on the package to obtain a target image of the barcode, providing undistorted barcode information for subsequent barcode recognition, thereby improving the accuracy of barcode recognition.
[0110] As can be seen from the above, the image correction method provided in the embodiments of the present application first obtains a first image captured by a line scan camera, the first image including an object to be measured and a background code in the same motion state; determines the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image; compares the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient; and corrects the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured. After the line scan camera scans the image of the object to be measured, the current distortion coefficient is calculated using the background code, and the image of the object to be measured is directly corrected using the distortion coefficient to reduce the distortion of the image output by the line scan camera. This method achieves adaptive alignment between the line scan camera's line frequency and the object's motion speed. Whether in variable-speed or uniform motion scenarios, pre-calibration of the line scan camera is unnecessary, reducing the difficulty of matching and debugging the line scan camera's line frequency with the object's motion speed, expanding the application scenarios of line scan cameras, and improving image acquisition efficiency using line scan cameras. Furthermore, the distortion of the output image is reduced, further improving the accuracy of subsequent processing of the line scan camera's output image.
[0111] In one embodiment of the present application, the size information to be corrected includes width and height information to be corrected, and the standard size ratio includes a standard width and height ratio, such as Figure 3-1 As shown, the above step S103 compares the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient, including:
[0112] Step S301, calculating the projection of the background code in the first direction without distortion according to the distortion coordinates and the width and height information to be corrected;
[0113] Step S302, correcting the width and height projection to be corrected using a standard width and height ratio to obtain the distortion-free coordinates of the background code;
[0114] Step S303 : comparing the difference between the distorted coordinates and the undistorted coordinates to obtain the current distortion coefficients.
[0115] Based on the distorted coordinates of each vertex and the width and height information to be corrected, the projection coordinates of each vertex in the first direction (width and height projection) are calculated. The projection coordinates are corrected using the pre-standard aspect ratio of the background code to obtain the undistorted coordinates of the background code when it is undistorted. The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficient.
[0116] For example, when the background code is a barcode, the side that is consistent with the barcode is considered to be the height, and the side that is perpendicular to the barcode is considered to be the width. Figure 3-2 As shown, the camera recognizes and outputs the coordinates of the four distorted vertices: (X1, Y1), (X2, Y2), (X3, Y3), and (X4, Y4). Image distortion occurs only along the Y axis, caused by the barcode's motion within the camera's field of view. At a certain tilt angle, the projection of the height H on the X axis is denoted by H1, and the projection of the width W on the X axis is W1.
[0117]
[0118] Under the known standard distortion-free condition, the aspect ratio of the background code is 1 / 2 = tanα, the width of the X-axis is distortion-free, and the distortion-free coordinates of the vertex X1 are as follows: Figure 3-3 Shown are:
[0119]
[0120] The distortion coefficient β on the Y axis is:
[0121]
[0122] This is the tensile distortion coefficient.
[0123] As can be seen from the above, the image correction method provided in the embodiment of the present application uses the distortion coordinates of each vertex of the currently identified background code and the true width-to-height ratio of the background code obtained in advance to identify the degree of distortion of the background code and calculate the current distortion coefficient. The calculation method is simple and effective, further improving the efficiency of image correction.
[0124] In one embodiment of the present application, Figure 4 As shown, after obtaining the target image, the method further includes:
[0125] Step S401, obtaining the current line frequency of the line scan camera;
[0126] Step S402, correcting the current line frequency based on the distortion coefficient to obtain a target line frequency of the line scan camera;
[0127] Step S403: adjusting the line frequency of the line scan camera to the target line frequency.
[0128] The line scan camera's line frequency is adjusted to the target line frequency, which matches the exposure speed. Based on this, images of the object under test are captured at the same speed. If the distortion coefficient is less than a preset coefficient threshold, the image correction step is skipped, and the resulting image is considered distortion-free. If the object's speed changes and the distortion coefficient exceeds the preset coefficient threshold, the image correction step is repeated.
[0129] For example, if the current line frequency is N and the target line frequency is M, then the target line frequency is:
[0130]
[0131] As can be seen from the above, the image correction method provided by the embodiment of the present application determines the distortion coefficient based on size information and can be directly applied to correct the camera line frequency. Unlike the need to calibrate the line frequency and object movement speed in advance, the line frequency can be adjusted in real time, adapting to various object movement scenes, thereby improving the efficiency of image correction. Unlike the method of calculating the corrected image based on the line frequency and movement speed after the image is output, the program that may introduce distortion errors is reduced, the probability of image distortion is reduced, and the accuracy of the output image is improved. By adjusting the line frequency through the embedded scanning method of the linear array camera, compared with the third-party device in the related art that detects the object movement speed in real time and sends it to the camera for adjustment, the present application can achieve distortion-free image output based on the camera's own dynamic modification of the line frequency, without the need to build a third-party speed detection device, reducing the complexity brought by the third-party detection setup, improving the simplicity of camera line frequency correction, reducing the difficulty of debugging the camera line frequency, and further improving the efficiency of image acquisition.
[0132] See also Figure 5 , the embodiment of the present application further provides a structural schematic diagram of an image correction device, including:
[0133] An image acquisition module 501 is configured to acquire a first image captured by a linear array camera, wherein the first image includes an object to be measured and a background code in the same motion state;
[0134] An information determination module 502 is configured to determine the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image;
[0135] The distortion coefficient determination module 503 is used to compare the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient;
[0136] The image correction module 504 is configured to correct the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured.
[0137] As can be seen from the above, the image correction device provided in the embodiments of the present application first obtains a first image captured by a line scan camera, the first image including an object to be measured and a background code in the same motion state; determines the image to be corrected of the object to be measured and the information to be corrected of the background code based on the first image; compares the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient; and corrects the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured. After the line scan camera scans the image of the object to be measured, the current distortion coefficient is calculated using the background code, and the image of the object to be measured is directly corrected using the distortion coefficient to reduce the distortion of the image output by the line scan camera. This achieves adaptive alignment between the line scan camera's line frequency and the object's motion speed. Pre-calibration of the line scan camera is unnecessary for both variable-speed and uniform motion scenarios, reducing the difficulty of matching and debugging the line scan camera's line frequency with the object's motion speed, expanding the application scenarios of line scan cameras, and improving image acquisition efficiency using line scan cameras. Furthermore, the distortion of the output image is reduced, further improving the accuracy of subsequent processing of the line scan camera's output image.
[0138] In one embodiment of the present application, the information determination module 502 is specifically configured to:
[0139] Identifying the object to be measured and the background code on the first image to obtain the image to be corrected of the object to be measured and the distorted coordinates of each vertex of the background code;
[0140] Based on the distorted coordinates of each vertex, the size information to be corrected of the background code is determined.
[0141] In the embodiment of the present application, the distortion coordinates of each vertex of the background code are obtained to determine the size information of the background code to be corrected, thereby providing a calculation basis for the subsequent calculation of the distortion coefficient.
[0142] In one embodiment of the present application, the standard information includes a standard size ratio, and the distortion coefficient determination module 503 is specifically configured to:
[0143] Using the ratio of the size information to be corrected to the standard size, the information to be corrected is compared with the standard information to obtain the degree of distortion of the background code;
[0144] A current distortion coefficient is determined based on the distortion degree of the background code.
[0145] The embodiment of the present application uses size information as a detection benchmark to identify and compare the degree of distortion of the background code. The collection of size information is relatively simple, and the calculation of the distortion coefficient based on this benchmark is also relatively easy, which can effectively improve the efficiency of image correction.
[0146] In one embodiment of the present application, the size information to be corrected includes width and height information to be corrected, the standard size ratio includes a standard width-to-height ratio, and the distortion coefficient determination module 503 is specifically configured to:
[0147] Calculating the to-be-corrected width and height projections of the background code in the first direction without distortion according to the distortion coordinates and the to-be-corrected width and height projections;
[0148] Correcting the to-be-corrected width-height projection using the standard width-height ratio to obtain the undistorted coordinates of the background code;
[0149] The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficient.
[0150] As can be seen from the above, the image correction device provided in the embodiment of the present application uses the width and height information of the currently identified background code and the true width and height ratio of the background code obtained in advance to identify the degree of distortion of the background code and calculate the current distortion coefficient. The calculation method is simple and effective, which further improves the efficiency of image correction.
[0151] In one embodiment of the present application, the object to be measured is a package including a barcode, the image to be corrected includes the barcode, and the image correction module 504 is specifically configured to:
[0152] The barcode image in the image to be corrected is corrected using the distortion coefficient to obtain a target image of the barcode.
[0153] In the package barcode recognition application scenario, the distortion coefficient is used to correct the package image. At the same time, the distortion coefficient is also used to correct the barcode image on the package to obtain the target image of the barcode, providing undistorted barcode information for subsequent barcode recognition and improving the accuracy of barcode recognition.
[0154] In one embodiment of the present application, the device further comprises:
[0155] A line frequency acquisition module, used to acquire the current line frequency of the line array camera;
[0156] A line frequency correction module, configured to correct the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera;
[0157] A line frequency adjustment module is used to adjust the line frequency of the line array camera to the target line frequency.
[0158] As can be seen from the above, the image correction device provided by the embodiment of the present application determines the distortion coefficient based on size information and can be directly applied to correct the camera line frequency. Unlike the need to calibrate the line frequency and object movement speed in advance, it can adjust the line frequency in real time, adapt to various object movement scenes, and improve the efficiency of image correction. Unlike the method of calculating the corrected image based on the line frequency and movement speed after the image is output, it reduces the procedures that may introduce distortion errors, reduces the probability of image distortion, and improves the accuracy of the output image. By adjusting the line frequency through the embedded scanning method of the linear array camera, compared with the third-party device in the related art that detects the object movement speed in real time and sends it to the camera for adjustment, the present application can achieve distortion-free image output based on the camera's own dynamic modification of the line frequency, without the need to build a third-party speed detection device, reducing the complexity brought by the third-party detection setup, improving the simplicity of camera line frequency correction, reducing the difficulty of debugging the camera line frequency, and further improving the efficiency of image acquisition.
[0159] The present application also provides a line array camera, such as Figure 6 Shown, including:
[0160] Image collector 601, used for collecting images;
[0161] Memory 602, for storing computer programs;
[0162] The processor 603 is configured to implement any of the above-mentioned image correction methods when executing the program stored in the memory.
[0163] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 603, the communication interface, and the memory 602 communicate with each other via the communication bus.
[0164] The communication bus mentioned in the electronic devices mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into address buses, data buses, control buses, etc. For ease of illustration, only a single thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0165] The communication interface is used for communication between the above electronic device and other devices.
[0166] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0167] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0168] In another embodiment provided in the present application, a computer-readable storage medium is further provided, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the steps of any of the above-mentioned image correction methods are implemented.
[0169] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the image correction methods in the above embodiments.
[0170] In the above embodiments, all or part of the embodiments can be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disk, hard disk, tape), optical media (e.g., DVD), or solid-state drive (SSD).
[0171] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0172] Each embodiment in this specification is described in a related manner. Similar portions between the embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences from other embodiments. In particular, the device embodiments are generally similar to the method embodiments, so their description is relatively simple. For related portions, refer to the description of the method embodiments.
[0173] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.
Claims
1. An image correction method, characterized in that: include: Acquire a first image captured by a line array camera, wherein the first image includes the object to be measured and a background code in the same motion state, the motion state including one of uniform speed motion and variable speed motion, and the background code is attached to a conveyor belt used to convey the object to be measured; Identifying the object to be measured and the background code on the first image to obtain a to-be-corrected image of the object to be measured and distorted coordinates of each vertex of the background code, wherein the distorted coordinates are coordinates of each vertex distorted due to stretching or compression distortion of the first image when a motion speed of the background code does not match a line frequency of the line scan camera; Determining size information to be corrected of the background code based on the distorted coordinates of each vertex, wherein the size information to be corrected includes width and height information to be corrected; Calculating the projection of the background code's width and height to be corrected in the first direction without distortion according to the distortion coordinates and the width and height information to be corrected; Correcting the to-be-corrected width-height projection using a standard width-height ratio to obtain the undistorted coordinates of the background code; Comparing the difference between the distorted coordinates and the undistorted coordinates to obtain the current distortion coefficient; The image to be corrected is corrected using the distortion coefficient to obtain a target image of the object to be measured.
2. The method according to claim 1, characterized in that The collection field of view of the line array camera includes multiple background codes placed at equal distances. The background codes placed at each distance include at least two background codes of different sizes and contents, which are respectively adapted to the maximum line frequency and the minimum line frequency of the line array camera. The scanning direction of the background codes is consistent with the movement direction of the object to be measured.
3. The method according to claim 1, characterized in that The object to be measured is a package including a barcode, the image to be corrected includes the barcode, and correcting the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured includes: The barcode image in the image to be corrected is corrected using the distortion coefficient to obtain a target image of the barcode.
4. The method according to claim 1, wherein After obtaining the target image, the method further includes: Obtaining the current line frequency of the linear array camera; Correcting the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera; The line frequency of the line array camera is adjusted to the target line frequency.
5. An image correction device, characterized in that: include: an image acquisition module, configured to acquire a first image captured by a line array camera, wherein the first image includes an object to be measured and a background code in the same motion state, the motion state including one of uniform motion and variable speed motion, and the background code is affixed to a conveyor belt used to convey the object to be measured; an information determination module, configured to identify the object to be measured and the background code in the first image, and obtain the image to be corrected of the object to be measured and the distorted coordinates of each vertex of the background code, wherein the distorted coordinates are the coordinates of each vertex distorted due to stretching or compression distortion of the first image when a motion speed of the background code does not match a line frequency of the line array camera; Determining size information to be corrected of the background code based on the distorted coordinates of each vertex, wherein the size information to be corrected includes width and height information to be corrected; A distortion coefficient determination module, configured to calculate the to-be-corrected width and height projections of the background code in the first direction without distortion based on the distortion coordinates and the to-be-corrected width and height projections; Correcting the to-be-corrected width-height projection using a standard width-height ratio to obtain the undistorted coordinates of the background code; Comparing the difference between the distorted coordinates and the undistorted coordinates to obtain the current distortion coefficient; The image correction module is used to correct the image to be corrected using the distortion coefficient to obtain a target image of the object to be measured.
6. The device according to claim 5, characterized in that The object to be measured is a package including a barcode, the image to be corrected includes the barcode, and the image correction module is specifically configured to: The barcode image in the image to be corrected is corrected using the distortion coefficient to obtain a target image of the barcode.
7. The device according to claim 5, characterized in that The device further comprises: A line frequency acquisition module, used to acquire the current line frequency of the line array camera; A line frequency correction module, configured to correct the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera; A line frequency adjustment module is used to adjust the line frequency of the line array camera to the target line frequency.
8. A line array camera, characterized in that: include: An image collector, used for collecting images; Memory for storing computer programs; A processor, configured to implement the method according to any one of claims 1 to 4 when executing a program stored in a memory.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Regulating and calibrating method for linear array CCD scanning detection system
CN101365144A
Battery piece defect detection method, detection device, detection system and storage medium
CN118150592A