CN109918961B - Barcode positioning method based on image characteristics - Google Patents
Barcode positioning method based on image characteristics Download PDFInfo
- Publication number
- CN109918961B CN109918961B CN201910129971.9A CN201910129971A CN109918961B CN 109918961 B CN109918961 B CN 109918961B CN 201910129971 A CN201910129971 A CN 201910129971A CN 109918961 B CN109918961 B CN 109918961B
- Authority
- CN
- China
- Prior art keywords
- image
- bar code
- barcode
- height
- positioning method
- 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
Landscapes
- Character Input (AREA)
- Image Analysis (AREA)
- Character Discrimination (AREA)
Abstract
The invention discloses a barcode positioning method based on image characteristics, which comprises the following steps: acquiring an image and carrying out early-stage processing on the image to obtain a binary image; for height of binary imageDividing the degree and the length to obtain an image I2(ii) a Extracting an image I2The part containing the character content is judged by the inclination; equally sampling the corrected or non-corrected image to find out the transverse bar code area; carrying out black-white continuity judgment on the longitudinal bar code area, and intercepting the required bar code length; and determining the bar code area in the image according to the transverse bar code area and the bar code length. The invention allows positioning with the label or image containing the bar code tilted. The method fully utilizes the morphological characteristics of the bar code in a sampling-like mode to judge the image, and the speed is improved by a plurality of methods compared with other methods.
Description
Technical Field
The invention relates to the field of image processing, in particular to a barcode positioning method based on image characteristics.
Background
A bar code (barcode) is a graphic identifier in which a plurality of black bars and spaces having different widths are arranged according to a certain coding rule to express a set of information. The bar code is the most economical and practical automatic identification mode so far, has the advantages of high input speed, high reliability, rich information quantity, flexible use and the like, and has very low manufacturing cost due to simple manufacturing of the bar code label. Although a barcode includes only a certain number of numeric and alphabetical information, various information composed of the above characters are widely used in many fields such as commodity circulation, book management, postal management, and banking systems.
The identification of bar codes, which is currently most widely used, is to scan a bar code, and read the bar code by converting an optical signal into an electrical signal (pulse digital signal) through an optical-electrical converter inside a scanner. There are also many methods for obtaining barcode regions by processing images, including region block, edge detection, and the like. However, the above methods all need to calculate all the pixel points of the image, so the processing speed is quite slow, and the method is not suitable for the field combination with high real-time requirement.
The image rotation is basically determined by edge detection, and various conventional detection methods include sobel edge detection, gradient direction detection, canny edge detection, and more commonly used hough transformation, so that the basic effect on processing rotation is ideal, namely, the speed is slow, and particularly, when the image is large, the processing time is too long.
Disclosure of Invention
The invention aims to provide a barcode positioning method based on image characteristics. The invention locates the image containing the bar code by a method of sampling and extracting the characteristics, thereby finding the information of the required bar code in the image. The abstracted features have the characteristics of small data volume, clearness and simplicity, so that the actual calculated amount is reduced, and the processing speed is accelerated.
The purpose of the invention can be realized by the following technical scheme:
a barcode positioning method based on image characteristics comprises the following specific steps:
acquiring an image containing a bar code and processing the image to obtain a binary image;
dividing the height and the length of the binary image respectively to obtain an image I2;
Extracting an image I2The part containing the character content is judged by the inclination; if the sampling part has inclination, performing deflection correction on the whole image;
equally sampling the corrected or non-corrected image, taking out pixel point data meeting the conditions, analyzing, and finding out a transverse bar code area;
carrying out black-white continuity judgment on the longitudinal bar code area, and intercepting the required bar code length;
and determining the bar code area in the image according to the transverse bar code area and the bar code length.
Specifically, the obtained image is subjected to threshold processing, and the pixel point value of the obtained binarized image is 0 or 1.
Specifically, in the step of dividing the height and the length of the binarized image, the dividing method includes:
the height of the obtained binary image is divided into M equal parts, and M continuous lines in the image are selected for processingThe value of the pixel of (a)1,a2,…,am(ii) a Wherein a isiI · a, i is 1,2, …, and M, a is the value of M equally divided height in the image. Performing conversion judgment on the pixels of the selected m lines, namely recording the times of black-white exchange and finding out the line a with the most conversion timesiThen take aiTo ai+1All pixels in the interval are denoted as image I1。
For image I1The length of the image is divided into N equal parts, and the value of the pixel point after continuous N lines of processing in the image, namely b1,b2,…,bn(ii) a Wherein b isjJ, b, j being 1,2, …, N, b being the value of each aliquot height in the N aliquot image. The pixels of the selected n rows are converted and judged to find out the row b with the most conversion timesjThen in the image I1Get bjTo bj+1All pixels of the interval, obtaining an image I2。
Further, for the selection of MN, a and b are generally 1/10 of the height and length of the initial binary image respectively; the MNs may be equal.
In particular, the decimated image I2In the step of judging the inclination of the part containing character content, the image I is processed2And carrying out Hough transformation to judge whether the image has inclination. If the image has inclination, obtaining the inclination angle and correcting the whole image to obtain Imn。
Specifically, in the step of equally sampling the corrected or non-corrected image, taking out pixel point data meeting the conditions for analysis, and finding out the transverse barcode region, the method for finding out the transverse barcode region includes:
image ImnThe height of the image is equally divided by P, and the value of the pixel point processed by continuous P lines in the image, namely c1,c2,…,cp(ii) a Wherein c iskK · c, k being 1,2, …, P, c being the value of each aliquot height in the P aliquot image. Recording the times of changing pixel points in p lines from 0 to 1 or from 1 to 0, and if the conversion times of continuous k lines are similar according to the selected value of c, not more than1/5 of the total conversion times of the bar code, c is takenpTo cp+k-1As an image Ip。
And extracting pixel point data of p rows for analysis, and finding out a horizontal area of the bar code in the character content according to the morphological characteristics of the bar code.
Further, said c is generally taken as 1/10 of the initial binarized image height;
the morphological characteristics of the bar code are: since the content of the bar code displayed in the upright position is completely the same regardless of the width of the image containing characters, when the image is divided into small images of equal height, the selection of c as the initial binary image height 1/10 ensures that a plurality of consecutive lines of images containing bar codes can be captured, so that a plurality of consecutive lines can be directly determined as a bar code region.
Specifically, the black-and-white continuity determination method includes: and recording the condition that the pixel points are continuously 0 or 1, finding out the initial coordinate and the end coordinate which are continuously the same value, and conveniently calculating the continuous length.
Specifically, in the step of determining the barcode region in the image according to the transverse barcode region and the barcode length, the method for determining the barcode region in the image is as follows:
from picture IpObtaining the coordinates of the pixel points of each line from 0 to 1 or from 1 to 0, recording the coordinates of each line, comparing the obtained coordinates with the coordinates of each line, and removing the parts with different coordinates to obtain the complete bar code area Ib。
Since the longitudinal content of the bar code is identical, in image IpOn the basis, if the pixel points have different conversion positions from 0 to 1 or from 1 to 0, the pixel points are not bar code areas, the areas are removed, and the reserved areas are bar code areas.
Compared with the prior art, the invention has the following beneficial effects:
1. the invention utilizes the characteristic that the graph of the bar code is rectangular to correct the angle of the image, and has the advantages of quick search and high efficiency.
2. The method for detecting the bar code area by sampling the width is adopted according to the characteristic that the longitudinal content of the bar code is completely the same under any width condition, the principle of the method is simple and can be quickly realized, and the area of the bar code can be quickly selected in an image containing characters without carrying out other processing on a text.
Drawings
FIG. 1 is a flowchart illustrating a barcode positioning method based on image features according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of extracting a portion containing character content based on a barcode with image features according to the present invention;
FIG. 3 is a schematic diagram of the present invention for locating a barcode based on image features.
Detailed Description
The present invention will be described in further detail with reference to examples and drawings, but the present invention is not limited thereto.
Examples
Fig. 1 is a flowchart of a barcode positioning method based on image features, which includes the following specific steps:
(1) acquiring an image containing a bar code and processing the image to obtain a binary image;
(2) dividing the height and the length of the binary image respectively to obtain an image I2;
Specifically, the obtained image is subjected to threshold processing, and the pixel point value of the obtained binarized image is 0 or 1.
(3) Extracting an image I2The part containing the character content is judged by the inclination; if the sampling part has inclination, performing deflection correction on the whole image;
specifically, in the step of dividing the height and the length of the binarized image, the dividing method includes:
the height of the obtained binary image is divided by M, and the value of the pixel point processed by M continuous lines in the image, namely a, is selected1,a2,…,am(ii) a Wherein a isi=i·aI is 1,2, …, and M, a is the value of M equally divided height in the image. Performing conversion judgment on the pixels of the selected m lines, namely recording the times of black-white exchange and finding out the line a with the most conversion timesiThen take aiTo ai+1All pixels in the interval are denoted as image I1。
For image I1The length of the image is divided into N equal parts, and the value of the pixel point after continuous N lines of processing in the image, namely b1,b2,…,bn(ii) a Wherein b isjJ, b, j being 1,2, …, N, b being the value of each aliquot height in the N aliquot image. The pixels of the selected n rows are converted and judged to find out the row b with the most conversion timesjThen in the image I1Get bjTo bj+1All pixels of the interval, obtaining an image I2Image I2As shown in fig. 2.
Further, for the selection of MN, a and b are generally 1/10 of the height and length of the initial binary image respectively; the MNs may be equal.
(4) Equally sampling the corrected or non-corrected image, taking out pixel point data meeting the conditions, analyzing, and finding out a transverse bar code area;
in particular, the decimated image I2In the step of judging the inclination of the part containing character content, the image I is processed2And carrying out Hough transformation to judge whether the image has inclination. If the image has inclination, obtaining the inclination angle and correcting the whole image to obtain Imn。
Further, in order to minimize the processed data, M, N should be made as large as possible while ensuring that image I is kept as small as possible2The tilt angle can be discerned and therefore the selection at M, N needs to be adjusted from case to case.
(5) Carrying out black-white continuity judgment on the longitudinal bar code area, and intercepting the required bar code length;
specifically, the method for finding out the transverse barcode area comprises the following steps:
image ImnIs equally divided by P, and an image is takenThe value of the pixel point processed in the middle p lines, i.e. c1,c2,…,cp(ii) a Wherein c iskK · c, k being 1,2, …, P, c being the value of each aliquot height in the P aliquot image. Recording the times of changing pixel point from 0 to 1 or changing pixel point from 1 to 0 after binary processing of p rows, and taking out c according to the selected value of c (if the conversion times of continuous k rows are similar, namely not more than 1/5 of the total conversion times of the bar code)pTo cp+k-1As an image Ip。
And extracting pixel point data of p rows for analysis, and finding out a horizontal area of the bar code in the character content according to the morphological characteristics of the bar code. And (4) judging the black-white continuity of the longitudinal direction, thereby intercepting the length of the needed bar code.
Further, said c is generally taken as 1/10 of the initial binarized image height;
the morphological characteristics of the bar code are: since the content of the bar code displayed in the upright position is completely the same regardless of the width of the image containing characters, when the image is divided into small images of equal height, the selection of c as the initial binary image height 1/10 ensures that a plurality of consecutive lines of images containing bar codes can be captured, so that a plurality of consecutive lines can be directly determined as a bar code region.
(6) And determining the bar code area in the image according to the transverse bar code area and the bar code length.
Specifically, the method for determining the barcode region in the image comprises the following steps:
from picture IpAnd acquiring the coordinates of the pixel points of each line from 0 to 1 or from 1 to 0, recording the coordinates of each line, comparing the acquired coordinates with the coordinates of each line, and removing the parts with different coordinates. The complete bar code region I can be obtainedbObtaining a bar code region IbAs shown in fig. 3.
Since the longitudinal content of the bar code is identical, in image IpOn the basis, if the pixel points have different conversion positions from 0 to 1 or from 1 to 0, the pixel points are not bar code areas, the areas are removed, and the reserved areas are bar code areas.
The above embodiments are preferred embodiments of the present invention, but the present invention is not limited to the above embodiments, and any other changes, modifications, substitutions, combinations, and simplifications which do not depart from the spirit and principle of the present invention should be construed as equivalents thereof, and all such changes, modifications, substitutions, combinations, and simplifications are intended to be included in the scope of the present invention.
Claims (8)
1. A barcode positioning method based on image features is characterized in that the method positions an image containing a barcode by a method of sampling and extracting features, and comprises the following specific steps:
acquiring an image containing a bar code and processing the image to obtain a binary image;
dividing the height and the length of the binary image respectively to obtain an image(ii) a Specifically, the method comprises the following steps: the height of the obtained binary image is divided into M equal parts, and continuous images are selectedThe value of the line-processed pixel, i.e.(ii) a Wherein,The value of each equally divided height in the M equally divided image; for selectionThe conversion judgment is carried out on the pixels of the line, namely the number of black-white exchange is recorded, and the line with the most conversion times is found outThen get itToAll pixels in the interval are recorded as an image(ii) a For imagesIs divided into N equal parts, and continuous images are selectedThe value of the line-processed pixel, i.e.(ii) a Wherein,The value of each equally divided height in the N equally divided images; for selectionThe pixels of the column are converted and judged to find out the column with the most conversion timesThen in the imageGet andtoAll pixels of the interval, obtaining an image(ii) a Extracting imagesThe part containing the character content is judged by the inclination; if the sampling part has inclination, performing deflection correction on the whole image;
equally sampling the corrected or non-corrected image, taking out pixel point data meeting the conditions, analyzing, and finding out a transverse bar code area;
carrying out black-white continuity judgment on the longitudinal bar code area, and intercepting the required bar code length;
and determining the bar code area in the image according to the transverse bar code area and the bar code length.
2. The image feature-based barcode positioning method according to claim 1, wherein a threshold processing is performed on the acquired image, and a pixel point value of the obtained binarized image is 0 or 1.
3. The image feature-based bar code positioning method according to claim 1, wherein for the selection of MN, a, b respectively take 1/10 of the height and length of the initial binarized image; the MNs are equal.
4. The image feature-based bar code positioning method according to claim 1, wherein the extracted imageIn the step of determining the inclination of the part containing the character content, the image is processedCarrying out Hough transformation to judge whether the image has inclination; if the image has inclination, the inclination angle is obtained and the whole image is corrected to obtain the corrected image。
5. The image feature-based bar code positioning method according to claim 1, wherein in the step of equally sampling the corrected or non-corrected image, extracting pixel point data meeting the condition, analyzing, and finding out the transverse bar code region, the method for finding out the transverse bar code region is:
dividing the height of the corrected or unnecessary image into P equal parts, and taking the imageThe value of the line-processed pixel, i.e.(ii) a Wherein,The value of each halved height in the P halved image; to pairRecording the times that the pixel point is changed from 0 to 1 or from 1 to 0 after the line is binary, if continuousLines with similar number of transitions, i.e., no more than 1/5 of the total number of transitions of the bar code, are fetchedToAs an image。
7. The image feature-based barcode positioning method according to claim 1, wherein in the step of determining black and white continuity of the longitudinal barcode region and intercepting a required barcode length, the black and white continuity determining method comprises: and recording the condition that the pixel points are continuously 0 or 1, and finding out the initial coordinate and the end coordinate which are continuously the same value.
8. The image feature-based barcode positioning method according to claim 1, wherein in the step of determining the barcode region in the image according to the horizontal barcode region and the barcode length, the method for determining the barcode region in the image comprises:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910129971.9A CN109918961B (en) | 2019-02-21 | 2019-02-21 | Barcode positioning method based on image characteristics |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910129971.9A CN109918961B (en) | 2019-02-21 | 2019-02-21 | Barcode positioning method based on image characteristics |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109918961A CN109918961A (en) | 2019-06-21 |
CN109918961B true CN109918961B (en) | 2021-03-30 |
Family
ID=66962102
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910129971.9A Active CN109918961B (en) | 2019-02-21 | 2019-02-21 | Barcode positioning method based on image characteristics |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109918961B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009181219A (en) * | 2008-01-29 | 2009-08-13 | Toshiba Tec Corp | Bar code reader and its method |
CN102279922A (en) * | 2010-06-12 | 2011-12-14 | 晨星软件研发(深圳)有限公司 | Bar code image recognition system applied to handheld device and relevant method |
CN107908996A (en) * | 2017-10-25 | 2018-04-13 | 福建联迪商用设备有限公司 | A kind of method and terminal for extracting bar code information |
CN109101854A (en) * | 2018-06-25 | 2018-12-28 | 华南理工大学 | A kind of multiple barcode localization method |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US4219152A (en) * | 1979-02-21 | 1980-08-26 | International Business Machines Corporation | Dual threshold comparator circuit |
US5463211A (en) * | 1993-05-07 | 1995-10-31 | Spectra-Physics Scanning Systems, Inc. | Method and apparatus for detecting transitions in a time sampled input signal |
WO1999010866A1 (en) * | 1997-08-25 | 1999-03-04 | Imagicolor Corp | A system for distributing and controlling color reproduction at multiple sites |
CN101882204B (en) * | 2010-06-01 | 2012-05-23 | 福建新大陆电脑股份有限公司 | Matrix type two-dimensional bar code searching method |
CN108256375B (en) * | 2018-01-10 | 2021-04-06 | 钱志明 | One-dimensional bar code scanning method |
-
2019
- 2019-02-21 CN CN201910129971.9A patent/CN109918961B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009181219A (en) * | 2008-01-29 | 2009-08-13 | Toshiba Tec Corp | Bar code reader and its method |
CN102279922A (en) * | 2010-06-12 | 2011-12-14 | 晨星软件研发(深圳)有限公司 | Bar code image recognition system applied to handheld device and relevant method |
CN107908996A (en) * | 2017-10-25 | 2018-04-13 | 福建联迪商用设备有限公司 | A kind of method and terminal for extracting bar code information |
CN109101854A (en) * | 2018-06-25 | 2018-12-28 | 华南理工大学 | A kind of multiple barcode localization method |
Also Published As
Publication number | Publication date |
---|---|
CN109918961A (en) | 2019-06-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6778703B1 (en) | Form recognition using reference areas | |
CN107590447B (en) | Method and device for recognizing word title | |
EP1580683B1 (en) | Barcode recognition apparatus | |
CN110598566A (en) | Image processing method, device, terminal and computer readable storage medium | |
US8000535B2 (en) | Methods and systems for refining text segmentation results | |
CN111339797A (en) | Decoding method and terminal capable of accurately identifying damaged one-dimensional bar code | |
US10055668B2 (en) | Method for the optical detection of symbols | |
KR100383858B1 (en) | Character extracting method and device | |
JP2004280334A (en) | Image reading device | |
US20140086473A1 (en) | Image processing device, an image processing method and a program to be used to implement the image processing | |
JP4865844B2 (en) | Two-dimensional code reading method, two-dimensional code for reading by the two-dimensional code reading method, and recording medium on which the two-dimensional code reading method is recorded | |
CN109918961B (en) | Barcode positioning method based on image characteristics | |
JP5601027B2 (en) | Image processing apparatus and image processing program | |
CN112069852A (en) | Low-quality two-dimensional code information extraction method and device based on run-length coding | |
CN110084117A (en) | Document table line detecting method, system based on binary map segmented projection | |
JP4314148B2 (en) | Two-dimensional code reader | |
JP3022459B2 (en) | Form identification registration device | |
JPH10111904A (en) | Bar code reader and recording medium | |
JP2010250387A (en) | Image recognition device and program | |
JP5298830B2 (en) | Image processing program, image processing apparatus, and image processing system | |
JP3253201B2 (en) | Image processing device and image type determination method | |
JP5453594B2 (en) | Symbol information reading apparatus and symbol information reading method | |
CN109117844B (en) | Password determination method and device | |
JP2010086324A (en) | Binarization processing apparatus, information processing apparatus, binarization processing method, and binarization processing program | |
JP3634248B2 (en) | Character area extraction method, character area extraction apparatus, and recording 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 | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20230625 Address after: 510000 Room 104, 105, and 106, Building 5, No. 539 Shibei Industrial Road, Dashi Street, Guangzhou, Guangdong Province Patentee after: Guangzhou Chaers Medical Technology Co.,Ltd. Address before: 510640 No. five, 381 mountain road, Guangzhou, Guangdong, Tianhe District Patentee before: SOUTH CHINA University OF TECHNOLOGY |