Nothing Special   »   [go: up one dir, main page]

CN111639507B - Positioning method and device for bar codes in image, code scanning equipment and storage medium - Google Patents

Positioning method and device for bar codes in image, code scanning equipment and storage medium Download PDF

Info

Publication number
CN111639507B
CN111639507B CN202010473318.7A CN202010473318A CN111639507B CN 111639507 B CN111639507 B CN 111639507B CN 202010473318 A CN202010473318 A CN 202010473318A CN 111639507 B CN111639507 B CN 111639507B
Authority
CN
China
Prior art keywords
image
candidate
angle
line segment
target
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
Application number
CN202010473318.7A
Other languages
Chinese (zh)
Other versions
CN111639507A (en
Inventor
张沐然
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianjin Weichuang Micro Intelligent Technology Co ltd
Original Assignee
Tianjin Weichuang Micro Intelligent Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tianjin Weichuang Micro Intelligent Technology Co ltd filed Critical Tianjin Weichuang Micro Intelligent Technology Co ltd
Priority to CN202010473318.7A priority Critical patent/CN111639507B/en
Publication of CN111639507A publication Critical patent/CN111639507A/en
Application granted granted Critical
Publication of CN111639507B publication Critical patent/CN111639507B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods 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/1404Methods for optical code recognition
    • G06K7/1439Methods for optical code recognition including a method step for retrieval of the optical code
    • G06K7/1443Methods for optical code recognition including a method step for retrieval of the optical code locating of the code in an image

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)
  • Image Analysis (AREA)

Abstract

The invention discloses a method and a device for positioning a bar code in an image, code scanning equipment and a storage medium, wherein the method comprises the following steps: searching candidate line segments from the scanned image to be positioned and obtaining candidate line segment information of each candidate line segment, wherein the candidate line segment information comprises position coordinate information and angle information; grouping the candidate line segments by taking the angles as references according to the information of the candidate line segments to obtain target angle groups meeting the set conditions; dividing the area of the image to be positioned into at least one image partition by taking the set length and width as references, and determining target image partitions from the image partitions according to each target angle group; the barcode region is located based on the candidate line segments in the target image partition. By utilizing the method, the problems of slow positioning and high positioning error rate of the bar code area caused by the excessively high noise proportion of the candidate line segments are effectively avoided, and the running strength of searching the line segments and positioning the bar code area is reduced, so that the positioning speed and the decoding speed of the bar code are ensured.

Description

Positioning method and device for bar codes in image, code scanning equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of image processing, in particular to a method and a device for positioning a bar code in an image, code scanning equipment and a storage medium.
Background
At present, the bar codes are widely applied to various fields in life, such as circulating commodities, express bill and the like, the price information of the circulating commodities is recorded through the bar codes or commodity information tracing is carried out, and the bar codes in the express bill can also be used for recording the logistics information of the express bill.
In general, information carried in a bar code is required to be obtained by decoding the bar code, and the key of decoding the bar code is to scan a target object containing the bar code and locate a location area where the bar code is located from an image obtained by scanning. At present, a target object containing a bar code is mostly scanned by a code scanning gun or electronic equipment integrated with a code scanning function, and then a global searching method is adopted to locate a position area where the bar code is located from an image captured by scanning.
In the process of implementing barcode positioning based on global search, the line segments (many of which are not black bar segments forming the barcode and also include other noise line segments) included in the image are generally searched globally, and then the line segments are screened to determine the rectangular area most likely to contain the black bar of the barcode. However, if the content contained in the scanned image is more complex, the smaller the ratio of the bar code black bar to the globally found line segment, if the globally found straight line is directly used for determining the rectangle where the subsequent bar code black bar is located, excessive occupation of operation resources can be caused, and meanwhile, a plurality of rectangular areas for identifying the bar code black bar can be possibly positioned from the image, or the determined rectangular areas contain wrong noise line segments, so that the timeliness of bar code positioning is influenced, and the accuracy of bar code positioning is also influenced.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a storage medium for positioning a bar code in an image, which solve the problems of slow positioning and high positioning error rate caused by too many line segments and too high noise ratio in the existing bar code positioning realization.
In a first aspect, an embodiment of the present invention provides a method for positioning a barcode in an image, including:
searching candidate line segments from the scanned image to be positioned and obtaining candidate line segment information of each candidate line segment, wherein the candidate line segment information comprises position coordinate information and angle information;
grouping the candidate line segments by taking angles as references according to the candidate line segment information to obtain target angle groups meeting set conditions;
dividing the region of the image to be positioned into at least one image partition by taking the set length and width as references, and determining a target image partition from the image partitions according to each target angle group;
and positioning a bar code area based on the candidate line segments in the target image partition.
In a second aspect, an embodiment of the present invention further provides a device for positioning a barcode in an image, including:
The line segment searching module is used for searching candidate line segments from the scanned image to be positioned and obtaining candidate line segment information of each candidate line segment, wherein the candidate line segment information comprises position coordinate information and angle information;
the line segment grouping module is used for grouping the candidate line segments by taking angles as references according to the candidate line segment information to obtain target angle groupings meeting set conditions;
the target determining module is used for dividing the region of the image to be positioned by taking the set length and width as the reference to form at least one image partition, and determining target image partitions from the image partitions according to each target angle group;
and the region positioning module is used for positioning the bar code region based on the candidate line segments in the target image partition.
In a third aspect, an embodiment of the present invention further provides a code scanning device, including: a memory and one or more processors;
the memory is used for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of locating a barcode in an image as described in the first aspect.
In a fourth aspect, embodiments of the present invention also provide a storage medium containing computer-executable instructions which, when executed by a computer processor, are used to perform a method of locating a barcode in an image as described in the first aspect.
The embodiment of the invention provides a method, a device, equipment and a storage medium for positioning a bar code in an image, wherein the method comprises the following steps: firstly searching candidate line segments from the scanned image to be positioned, obtaining line segment information of each candidate line segment, and then grouping each candidate point segment by taking an angle as a reference according to the line segment information to obtain a target angle group meeting a set condition; and then carrying out region division on the image to be positioned by taking the length and width of the set layer as a reference to form at least one image partition, determining a target image partition from the image partitions according to each target group, and finally positioning the bar code region based on candidate line segments in the target image partition. According to the technical scheme, the image partitions with the highest bar code segment occupation ratio can be screened out according to the segment information of the candidate segment and combined according to the angle and the length and width regions to be used for positioning the bar code regions, and the method can effectively avoid the problems of low bar code region positioning and high positioning error rate caused by the fact that the noise proportion of the candidate segment is too high, reduces the running strength of searching the segment and positioning the bar code regions, and accordingly ensures the positioning speed and decoding speed of the bar code.
Drawings
Fig. 1 is a flowchart of a method for positioning a barcode in an image according to a first embodiment of the present invention;
fig. 2 is a flow chart of a method for positioning a barcode in an image according to a second embodiment of the present invention;
fig. 3 is a block diagram of a positioning device for a barcode in an image according to a third embodiment of the present invention, and fig. 4 is a schematic diagram of a barcode scanning device 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 further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Example 1
Fig. 1 is a flow chart of a method for positioning a barcode in an image according to a first embodiment of the present invention, where the method is suitable for positioning the barcode in a captured image so as to decode the barcode, and the method is performed by a positioning device for the barcode in the image, where the positioning device for the barcode in the image may be implemented in a software and/or hardware manner, and may be specifically integrated in an electronic device with a specific barcode scanning function, where the electronic device may be a barcode scanning gun or a barcode scanning desk lamp. As shown in fig. 1, the method specifically includes the following steps:
S101, searching candidate line segments from the scanned image to be positioned, and obtaining candidate line segment information of each candidate line segment.
In this embodiment, the image to be positioned may be specifically understood as an image containing a barcode to be identified, where the image to be positioned may be captured by an information capturing component built in the code scanning device, and, for example, when the code scanning device is a code scanning gun, an image containing the barcode to be identified may be captured by a scanning component built in the front end of the code scanning gun and recorded as an image to be positioned. It is known that in practical applications, the code scanning device can aim the code scanning component at an article (such as an express item, a document, and a commodity to be purchased) containing a bar code to be identified, so that image information of the article can be obtained through capturing.
In this embodiment, the image to be located may be processed in a conventional manner, such as gray boundary location or binary image location, so that all the line segments included in the image to be located may be obtained, and the obtained line segments may be recorded as candidate line segments. In this embodiment, the candidate line segment information of each candidate line segment preferably includes position coordinate information and angle information.
S102, grouping the candidate line segments by taking angles as references according to the candidate line segment information to obtain target angle groups meeting set conditions.
It should be noted that, for an image to be positioned captured by the code scanning device, assuming that a coordinate system is constructed by taking the top left corner vertex of the image to be positioned as the origin of coordinates, a line segment included in the image to be positioned may not be parallel or perpendicular to the abscissa axis/ordinate axis of the constructed coordinate system, but may exhibit various different angle values on the coordinate axis (based on the abscissa axis), and the angle value of each line segment may be used as the angle information of the line segment in this embodiment, and the angle information is included in the obtained candidate line segment information.
On the basis that the candidate line segments have angle information, the embodiment can group the candidate line segments based on the angle, namely, the circumference can be considered to be divided into a plurality of angle partitions with equal angles by 360 degrees, and then the angle information of the candidate line segments can be used for judging which angle partition the candidate line segments can fall into. In addition, after dividing the candidate line segments into different angle partitions according to the angle information, it can determine how many candidate line segments are included in each angle partition, and in this embodiment, the number of the included candidate line segments may be used as a screening dimension to set a setting condition, for example, the setting condition is that the data amount of the candidate line segments is greater than a threshold value, or the number ranking of the candidate line segments needs to be before which, and in this step, the angle partition meeting the condition may be determined as the target angle group through the screening of the setting condition.
S103, carrying out region division on the image to be positioned by taking the set length and width as a reference to form at least one image partition, and determining a target image partition from the image partitions according to each target angle group.
In this embodiment, after the candidate line segments are angularly divided and screened in S102, the image division may be performed by this step based on the image division of the image to be located, and the target image partition with the highest bar code line segment ratio among the line segments included in the divided image partitions may be selected based on the candidate line segments included in the selected target angular group.
Specifically, the set length and width can be set according to the image resolution of the image to be positioned, so as to ensure that the image to be positioned can be divided into at least one image partition with equal area according to the set length and width. It can be understood that, after the image to be positioned is partitioned by adopting the set length and width in this step, the determined candidate line segments may fall into each formed image partition, that is, each image partition may include some candidate line segments with the same or different angle information.
In this embodiment, because the candidate line segments falling into different image partitions may also fall into different angle partitions based on the angle information included therein, after the above-mentioned determination of the target angle group, it is known which candidate line segments are included in the target angle group, so that after the determination of the image partition, it is determined which image partition includes the most line segments of the candidate line segments included in the target angle group, and this step may finally determine the image partition including the most line segments of the candidate line segments included in the target angle group as the target image partition.
It should be noted that, when more than one target angle group is determined in S102, the method of this step may be adopted to first select, from the image partitions, the candidate image partition with the most candidate line segments corresponding to each target angle group, and then select the candidate image partition according to a certain condition to determine one of the candidate image partitions as the target image partition. For example, the certain condition may be a comparison of the number of candidate segments under the target angle group contained in the image partition.
S104, positioning a bar code area based on the candidate line segments in the target image partition.
In this embodiment, the candidate line segments grouped at a certain target angle in the determined target image partition have the same angle value, and in this step, the image partition may be extended along the complementary angle direction of the angle value according to the angle values of the candidate line segments until reaching the extension end condition, and the formed region is determined as the barcode region.
According to the method for positioning the bar code in the image, which is provided by the embodiment of the invention, the image partition with the highest bar code segment occupation ratio can be screened out according to the segment information of the candidate segment and combined with the grouping according to the angle and the length and width regions to be used for positioning the bar code region.
Example two
Fig. 2 is a flow chart of a method for positioning a barcode in an image according to a second embodiment of the present invention, where the embodiment is optimized based on the foregoing embodiment, and in this embodiment, the step of grouping each candidate line segment based on an angle according to each candidate line segment information to obtain a target angle group satisfying a set condition is further performed as follows: acquiring angle information in the candidate line segment information, and determining a display angle value of each candidate line segment in the image to be positioned; acquiring a set angle dividing step length, and dividing the peripheral angle according to the angle dividing step length from an angle value 0 to form at least one angle dividing section; according to the display angle value of each candidate line segment, determining an angle division interval to which each candidate line segment belongs, and forming at least one candidate angle group; and sequencing the candidate angle groups in the preset position according to the number of the candidate line segments contained in each candidate angle group from big to small, and determining the candidate angle group with the sequence in the preset position as a target angle group.
Meanwhile, determining a target image partition from the image partitions according to each of the target angle groups is further embodied as: for each target angle group, determining a target line segment with the largest length according to candidate line segment information of candidate line segments in the target angle group, and recording a target angle value of the target line segment; traversing each image partition, counting the number of line segments with the target angle value in each image partition, and determining the image partition corresponding to the maximum number of line segments as a candidate image partition; and comparing the maximum line segments of the candidate image partitions corresponding to the target angle groups, and determining the target image partition from the candidate image partitions according to the comparison result.
In addition, the present embodiment further embodies locating a barcode region based on the candidate line segments in the target image partition as follows: extracting target angle information of the longest candidate line segment included in the target image partition; determining a reference extending direction according to the target angle information, and performing regional extension on the target image partition along the reference extending direction; when the extension is detected to meet the set extension condition, the image area formed after the extension is determined as a bar code area.
As shown in fig. 2, a method for positioning a barcode in an image according to a second embodiment of the present invention specifically includes the following steps:
s201, searching candidate line segments from the scanned image to be positioned, and obtaining candidate line segment information of each candidate line segment.
For example, an image binarization positioning method may be used to obtain candidate line segments and corresponding candidate line segment information in the image to be positioned. The candidate line segment information comprises end point coordinate information of the candidate line segment and angle information presented by the candidate line segment in the image to be positioned.
S202, acquiring angle information in the candidate line segment information, and determining a display angle value of each candidate line segment in the image to be positioned.
In this embodiment, the angle information may specifically be an angle value represented by the candidate line segment in the image to be positioned, where the angle value may be determined with respect to a coordinate system constructed by the top left corner vertex of the image to be positioned, and this embodiment is denoted as a display angle value.
S203, acquiring a set angle dividing step length, and dividing the peripheral angle according to the angle dividing step length from an angle value 0 to form at least one angle dividing section.
In the present embodiment, the entire angle range in which the angle division is performed is 0 to 360 degrees, and the angle division step size can be set to 10 degrees, thereby forming 36 angle division sections.
S204, determining an angle division interval to which each candidate line segment belongs according to the display angle value of each candidate line segment, and forming at least one candidate angle group.
In this embodiment, each candidate line segment has a display angle value, and after the angle division section is formed in S203, the angle division range of each angle division section is clarified, and if the angle division section is formed in this embodiment, the section number of each angle division section is also determined correspondingly, and each determined division section may be represented by the section number.
For example, assuming that the angular division range of one of the angular division sections is 0 to 10 degrees, if the display angle value of one candidate line segment is 5 degrees, the candidate line segment may be considered to belong to the angular division section with the section number of 1, or if each angular division section is not identified by the section number and is directly represented by the angular division range of the angular division section, the candidate line segment may be recorded to belong to the angular division section of [0,10 ° ].
Through the operation of the step, which angle division section each candidate line segment belongs to can be determined, and after the angle division sections to which all the candidate line segments belong are determined, the angle division sections and the belonged candidate line segments are associated to form candidate angle groups with the same number as the angle division sections.
S205, sorting according to the number of candidate line segments contained in each candidate angle group from large to small, and determining the candidate angle group with the sorting in the preset position as a target angle group.
Illustratively, this step may sort the number of candidate line segments as a set condition for the screening target angle group, and may sort the top 3 bits as a set condition to be possessed. Thus, if the number of candidate line segments included in three candidate angle groups of [40 °,50 ° ], 90 °,100 ° ] and [30 °,40 ° ] among the candidate angle groups is set to the first three, the three candidate angle groups can be determined as target angle groups.
S206, carrying out region division on the image to be positioned by taking the set length and width as a reference to form at least one image partition.
For example, assuming that the image resolution of the image to be positioned is 960×640, the length of the entire image to be positioned is 960 pixels, the width is 640 pixels, and if the length and width are set to 30 and 20, 32×32 image partitions can be divided.
S207, for each target angle group, determining a target line segment with the largest length according to the candidate line segment information of each candidate line segment in the target angle group, and recording the target angle value of the target line segment.
By the execution of S205, at least one target angle group can be obtained, the specific implementation procedure of the target image partition is given in this step and S208 and S209 described below, and the operations of this step and S207 described below are the operations for each target angle group. For each target angle group, the candidate line segments may be screened according to candidate line segment information of the candidate line segments included in the target angle group. For example, the length of each candidate line segment may be determined according to position coordinate information (mainly composed of coordinates of two end points of the line segment) in the candidate line segment information, and a target line segment having the largest line segment may be selected, and the display angle of the target line segment may be determined as the target angle value of the target line segment.
It will be appreciated that for the current bar codes of comparison, the length of the bar code line segments is of a certain character, the length of the line segments is longer than the length of other lines (such as text lines or marking lines) on the article carrying the bar code, and the number of the line segments with the same display angle is also different. In this case, when a plurality of candidate line segments having the largest line segment lengths are determined from the position coordinate information, the candidate line segments are considered to be the longest line segments, and if the display angles of the longest line segments are the same, the longest line segments are considered to be target line segments, and if some of the longest line segments have different display angles, the longest line segments having the same display angle are considered to be target line segments, and the display angle corresponding to the target line segments corresponds to the target angle value.
S208, traversing each image partition, counting the number of line segments with the target angle value in each image partition, and determining the image partition corresponding to the maximum number of line segments as a candidate image partition.
In this embodiment, after determining the target line segments and the corresponding target angle values from the processed target angle groups, the above-mentioned divided image partitions may be traversed through this step, and the number of line segments of the candidate line segments having the determined target angle values in each image partition may be determined through the traversing operation, and the number of line segments of which image partition has the largest value may be determined, so that the image partition corresponding to the largest number of line segments may be determined as the candidate image partition.
It can be appreciated that the number of candidate image partitions provided in this embodiment is the same as the number of target angle groups provided, i.e. one candidate image partition corresponds to one candidate image partition.
S209, comparing the maximum line segments of the candidate image partitions corresponding to the target angle groups, and determining the target image partition from the candidate image partitions according to the comparison result.
In this embodiment, the target image partition may be further selected from the candidate image partitions through this step. Specifically, for each candidate image partition corresponding to the target angle group, there is data information of the maximum line segment number determined through the above operation. The step can compare the number of the maximum line segments with a set number value, or compare the number of the maximum line segments, and determine the final target image partition through the comparison result.
Preferably, in this embodiment, the comparing the maximum line segments of the candidate image partitions corresponding to the target angle groups may further include: comparing the number of the maximum line segments with the set line segment number respectively; if the comparison result shows that the candidate image partition with the maximum line segment quantity being greater than or equal to the set line segment quantity exists, determining the candidate image partition with the maximum line segment quantity being greater than the set line segment quantity as a target image partition; otherwise, comparing the sizes of the maximum line segment quantities, and determining the candidate image partition with the maximum value of the maximum line segment quantity as the target image partition.
In this embodiment, regarding the process of selecting the target image partition based on the maximum number of line segments as two comparison operations, first, this embodiment presets a set line segment amount for which the set line segment amount is determined as a percentage value (e.g., 70%) of the number of line segments in consideration of the number of line segments that the bar code can have (this percentage value can be set mainly by taking into consideration the distance between two adjacent line segments, the number of line segments that the bar code has, and the area size of each image partition, etc.).
In this step, the number of the maximum line segments may be compared with the determined set line segment number, and when the number of the maximum line segments exceeds the set line segment number, the candidate image partition corresponding to the number of the maximum line segments includes the maximum possible number of the bar line segments, so that the candidate image partition corresponding to the number of the maximum line segments (or possibly a plurality of candidate image partitions, mainly considering that one image to be positioned may contain a plurality of bar codes) may be directly used as the target image partition.
In contrast, it is also possible to find that there is no maximum number of line segments satisfying the above condition by the above comparison with the set number of line segments, and the present embodiment further compares these maximum number of line segments, thereby selecting the maximum number of line segments with the largest value, and taking the candidate image partition corresponding thereto as the target image partition.
The following S210 to S212 of the present embodiment give an implementation procedure of determining a barcode region by target image division.
S210, extracting target angle information of the longest candidate line segment included in the target image partition.
Specifically, the implementation of the barcode region positioning in this embodiment may be reduced to be performed as much as possible on the basis of the target image partition, that is, the barcode line may extend only in the direction in which the barcode line may exist on the basis of the candidate line included in the target image partition, based on which, firstly, the longest candidate line having the largest length value may be selected from the candidate line segments included in the target image partition through this step, and the angle information may be obtained from the candidate line segment information of the longest candidate line segment as the target angle information.
S211, determining a reference extending direction according to the target angle information, and performing regional extension on the target image partition along the reference extending direction.
After the target angle information is determined, in order to find all candidate line segments identical to the target angle information, the candidate line segments can extend in the complementary angle direction of the target angle information, and the extending direction can be regarded as a reference extending direction, and the covering area of the extending target image partition can be controlled under the limitation of the reference extending direction.
And S212, when the extension is detected to meet the set extension condition, determining the image area formed after extension as a bar code area.
In the process of executing S211 described above, if it is monitored that the extension of the target image partition satisfies the set extension condition, the extension of the target image partition may be stopped, and the image area formed after the extension may be determined as a barcode area.
Preferably, the setting the extension condition may include: the extension position reaches the image edge of the image to be positioned, or the formed extension area contains a pre-designated target object. The target object may be, for example, an extension end mark previously identified in the image to be localized.
The method for positioning the bar code in the image provided by the embodiment II of the invention embodies the determination process of the target angle grouping, also embodies the acquisition process of the target image partition, and finally provides the specific positioning operation of the bar code area. By using the method provided by the embodiment, the image partition with the heaviest line segment ratio as the bar code is determined from the angle dimension of the line segment display angle and the area division dimension of the image division, and then the positioning of the bar code area can be obtained only by processing the high-weight image partition, so that the problems of slow positioning and high positioning error rate of the bar code area caused by the excessively high noise proportion of the candidate line segment are effectively avoided, the running strength of searching the line segment and positioning the bar code area is reduced, and the positioning speed and decoding speed of the bar code are ensured.
Example III
Fig. 3 is a block diagram of a positioning device for bar codes in images according to a third embodiment of the present invention, where the device may be implemented in software and/or hardware, and the device may be configured in a device, for example, a code scanning device such as a code scanning gun or a code scanning platform. As shown in fig. 3, the apparatus may specifically include: a line segment searching module 31, a line segment grouping module 32, a target determining module 33 and a region positioning module 34.
The line segment searching module 31 is configured to search candidate line segments from the scanned captured image to be positioned and obtain candidate line segment information of each candidate line segment, where the candidate line segment information includes position coordinate information and angle information;
a line segment grouping module 32, configured to group each candidate line segment with an angle as a reference according to each candidate line segment information, so as to obtain a target angle group that meets a set condition;
a target determining module 33, configured to divide the to-be-positioned image into at least one image partition by using a set length and a set width as references, and determine a target image partition from the image partitions according to each target angle group;
and the region positioning module 34 is used for positioning the bar code region based on the candidate line segments in the target image partition.
According to the positioning device for the bar code in the image, provided by the embodiment of the invention, the image partitions with the highest bar code segment occupation ratio can be screened out according to the segment information of the candidate segment and combined according to the angle and the length and width regions for positioning the bar code region.
Further, the line segment grouping module 32 may be specifically configured to obtain angle information in each candidate line segment information, and determine a display angle value of each candidate line segment in the image to be positioned; acquiring a set angle dividing step length, and dividing the peripheral angle according to the angle dividing step length from an angle value 0 to form at least one angle dividing section; according to the display angle value of each candidate line segment, determining an angle division interval to which each candidate line segment belongs, and forming at least one candidate angle group; and sequencing the candidate angle groups in the preset position according to the number of the candidate line segments contained in each candidate angle group from big to small, and determining the candidate angle group with the sequence in the preset position as a target angle group.
Further, the targeting module 33 may specifically include:
the angle value determining unit is used for determining a target line segment with the largest length according to the candidate line segment information of each candidate line segment in each target angle group and recording the target angle value of the target line segment;
the candidate determining unit is used for traversing each image partition, counting the number of line segments with the target angle value in each image partition, and determining the image partition corresponding to the maximum number of line segments as a candidate image partition;
and the target determining unit is used for comparing the maximum line segments of the candidate image partitions corresponding to the target angle groups and determining the target image partition from the candidate image partitions according to the comparison result.
Further, the target determining unit may specifically be configured to compare the number of the maximum line segments with a set line segment number, respectively; if the comparison result shows that the candidate image partition with the maximum line segment quantity being greater than or equal to the set line segment quantity exists, determining the candidate image partition with the maximum line segment quantity being greater than the set line segment quantity as a target image partition; otherwise, comparing the sizes of the maximum line segment quantities, and determining the candidate image partition with the maximum value of the maximum line segment quantity as the target image partition.
Further, the region positioning module 34 may be specifically configured to extract target angle information of a longest candidate line segment included in the target image partition; determining a reference extending direction according to the target angle information, and performing regional extension on the target image partition along the reference extending direction; when the extension is detected to meet the set extension condition, the image area formed after the extension is determined as a bar code area.
Further, setting the extension condition includes: the extension position reaches the image edge of the image to be positioned, or the formed extension area contains a pre-designated target object.
The device for positioning the bar code in the image can execute the method for positioning the bar code in the image provided by any embodiment of the invention, and has the corresponding functional module and beneficial effects of the execution method.
Example IV
Fig. 4 is a schematic structural diagram of a code scanning device according to a fourth embodiment of the present invention. Referring to fig. 4, the code scanning apparatus includes: processor 810, memory 820, input device 830, and output device 840. The number of processors 810 in the code scanning device may be one or more, and one processor 810 is illustrated in fig. 4. The number of memories 820 in the code scanning device may be one or more, and one memory 820 is illustrated in fig. 4. The processor 810, memory 820, input device 830, and output device 840 of the code scanning apparatus may be connected by a bus or other means, for example, in fig. 4. In an embodiment, the code scanning device may be a terminal device with a development function, such as a desktop computer, a notebook computer, or the like, or may be an electronic device for scanning codes, such as a code scanning gun, a code scanning platform, or the like.
The memory 820 is used as a computer readable storage medium for storing a software program, a computer executable program, and modules corresponding to the code scanning device according to any embodiment of the present invention (for example, the line segment searching module 31, the line segment grouping module 32, the target determining module 33, and the region locating module 34 in the locating device of the barcode in the image). Memory 820 may include primarily a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application program required for functionality; the storage data area may store data created according to the use of the device, etc. In addition, memory 820 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 820 may further include memory located remotely from processor 810, 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 means 830 may be used to receive input digital or character information and to generate key signal inputs related to user settings and function control of the device, as well as cameras for capturing images and pickup devices for capturing audio data. Output device 840 may include an audio device such as a speaker. It should be noted that the specific composition of the input device 830 and the output device 840 may be set according to the actual situation.
The processor 810 executes various functional applications of the device and data processing by running software programs, instructions and modules stored in the memory 820, namely, to implement the above-described method of locating a bar code in an image:
searching candidate line segments from the scanned image to be positioned and obtaining candidate line segment information of each candidate line segment, wherein the candidate line segment information comprises position coordinate information and angle information; grouping the candidate line segments by taking angles as references according to the candidate line segment information to obtain target angle groups meeting set conditions; dividing the region of the image to be positioned into at least one image partition by taking the set length and width as references, and determining a target image partition from the image partitions according to each target angle group; and positioning a bar code area based on the candidate line segments in the target image partition.
The code scanning device provided by the above embodiment can be used for executing the positioning method of the bar code in the image provided by any embodiment, and has corresponding functions and beneficial effects.
A fourth 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 method of locating a bar code in an image, comprising:
searching candidate line segments from the scanned image to be positioned and obtaining candidate line segment information of each candidate line segment, wherein the candidate line segment information comprises position coordinate information and angle information; grouping the candidate line segments by taking angles as references according to the candidate line segment information to obtain target angle groups meeting set conditions; dividing the region of the image to be positioned into at least one image partition by taking the set length and width as references, and determining a target image partition from the image partitions according to each target angle group; and positioning a bar code area based on the candidate line segments in the target image partition.
Of course, the storage medium containing the computer executable instructions provided by the embodiment of the invention is not limited to the operation of the method for positioning the bar code in the image as described above, but can also execute the related operation in the method for positioning the bar code in the image provided by any embodiment of the invention, and has the corresponding functions and beneficial effects.
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 robot, a personal computer, a server, or a network device, etc.) to execute the method for positioning a barcode in an image according to any embodiment of the present invention.
It should be noted that, in the positioning device for a barcode in an image, each unit and module included in the positioning device are only divided according to 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.
It is to be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, may be implemented using any one or combination of the following techniques, as is well known in the art: discrete logic circuits having logic gates for implementing logic functions on data signals, application specific integrated circuits having suitable combinational logic gates, programmable Gate Arrays (PGAs), field Programmable Gate Arrays (FPGAs), and the like.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
The above description is only illustrative of the preferred embodiments of the present invention and of the principles of the technology employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in the present invention is not limited to the specific combinations of the technical features described above, but also covers other technical features formed by any combination of the technical features described above or their equivalents without departing from the inventive concept described above. Such as the above-mentioned features and the technical features disclosed in the present invention (but not limited to) having similar functions are replaced with each other.

Claims (8)

1. A method for locating a bar code in an image, comprising:
searching candidate line segments from the scanned image to be positioned and obtaining candidate line segment information of each candidate line segment, wherein the candidate line segment information comprises position coordinate information and angle information;
grouping the candidate line segments by taking angles as references according to the candidate line segment information to obtain at least one target angle group meeting the set condition;
dividing the region of the image to be positioned into at least one image partition by taking the set length and width as references, and determining a target image partition from the image partitions according to each target angle group;
Locating a bar code region based on the candidate line segments in the target image partition;
grouping each candidate line segment by taking an angle as a reference according to the candidate line segment information to obtain at least one target angle group meeting a set condition, wherein the method comprises the following steps:
acquiring angle information in the candidate line segment information, and determining a display angle value of each candidate line segment in the image to be positioned;
acquiring a set angle dividing step length, and dividing the peripheral angle according to the angle dividing step length from an angle value 0 to form at least one angle dividing section;
according to the display angle value of each candidate line segment, determining an angle division interval to which each candidate line segment belongs, and forming at least one candidate angle group;
and sequencing the candidate angle groups in the preset position according to the number of the candidate line segments contained in each candidate angle group from big to small, and determining the candidate angle group with the sequence in the preset position as a target angle group.
2. The method of claim 1, wherein said determining a target image partition from each of said image partitions based on each of said target angle groupings comprises:
for each target angle group, determining a target line segment with the largest length according to candidate line segment information of candidate line segments in the target angle group, and recording a target angle value of the target line segment;
Traversing each image partition, counting the number of line segments with the target angle value in each image partition, and determining the image partition corresponding to the maximum number of line segments as a candidate image partition;
and comparing the maximum line segments of the candidate image partitions corresponding to the target angle groups, and determining the target image partition from the candidate image partitions according to the comparison result.
3. The method according to claim 2, wherein comparing the maximum number of line segments of the candidate image partitions corresponding to each of the target angle groups, and determining the target image partition from the candidate image partitions according to the comparison result, comprises:
comparing the number of the maximum line segments with the set line segment number respectively;
if the comparison result shows that the candidate image partition with the maximum line segment number larger than or equal to the set line segment number exists, determining the candidate image partition with the maximum line segment number larger than or equal to the set line segment number as a target image partition; otherwise the first set of parameters is selected,
and comparing the sizes of the maximum line segments, and determining the candidate image partition with the maximum line segment number and the maximum value as the target image partition.
4. A method according to any of claims 1-3, wherein said locating a barcode region based on candidate line segments in the target image partition comprises:
Extracting target angle information of the longest candidate line segment included in the target image partition;
determining a reference extending direction according to the target angle information, and performing regional extension on the target image partition along the reference extending direction;
when the extension is detected to meet the set extension condition, the image area formed after the extension is determined as a bar code area.
5. The method of claim 4, wherein the setting extension conditions comprises: the extension position reaches the image edge of the image to be positioned, or the formed extension area contains a pre-designated target object.
6. A device for locating a bar code in an image, comprising:
the line segment searching module is used for searching candidate line segments from the scanned image to be positioned and obtaining candidate line segment information of each candidate line segment, wherein the candidate line segment information comprises position coordinate information and angle information;
the line segment grouping module is used for grouping the candidate line segments by taking angles as references according to the candidate line segment information to obtain at least one target angle group meeting the set conditions;
the target determining module is used for dividing the region of the image to be positioned by taking the set length and width as the reference to form at least one image partition, and determining target image partitions from the image partitions according to each target angle group;
The region positioning module is used for positioning a bar code region based on the candidate line segments in the target image partition;
the line segment grouping module is specifically configured to:
acquiring angle information in the candidate line segment information, and determining a display angle value of each candidate line segment in the image to be positioned;
acquiring a set angle dividing step length, and dividing the peripheral angle according to the angle dividing step length from an angle value 0 to form at least one angle dividing section;
according to the display angle value of each candidate line segment, determining an angle division interval to which each candidate line segment belongs, and forming at least one candidate angle group;
and sequencing the candidate angle groups in the preset position according to the number of the candidate line segments contained in each candidate angle group from big to small, and determining the candidate angle group with the sequence in the preset position as a target angle group.
7. A code scanning device, comprising: a memory and one or more processors;
the memory is used for storing one or more programs;
when executed by the one or more processors, causes the one or more processors to implement the method of locating a barcode in an image as claimed in any one of claims 1 to 5.
8. A storage medium containing computer executable instructions which, when executed by a computer processor, are for performing the method of locating a bar code in an image as claimed in any one of claims 1 to 5.
CN202010473318.7A 2020-05-29 2020-05-29 Positioning method and device for bar codes in image, code scanning equipment and storage medium Active CN111639507B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010473318.7A CN111639507B (en) 2020-05-29 2020-05-29 Positioning method and device for bar codes in image, code scanning equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010473318.7A CN111639507B (en) 2020-05-29 2020-05-29 Positioning method and device for bar codes in image, code scanning equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111639507A CN111639507A (en) 2020-09-08
CN111639507B true CN111639507B (en) 2023-06-09

Family

ID=72332241

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010473318.7A Active CN111639507B (en) 2020-05-29 2020-05-29 Positioning method and device for bar codes in image, code scanning equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111639507B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004251855A (en) * 2003-02-21 2004-09-09 Toyo Seikan Kaisha Ltd Method for inspecting external surface of can
CN106056020A (en) * 2016-06-01 2016-10-26 东莞理工学院 Bar code detection and recognition method and system based on machine vision system
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN108073849A (en) * 2016-11-18 2018-05-25 杭州海康威视数字技术股份有限公司 Code detection method, apparatus and system
CN109711415A (en) * 2018-11-13 2019-05-03 平安科技(深圳)有限公司 Certificate profile determines method, apparatus and storage medium, server

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI369637B (en) * 2010-06-17 2012-08-01 Mstar Semiconductor Inc Barcode image recognition system and associated method for hand-held device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004251855A (en) * 2003-02-21 2004-09-09 Toyo Seikan Kaisha Ltd Method for inspecting external surface of can
CN106056020A (en) * 2016-06-01 2016-10-26 东莞理工学院 Bar code detection and recognition method and system based on machine vision system
CN106485183A (en) * 2016-07-14 2017-03-08 深圳市华汉伟业科技有限公司 A kind of Quick Response Code localization method and system
CN108073849A (en) * 2016-11-18 2018-05-25 杭州海康威视数字技术股份有限公司 Code detection method, apparatus and system
CN109711415A (en) * 2018-11-13 2019-05-03 平安科技(深圳)有限公司 Certificate profile determines method, apparatus and storage medium, server

Also Published As

Publication number Publication date
CN111639507A (en) 2020-09-08

Similar Documents

Publication Publication Date Title
CN111860502B (en) Picture form identification method and device, electronic equipment and storage medium
CN109753838B (en) Two-dimensional code identification method, device, computer equipment and storage medium
CN106156766B (en) Method and device for generating text line classifier
CN110619333B (en) Text line segmentation method, text line segmentation device and electronic equipment
CN109214334B (en) Lane line processing method and device
CN110503682B (en) Rectangular control identification method and device, terminal and storage medium
CN103984776A (en) Repeated image identification method and image search duplicate removal method and device
CN112990792A (en) Method and device for automatically detecting infringement risk and electronic equipment
CN107578011A (en) The decision method and device of key frame of video
CN114638294A (en) Data enhancement method and device, terminal equipment and storage medium
CN110796130A (en) Method, device and computer storage medium for character recognition
CN111767908A (en) Character detection method, device, detection equipment and storage medium
CN101989322B (en) Method and system for automatically extracting memory features of malicious code
US9922263B2 (en) System and method for detection and segmentation of touching characters for OCR
CN112132892B (en) Target position labeling method, device and equipment
CN111639507B (en) Positioning method and device for bar codes in image, code scanning equipment and storage medium
CN110796129A (en) Text line region detection method and device
CN111709951B (en) Target detection network training method and system, network, device and medium
CN111401377B (en) Meter data reading method and device, electronic equipment and storage medium
CN111639506B (en) Positioning method and device for bar codes in image and code scanning equipment
CN110826488B (en) Image identification method and device for electronic document and storage equipment
CN110688995B (en) Map query processing method, computer-readable storage medium and mobile terminal
CN113378902B (en) Video plagiarism detection method based on optimized video features
CN113065597A (en) Clustering method, device, equipment and storage medium
CN114495144A (en) Method and device for extracting form key-value information in text image

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