CN111639508B - Bar code positioning frame correction method, device, equipment and storage medium - Google Patents
Bar code positioning frame correction method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN111639508B CN111639508B CN202010474202.5A CN202010474202A CN111639508B CN 111639508 B CN111639508 B CN 111639508B CN 202010474202 A CN202010474202 A CN 202010474202A CN 111639508 B CN111639508 B CN 111639508B
- Authority
- CN
- China
- Prior art keywords
- positioning frame
- bar code
- corrected
- boundary
- determining
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/1439—Methods for optical code recognition including a method step for retrieval of the optical code
- G06K7/1443—Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Electromagnetism (AREA)
- General Health & Medical Sciences (AREA)
- Toxicology (AREA)
- Artificial Intelligence (AREA)
- Computer Vision & Pattern Recognition (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Character Input (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses a bar code positioning frame correction method, a device, equipment and a storage medium, wherein the method comprises the following steps: determining a transverse correction parameter according to the projection length of the reference information bar of the bar code on the boundary of the bar code image; adjusting the broadside position of the positioning frame to be corrected based on the transverse correction parameters; and adjusting the position of the long side of the positioning frame to be corrected according to the incremental decremental boundary threshold value. According to the embodiment of the invention, the positioning frame is adjusted through the reference information bar and the incremental decremental boundary threshold value, so that the position of the positioning frame is corrected, the recognition rate of the bar code is improved, and the decoding rate of the bar code can be improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of automatic control, in particular to a bar code positioning frame correction method, a device, equipment and a storage medium.
Background
With the development of the internet of things technology, the bar code is widely applied, and when the bar code is decoded, a positioning frame of the bar code needs to be determined, and data is obtained according to transverse scribing of the positioning frame for decoding. Currently, the positioning frame of the bar code is determined by a gray boundary searching or binarization image searching mode.
Because the determination of the bar code positioning frame depends on the gray level boundary or the line segment searched by the binary image, when the parameter setting is inaccurate or the noise point of the bar code image is large, the determined positioning frame can not accurately position the bar code, so that the deviation exists between the length of the line segment of the bar code and the actual length. For the bar code image in the non-ideal state of bar code fold or bar code distortion, because the length of the bar code segment and the time length have errors, and most of information in the positioning frame cannot be read normally, the inclusion of the missing bar code segment into the positioning frame has very important effect, and the correction of the bar code positioning frame has significant influence on the decoding rate.
Disclosure of Invention
The invention provides a method, a device, equipment and a storage medium for correcting a bar code positioning frame, which are used for realizing accurate correction of the positioning frame, increasing the readable information quantity of a bar code and improving the decoding accuracy of the bar code.
In a first aspect, an embodiment of the present invention provides a method for correcting a barcode positioning frame, where the method includes:
determining a transverse correction parameter according to the projection length of the reference information bar of the bar code on the boundary of the bar code image;
adjusting the long side position of the positioning frame to be corrected based on the transverse correction parameters;
and adjusting the broadside position of the positioning frame to be corrected according to the incremental decremental boundary threshold value.
In a second aspect, an embodiment of the present invention provides a barcode positioning frame correction device, including:
the parameter determining module is used for determining a transverse correction parameter according to the projection length of the reference information bar of the bar code on the boundary of the bar code image;
the broadside adjusting module is used for adjusting the long side position of the positioning frame to be corrected based on the transverse correction parameters;
and the long-side adjusting module is used for adjusting the wide-side position of the positioning frame to be corrected according to the incremental decreasing boundary threshold value.
In a third aspect, an embodiment of the present invention provides an apparatus, including:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the barcode positioning frame correction method according to any one of the embodiments of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium having a computer program stored thereon, where the program when executed by a processor implements a barcode positioning frame correction method according to any of the embodiments of the present invention. According to the embodiment of the invention, the transverse correction parameters are determined through the projection length of the bar code reference information bar on the bar code image boundary, the long-side position of the positioning frame to be corrected is adjusted according to the transverse correction parameters, and the wide-side position of the positioning frame to be corrected is adjusted through increasing and decreasing the boundary, so that the position correction of the positioning frame is realized, the accuracy of bar code identification is improved, and the decoding rate of the bar code is improved.
Drawings
FIG. 1 is a flowchart illustrating a method for correcting a bar code positioning frame according to an embodiment of the present invention;
FIG. 2 is an exemplary view of a bar code image provided in accordance with a first embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for correcting a bar code positioning frame according to a second embodiment of the present invention;
fig. 4 is an exemplary diagram of a positioning frame to be corrected according to a second embodiment of the present invention;
FIG. 5 is a diagram illustrating a bar code positioning frame correction method according to a second embodiment of the present invention;
fig. 6 is a schematic structural diagram of a bar code positioning frame correction device according to a third embodiment of the present invention;
fig. 7 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings, and furthermore, embodiments of the present invention and features in the embodiments may be combined with each other without conflict.
Example 1
Fig. 1 is a flowchart of a method for correcting a barcode positioning frame according to an embodiment of the present invention, where the method may be performed by a barcode positioning frame correction device, and the device may be implemented in hardware and/or software, and referring to fig. 1, the method may generally include the following steps:
and 101, determining a transverse correction parameter according to the projection length of the reference information bar of the bar code on the boundary of the bar code image.
The bar code is a graphic identifier for expressing information, wherein a plurality of black bars and white bars with different widths are arranged according to a preset coding rule, the reference information bars are black bars or white bars in the bar code, and the number of the reference information bars can be one or more. The bar code image is image information carrying bar code, the bar code can be generated by shooting the bar code through a decoder or a camera and the like, and the boundary of the bar code image can comprise an upper boundary, a lower boundary, a left boundary, a right boundary and the like of the bar code image. Fig. 2 is an exemplary diagram of a barcode image provided in the first embodiment of the present invention, referring to fig. 2, the barcode image includes a barcode 10, and a black bar or a white bar in the barcode 10 may be a reference information bar. The barcode image boundaries include an upper boundary 111, a right boundary 112, a lower boundary 113, and a left boundary 114. The projection length is the length of the reference information bar projected on each boundary of the bar code image, and can comprise the projection length of the boundary on the bar code image, the projection length of the right boundary of the bar code image, the projection length of the lower boundary of the bar code image, the projection length of the left boundary of the bar code image and the like.
In the embodiment of the invention, the transverse correction parameter is a parameter for correcting the bar code positioning frame, and the parameter is used for correcting the positioning frame in the transverse direction of the bar code, namely correcting the length and/or the position of the long side of the positioning frame.
Specifically, length information of a reference information bar of the bar code and included angle information of the reference information bar and a bar code image boundary are obtained, and the projection length of the reference information bar on the bar code image boundary is determined according to the length information and the included angle information, wherein the projection length can be one or more of the projection length of the reference information bar on a bar code image left boundary, the projection length of the reference information bar on a bar code image upper boundary, the projection length of the reference information bar on a bar code image right boundary and the projection length of the reference information bar on a bar code image lower boundary. After the projection length is obtained, the projection length may be used as a lateral correction parameter.
And 102, adjusting the broadside position of the positioning frame to be corrected based on the transverse correction parameters.
The positioning frame to be corrected is a rectangular frame created for positioning the bar code in the bar code image, and is realized by searching gray level conversion boundary line segments between black bar and white bar of the bar code in the bar code image, or acquiring black and white line segments in the binarized bar code image, and combining the acquired line segments into a rectangle. Due to the influence of the state of the bar code when an image is generated, when the bar code is wrinkled or distorted, the position of the positioning frame to be corrected, which is determined by the method, is inaccurate, and some bar code information can be missed. The broadside position may be the position where the broadside of the positioning frame to be corrected is located.
In the embodiment of the invention, the broadside of the positioning frame to be corrected is adjusted based on the acquired transverse correction parameters, the position of the broadside to be corrected is changed based on the length of the transverse correction parameters, for example, the coordinates of the endpoints of the broadside of the positioning frame to be corrected are respectively increased by the numerical values corresponding to the transverse correction parameters, and the line segment formed by connecting the new endpoints is used as the position of the broadside of the positioning frame to be corrected after adjustment.
And 103, adjusting the long edge position of the positioning frame to be corrected according to the incremental and decremental boundary threshold value.
The incremental decrease boundary threshold is a quantity value determined according to black and white bar information of the bar code, the quantity value is the minimum information bar quantity capable of judging bar code decoding, the incremental decrease boundary is a pixel value conversion boundary generated by arrangement of the black and white bars in the bar code, the incremental decrease boundary can reflect the quantity information of the black and white bars in the bar code, and when the quantity of the incremental decrease boundary of the image data of the bar code image is smaller than the incremental decrease boundary threshold, the bar code black and white bars are not present at the position corresponding to the image data and exceed the bar code range.
Specifically, the long side position is the position of the long side of the positioning frame to be corrected, after the wide side position of the positioning frame to be corrected is corrected based on the incremental decremental boundary threshold value, the long side of the positioning frame to be corrected can be moved outwards, image data of a bar code image collected along the direction parallel to the long side of the positioning frame to be corrected is obtained at the moved position, the incremental decremental boundary is determined according to the image data, if the number of the incremental decremental boundaries is greater than or equal to the incremental decremental boundary threshold value, the long side is continuously moved outwards until the number of the incremental decremental boundaries determined according to the moved long side position is smaller than the incremental decremental boundary value, and the position is taken as the corrected long side position of the positioning frame to be corrected. And the long-side position can be directly moved outwards by a preset distance, and if the number of the increment and decrement boundaries acquired based on the position is larger than or equal to the increment and decrement boundary threshold, the position is directly used as the corrected long-side position of the positioning frame to be corrected.
According to the embodiment of the invention, the transverse correction parameters are determined according to the projection length of the reference information bar of the bar code on the boundary of the bar code image, the broadside position of the positioning frame to be corrected is adjusted according to the transverse correction parameters, and the long side position of the positioning frame to be corrected is adjusted by increasing and decreasing the boundary threshold value, so that the correction of the bar code positioning frame is realized, the data quantity of the bar code information in the positioning frame is improved, the accuracy of bar code identification is improved, and the bar code decoding efficiency is enhanced.
Example two
Fig. 3 is a flowchart of steps of a method for correcting a barcode positioning frame according to a second embodiment of the present invention, referring to fig. 3, in which the embodiment of the present invention is based on the above embodiment, accuracy of a lateral correction parameter is further improved by an angle of a black information bar, and a preset distance is used to adjust a broadside position of a positioning frame to be corrected, referring to fig. 3, the method for correcting a barcode positioning frame according to the embodiment of the present invention includes:
In the embodiment of the invention, the bar code comprises black information bars and white information bars, the lengths of the black information bars in the bar code image can be different due to the influence of bar code states such as distortion or folds, the smaller the length of the black information bars is, the smaller the influence of the bar code states is, and the longest black information bar in the bar code image is selected as the reference information bar.
In the embodiment of the invention, the included angle between the reference information bar and the long side of the bar code image and the wide side of the bar code image is obtained, the projection length at the long side is determined by the included angle between the long side of the bar code image and the reference information bar and the length of the reference information bar, and if the included angle between the long side of the bar code image and the reference information bar is a and the length of the reference information bar is l, the projection length dx=cos (a×pi/180) of the reference information bar at the long side of the bar code image is equal to the corresponding projection width of the reference information bar at the wide side of the bar code image can be determined in the above manner, and further, when the long side of the bar code image is perpendicular to the wide side of the bar code image, the projection width dy=sin (a×pi/180) of the reference information bar at the wide side of the bar code image is equal to l.
And 203, adjusting the coordinates of the end points of the long side on the positioning frame to be corrected according to the projection length and the projection width.
The top end points of the positioning frame to be corrected are the top points of the two sides of the long side of the positioning frame to be corrected, and fig. 4 is an exemplary diagram of a positioning frame to be corrected according to the second embodiment of the present invention, and referring to fig. 4, the positioning frame to be corrected 20 includes four end points of R1, R2, R3 and R4, where R1 and R2 may be the top end points of the long side of the positioning frame to be corrected.
In an exemplary embodiment, coordinates (x 1, y 1) and (x 2, y 2) of R1 and R2 of the left end point on the upper edge of the frame to be positioned are obtained respectively, and the coordinates of R1 and R2 are adjusted by the projection length dy and the projection width dx, so that the distance between R1 and R2 is increased or decreased, for example, the coordinates after adjustment of R1 may be (x 1-dx, y 1-dy), and the coordinates after adjustment of R2 may be (x2+dx, y 2-dy). Further, in another exemplary embodiment, the coordinates of the end point of the lower long side of the positioning frame to be corrected may be adjusted according to the projection length and the projection width, that is, the coordinates of R3 and R4 may be adjusted according to the projection length and the projection width, so as to increase the distance between R3 and R4.
Wherein the first distance is the distance between the front upper long side ends, that is, the length M1 of the long side of the positioning frame to be corrected before adjustment, and the second distance is the distance after adjustment of the coordinates of the upper long side ends, and can be determined by the coordinates of the two modified ends, for example, the coordinates of the modified R1 end point are (x 1-dx, y 1-dy), the coordinates of the modified R2 end point are (x2+dx, y 2-dy), and the corresponding second distance between the adjusted upper long side ends
Specifically, the side length M1 of the long side of the positioning frame to be corrected before adjustment is obtained as a first distance, a second distance M2 is determined according to the coordinates of the end point of the upper long side after adjustment, the length of the long side of the positioning frame to be corrected, which needs to be increased transversely, can be determined by the second distance M2 and the first distance M1, a difference value between the first distance M1 and the second distance M2 is calculated, and the difference value is used as a transverse correction parameter.
And 205, respectively shifting the left wide edge end point and the right wide edge end point of the positioning frame to be corrected to the left and the right according to the transverse correction parameters.
In the embodiment of the present invention, the left broadside end points are the end points of the two ends of the left broadside in the positioning frame to be corrected, the right broadside end points are the end points of the two ends of the right broadside in the positioning frame to be corrected, referring to fig. 4, the left broadside end points are R1 and R3, and the right broadside end points are R2 and R4. Specifically, the long side of the positioning frame to be corrected is adjusted according to the transverse correction parameters, the side length of the long side and the transverse correction parameters can be added to obtain, the left broadside end points R1 and R3 move leftwards, the corresponding abscissa subtracts half of the transverse correction parameters, the right broadside end points R2 and R4 move rightwards, and the corresponding abscissa adds half of the transverse correction parameters. Further, the lateral correction parameter may be directly set to be half of the difference between the first distance and the second distance, and the coordinates of the end point of the positioning frame to be corrected are correspondingly increased or decreased directly to achieve displacement of the end point.
And 206, respectively determining the coordinates of the middle points of the left wide edge end point and the right wide edge end point of the positioning frame to be corrected after displacement.
Wherein the middle point coordinates include the position coordinates of the middle point of the two end points of the shifted left broadside and the position coordinates of the center point of the two end points of the shifted right broadside.
Specifically, the long-side position of the positioning frame to be corrected is adjusted by means of the reference information bar, and because the reference information bar still has the influence of factors such as bar code folds and distortions, in order to improve the accuracy of long-side position adjustment, the middle point coordinates of the center point are determined by taking the coordinates of the two end points corresponding to the left broadside and the middle point coordinates of the center point are determined by taking the coordinates of the two end points corresponding to the right broadside.
In an exemplary embodiment, each black information bar in the barcode image is fitted, a straight line corresponding to the fitted black information bar is intersected with a straight line where the barcode image side is located, and an included angle between each black information bar and the barcode image side is obtained, wherein the included angle can include an included angle between each black information bar and the long side of the barcode image and an included angle between each black information bar and the wide side of the barcode image, when the long side and the wide side of the barcode image are perpendicular, only the included angle between each black information bar and the wide side of the barcode image is obtained, and after the included angle between each black information bar and the long side of the barcode image is obtained, the average included angle of each black information bar is counted.
And step 208, determining the position of the broadside adjusted by the positioning frame to be corrected according to the coordinates of the middle point and the average angle of the included angle.
In the embodiment of the invention, the coordinates of the middle point and the average angle of the included angle are substituted into a linear formula y=k×x+b, wherein k can be a slope determined by the average angle of the included angle, the intercept b can be obtained by substituting the coordinates of the middle point into the linear formula, the coordinates of the middle point corresponding to the broadside on the left side can obtain the intercept corresponding to the broadside on the left side, the coordinates of the middle point corresponding to the broadside on the right side can obtain the intercept corresponding to the broadside on the right side, the slope k and the intercept b corresponding to the broadside are substituted into the linear formula to obtain the linear formula corresponding to the broadside, and the position corresponding to the linear formula in the bar code image can be used as the broadside position of the positioning frame to be corrected.
The preset distance is a distance value for expanding the long side position, the acquisition position is a position for acquiring image data in the bar code image, and the acquisition position can be parallel to the long side of the positioning frame to be corrected. The incremental decreasing boundary is a pixel value jump boundary formed by alternately sequencing black information strips and white information strips in the bar code, and the incremental decreasing boundary can reflect the quantity of the black information strips and the white information strips.
Specifically, the acquisition position is determined at a preset distance outside the long side of the positioning frame to be corrected, that is, the shortest distance from the pixel point at the acquisition position to the long side of the positioning frame to be corrected is the preset distance, the image data at the acquisition position in the bar code image is obtained, and the image data is analyzed to obtain the incremental and decremental boundary.
The incremental decrease boundary threshold is a quantity value determined according to black and white bar information of the bar code, the quantity value is the minimum quantity of information bars capable of decoding the bar code, the incremental decrease boundary is a pixel value conversion boundary generated by arrangement of the black and white bars in the bar code, the incremental decrease boundary can reflect the quantity information of the black and white bars in the bar code, and when the quantity of the incremental decrease boundary of image data of a bar code image is smaller than the incremental decrease boundary threshold, the information bars at positions corresponding to the image data can be considered to be insufficient to support the bar code to be decoded.
Specifically, if the number of the incremental decrease boundaries at the acquisition position is greater than the incremental decrease boundary threshold, it is indicated that the number of the black information bars and the white information bars at the acquisition position meets the bar code decoding requirement, the acquisition position can be used as the position of the long side of the positioning frame to be corrected after adjustment, and the long side of the positioning frame can be translated to the acquisition position.
Specifically, if the number of the incremental decrease boundaries at the acquisition position is greater than the incremental decrease boundary threshold, it is indicated that the number of the black information bars and the white information bars at the acquisition position does not meet the bar code decoding requirement, the acquisition position cannot be used as the long-side position after the adjustment of the positioning frame to be corrected, and the long-side position of the positioning frame to be corrected is not adjusted.
According to the embodiment of the invention, the longest black information bar is selected as the reference information bar, the projection length and the projection width of the reference information bar on the long side and the wide side of the bar code image are respectively determined, the end points of the positioning frame to be corrected are adjusted based on the projection length and the projection width, the first distance of the long side before adjustment and the second distance of the long side after adjustment are obtained, the difference value between the second distance and the first distance is used as a transverse correction parameter, the end points of the positioning width to be corrected are adjusted based on the transverse correction parameter, the middle point coordinates of the wide side after adjustment are obtained, the average angle of the included angle between the two information bars is obtained, the position of the wide side is determined through the middle point coordinates and the average angle of the included angle, the position of the long side to be corrected is judged, when the increment and decrement boundary number of the preset distance from the long side exceeds the increment and decrement boundary threshold, the position of the acquisition position is used as the long side position of the positioning frame to be corrected, the quick correction of the bar code positioning frame is realized, the data quantity of bar code information in the positioning frame is improved, the bar code recognition accuracy is improved, and the bar code decoding efficiency can be enhanced.
Further, on the basis of the embodiment of the present invention, determining an increasing and decreasing boundary according to an acquisition position at a preset distance from the long side of the positioning frame to be corrected includes:
taking the position of the preset distance outside the long side of the positioning frame to be corrected as an acquisition position; collecting image information of the bar code image along a direction parallel to the long side of the positioning frame to be corrected from the collecting position; and respectively searching an increasing boundary and a decreasing boundary in the image information according to the gray level boundary and/or the binarized image to serve as increasing and decreasing boundaries.
In the embodiment of the invention, the outer side of the long side of the positioning frame to be corrected is selected as the acquisition position, the distance between the pixel point at the acquisition position and the long side of the positioning frame to be corrected is a preset distance, the acquisition position is parallel to the long side, the image information in the bar code image is acquired at the acquisition position according to the sequence from one side to the other side, wherein the image information can correspond to the pixel value of the pixel point, after the image information is acquired, the number of the increasing boundaries and the number of the decreasing boundaries in the image information can be extracted, and the extraction of the increasing boundaries or the decreasing boundaries can be realized by a gray level boundary and/or a binarization image searching mode. It will be appreciated that the increasing and decreasing boundary threshold may include increasing and decreasing boundary thresholds, respectively, from which the image information is extracted.
Fig. 5 is an exemplary diagram of a bar code positioning frame correction method according to a second embodiment of the present invention, referring to fig. 5, after a positioning frame is obtained by a bar code positioning method according to a conventional method, verification and reliability determination are performed on the obtained positioning frame, and whether the number of information bars in the positioning frame meets the bar code requirement is determined. And when the bar code requirement is met, correcting the positioning frame. Four end point coordinates of R1, R2, R3 and R4 of the positioning frame 20 are obtained, the side lengths of the R1R2 side and the R3R4 side of the positioning frame 20 are respectively obtained, and the side lengths of the R1R3 side and the R2R4 side of the positioning frame 20 are obtained. Firstly, the positioning frame 20 is transversely expanded, the longest black information strip found in the positioning frame 20 is searched, and the projection is determined as a transverse correction parameter according to a sine formula and a cosine formula according to the angle between the black information strip and the boundary 21 and the length of the black information strip. The length of the side where the corrected positioning frame 200 is located can be obtained by adding the length of the side of the positioning frame 20 and the transverse correction parameters, the central points of the sides R1R3 and R2R4 of the expanded positioning frame 200 are calculated, the average angle between the black information bar and the boundary 21 in the positioning frame 20 and the coordinates of the two central points are respectively substituted into the straight line calculation formula y=k x+b, the fitted straight line R1R3 and straight line R2R4 of the short side of the positioning frame 200 are corrected on the basis of the long side of the positioning frame 20, and the new four end point coordinate positions are obtained according to the intersection points of the new straight lines R1R3 and R2R4 of the positioning frame 200 and the straight lines R1R2 and R2R4 of the previous positioning frame 20. The positioning frame 20 is further extended longitudinally, and the lengths of R1R3 and R2R4 of the positioning frame 200 are extended based on the positioning frame 20 after the lateral extension. The distance dis1 from R1 to R3 and the distance dis2 from R2 to R4 are found, and then the step N is set. Accurately calculating a point T1 with the length of dis1+N in the direction of R1 to R3 and a point T2 with the length of dis2+N in the direction of R4, extracting image data on a T1T2 line segment, searching the number of increasing boundaries and decreasing boundaries of the partial image data, finding out the number of N1 and N2, and expanding the length of a short side of the positioning frame 20 to the directions of R1R3 and R2R4 by 0.3 times when the number of N1 and N2 is simultaneously larger than a boundary threshold value to obtain a new rectangular side position; accurately calculating a point T3 with the length of dis1+N in the R1 direction, accurately calculating a point T4 with the length of dis2+N in the R2 direction, extracting image data on a T3T4 line segment, searching the number of increasing boundaries and decreasing boundaries of the partial image data, finding out the number of N3 and N4, and expanding the length of a short side of a rectangle to the directions of R3R1 and R4R2 to obtain the end point position of a new positioning frame 200 when the number of N3 and N4 is simultaneously larger than a boundary threshold value.
Example III
Fig. 6 is a schematic structural diagram of a bar code positioning frame correction device according to a third embodiment of the present invention, where the bar code positioning frame correction method according to any embodiment of the present invention can be implemented, and the bar code positioning frame correction device has functional modules and beneficial effects corresponding to the implementation method. The apparatus may be implemented by software and/or hardware, and specifically includes: a parameter determination module 301, a broadside adjustment module 302, and a long-side adjustment module 303.
The parameter determining module 301 is configured to determine a lateral correction parameter according to a projection length of a reference information bar of the barcode on a barcode image boundary.
The broadside adjustment module 302 is configured to adjust the broadside position of the positioning frame to be corrected based on the lateral correction parameter.
And the long-side adjusting module 303 is configured to adjust the long-side position of the positioning frame to be corrected according to the incremental decrease boundary threshold.
According to the embodiment of the invention, the parameter determination module determines the transverse correction parameter according to the projection length of the reference information bar of the bar code on the boundary of the bar code image, the broadside adjustment module adjusts the broadside position of the positioning frame to be corrected according to the transverse correction parameter, and the long side adjustment module adjusts the long side position of the positioning frame to be corrected by increasing and decreasing the boundary threshold value, so that the correction of the bar code positioning frame is realized, the data quantity of the bar code information in the positioning frame is improved, the accuracy of bar code identification is improved, and the bar code decoding efficiency is enhanced.
Further, on the basis of the embodiment of the invention, the method further comprises the following steps:
and the reference determining module is used for selecting the longest black information bar in the bar code as the reference information bar.
Further, on the basis of the above embodiment of the present invention, the parameter determining module 301 includes:
and the projection determining unit is used for determining the projection length and the projection width of the reference information bar on the long side and the wide side of the bar code image respectively.
And the coordinate adjusting unit is used for adjusting the coordinates of the long side end points on the positioning frame to be corrected according to the projection length and the projection width.
And the parameter determining unit is used for respectively determining a first distance between the upper long side end points before adjustment and a second distance between the upper long side end points after adjustment, and taking the difference between the second distance and the first distance as a transverse correction parameter.
Further, on the basis of the above embodiment of the present invention, the broadside adjustment module 302 includes:
and the length adjusting unit is used for respectively shifting the left wide edge end point and the right wide edge end point of the positioning frame to be corrected to the left and right according to the transverse correction parameters.
And the center determining unit is used for respectively determining the coordinates of the middle points of the left wide edge end point and the right wide edge end point of the positioning frame to be corrected after the positioning frame is shifted.
And the angle determining unit is used for averaging the angles between the black information bars in the bar code image and the edges of the bar code image according to the included angles between the black information bars in the bar code image and the edges of the bar code image.
And the broadside position unit is used for determining the broadside position of the positioning frame to be corrected after adjustment according to the coordinates of the middle point and the average angle of the included angle.
Further, on the basis of the above embodiment of the present invention, the long-side adjustment module 303 includes:
the boundary determining unit is used for determining an increasing and decreasing boundary according to the acquisition position which is a preset distance away from the long side of the positioning frame to be corrected.
And the long-side position unit is used for determining the acquisition position as the long-side position after the adjustment of the positioning frame to be corrected if the number of the incremental and decremental boundaries is greater than the incremental and decremental boundary threshold value.
Further, on the basis of the above embodiment of the invention, the boundary determining unit includes:
and the position subunit is used for taking the position of the preset distance outside the long side of the positioning frame to be corrected as the acquisition position.
And the information acquisition subunit is used for acquiring the image information of the bar code image from the acquisition position along the direction parallel to the long side of the positioning frame to be corrected.
And the boundary determining subunit is used for respectively searching an increasing boundary and a decreasing boundary in the image information as increasing and decreasing boundaries according to the gray level boundary and/or the binarized image.
Further, on the basis of the embodiment of the invention, the method further comprises the following steps:
and the second broadside module is used for not adjusting the broadside position of the positioning frame to be corrected if the number of the incremental decreasing boundaries is smaller than or equal to the incremental decreasing boundary threshold value.
Example IV
Fig. 7 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention, and as shown in fig. 7, the apparatus includes a processor 70, a memory 71, an input device 72, and an output device 73; the number of processors 70 in the device may be one or more, one processor 70 being taken as an example in fig. 7; the processor 70, memory 71, input means 72 and output means 73 in the device may be connected by a bus or other means, in fig. 7 by way of example.
The memory 71 is used as a computer readable storage medium for storing software programs, computer executable programs and modules, such as program instructions/modules corresponding to the barcode positioning frame correction method in the embodiment of the present invention (for example, the parameter determination module 301, the broadside adjustment module 302 and the long side adjustment module 303 in the barcode positioning frame correction device). The processor 70 executes various functional applications of the apparatus and data processing by running software programs, instructions and modules stored in the memory 71, i.e., implements the barcode positioning frame correction method described above.
The memory 71 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the terminal, etc. In addition, memory 71 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 71 may further include memory remotely located relative to processor 70, which may be connected to the device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 72 may be used to receive entered numeric or character information and to generate key signal inputs related to user settings and function control of the apparatus. The output means 73 may comprise a display device such as a display screen.
Example five
A fifth embodiment of the present invention also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing a barcode-positioning-frame correction method, the method comprising:
determining a transverse correction parameter according to the projection length of the reference information bar of the bar code on the boundary of the bar code image;
adjusting the broadside position of the positioning frame to be corrected based on the transverse correction parameters;
and adjusting the position of the long side of the positioning frame to be corrected according to the incremental decremental boundary threshold value.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present invention is not limited to the above-mentioned method operations, and may also perform the related operations in the barcode positioning frame correction method provided in any embodiment of the present invention.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, etc., and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present invention.
It should be noted that, in the embodiment of the bar code positioning frame correction device, each unit and module included are only divided according to the functional logic, but not limited to the above division, so long as the corresponding functions can be realized; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.
Claims (5)
1. A method for correcting a barcode positioning frame, the method comprising:
selecting the longest black information bar in the bar code as a reference information bar;
respectively determining the projection length and the projection width of the reference information bar on the long side and the wide side of the bar code image;
adjusting the coordinates of the end points of the long side on the positioning frame to be corrected according to the projection length and the projection width;
respectively determining a first distance between the upper long side end points before adjustment and a second distance between the long side end points after adjustment, and taking the difference between the second distance and the first distance as a transverse correction parameter;
respectively shifting left and right wide edge points of the positioning frame to be corrected to left and right according to the transverse correction parameters;
respectively determining the coordinates of the middle points of the left wide edge end point and the right wide edge end point of the positioning frame to be corrected after the positioning is moved;
according to the average angle between each black information bar in the bar code image and the bar code image side;
determining the position of the broadside adjusted by the positioning frame to be corrected according to the coordinates of the middle point and the average angle of the included angle;
taking the position of the preset distance outside the long side of the positioning frame to be corrected as an acquisition position;
collecting image information of the bar code image along a direction parallel to the long side of the positioning frame to be corrected from the collecting position;
respectively searching an increasing boundary and a decreasing boundary in the image information according to the gray level boundary and/or the binarized image to serve as increasing and decreasing boundaries;
and if the number of the incremental decreasing boundaries is larger than the incremental decreasing boundary threshold, determining the acquisition position as the position of the long side of the positioning frame to be corrected after adjustment.
2. The method as recited in claim 1, further comprising:
and if the number of the incremental decreasing boundaries is smaller than or equal to the incremental decreasing boundary threshold, not adjusting the broadside position of the positioning frame to be corrected.
3. A bar code positioning frame correction device, the device comprising:
the parameter determining module is used for determining a transverse correction parameter according to the projection length of the reference information bar of the bar code on the boundary of the bar code image;
the parameter determining module comprises:
a projection determining unit for determining the projection length and the projection width of the reference information bar on the long side and the wide side of the bar code image respectively;
the coordinate adjusting unit is used for adjusting the coordinates of the long side end points on the positioning frame to be corrected according to the projection length and the projection width;
a parameter determining unit, configured to determine a first distance between the upper long edge end points before adjustment and a second distance between the upper long edge end points after adjustment, respectively, and take a difference between the second distance and the first distance as the lateral correction parameter;
the broadside adjustment module is used for adjusting the broadside position of the positioning frame to be corrected based on the transverse correction parameters;
the broadside adjustment module includes:
the length adjusting unit is used for respectively shifting the left wide edge end point and the right wide edge end point of the positioning frame to be corrected to the left and the right according to the transverse correction parameters;
the center determining unit is used for respectively determining the coordinates of the middle points of the left wide edge end point and the right wide edge end point of the positioning frame to be corrected after the positioning frame is moved;
the angle determining unit is used for averaging the angles between the black information bars in the bar code image and the edges of the bar code image according to the angles;
the broadside position unit is used for determining the broadside position of the positioning frame to be corrected after adjustment according to the coordinates of the middle point and the average angle of the included angle;
the long-side adjusting module is used for adjusting the long-side position of the positioning frame to be corrected according to the incremental decreasing boundary threshold value;
the long-side adjusting module comprises:
the boundary determining unit is used for determining the incremental decreasing boundary according to the acquisition position which is a preset distance away from the long side of the positioning frame to be corrected;
the long-side position unit is used for determining the acquisition position as the long-side position of the positioning frame to be corrected after adjustment if the number of the incremental and decremental boundaries is larger than the incremental and decremental boundary threshold value;
wherein the boundary determining unit includes:
the position subunit is used for taking the position of the preset distance outside the long side of the positioning frame to be corrected as the acquisition position;
the information acquisition subunit is used for acquiring the image information of the bar code image from the acquisition position along the direction parallel to the long side of the positioning frame to be corrected;
and the boundary determining subunit is used for respectively searching an increasing boundary and a decreasing boundary in the image information as the increasing and decreasing boundary according to the gray level boundary and/or the binarized image.
4. An electronic device, the electronic device comprising:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the barcode bezel correction method as recited in any one of claims 1-2.
5. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the bar code positioning frame correction method according to any one of claims 1-2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010474202.5A CN111639508B (en) | 2020-05-29 | 2020-05-29 | Bar code positioning frame correction method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010474202.5A CN111639508B (en) | 2020-05-29 | 2020-05-29 | Bar code positioning frame correction method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111639508A CN111639508A (en) | 2020-09-08 |
CN111639508B true CN111639508B (en) | 2023-04-25 |
Family
ID=72332272
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010474202.5A Active CN111639508B (en) | 2020-05-29 | 2020-05-29 | Bar code positioning frame correction method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111639508B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112444203B (en) * | 2020-11-18 | 2022-06-21 | 上海原观科技有限公司 | Vehicle position detection device and method based on barcode strip and vehicle positioning system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106599758A (en) * | 2016-11-29 | 2017-04-26 | 努比亚技术有限公司 | Image quality processing method and terminal |
CN107644183A (en) * | 2017-09-01 | 2018-01-30 | 福建联迪商用设备有限公司 | One-dimension code CMOS images the coding/decoding method and terminal of engine |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP2393036B1 (en) * | 2010-06-01 | 2016-03-02 | Fujian Newland Computer Co., Ltd. | Barcode decoding chip |
-
2020
- 2020-05-29 CN CN202010474202.5A patent/CN111639508B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106599758A (en) * | 2016-11-29 | 2017-04-26 | 努比亚技术有限公司 | Image quality processing method and terminal |
CN107644183A (en) * | 2017-09-01 | 2018-01-30 | 福建联迪商用设备有限公司 | One-dimension code CMOS images the coding/decoding method and terminal of engine |
Also Published As
Publication number | Publication date |
---|---|
CN111639508A (en) | 2020-09-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109657629B (en) | Text line extraction method and device | |
US9135489B2 (en) | System for decoding two dimensional code and method thereof | |
US9070034B2 (en) | Method and system for correcting QR code image | |
CN110502985B (en) | Form identification method and device and form identification equipment | |
US9449210B2 (en) | Method and system for detecting a correction pattern in a QR code | |
CN110796095B (en) | Instrument template establishing method, terminal equipment and computer storage medium | |
CN112528776B (en) | Text line correction method and device | |
CN111639508B (en) | Bar code positioning frame correction method, device, equipment and storage medium | |
US8538191B2 (en) | Image correction apparatus and method for eliminating lighting component | |
CN101727580A (en) | Image processing apparatus, electronic medium, and image processing method | |
CN111046693B (en) | Two-dimensional code scanning method and device, terminal equipment and storage medium | |
CN114500205B (en) | AIS signal decoding method, AIS signal decoding device and storage medium | |
CN110110697B (en) | Multi-fingerprint segmentation extraction method, system, device and medium based on direction correction | |
CN103034830A (en) | Bar code decoding method and device | |
CN110929738A (en) | Certificate card edge detection method, device, equipment and readable storage medium | |
US20220276754A1 (en) | Stroke erase method, terminal, and computer-readable storage medium | |
CN113139399A (en) | Image line frame identification method and server | |
CN112766266A (en) | Text direction correction method, system and device based on staged probability statistics | |
CN112528889A (en) | OCR information detection and correction method, device, terminal and storage medium | |
CN111291649A (en) | Image recognition method and device and electronic equipment | |
CN111639506B (en) | Positioning method and device for bar codes in image and code scanning equipment | |
JP2011008770A (en) | Method and device for detecting document direction | |
CN113378865B (en) | Image pyramid matching method and device | |
CN113505745B (en) | Character recognition method and device, electronic equipment and storage medium | |
CN111709419A (en) | Method, system and equipment for positioning banknote serial number and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |