CN111597849B - Method for extracting variable code region - Google Patents

Method for extracting variable code region Download PDF

Info

Publication number
CN111597849B
CN111597849B CN202010377847.7A CN202010377847A CN111597849B CN 111597849 B CN111597849 B CN 111597849B CN 202010377847 A CN202010377847 A CN 202010377847A CN 111597849 B CN111597849 B CN 111597849B
Authority
CN
China
Prior art keywords
lines
length
horizontal
region
vertical
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
CN202010377847.7A
Other languages
Chinese (zh)
Other versions
CN111597849A (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.)
Luster LightTech Co Ltd
Original Assignee
Luster LightTech 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 Luster LightTech Co Ltd filed Critical Luster LightTech Co Ltd
Priority to CN202010377847.7A priority Critical patent/CN111597849B/en
Publication of CN111597849A publication Critical patent/CN111597849A/en
Application granted granted Critical
Publication of CN111597849B publication Critical patent/CN111597849B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • 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/1452Methods for optical code recognition including a method step for retrieval of the optical code detecting bar code edges
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The application discloses a method for extracting a variable code region, which is used for extracting the variable code region in a surface image of a printed product, and is particularly suitable for the condition that the surface of the printed product to be detected contains a large number of variable codes densely distributed. In the application, by analyzing the feature difference between the shape of the variable code and other complex background patterns, and then according to the shape features of the variable code, the shape features comprise edge features, area features, corner features and the like, all bar codes, QR and DM variable code areas on the surface of the printed matter are extracted. Compared with the existing method for manually drawing the variable code region, the method for extracting the variable code region considers the morphological characteristics of the variable code, and automatically extracts the variable code region through the difference between the morphological characteristics, so that the running stability and usability of variable code detection software are improved, the modeling efficiency is obviously improved, and meanwhile, the expenditure of manpower and time is greatly reduced.

Description

Method for extracting variable code region
Technical Field
The application relates to the technical field of image information positioning and identification, in particular to a method for extracting a variable code region.
Background
Along with the popularization of terminal equipment such as computers, smart phones and the like, the variable code is used as an efficient information carrier and is widely applied to the fields of smoke and wine, foods, medicines, electronic products, article identification, logistics tracking and the like. The commonly used variable codes comprise bar codes and two-dimensional codes, wherein the two-dimensional codes comprise QR (Quick Response) codes and DM (Data Matrix) codes.
For variable codes printed on the surface of a print, quality detection is required for the variable codes on the surface of the print to detect unidentifiable or repeatedly occurring variable codes, thereby ensuring the accuracy of the variable codes. When the quality detection of the variable code is carried out, the positioning of the variable code area is needed first, namely the position range of the variable code on the surface of the printed product is determined, and the accurate positioning of the variable code area can effectively improve the quality detection efficiency. At present, the positioning process of the variable code area is mostly completed manually, and the specific process is as follows: and the operator determines the variable code area according to the printing position and the type of the variable code on the surface of the printed matter, and then draws the variable code area into variable code quality detection software, so that the positioning process of the variable code area is completed.
However, in the actual quality detection process, when the surface of the to-be-detected printed product contains a large number of variable codes densely distributed, as shown in fig. 1, if the above-mentioned manual positioning variable code area is still adopted, the workload of operators is increased, so that the complexity of the variable code detection software in the quality detection process in use is further increased, and the modeling efficiency in the variable code detection process is not utilized, so that the variable code quality detection process is time-consuming and labor-consuming.
Disclosure of Invention
The application provides a method for extracting a variable code region, which aims to solve the problems that the existing variable code region positioning process needs to be completed manually, the workload of operators is increased, and the complexity of a quality detection process is increased, so that the time and the labor are consumed in the variable code quality detection process.
The application provides a method for extracting a variable code region, which comprises the following steps:
extracting a bar code area in a surface image of a to-be-detected printed product, comprising: obtaining horizontal and vertical distribution lines according to edge features and area features of the surface image of the to-be-detected printed matter; dividing the horizontal and vertical distribution lines into a plurality of disjoint communicating domains according to the position characteristics of the horizontal and vertical distribution lines; according to the characteristic that the inclination angle of the communicating region is perpendicular to the included lines of the communicating region and the lengths of the included lines are basically equal, equal-length lines in each communicating region are obtained, and according to the equal-length lines, bar code candidate regions are determined; calculating the line distribution density of each candidate area according to the line number of the effective lines in the bar code candidate areas, and screening out the bar code areas from the plurality of bar code candidate areas according to the line number and the line distribution density;
extracting a QR code area in a surface image of a to-be-detected printed product comprises the following steps: carrying out Gaussian noise reduction, threshold segmentation and region screening on the image to obtain a plurality of suspected positioning blocks; screening to obtain a positioning block according to the gray standard deviation of the suspected positioning block and the number of the internal holes; performing adjacent traversal on all the positioning blocks, and obtaining a plurality of matched positioning blocks according to the position relationship of isosceles right triangles of three positioning blocks belonging to the same QR code; acquiring a QR code candidate region corresponding to the positioning block according to the included angle and the length ratio between the positioning block and the matched positioning block; screening to obtain QR code regions according to the number of corner points and the distribution density of the corner points contained in each QR code candidate region;
extracting a DM code area in a surface image of a to-be-detected printing product comprises the following steps: according to the edge detection operator, extracting edge features contained in the image, and splitting the edge features into straight lines; according to the length, the length-width ratio and the inclination angle of the straight line, horizontal distribution lines and vertical distribution lines are obtained through screening from the straight line; traversing the horizontal distribution lines and the vertical distribution lines to obtain straight line pairs with orthogonal distribution and equal length, and determining a minimum surrounding area formed by the straight line pairs as a DM code candidate area; obtaining a DM code area according to the number of corner points and the distribution density of the corner points contained in the DM code candidate area;
and carrying out region integration on the obtained bar code region, QR code region and DM code region to obtain a variable code region of the surface image of the to-be-detected printed product.
Optionally, according to the edge feature and the area feature of the surface image of the to-be-detected printed matter, obtaining horizontal and vertical distribution lines includes:
obtaining edge characteristics in the image through an edge detection algorithm;
splitting the edge features into straight lines and circular arcs according to the morphological differences of the edge features, and eliminating the circular arcs;
the regional characteristics comprise pixel area, length-width ratio and inclination angle, and the straight line with the pixel area larger than the preset pixel area, the length-width ratio larger than the preset length-width ratio and the inclination angle of [ -10,10], [ -90, -80] or [80,90] is obtained according to the pixel area, the length-width ratio and the inclination angle of the straight line;
and dividing the straight line obtained in the previous step into horizontal distribution lines and vertical distribution lines according to the inclination angle of the straight line.
Optionally, dividing the horizontal and vertical distribution lines into a plurality of disjoint connected domains according to the position features of the horizontal and vertical distribution lines, including:
the location features include euclidean distances between adjacent lines,
according to Euclidean distance of adjacent lines, the horizontal distribution lines are aggregated to obtain a plurality of disjoint horizontal line connected domains formed by the horizontal distribution lines;
and according to the Euclidean distance of the adjacent lines, the vertical distribution lines are aggregated to obtain a plurality of disjoint vertical line connected domains consisting of the vertical distribution lines.
Optionally, according to the feature that the inclination angle of the communicating domain is perpendicular to the included lines of the communicating domain and the lengths of the included lines are substantially equal, the equal length lines in each communicating domain are obtained, and according to the equal length lines, the bar code candidate region is determined, including:
calculating the corresponding inclination angle of each horizontal line communicating domain, obtaining equal-length horizontal lines of each horizontal line communicating domain according to the characteristic that the bar code direction is perpendicular to the line direction and the line length is basically equal, and determining a vertical bar code candidate region according to the equal-length horizontal lines;
calculating the corresponding inclination angle of each vertical line communicating domain, obtaining equal-length vertical lines of each vertical line communicating domain according to the characteristic that the bar code direction is vertical to the line direction and the line length is basically equal, and determining a horizontal bar code candidate region according to the equal-length vertical lines.
Optionally, calculating the line distribution density of each candidate region according to the number of lines of the effective lines in the bar code candidate regions, and screening the bar code regions from the plurality of bar code candidate regions according to the number of lines and the line distribution density, including:
acquiring all vertical lines contained in each horizontal bar code candidate area, and screening to obtain effective vertical lines with approximately equal length and vertical direction according to the average length and the central abscissa deviation of the lines; calculating the number of effective vertical lines and the line distribution density in the horizontal bar code candidate area; screening to obtain a horizontal bar code area according to the number of lines and the line distribution density;
acquiring all horizontal lines contained in each vertical bar code candidate area, and screening to obtain effective horizontal lines with approximately equal length and vertical direction according to the average length and the central abscissa deviation of the lines; calculating the number of effective horizontal lines and the line distribution density in the vertical bar code candidate area; screening to obtain a vertical bar code area according to the number of lines and the line distribution density;
and integrating all the horizontal bar code areas with the vertical bar code areas to obtain the bar code areas.
Optionally, performing gaussian noise reduction, threshold segmentation and region screening on the image to obtain a plurality of suspected positioning blocks, wherein the method comprises the following steps:
gaussian noise reduction is carried out on the image;
extracting all corner features of the image through a corner detection algorithm, and recording corner coordinates;
extracting a segmentation area with gray level difference larger than a preset gray level value from the surrounding neighborhood through threshold segmentation;
the method specifically comprises the steps of screening the partitioned area according to the rectangular degree, the width, the height, the length-width ratio and the number of internal holes of the partitioned area, and obtaining a plurality of suspected positioning blocks from the partitioned area.
Optionally, the calculation formula of the angular point distribution density is:
ρ=N/(W·H),
wherein N is the number of corner points contained in the QR code candidate region, and W and H are the width and the height of the QR code candidate region respectively.
Optionally, according to the length, the length-width ratio and the inclination angle of the straight line, horizontal distribution lines and vertical distribution lines are obtained by screening from the straight line, including:
according to the length, the length-width ratio and the inclination angle of the straight line, shape screening is carried out on the straight line, and the excessively long or excessively short interference line is removed, so that a horizontal or vertical straight line with moderate length is obtained;
respectively carrying out neighbor merging on the horizontal or vertical distribution lines to obtain merging lines;
then, according to the length-width ratio and the length of the combined lines, shape screening is carried out on the combined lines, and overlong or overlong lines are removed;
and screening the rest merging straight lines according to the inclination angle to obtain horizontal distribution lines and vertical distribution lines.
The application provides a method for extracting a variable code region, which is used for extracting the variable code region in a surface image of a printing product, in particular when the surface of the printing product to be detected contains a large number of variable codes densely distributed. In the application, all bar codes, QR and DM variable code areas on the surface of a printed matter are extracted by analyzing the difference characteristics between the morphological characteristics of the variable codes and the background patterns and then according to the morphological characteristics of the variable codes, wherein the morphological characteristics comprise edge characteristics, area characteristics, corner characteristics and the like.
Compared with the existing method for manually drawing the variable code region, the method for extracting the variable code region considers the morphological characteristics of the variable code, and automatically extracts the variable code region through the difference between the morphological characteristics, so that the running stability and usability of variable code detection software are improved, the modeling efficiency is obviously improved, and meanwhile, the expenditure of manpower and time is greatly reduced.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings that are needed in the embodiments will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a print image with a large number of dense variable codes on the surface, wherein a is a print image with only bar codes, b is a print image with only two-dimensional codes, c is a print image with both bar codes and two-dimensional codes, d is a dense bar code thumbnail, e is a dense QR code thumbnail, and f is a dense DM code thumbnail;
FIG. 2 is a flow chart of a method of extracting a variable code region according to the present application;
FIG. 3 is a flow chart of the present application for extracting bar code areas in a surface image of a print to be measured;
FIG. 4 is a flowchart of the present application for extracting QR regions in a surface image of a print to be tested;
FIG. 5 is a schematic diagram of locating block pairing;
fig. 6 is a flowchart of the present application for extracting DM area in a surface image of a print to be measured.
Detailed Description
The application provides a method for extracting a variable code region, which is used for extracting the variable code region in a surface image of a printing product, in particular when the surface of the printing product to be detected contains a large number of variable codes densely distributed.
Fig. 2 is a flowchart of a method for extracting a variable code region according to the present application, and as shown in fig. 2, the method for extracting a variable code region according to the present application includes:
step S100, extracting a bar code area in the surface image of the to-be-detected printing product.
Fig. 3 is a flowchart of extracting a bar code area in a surface image of a to-be-detected print, and as shown in fig. 3, the extracting of the bar code area in the surface image of the to-be-detected print includes the following steps:
step S110, according to the edge characteristics and the area characteristics of the surface image of the to-be-detected printing product, horizontal and vertical distribution lines are obtained.
In this example, the specific implementation method of step S110 includes: step S111, obtaining edge characteristics in the image through an edge detection algorithm; step S112, splitting the edge features into straight lines and circular arcs according to the morphological differences of the edge features, and eliminating the circular arcs; step S113, the regional characteristics comprise pixel area, length-width ratio and inclination angle, and the straight line with the pixel area larger than the preset pixel area, the length-width ratio larger than the preset length-width ratio and the inclination angle of [ -10,10], [ -90, -80] or [80,90] is obtained according to the pixel area, the length-width ratio and the inclination angle of the straight line; step S114, dividing the straight line obtained in the previous step into horizontal distribution lines and vertical distribution lines according to the inclination angle of the straight line.
It should be noted that, a person skilled in the art may adjust the specific value of the preset Pixel area according to actual needs, for example, set the preset Pixel area to be 50Pixel. The specific value of the preset length-width ratio can be adjusted according to actual needs by a person skilled in the art, for example, the preset length-width ratio is set to be 3.
Step S120, dividing the horizontal and vertical distribution lines into a plurality of disjoint connected domains according to the position features of the horizontal and vertical distribution lines.
In this example, the specific implementation method of step S120 includes: the position features comprise Euclidean distances between adjacent lines, and the horizontal distribution lines are aggregated according to the Euclidean distances of the adjacent lines to obtain a plurality of disjoint horizontal line connected domains consisting of the horizontal distribution lines; and according to the Euclidean distance of the adjacent lines, the vertical distribution lines are aggregated to obtain a plurality of disjoint vertical line connected domains consisting of the vertical distribution lines.
For better understanding of the polymerization process, a vertical distribution line will be described as an example, assuming that the center coordinates of two adjacent vertical distribution lines are P 1 (x 1 ,y 1 ) And P 2 (x 2 ,y 2 ) P is then 1 And P 2 The Euclidean distance between is expressed as:
and merging the vertical distribution lines which are relatively close to each other into a vertical line connected domain.
Step S130: and acquiring equal length lines in each communication domain according to the characteristic that the inclination angle of the communication domain is perpendicular to the included lines in the communication domain and the lengths of the included lines are basically equal, and determining a bar code candidate region according to the equal length lines.
In this example, the specific implementation method of step S130 includes:
calculating the corresponding inclination angle of each horizontal line connected domain, obtaining equal-length horizontal lines of each horizontal line connected domain according to the characteristic that the bar code direction is perpendicular to the line direction and the line length is basically equal, and determining a vertical bar code candidate region according to the equal-length horizontal lines. Similarly, calculating the corresponding inclination angle of each vertical line connected domain, obtaining equal-length vertical lines of each vertical line connected domain according to the characteristic that the bar code direction is vertical to the line direction and the line length is basically equal, and determining a horizontal bar code candidate region according to the equal-length vertical lines.
Step S140: according to the number of the effective lines in the bar code candidate areas, calculating the line distribution density of each candidate area, and screening the bar code areas from the plurality of bar code candidate areas according to the number of the lines and the line distribution density.
In this example, the specific implementation method of step S140 includes:
step S141, obtaining all vertical lines contained in each horizontal bar code candidate area, and screening to obtain effective vertical lines with approximately equal length and vertical direction according to the average length and the central abscissa deviation of the lines; calculating the number of effective vertical lines and the line distribution density in the horizontal bar code candidate area; and screening to obtain a horizontal bar code area according to the number of the lines and the line distribution density.
Step S142, obtaining all horizontal lines contained in each vertical bar code candidate area, and screening to obtain effective horizontal lines with approximately equal length and vertical direction according to the average length and the central abscissa deviation of the lines; calculating the number of effective horizontal lines and the line distribution density in the vertical bar code candidate area; and screening to obtain the vertical bar code area according to the number of the lines and the line distribution density.
For better understanding of the line distribution density calculation process, a horizontal bar code candidate region will be taken as an example, and assuming that in the horizontal bar code candidate region, the number of effective lines in the region is N, the width of the region in the horizontal direction is L, and the width of the region in the vertical direction is W, the line distribution density is as follows: ρ=n/W (2).
In step S143, all the horizontal barcode regions and the vertical barcode regions are region-integrated to obtain the barcode regions.
And step S200, extracting a QR code area in the surface image of the to-be-detected printed product.
Fig. 4 is a flowchart of extracting a QR region in a surface image of a to-be-detected print, and as shown in fig. 4, the extracting of the QR region in the surface image of the to-be-detected print includes the following steps:
step S210, gaussian noise reduction, threshold segmentation and region screening are carried out on the image, and a plurality of suspected positioning blocks are obtained through screening.
In this example, the region shape screening is performed on the image to obtain the positioning block, which specifically includes the following steps:
in step S211, gaussian noise reduction is performed on the image. In this example, the image is subjected to gaussian filtering to remove noise in the image, thereby improving the image quality.
In step S212, all corner features of the image are extracted by a corner detection algorithm, and corner coordinates are recorded. In the present application, corner features include the number of corners and the distribution density of corners.
In step S213, a segmentation region having a gray level difference from the surrounding neighborhood greater than a preset gray level value is extracted by threshold segmentation.
In this example, the denoising image is subjected to dynamic threshold segmentation, and a segmented region with a gray level difference greater than a preset gray level value from the surrounding neighborhood is extracted, wherein the extracted region contains a real variable code region and also contains a similar background pattern region.
It should be noted that, a person skilled in the art may adjust the specific value of the preset gray value according to actual needs, for example, set the preset gray value to 40Pixel.
In step S214, the area screening is performed on the segmented area, which specifically includes screening a plurality of suspected positioning blocks from the segmented area according to the rectangle degree, width, height, length-width ratio and number of internal holes of the segmented area.
In step S220, the positioning block is obtained by screening according to the gray standard deviation of the suspected positioning block and the number of the internal holes.
In step S230, all positioning blocks are traversed adjacently, and a plurality of paired positioning blocks are obtained according to the positional relationship of isosceles right triangles of three positioning blocks belonging to the same QR code.
In step S240, a QR code candidate region corresponding to the positioning block is obtained according to the included angle and the length ratio between the positioning block and the paired positioning block.
To facilitate a better understanding of the process of traversing the positioning block and extracting the QR code candidate region, the traversing process will be described by way of an example: for a certain positioning block, locally searching the other two paired positioning blocks in the left, right, upward and downward directions within a preset detection range of the center of the positioning block, and calculating an included angle and a length ratio formed by connecting the other two paired positioning blocks to the positioning block after the other two paired positioning blocks corresponding to the positioning block are searched as shown in fig. 5; when the included angles formed by the connecting lines are approximately right angles and the lengths are approximately equal, the minimum surrounding area formed by the three positioning blocks is set as a QR code candidate area. It should be noted that, a person skilled in the art may adjust the specific value of the preset detection range according to actual needs, for example, set the preset detection range to 200Pixel.
In step S250, the QR code regions are obtained by screening according to the number of corner points and the distribution density of corner points contained in each QR code candidate region.
In practical application, firstly, the number of corner points contained in a QR code candidate area is calculated, then, the calculated number of corner points is divided by the area of the area, and the distribution density of the corner points is obtained, wherein the calculation formula of the distribution density of the corner points is as follows:
ρ=N/(W·H) (3),
wherein N is the number of corner points contained in the QR code candidate region, and W and H are the width and the height of the QR code candidate region respectively.
When the number of corner points and the distribution density of the corner points reach the preset number of corner points and the preset distribution density of the corner points, a QR code area exists in the rectangular area surrounded by the three positioning blocks.
It should be noted that, a person skilled in the art may adjust the number of preset corner points and the specific value of the distribution density of preset corner points according to actual needs, for example, set the number of preset corner points to be 60 and the distribution density of preset corner points to be 0.006.
And step S300, extracting a DM code area in the surface image of the to-be-detected printing product.
Fig. 6 is a flowchart of extracting a DM area in a surface image of a print to be measured according to the present application, and as shown in fig. 6, extracting a DM area in a surface image of a print to be measured includes the following steps:
in step S300, the specific implementation method for obtaining the DM code area includes:
step S310, according to the edge detection operator, extracting edge features contained in the image, and splitting the edge features into straight lines.
Step S320, screening the horizontal distribution lines and the vertical distribution lines from the straight lines according to the length, the length-width ratio and the inclination angle of the straight lines.
In this application, step S320 specifically includes the following steps:
step S321, performing shape screening on the straight line according to the length, the length-width ratio and the inclination angle of the straight line, and removing the excessively long or excessively short interference line to obtain a horizontal or vertical straight line with moderate length;
step S322, respectively carrying out neighbor merging on the horizontal or vertical distribution lines to obtain merged lines;
step S323, the shape of the combined lines is screened according to the length-width ratio and the length of the combined lines, and overlong or too short lines are removed.
Step S324, screening the rest combined straight lines according to the inclination angle to obtain horizontal distribution lines and vertical distribution lines.
Step S330, traversing the horizontal distribution lines and the vertical distribution lines to obtain straight line pairs with orthogonal distribution and equal length, and determining the minimum surrounding area formed by the straight line pairs as a DM code candidate area.
To facilitate a better understanding of the process of traversing horizontal and vertical distribution lines, obtaining pairs of straight lines of equal length in orthogonal distribution, the traversing process will be described by way of example: for a certain horizontal distribution line, a plurality of vertical distribution lines which are distributed at right angles to the horizontal distribution line and have approximately equal lengths are found out in a smaller range at the head end and the tail end of the horizontal distribution line, so that the vertical distribution line and the horizontal distribution line which meet the conditions form a straight line pair, and a minimum surrounding area formed by the vertical distribution line and the horizontal distribution line which meet the conditions is defined as a DM code candidate area.
In step S340, the DM code area is obtained according to the number of corner points and the distribution density of corner points contained in the DM code candidate area.
In step S400, the obtained barcode region, QR code region and DM code region are region-integrated to obtain a variable code region of the surface image of the print to be detected.
The application provides a method for extracting a variable code region, which is used for extracting the variable code region in a surface image of a printing product, in particular when the surface of the printing product to be detected contains a large number of variable codes densely distributed. In the application, all bar codes, QR and DM variable code areas on the surface of a printed matter are extracted by analyzing the difference characteristics between the morphological characteristics of the variable codes and the background patterns and then according to the morphological characteristics of the variable codes, wherein the morphological characteristics comprise edge characteristics, area characteristics, corner characteristics and the like.
Compared with the existing method for manually drawing the variable code region, the method for extracting the variable code region considers the morphological characteristics of the variable code, and automatically extracts the variable code region through the difference between the morphological characteristics, so that the running stability and usability of variable code detection software are improved, the modeling efficiency is obviously improved, and meanwhile, the expenditure of manpower and time is greatly reduced.
The above-described embodiments of the present application are not intended to limit the scope of the present application. It should be noted that, for the processes not specifically described in the present application, the specific implementation processes are all conventional techniques for those skilled in the art, and will not be described in detail in the present application.

Claims (8)

1. A method for extracting a variable code region, comprising:
extracting a bar code area in a surface image of a to-be-detected printed product, comprising: obtaining horizontal and vertical distribution lines according to edge features and area features of the surface image of the to-be-detected printed matter; dividing the horizontal and vertical distribution lines into a plurality of disjoint communicating domains according to the position characteristics of the horizontal and vertical distribution lines; according to the characteristic that the inclination angle of the communicating region is perpendicular to the included lines of the communicating region and the lengths of the included lines are equal, equal-length lines in each communicating region are obtained, and according to the equal-length lines, bar code candidate regions are determined; calculating the line distribution density of each candidate area according to the line number of the effective lines in the bar code candidate areas, and screening out the bar code areas from the plurality of bar code candidate areas according to the line number and the line distribution density;
extracting a QR code area in a surface image of a to-be-detected printed product comprises the following steps: carrying out Gaussian noise reduction, threshold segmentation and region screening on the image to obtain a plurality of suspected positioning blocks; screening to obtain a positioning block according to the gray standard deviation of the suspected positioning block and the number of the internal holes; performing adjacent traversal on all the positioning blocks, and obtaining a plurality of matched positioning blocks according to the position relationship of isosceles right triangles of three positioning blocks belonging to the same QR code; acquiring a QR code candidate region corresponding to the positioning block according to the included angle and the length ratio between the positioning block and the matched positioning block; screening to obtain QR code regions according to the number of corner points and the distribution density of the corner points contained in each QR code candidate region;
extracting a DM code area in a surface image of a to-be-detected printing product comprises the following steps: according to the edge detection operator, extracting edge features contained in the image, and splitting the edge features into straight lines; according to the length, the length-width ratio and the inclination angle of the straight line, horizontal distribution lines and vertical distribution lines are obtained through screening from the straight line; traversing the horizontal distribution lines and the vertical distribution lines to obtain straight line pairs with orthogonal distribution and equal length, and determining a minimum surrounding area formed by the straight line pairs as a DM code candidate area; obtaining a DM code area according to the number of corner points and the distribution density of the corner points contained in the DM code candidate area;
and carrying out region integration on the obtained bar code region, QR code region and DM code region to obtain a variable code region of the surface image of the to-be-detected printed product.
2. The method for extracting a variable code region according to claim 1, wherein obtaining horizontal and vertical distribution lines according to edge features and region features of a surface image of a print to be detected comprises:
obtaining edge characteristics in the image through an edge detection algorithm;
splitting the edge characteristics into straight lines and circular arcs according to the morphological differences of the edge characteristics, and eliminating the circular arcs;
the regional characteristics comprise pixel area, length-width ratio and inclination angle, and according to the pixel area, length-width ratio and inclination angle of the straight line, straight line strips with the pixel area larger than the preset pixel area, length-width ratio larger than the preset length-width ratio and inclination angle of [ -10,10], [ -90, -80] or [80,90] are obtained;
and dividing the obtained straight line into horizontal distribution lines and vertical distribution lines according to the inclination angle.
3. The method for extracting a variable code region according to claim 1, wherein dividing the horizontal and vertical distribution lines into a plurality of disjoint connected regions according to the position features of the horizontal and vertical distribution lines, comprises:
the location features include euclidean distances between adjacent lines,
according to Euclidean distance of adjacent lines, the horizontal distribution lines are aggregated to obtain a plurality of disjoint horizontal line connected domains formed by the horizontal distribution lines;
and according to the Euclidean distance of the adjacent lines, the vertical distribution lines are aggregated to obtain a plurality of disjoint vertical line connected domains consisting of the vertical distribution lines.
4. The method for extracting a variable code region according to claim 1, wherein the step of obtaining equal length lines in each connected domain based on the feature that the inclination angle of the connected domain is perpendicular to the included lines of the connected domain and the length of the included lines is equal, and the step of determining the bar code candidate region based on the equal length lines comprises:
calculating the corresponding inclination angle of each horizontal line communicating domain, obtaining equal-length horizontal lines of each horizontal line communicating domain according to the characteristic that the bar code direction is perpendicular to the line direction and the line length is equal, and determining a vertical bar code candidate region according to the equal-length horizontal lines;
calculating the corresponding inclination angle of each vertical line communicating region, obtaining equal-length vertical lines of each vertical line communicating region according to the characteristic that the bar code direction is vertical to the line direction and the line length is equal, and determining a horizontal bar code candidate region according to the equal-length vertical lines.
5. The method according to claim 4, wherein calculating the line distribution density of each candidate region according to the number of effective lines in the bar code candidate region, and screening out the bar code region from the plurality of bar code candidate regions according to the number of lines and the line distribution density, comprises:
acquiring all vertical lines contained in each horizontal bar code candidate area, and screening to obtain effective vertical lines with equal length and vertical direction according to the average length and the central abscissa deviation of the lines; calculating the number of effective vertical lines and the line distribution density in the horizontal bar code candidate area; screening to obtain a horizontal bar code area according to the number of lines and the line distribution density;
acquiring all horizontal lines contained in each vertical bar code candidate area, and screening to obtain effective horizontal lines with equal length and vertical direction according to the average length and the central abscissa deviation of the lines; calculating the number of effective horizontal lines and the line distribution density in the vertical bar code candidate area; screening to obtain a vertical bar code area according to the number of lines and the line distribution density;
and integrating all the horizontal bar code areas with the vertical bar code areas to obtain the bar code areas.
6. The method for extracting a variable code region according to claim 1, wherein the steps of performing gaussian noise reduction, threshold segmentation and region screening on the image to obtain a plurality of suspected positioning blocks include:
gaussian noise reduction is carried out on the image;
extracting all corner features of the image through a corner detection algorithm, and recording corner coordinates;
extracting a segmentation area with gray level difference larger than a preset gray level value from the surrounding neighborhood through threshold segmentation;
the method specifically comprises the steps of screening the partitioned area according to the rectangular degree, the width, the height, the length-width ratio and the number of internal holes of the partitioned area, and obtaining a plurality of suspected positioning blocks from the partitioned area.
7. The method for extracting a variable code region according to claim 1, wherein,
when the QR code area in the surface image of the to-be-detected printed product is extracted, the calculation formula of the angular point distribution density is as follows:
wherein N is the number of corner points contained in the QR code candidate region, and W and H are the width and the height of the QR code candidate region respectively;
when extracting a DM code area in a surface image of a print to be detected, the calculation formula of the angular point distribution density is as follows:
wherein N is the number of corner points contained in the DM code candidate region, and W and H are the width and the height of the DM code candidate region respectively.
8. The method for extracting a variable code region according to claim 1, wherein the step of selecting horizontal distribution lines and vertical distribution lines from the straight lines according to the length, the length-width ratio and the inclination angle of the straight lines comprises:
according to the length, the length-width ratio and the inclination angle of the straight line, shape screening is carried out on the straight line, and the excessively long or excessively short interference line is removed, so that a horizontal or vertical straight line with moderate length is obtained;
respectively carrying out neighbor merging on the horizontal or vertical distribution lines to obtain merging lines;
then, according to the length-width ratio and the length of the combined lines, shape screening is carried out on the combined lines, and overlong or overlong lines are removed;
and screening the rest merging straight lines according to the inclination angle to obtain horizontal distribution lines and vertical distribution lines.
CN202010377847.7A 2020-05-07 2020-05-07 Method for extracting variable code region Active CN111597849B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010377847.7A CN111597849B (en) 2020-05-07 2020-05-07 Method for extracting variable code region

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010377847.7A CN111597849B (en) 2020-05-07 2020-05-07 Method for extracting variable code region

Publications (2)

Publication Number Publication Date
CN111597849A CN111597849A (en) 2020-08-28
CN111597849B true CN111597849B (en) 2023-07-18

Family

ID=72189672

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010377847.7A Active CN111597849B (en) 2020-05-07 2020-05-07 Method for extracting variable code region

Country Status (1)

Country Link
CN (1) CN111597849B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20240064353A1 (en) * 2021-04-27 2024-02-22 Boe Technology Group Co., Ltd. Media monitoring method, apparatus and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6565003B1 (en) * 1998-12-16 2003-05-20 Matsushita Electric Industrial Co., Ltd. Method for locating and reading a two-dimensional barcode
CN101430768A (en) * 2007-11-07 2009-05-13 刘涛 Two-dimension bar code system and its positioning method
JP2011014012A (en) * 2009-07-03 2011-01-20 Fujitsu Computer Technologies Ltd Two-dimensional code reading method, two-dimensional code extraction method, two-dimensional code recognition method and two-dimensional code reader
CN108021837A (en) * 2016-11-04 2018-05-11 株式会社理光 A kind of bar code detection method, bar code detecting device and electronic equipment
CN108573184A (en) * 2018-03-12 2018-09-25 深圳元启智能技术有限公司 A kind of two-dimensional code identification method, module and computer readable storage medium
CN109409163A (en) * 2018-11-12 2019-03-01 凌云光技术集团有限责任公司 A kind of QR code method for rapidly positioning based on texture features

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6565003B1 (en) * 1998-12-16 2003-05-20 Matsushita Electric Industrial Co., Ltd. Method for locating and reading a two-dimensional barcode
CN101430768A (en) * 2007-11-07 2009-05-13 刘涛 Two-dimension bar code system and its positioning method
JP2011014012A (en) * 2009-07-03 2011-01-20 Fujitsu Computer Technologies Ltd Two-dimensional code reading method, two-dimensional code extraction method, two-dimensional code recognition method and two-dimensional code reader
CN108021837A (en) * 2016-11-04 2018-05-11 株式会社理光 A kind of bar code detection method, bar code detecting device and electronic equipment
CN108573184A (en) * 2018-03-12 2018-09-25 深圳元启智能技术有限公司 A kind of two-dimensional code identification method, module and computer readable storage medium
CN109409163A (en) * 2018-11-12 2019-03-01 凌云光技术集团有限责任公司 A kind of QR code method for rapidly positioning based on texture features

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于图像处理的数字印刷线条质量检测方法研究;孙小鹏;孔玲君;;包装工程(第07期);全文 *
复杂背景下的DataMatrix二维码识别算法研究;郭浩铭;CNKI优秀硕士论文信息科技辑(第2017年第7期期);全文 *

Also Published As

Publication number Publication date
CN111597849A (en) 2020-08-28

Similar Documents

Publication Publication Date Title
CN109299720B (en) Target identification method based on contour segment spatial relationship
CN106407883B (en) Complex form and identification method for handwritten numbers in complex form
CN110909732B (en) Automatic extraction method of data in graph
Chiang et al. A general approach for extracting road vector data from raster maps
CN113109368B (en) Glass crack detection method, device, equipment and medium
CN107452035B (en) Method and apparatus for analyzing lane line image and computer readable medium thereof
CN109870458B (en) Pavement crack detection and classification method based on three-dimensional laser sensor and bounding box
CN106991460A (en) A kind of quick detection and localization algorithm of QR codes
CN113177959B (en) QR code real-time extraction method in rapid movement process
CN113592862A (en) Point cloud data segmentation method, system, device and medium for steel plate surface defects
CN112233116A (en) Concave-convex mark visual detection method based on neighborhood decision and gray level co-occurrence matrix description
CN116740072B (en) Road surface defect detection method and system based on machine vision
CN114022439A (en) Flexible circuit board defect detection method based on morphological image processing
CN113689429A (en) Wood board defect detection method based on computer vision
CN111597849B (en) Method for extracting variable code region
CN108256518B (en) Character area detection method and device
CN113240623A (en) Pavement disease detection method and device
CN112649793A (en) Sea surface target radar trace condensation method and device, electronic equipment and storage medium
CN112308872A (en) Image edge detection method based on multi-scale Gabor first-order derivative
CN115272312A (en) Plastic mobile phone shell defect detection method based on machine vision
CN107516315B (en) Tunneling machine slag tapping monitoring method based on machine vision
CN110288040B (en) Image similarity judging method and device based on topology verification
CN114970590A (en) Bar code detection method
CN111008964A (en) Component surface defect detection method
Pan et al. An efficient method for skew correction of license plate

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
CB02 Change of applicant information

Address after: 100094 Beijing city Haidian District Cui Hunan loop 13 Hospital No. 7 Building 7 room 701

Applicant after: Lingyunguang Technology Co.,Ltd.

Address before: 100094 Beijing city Haidian District Cui Hunan loop 13 Hospital No. 7 Building 7 room 701

Applicant before: Beijing lingyunguang Technology Group Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant