Image correction method and device, line-scan digital camera and storage medium
By identifying the background code and objects in the image of the camera, calculate the coefficient of distortion and correct the image, solve the problem that the camera in the existing technology needs to be defined in advance to match the speed of the object, realize the adaptive image collection, improve efficiency and accurate accuracy sex.
Patent Information
- Application Number
- CN202411895693.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-12-20
AI Technical Summary
When scanning moving objects with a linear array camera, the prior art needs to precalibrate the camera in advance to match the moving speed of the object, resulting in low image acquisition efficiency and recalibration when the object speed changes, increasing the debugging difficulty.
By obtaining the image collected by the wire array camera, identify the objects and background code to be tested, calculate the distortion coefficient of the background code, and use this coefficient to correct the image of the object to realize the imageless output of the image. At the same time, adjust the frequency of the camera to match to match Motion speed of objects.
The adaptive image acquisition of the linear camera in the field of transmission or uniform speed, does not need to calibrate the camera in advance, reduce the difficulty of debugging, improve the efficiency of image collection, reduce image distortion, and improve the accuracy of subsequent processing.
Smart Images

Figure CN119379567A_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] Using a linear array camera to scan moving objects is a common image acquisition method. For example, in smart logistics application scenarios, a linear array camera is used to scan and identify the barcode of a package being transported on a conveyor belt. In order to obtain clearer images and more accurate recognition results, the object's movement speed should match the imaging speed of the linear array camera to reduce the probability of imaging distortion. In related technologies, most of them use a moving calibration plate to pre-calibrate the linear array camera, and use the calibrated linear array camera to scan objects at the same movement speed as the calibration plate. However, when the object's movement speed changes, the linear array camera needs to be recalibrated, resulting in low efficiency in acquiring images. 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 solution is 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] 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;
[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 a possible implementation, the collection field of view of the linear array camera includes a plurality of background codes placed at equal distances, and 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 linear array camera, and the scanning direction of the background code is consistent with the movement direction of the object to be measured.
[0010] In a possible implementation manner, determining the image to be corrected of the object to be detected and the information to be corrected of the background code based on the first image includes:
[0011] Identify the object to be detected and the background code on the first image to obtain the image to be corrected of the object to be detected and the distorted coordinates of each vertex of the background code;
[0012] Based on the distorted coordinates of each of the vertices, 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] By 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] Based on the distortion degree of the background code, a current distortion coefficient is determined.
[0016] 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 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] Calculate 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 distortion-free coordinates of the background code;
[0019] The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficients.
[0020] In a 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 manner, 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, including:
[0027] An image acquisition module, used 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, used 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, used for comparing the difference between the standard information of the background code and the information to be corrected, and determining the current distortion coefficient;
[0030] The image correction module is used to correct the image to be corrected by using the distortion coefficient to obtain a target image of the object to be measured.
[0031] In a possible implementation manner, the information determination module is specifically configured to:
[0032] Identify the object to be detected and the background code on the first image to obtain the image to be corrected of the object to be detected and the distorted coordinates of each vertex of the background code;
[0033] Based on the distorted coordinates of each of the vertices, the size information to be corrected of the background code is determined.
[0034] In a possible implementation manner, the standard information includes a standard size ratio, and the distortion coefficient determination module is specifically configured to:
[0035] By 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] Based on the distortion degree of the background code, a current distortion coefficient is determined.
[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] Calculate 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 distortion-free coordinates of the background code;
[0040] The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficients.
[0041] In a possible implementation, the object to be detected 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 manner, the device 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, used for correcting the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera;
[0046] The 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 array camera, including:
[0048] An image collector, used for collecting images;
[0049] Memory, used to store computer programs;
[0050] The processor is used 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, the image correction method described above is implemented.
[0052] An embodiment of the present application also 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, linear array camera and storage medium provided in the embodiment of the present application first obtain a first image captured by the linear array camera, wherein the first image includes an object to be measured and a background code in the same motion state; based on the first image, determine the image to be corrected of the object to be measured and the information to be corrected of the background code; compare the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient; correct the image to be corrected using the distortion coefficient to obtain the target image of the object to be measured. After the linear array 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 linear array camera. The line frequency of the linear array camera and the motion speed of the object to be measured are adaptively matched. Whether in a variable speed motion scene or a uniform speed motion scene, the linear array camera does not need to be calibrated in advance, which reduces the difficulty of matching and debugging the line frequency of the linear array camera and the object motion speed, expands the application scene of the linear array camera, and realizes the use of the linear array camera to improve the efficiency of image acquisition. In addition, the distortion of the output image is reduced, and the accuracy of subsequent processing of the output image of the linear array camera is further improved.
[0055] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. 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 drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0057] Figure 1-1 A schematic diagram of a flow chart of a 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 array 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 An example diagram of a background code under compression distortion provided in an embodiment of the present application;
[0062] Figure 1-6 A front view of the installation 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 the installation of a linear array camera and a conveyor belt in a parcel barcode recognition application scenario provided in an embodiment of the present application;
[0064] Figure 1-8 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 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 An example diagram of distorted coordinates of each vertex of a background code provided in an embodiment of the present application;
[0069] Figure 3-3 An example diagram of calculating a distortion coefficient provided in an embodiment of the present application;
[0070] Figure 4 A schematic diagram of a flow chart of a second image correction method provided in an embodiment of the present application;
[0071] Figure 5 A schematic diagram of the structure 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 the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0074] The linear array camera collects images of objects in the field of view by scanning line by line. When the object passes through the field of view at a constant or variable speed in motion, the linear array camera accumulates images line by line according to the length of the photoelectric signal and outputs them to the processing algorithm, which then uses the processing algorithm to identify and detect the image. For example, the image of the package on the conveyor belt is collected and output to realize the barcode (two-dimensional code or one-dimensional code) recognition of the package.
[0075] The cumulative imaging principle of the line array camera makes the imaging effect easily affected by the speed of the object. When the object speed does not match the line frequency of the line array camera (the number of exposures per unit time, that is, the number of scans per second of the line array camera), the imaging is easily distorted. For example, when the object speed is greater than the line frequency of the line array camera, the object image is compressed; when the object speed is less than the line frequency, the image is stretched.
[0076] In order to reduce the probability of imaging distortion, even in scenes where objects move at a uniform speed, it is necessary to use calibration plates (such as black and white plates, checkerboard plates, etc.) to repeatedly test the matching degree between the line frequency of the linear array camera and the object's speed in advance, so as to calibrate the linear array camera at the current speed. However, in scenes where objects move at non-uniform speeds, linear array cameras still have imaging distortion and output image distortion problems, and if calibration is performed based on the speed of each object, the efficiency is too low.
[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, obtaining 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 for each field of view and outputs an image obtained by stitching multiple lines of images. Figure 1-2 As shown, including a centrally located camera.
[0082] The linear array camera always scans the image towards the acquisition field of view. The background code is in the acquisition field of view of the linear array camera. The first image represents the image of the object to be measured captured by the linear array camera when the object to be measured passes through the acquisition field of view of the linear array camera, including the background code in the acquisition field of view. Exemplarily, the background code can be various one-dimensional codes (barcodes), such as EAN code (European Article Number), 39 code, cross 25 code, UPC code (Universal Product Code), 128 code, 93 code, Codabar code, etc.
[0083] In one embodiment of the present application, the collection field of view of the line array camera includes a plurality of background codes placed at equal distances, and the background codes placed at each distance include at least two background codes of different scales and contents, which are respectively adapted to the maximum line frequency and the minimum line frequency of the line array camera and have differences after recognition. The scanning direction of the background code is consistent with the moving direction of the object to be detected.
[0084] In order to ensure that the first image output by the line array camera each time includes the background code, multiple background codes are placed at equal distances in the acquisition field of the line array camera, and the spacing distance is determined according to the actual line frequency of the line array camera, so that the first image output by the line array camera each time includes at least one complete background code.
[0085] Due to the mismatch between the object's speed and the camera's line frequency, the image will be stretched or compressed. In order to ensure that the first image includes at least one complete background code at any degree of distortion, at least two barcodes of different sizes are placed at each distance to capture the complete background code image at both the maximum and minimum line frequencies 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. In the case of high line frequency and low motion speed, the image is stretched and distorted to the maximum, and only the background code with a ratio of 4:1 can be completely captured, as shown in the figure. Figure 1-4 As shown in the figure; in the case of low line frequency and high motion speed, the image compression distortion is maximized. Although the three background codes can capture complete images, the 4:1 background code is difficult to be fully recognized due to the decrease in vertical pixel points 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 moving direction of the object to be measured to reduce the distortion error introduced by the tilt factor. In this case, the image distortion usually has only one distortion direction, that is, the direction perpendicular to the moving direction, and the moving direction is the distortion-free direction.
[0089] For example, Figure 1-6 and Figure 1-7 As shown in the application scenario of parcel barcode recognition, the line scan camera scans the image toward the moving conveyor belt, and the background code is placed on the conveyor belt at an equal distance. The first image of the package captured by the line scan camera includes the background code. In an example, for a multi-section conveyor belt, the background code can be attached to the conveyor belt with 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 detected and the information to be corrected of the background code based on the first image.
[0091] The first image includes the object to be detected and the background code, in which the image of the object to be detected is determined, and because of possible distortion, it is used as the image to be corrected of the object to be detected. The image of the background code is determined in the first image, and the information to be corrected of the detected background code is identified. Exemplarily, the information to be corrected may include size information of the background code, or content identification information of the background code.
[0092] Step S103, comparing the difference between the standard information of the background code and 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 for the background code, such as the real size information and real content identification information of the background code collected in advance. 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 detected and the information to be corrected of the background code based on the first image, including:
[0095] Step 1: Identify the object to be tested and the background code on the first image to obtain the image to be corrected of the object to be tested 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 of the vertices.
[0097] In the first image, a coordinate system is established with a vertex of the background code as the origin center, the moving direction of the object to be measured as the Y axis, and the direction perpendicular to the moving direction as the X axis. The coordinates of each vertex of the background code are identified to obtain the distorted coordinates. Specifically, the code reading algorithm can also be used to achieve this. At this time, the distortion of the background code is only caused by the movement in the Y axis direction, and the X axis is the first direction without distortion.
[0098] The embodiment of the present application obtains the distortion coordinates of each vertex of the background code to determine the size information to be corrected of the background code, thereby providing a calculation basis for the subsequent calculation of the distortion coefficient.
[0099] In one embodiment of the present application, the standard information mentioned above includes a standard size ratio, 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 compression distortion. The current distortion coefficient is determined according to the degree of distortion. Specifically, the distortion coefficient can be directly calculated to obtain coefficients including positive and negative directions, corresponding to the degree of tensile distortion and the degree of compression distortion respectively; it can also be determined in advance whether the distortion is in the tensile direction or the compression direction, and then the directionless coefficient is determined for the tensile distortion or the compression distortion.
[0103] The embodiment of the present application uses size information as a detection reference 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 reference is also relatively easy, which can effectively improve the efficiency of image correction.
[0104] Step S104: Correct 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 array camera may have an embedded 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 to be corrected of the object to be measured. The output of the line array camera may 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. The above 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 package barcode recognition application scenario, such as Figure 1-9As shown, the first image includes a package and a barcode, and 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 distortion-free 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 by the embodiment of the present application first obtains the first image captured by the linear array camera, and the first image includes the object to be measured and the 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, and determines the current distortion coefficient; corrects the image to be corrected using the distortion coefficient to obtain the target image of the object to be measured. After the linear array 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 by the distortion coefficient to reduce the distortion of the image output by the linear array camera. The line frequency of the linear array camera and the motion speed of the object to be measured are adaptively matched. Whether it is a variable speed motion scene or a uniform speed motion scene, there is no need to calibrate the linear array camera in advance, which reduces the difficulty of matching and debugging the line frequency of the linear array camera and the object motion speed, expands the application scene of the linear array camera, and realizes the use of the linear array camera to improve the efficiency of image acquisition. In addition, the distortion of the output image is reduced, and the accuracy of subsequent processing of the output image of the linear array camera is further improved.
[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's width and height to be corrected in a first direction without distortion according to each distortion coordinate 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: compare the difference between the distorted coordinates and the undistorted coordinates to obtain the current distortion coefficients.
[0115] According to the distorted coordinates of each vertex and the width and height information to be corrected, the projection coordinates (width and height projection) of each vertex in the first direction are calculated, and the projection coordinates are corrected using the pre-standard width and height ratio of the background code to obtain the undistorted coordinates of the background code in the undistorted state. 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 vertices of the distortion, including (X1, Y1), (X2, Y2), (X3, Y3), and (X4, Y4). The distortion of the image only occurs in the Y-axis direction, which is caused by the barcode moving in the camera field of view along the Y-axis direction. In the case of a certain tilt angle, the projection of the height H on the X-axis is represented 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 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] From the above, it can be seen that the image correction method provided in the embodiment of the present application utilizes the distortion coordinates of each vertex of the currently identified background code and the true width-to-height ratio of the background code acquired in advance to identify the distortion degree of the background code, and calculates the current distortion coefficient. The calculation method is simple and effective, which further improves 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 array camera;
[0126] Step S402, correcting the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera;
[0127] Step S403: adjusting the line frequency of the line array camera to the target line frequency.
[0128] The line frequency of the linear array camera is adjusted to the target line frequency, which matches the exposure motion speed. Based on this, the image of the object to be measured at the same motion speed is collected. When the distortion coefficient is less than the preset coefficient threshold, the above image correction step can be skipped, and the obtained image is considered to be distortion-free. When the motion speed of the object to be measured changes, the distortion coefficient exceeds the preset coefficient threshold, and the above image correction step is repeated.
[0129] Exemplarily, the existing line frequency is N, the target line frequency is M, and 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 can be directly applied to correct the camera line frequency by determining the distortion coefficient based on the size information. Different from the need to calibrate the line frequency and the object movement speed in advance, the line frequency can be adjusted in real time, adapting to various object movement scenes, and improving the efficiency of image correction; different from the calculation of 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 code 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 to make the camera adjust, the present application can realize 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 construction, 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 also provides a structural schematic diagram of an image correction device, including:
[0133] An image acquisition module 501 is used to acquire a first image captured by a linear array camera, wherein the first image includes an object to be detected and a background code in the same motion state;
[0134] An information determination module 502 is used 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 used 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 by the embodiment of the present application first obtains the 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; 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, and determines the current distortion coefficient; corrects the image to be corrected using the distortion coefficient to obtain the target image of the object to be measured. After the linear array 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 by the distortion coefficient to reduce the distortion of the image output by the linear array camera. The line frequency of the linear array camera and the motion speed of the object to be measured are adaptively matched. Whether it is a variable speed motion scene or a uniform speed motion scene, there is no need to calibrate the linear array camera in advance, which reduces the difficulty of matching and debugging the line frequency of the linear array camera and the object motion speed, expands the application scene of the linear array camera, and realizes the use of the linear array camera to improve the efficiency of image acquisition. In addition, the distortion of the output image is reduced, and the accuracy of subsequent processing of the output image of the linear array camera is further improved.
[0138] In one embodiment of the present application, the information determination module 502 is specifically used to:
[0139] Identify the object to be detected and the background code on the first image to obtain the image to be corrected of the object to be detected and the distorted coordinates of each vertex of the background code;
[0140] Based on the distorted coordinates of each of the vertices, the size information to be corrected of the background code is determined.
[0141] The embodiment of the present application obtains the distortion coordinates of each vertex of the background code to determine the size information to be corrected of the background code, 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 used to:
[0143] By 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] Based on the distortion degree of the background code, a current distortion coefficient is determined.
[0145] The embodiment of the present application uses size information as a detection reference 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 reference 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 and height ratio, and the distortion coefficient determination module 503 is specifically used to:
[0147] Calculate 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 distortion-free coordinates of the background code;
[0149] The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficients.
[0150] From the above, it can be seen that 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 actual width and height ratio of the background code obtained in advance to identify the distortion degree 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 detected is a package including a barcode, the image to be corrected includes the barcode, and the image correction module 504 is specifically used 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, and the distortion coefficient is also used to correct the barcode image on the package to obtain the target image of the barcode, providing distortion-free barcode information for subsequent barcode recognition and improving the accuracy of barcode recognition.
[0154] In one embodiment of the present application, the device further includes:
[0155] A line frequency acquisition module, used to acquire the current line frequency of the line array camera;
[0156] A line frequency correction module, used for correcting the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera;
[0157] The 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 can be directly applied to correct the camera line frequency by determining the distortion coefficient based on the size information. Different from the need to calibrate the line frequency and the object movement speed in advance, the line frequency can be adjusted in real time, adapting to various object movement scenes, and improving the efficiency of image correction; different from the output image and then calculating the corrected image according to the line frequency and movement speed, 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 code 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 to make the camera adjust, the present application can realize 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 construction, 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 linear array camera. Figure 6 As shown, including:
[0160] An image collector 601, used for collecting images;
[0161] Memory 602, used for storing computer programs;
[0162] The processor 603 is used 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 above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or 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 a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned 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, discrete hardware components.
[0168] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. 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 in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any image correction method in the above embodiments.
[0170] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part 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 process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by 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 may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.
[0171] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0172] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0173] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. An image correction method, characterized in that: include: 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; 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; Comparing the difference between the standard information of the background code and the information to be corrected to determine 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 linear array camera includes a plurality of 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 linear array camera. The scanning direction of the background code is consistent with the movement direction of the object to be measured.
3. The method according to claim 1, characterized in that The determining, based on the first image, the image to be corrected of the object to be detected and the information to be corrected of the background code includes: Identify the object to be detected and the background code on the first image to obtain the image to be corrected of the object to be detected and the distorted coordinates of each vertex of the background code; Based on the distorted coordinates of each of the vertices, the size information to be corrected of the background code is determined.
4. The method according to claim 3, characterized in that The standard information includes a standard size ratio, and the comparing the difference between the standard information of the background code and the information to be corrected to determine the current distortion coefficient includes: By 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; Based on the distortion degree of the background code, a current distortion coefficient is determined.
5. The method according to claim 4, characterized in that 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: Calculate 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 the standard width-height ratio to obtain the distortion-free coordinates of the background code; The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficients.
6. 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 the image to be corrected is corrected by using the distortion coefficient to obtain a target image of the object to be measured, including: 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 method according to claim 1, characterized in that 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.
8. An image correction device, characterized in that: include: An image acquisition module, used 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; An information determination module, used 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; A distortion coefficient determination module, used for comparing the difference between the standard information of the background code and the information to be corrected, and determining the current distortion coefficient; The image correction module is used to correct the image to be corrected by using the distortion coefficient to obtain a target image of the object to be measured.
9. The device according to claim 8, characterized in that The information determination module is specifically used for: Identify the object to be detected and the background code on the first image to obtain the image to be corrected of the object to be detected and the distorted coordinates of each vertex of the background code; Based on the distorted coordinates of each of the vertices, the size information to be corrected of the background code is determined.
10. The device according to claim 9, characterized in that The standard information includes a standard size ratio, and the distortion coefficient determination module is specifically used to: By 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; Based on the distortion degree of the background code, a current distortion coefficient is determined.
11. The device according to claim 10, characterized in that 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 used to: Calculate 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; Correcting the to-be-corrected width-height projection using the standard width-height ratio to obtain the distortion-free coordinates of the background code; The difference between the distorted coordinates and the undistorted coordinates is compared to obtain the current distortion coefficients.
12. The device according to claim 8, characterized in that The object to be detected is a package including a barcode, the image to be corrected includes the barcode, and the image correction module is specifically used to: The barcode image in the image to be corrected is corrected using the distortion coefficient to obtain a target image of the barcode.
13. The device according to claim 8, characterized in that The device also includes: A line frequency acquisition module, used to acquire the current line frequency of the line array camera; A line frequency correction module, used for correcting the current line frequency based on the distortion coefficient to obtain a target line frequency of the line array camera; The line frequency adjustment module is used to adjust the line frequency of the line array camera to the target line frequency.
14. A linear array camera, characterized in that: include: An image collector, used for collecting images; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-7 when executing a program stored in a memory.
15. 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 7 is implemented.
Citation Information
Patent Citations
Regulating and calibrating method for linear array CCD scanning detection system
CN101365144A
Method and device for repairing image deformation
CN107818542A
Single linear array camera distortion calibration method
CN108428252A
Method and device for correcting image distortion of linear array camera of rail train
CN112950493A
Method and device for adjusting image acquisition frequency of camera and method and device for image acquisition
CN115174761A