CN114528865A - Bar code detection model training method and device and bar code detection method and device - Google Patents
Bar code detection model training method and device and bar code detection method and device Download PDFInfo
- Publication number
- CN114528865A CN114528865A CN202210162962.1A CN202210162962A CN114528865A CN 114528865 A CN114528865 A CN 114528865A CN 202210162962 A CN202210162962 A CN 202210162962A CN 114528865 A CN114528865 A CN 114528865A
- Authority
- CN
- China
- Prior art keywords
- bar code
- sample data
- training
- barcode
- detection model
- 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.)
- Granted
Links
- 238000012549 training Methods 0.000 title claims abstract description 78
- 238000001514 detection method Methods 0.000 title claims abstract description 76
- 238000000034 method Methods 0.000 title claims abstract description 33
- 230000008859 change Effects 0.000 claims description 13
- 230000004927 fusion Effects 0.000 claims description 10
- 238000000605 extraction Methods 0.000 claims description 9
- 238000004364 calculation method Methods 0.000 claims description 4
- 238000006243 chemical reaction Methods 0.000 claims description 4
- 238000013527 convolutional neural network Methods 0.000 claims description 4
- 238000005520 cutting process Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 6
- 239000011159 matrix material Substances 0.000 description 4
- 238000013135 deep learning Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- ORILYTVJVMAKLC-UHFFFAOYSA-N Adamantane Natural products C1C(C2)CC3CC1CC2C3 ORILYTVJVMAKLC-UHFFFAOYSA-N 0.000 description 1
- 238000005299 abrasion Methods 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000009776 industrial production Methods 0.000 description 1
- 238000002372 labelling Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000003860 storage Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001629 suppression Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/1408—Methods for optical code recognition the method being specifically adapted for the type of code
- G06K7/1413—1D bar codes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06018—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking one-dimensional coding
- G06K19/06028—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking one-dimensional coding using bar codes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06037—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/1408—Methods for optical code recognition the method being specifically adapted for the type of code
- G06K7/1417—2D bar codes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Life Sciences & Earth Sciences (AREA)
- Data Mining & Analysis (AREA)
- Toxicology (AREA)
- Electromagnetism (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Computation (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses a training method and a device of a bar code detection model, and a bar code detection method and a device, which can obtain a large amount of high-quality training Data only by a small amount of initial sample Data.
Description
Technical Field
The invention belongs to the technical field of machine vision, and particularly relates to a training method and device of a bar code detection model, and a bar code detection method and device.
Background
The barcode (barcode) is a graphic identifier in which a plurality of black bars and spaces having different widths are arranged according to a certain encoding rule to express a group of information, and includes a one-dimensional barcode (one-dimensional code) and a two-dimensional barcode (two-dimensional code). With the increasing demand of intelligent industrial production, the complexity of an intelligent manufacturing system is increasing, and the one-dimensional code and the two-dimensional code are used for identifying industrial products and parts, so that the generation tracking, the assembly management, the life cycle maintenance and the like of the products and the parts become the industrial standards of the automation industry. Meanwhile, the application of the two-dimensional codes in aspects of warehouse logistics, file management, ticket information storage and processing and the like enables the convenience of the fields to be improved remarkably.
Different from civil barcodes, the application environment of industrial barcodes is generally complex, for example, the problems of distortion, blurring, abrasion, low contrast, no static area, serious noise interference and the like exist, so that the conventional detection positioning method cannot meet the requirements of the conventional detection positioning method.
The detection positioning method based on deep learning is superior to the conventional detection positioning method in robustness and accuracy, however, training data with larger scale is needed when a training model is based on deep learning, and the method has higher requirements on hardware when being implemented.
Disclosure of Invention
The invention provides a training method and a device of a bar code detection model, and a bar code detection method and a bar code detection device, which can solve or at least partially solve the technical problems.
Therefore, the invention adopts the following technical scheme:
in a first aspect, a training method for a barcode detection model is provided, including:
acquiring first sample data, wherein the first sample data comprises a first number of bar code pictures with bar code graphs, and the bar code graphs comprise one-dimensional codes and/or two-dimensional codes;
acquiring second sample data, wherein the second sample data comprises a second number of background pictures without bar code graphics;
generating third sample data based on the first sample data and the second sample data, wherein the third sample data comprises a third amount of training data, the training data is obtained by combining the bar code graph and the background picture, and the third amount is larger than the second amount and the first amount;
and training to obtain a detection model of the bar code based on the third sample data and the target frame of the bar code graph in the third sample data.
Optionally, the generating third sample data based on the first sample data and the second sample data comprises:
respectively cutting the bar code pictures of the first quantity to obtain bar code graphs in the bar code pictures;
carrying out geometric image change operation on the cut bar code graph to obtain the bar code graph after the geometric image change operation;
and respectively and randomly pasting the bar code graphs after the geometric image change operation on the second number of background pictures to generate the third number of training data.
Optionally, the training of the detection model of the barcode based on the third sample data and the target frame of the barcode graph in the third sample data includes:
and gradually adjusting model parameters for each batch of third sample data sequentially through stages of feature extraction, feature fusion, target prediction, loss calculation, parameter updating and the like based on the third sample data and a target frame of a bar code graph in the third sample data, and training to obtain the detection model of the bar code.
Optionally, in the feature extraction stage, a feature map of the third sample data is extracted and obtained.
Optionally, in the feature fusion stage, the feature map size input into the convolutional neural network is reduced to a first size, a second size, and a third size, respectively.
Optionally, in the target prediction stage, the data obtained in the feature fusion stage is predicted, and an abscissa of a center point of the barcode graph in the third sample data, a ordinate of the center point, a width, a height, and a rotation angle are obtained respectively.
Optionally, the geometric image change operation includes at least one of flipping, rotating, scaling, blurring, noising, color conversion, and random erasure.
In a second aspect, a barcode detection method is provided, including:
acquiring a target picture to be detected;
and detecting the bar code in the target picture based on the detection model of the bar code trained by the method, and if the bar code exists, outputting the position and the type of the bar code.
In a third aspect, a training apparatus for a barcode detection model is provided, including:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring first sample data, the first sample data comprises a first number of bar code pictures with bar code graphs, and the bar code graphs comprise one-dimensional codes and/or two-dimensional codes;
the second acquisition unit is used for acquiring second sample data, wherein the second sample data comprises a second number of background pictures without bar code graphs;
a generating unit, configured to generate third sample data based on the first sample data and the second sample data, where the third sample data includes a third number of training data, the training data is obtained by combining the barcode graph and the background picture, and the third number is greater than the second number and the first number;
and the model training unit is used for training to obtain a detection model of the bar code based on the third sample data and the target frame of the bar code graph in the third sample data.
In a fourth aspect, there is provided a barcode detection apparatus comprising:
the image acquisition module is used for acquiring a target image to be detected;
and the bar code detection module is used for detecting the bar code in the target picture based on the bar code detection model obtained by the training of the method, and outputting the position and the type of the bar code if the bar code exists.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
according to the training method and device for the bar code detection model, provided by the embodiment of the invention, a large amount of high-quality third sample Data (third amount of training Data) can be obtained only by a small amount of first sample Data (first amount of bar code pictures) and second sample Data which is convenient to obtain, the bar code detection model obtained based on the Data training has the advantages of strong universality, high robustness, high accuracy and high detection speed, is suitable for code reading positioning in various different industrial scenes, and can be used for positioning and identifying QRCode, Data Matrix two-dimensional codes and one-dimensional codes which are commonly used in industry and have any angle.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
The structures, ratios, sizes, and the like shown in the present specification are only used for matching with the contents disclosed in the specification, so that those skilled in the art can understand and read the present invention, and do not limit the conditions for implementing the present invention, so that the present invention has no technical significance, and any structural modifications, changes in the ratio relationship, or adjustments of the sizes, without affecting the functions and purposes of the present invention, should still fall within the scope covered by the contents disclosed in the present invention.
Fig. 1 and fig. 2 are flowcharts of a method for training a barcode detection model according to the present embodiment;
FIG. 3 is a flowchart of a method of detecting a barcode according to the present embodiment;
fig. 4 is a diagram of the components of the training apparatus for the barcode detection model provided in this embodiment;
FIG. 5 is a block diagram illustrating the components of the barcode detection apparatus according to the present embodiment;
fig. 6 is a network structure diagram of the detection model provided in this embodiment;
FIG. 7 is a representation of a one-dimensional or two-dimensional object box;
FIG. 8 is a schematic diagram of a data set;
FIG. 9 is a plurality of normal target pictures;
fig. 10 to 19 are schematic diagrams illustrating detection effects of different target pictures.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Please refer to fig. 1 to 19.
As shown in fig. 1 to fig. 3, the present embodiment provides a training method for a barcode detection model and a barcode detection method, which have the advantages of less data dependency, high quality of generated data, strong model universality, high robustness, and the like, and are used to solve the problems in the prior art, such as large one-dimensional code or two-dimensional code dependent data scale, poor generality, low robustness, and the like. Specifically, as shown in fig. 1, the training method of the barcode detection model includes the following steps:
s11, acquiring first sample data, wherein the first sample data comprises a first number of bar code pictures with bar code graphs, and the bar code graphs comprise one-dimensional codes and/or two-dimensional codes; optionally, a barcode pattern may include one or more one-dimensional codes, or include one or more two-dimensional codes, or may include both one or more one-dimensional codes and one or more two-dimensional codes.
S12, acquiring second sample data, wherein the second sample data comprises a second number of background pictures without bar code graphics;
s13, generating third sample data based on the first sample data and the second sample data, wherein the third sample data comprises a third amount of training data, the training data is obtained by combining the bar code graph and the background picture, and the third amount is larger than the second amount and the first amount; optionally, the combined training data may include: the combined data of the one-dimensional code and the background picture, the combined data of the two-dimensional code and the background picture, or the combined data of the one-dimensional code, the two-dimensional code and the background picture.
And S14, training to obtain a detection model of the bar code based on the third sample data and the target frame of the bar code graph in the third sample data.
In step S11, the first sample data only needs to include a small number of barcode pictures, and the barcode patterns in the barcode pictures may be rotated or not rotated. Specifically, after the first sample data is collected, a rectangular frame of the barcode graph may be labeled, and then each barcode graph is cut according to the labeling information, so as to generate a data set, as shown in fig. 8.
The purpose of steps S12-S13 is to generate a large amount of training data, i.e., third sample data. The second sample data is easier to obtain than the first sample data, and for example, an industrial camera may be used to take a picture or a web crawler may be used to capture a picture, so as to obtain a background picture. In step S13, a large amount (i.e., a third amount) of training data may be obtained by combining the barcode pattern and the background picture. Then, in step S14, the barcode detection model can be trained successfully.
As shown in fig. 2, as an optional implementation manner of this embodiment, step S13 specifically includes the following steps:
s131, respectively cutting the bar code pictures of the first quantity to obtain bar code graphs in the bar code pictures;
s132, carrying out geometric image change operation on the cut bar code graph to obtain the bar code graph after the geometric image change operation;
and S133, respectively and randomly pasting the bar code patterns after the geometric image change operation onto the second number of background images to generate the third number of training data.
Wherein the geometric image change operation includes at least one of flipping, rotating, scaling, blurring, noising, color conversion, and random erasure. It should be noted that, when the geometric image change operation is performed, at least one of flipping, rotating, scaling, blurring, noise adding, color conversion, and random erasing may be randomly selected to perform the operation.
It should be noted that, in this embodiment, not only the third sample data may be used for model training, but also the original first sample data may be selected for model training.
For step S133, in the process of random pasting, a pre-pasted position is randomly generated, a maximum value Max _ IOU (image intersection ratio) of IOU to the pasted area is calculated, and if Max _ IOU <0.1 (indicating no overlap with the pasted area or a low repetition rate), the position is pasted, and the barcode information of the position is recorded.
Further, as shown in fig. 6, the network structure of the detection model includes three parts, feature extraction, feature fusion and object prediction. Therefore, step S14 may include the steps of:
and gradually adjusting model parameters for each batch of third sample data sequentially through stages of feature extraction, feature fusion, target prediction, loss calculation, parameter updating and the like based on the third sample data and a target frame of a bar code graph in the third sample data, and training to obtain the detection model of the bar code.
Specifically, in the feature extraction stage, a feature map of third sample data is extracted and obtained.
Further, in the feature fusion stage, the size of the feature map input into the convolutional neural network is respectively reduced to a first size, a second size and a third size, and the feature map is obtained by extracting the third sample data in the feature extraction stage. For example, the first size (width or height) is 16 times smaller than the target image size, the second size is 32 times smaller, and the third size is 64 times smaller, so that the model size can be reduced and the detection efficiency can be improved.
Further, as shown in fig. 7, in the target prediction stage, in the embodiment, data obtained in the feature fusion stage is predicted, and an abscissa x of a central point of a barcode pattern in the third sample data, a ordinate y of the central point, a width w, a height h, and a rotation angle θ are obtained respectively. Compared with the prior art, the predicted target frame is described by adding the rotation angle theta, so that the QRCode, the Data Matrix two-dimensional code and the one-dimensional code with any angle commonly used in the industry can be positioned and identified.
Specifically, in the target prediction stage, clustering analysis is carried out on bar code data, 3 heads are designed in a network structure, each Head has 4 anchor frames, and the description of a predicted target frame is increased by a rotation angle theta.
The calculation formula of the calculated amount of the model is as follows:
wherein, ClC in (1) represents the number of convolution kernels and represents the second layer of convolution; k represents the size of the convolution kernel, e.g., the size of a particular convolution kernel may be represented as K x K, 3 x 3, etc.; n represents that the network has N convolutional layers; fwWidth of the characteristic diagram; fhIndicating a high profile.
As a specific application scenario of this embodiment, if the detection model is YOLO V5, and for the input target picture to be detected, the parameters of the target picture to be detected are WxH (where W is the width of the target picture and H is the height of the target picture), in the model of this embodiment, the size of the feature map input to the convolutional neural network is reduced to W/8 × H/8 (which represents that W is reduced to one eighth of the original size and H is reduced to one eighth of the original size), W/16 × H/16, and W/32 × H/32, so that the detection speed can be improved.
Further, the present embodiment modifies the description (x, y, w, h) of the existing predicted target frame into (x, y, w, h, θ), that is, adds the description of the rotation angle θ of the image, and has the capability of detecting the two-dimensional code and the one-dimensional code with the rotation angle.
Specifically, the network structure can check three types of common codes, namely a QRCode, a Data Matrix two-dimensional code and a one-dimensional code, and each layer of target prediction module comprises 4 anchor frames with different scales, so that the output dimension of the module is as follows:
4*(x,y,w,h,θ,conf,pdm,pqr,pbarcode)=36
wherein, x, y, w, h and theta respectively represent the coordinates (x, y) of the central point of the frame, the width w, the height h and the rotation angle theta, the confidence conf of the existence of the bar code, and the probabilities of the DM, the QR and the one-dimensional code are respectively pdm,pqr,pbarcode。
Further, the loss function of the model is:
Loss=λcoord∑loss(xy)+λcoord∑loss(wh)+λconf∑loss(con f)+λcls∑loss(cls)+λangle∑loss(θ)
wherein, loss (xy) represents the loss of the central point of the model prediction code, loss (wh) represents the loss of the width and height of the model prediction code, loss (conf) represents whether the model prediction is the confidence loss of the code, loss (cls) represents the class loss of the model prediction, and loss (theta) represents the loss of the model prediction angle.
Specifically, the optimizer of the model can adopt an Adam optimization algorithm, momentum is 0.937, the initial learning rate is 0.01, the scale of training data is 50 ten thousand pictures, and the model is stopped after 90 rounds of training.
Referring to fig. 3, the barcode detection method provided in this embodiment includes the following steps:
s21, acquiring a target picture to be detected;
s22, detecting the barcode in the target picture based on the barcode detection model obtained by the training method, and if the barcode exists, outputting the position and type (for example, one-dimensional code or two-dimensional code) of the barcode.
Specifically, feature extraction is carried out on the target picture to be detected through a model, and a large number of candidate two-dimensional code or one-dimensional code target candidate frames are obtained through target prediction; and then deleting redundant candidate frames from the candidate frames by using a non-maximum suppression algorithm, setting a proper threshold value tau, and outputting target frames with confidence conf _ i > tau of the candidate frames.
As a result of the experiment of this embodiment, as shown in fig. 9, a plurality of normal target pictures are provided, and the detection effect of the target pictures detected by the barcode detection method provided in this embodiment is shown in fig. 10 to 19.
According to the bar code detection method provided by the embodiment, a large amount of high-quality third sample data (a third amount of training data) can be obtained only by a small amount of first sample data (a first amount of bar code pictures); the bar code detection model obtained based on the Data training has strong universality and high robustness, is suitable for code reading positioning in various different industrial scenes, can position and identify QRCode, Data Matrix two-dimensional code and one-dimensional code at any angle commonly used in industry, and has the advantages of high detection speed, high universality, high detection accuracy and the like.
As shown in fig. 4, in another embodiment of the present application, a training apparatus for a barcode detection model is provided, which can be used to implement the above training method for a barcode detection model, and specifically includes:
a first obtaining unit 11, configured to obtain first sample data, where the first sample data includes a first number of barcode pictures with barcode graphics, and the barcode graphics include one-dimensional codes and/or two-dimensional codes;
a second obtaining unit 12, configured to obtain second sample data, where the second sample data includes a second number of background pictures without barcode graphics, and the second number is greater than the first number;
a generating unit 13, configured to generate third sample data based on the first sample data and the second sample data, where the third sample data includes a third number of training data, the training data is obtained by combining the barcode graph and the background picture, and the third number is greater than the second number;
and a model training unit 14, configured to train to obtain a detection model of the barcode based on the third sample data and the target frame of the barcode graph in the third sample data.
Since the specific training method for implementing the barcode detection model has been explained above, it is not described herein again. Compared with the prior art, the training device for the bar code detection model provided by the embodiment can obtain a large amount of high-quality training sample data only by a small amount of initial sample data, and has the advantages of less labeled data, high quality of generated training data, high detection accuracy rate of the positioning model obtained by training, high speed and the like.
As shown in fig. 5, in another embodiment of the present application, there is further provided a barcode detection apparatus, specifically including:
the image acquisition module 21 is configured to acquire a target image to be detected;
the barcode detection module 22 is configured to detect a barcode in the target picture based on a barcode detection model obtained through training by the training method as described above, and if the barcode exists, output a position and a type (for example, a one-dimensional code or a two-dimensional code) of the barcode.
Since the specific training method for implementing the barcode detection model and the barcode detection method have been explained above, they are not described herein again. Compared with the prior art, the bar code detection device provided by the embodiment can obtain a large amount of high-quality training sample data only by a small amount of initial sample data, and has the advantages of less labeled data, high quality of generated training data, high detection accuracy rate of the positioning model obtained by training, high speed and the like.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (10)
1. The training method of the bar code detection model is characterized by comprising the following steps:
acquiring first sample data, wherein the first sample data comprises a first number of bar code pictures with bar code graphs, and the bar code graphs comprise one-dimensional codes and/or two-dimensional codes;
acquiring second sample data, wherein the second sample data comprises a second number of background pictures without bar code graphics;
generating third sample data based on the first sample data and the second sample data, wherein the third sample data comprises a third amount of training data, the training data is obtained by combining the bar code graph and the background picture, and the third amount is larger than the second amount and the first amount;
and training to obtain a detection model of the bar code based on the third sample data and the target frame of the bar code graph in the third sample data.
2. The training method of claim 1, wherein generating third sample data based on the first sample data and the second sample data comprises:
respectively cutting the bar code pictures of the first quantity to obtain bar code graphs in the bar code pictures;
carrying out geometric image change operation on the cut bar code graph to obtain the bar code graph after the geometric image change operation;
and respectively and randomly pasting the bar code graphs after the geometric image change operation on the second number of background pictures to generate the third number of training data.
3. The training method according to claim 1, wherein the training of the detection model of the barcode based on the third sample data and the target box of the barcode pattern in the third sample data comprises:
and gradually adjusting model parameters for each batch of third sample data sequentially through stages of feature extraction, feature fusion, target prediction, loss calculation, parameter updating and the like based on the third sample data and a target frame of a bar code graph in the third sample data, and training to obtain the detection model of the bar code.
4. The training method according to claim 3, wherein in the feature extraction stage, a feature map of the third sample data is extracted.
5. The training method of claim 3, wherein in the feature fusion stage, the feature map size input into the convolutional neural network is reduced to a first size, a second size and a third size, respectively.
6. The training method according to claim 3, wherein in the target prediction stage, the data obtained in the feature fusion stage is predicted to obtain an abscissa of a center point of the barcode pattern in the third sample data, and an ordinate, a width, a height, and a rotation angle of the center point, respectively.
7. The training method of claim 2, wherein the geometric image change operation comprises at least one of flipping, rotating, scaling, blurring, noising, color conversion, and random erasure.
8. A bar code detection method, comprising:
acquiring a target picture to be detected;
detecting the bar code in the target picture based on a detection model of the bar code obtained by training according to the method of any one of claims 1 to 7, and outputting the position and the type of the bar code if the bar code exists.
9. The training device of the bar code detection model is characterized by comprising:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring first sample data, the first sample data comprises a first number of bar code pictures with bar code graphs, and the bar code graphs comprise one-dimensional codes and/or two-dimensional codes;
the second acquisition unit is used for acquiring second sample data, wherein the second sample data comprises a second number of background pictures without bar code graphs;
a generating unit, configured to generate third sample data based on the first sample data and the second sample data, where the third sample data includes a third number of training data, the training data is obtained by combining the barcode graph and the background picture, and the third number is greater than the second number and the first number;
and the model training unit is used for training to obtain a detection model of the bar code based on the third sample data and the target frame of the bar code graph in the third sample data.
10. A bar code detection device, comprising:
the image acquisition module is used for acquiring a target image to be detected;
a barcode detection module, configured to detect a barcode in the target picture based on a barcode detection model trained by the method according to any one of claims 1 to 7, and output a position and a type of the barcode if the barcode exists.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210162962.1A CN114528865B (en) | 2022-02-22 | 2022-02-22 | Training method and device of bar code detection model and bar code detection method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210162962.1A CN114528865B (en) | 2022-02-22 | 2022-02-22 | Training method and device of bar code detection model and bar code detection method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114528865A true CN114528865A (en) | 2022-05-24 |
CN114528865B CN114528865B (en) | 2024-02-20 |
Family
ID=81625708
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210162962.1A Active CN114528865B (en) | 2022-02-22 | 2022-02-22 | Training method and device of bar code detection model and bar code detection method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114528865B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115310469A (en) * | 2022-10-12 | 2022-11-08 | 广东奥普特科技股份有限公司 | Bar code positioning model training method, positioning method, system, equipment and medium |
CN117036767A (en) * | 2023-04-10 | 2023-11-10 | 广东奥普特科技股份有限公司 | Two-dimensional code identification method, device, equipment and storage medium |
US12020114B1 (en) * | 2024-01-22 | 2024-06-25 | The DTX Company | Real-time comprehensive quick response (“QR”) code testing for reliable scanning |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109376830A (en) * | 2018-10-17 | 2019-02-22 | 京东方科技集团股份有限公司 | Two-dimensional code generation method and device |
CN111523610A (en) * | 2020-05-06 | 2020-08-11 | 青岛联合创智科技有限公司 | Article identification method for efficient sample marking |
CN111861955A (en) * | 2020-06-22 | 2020-10-30 | 北京百度网讯科技有限公司 | Method and device for constructing image editing model |
CN111931783A (en) * | 2020-08-18 | 2020-11-13 | 创新奇智(重庆)科技有限公司 | Training sample generation method, machine-readable code identification method and device |
CN112183150A (en) * | 2020-10-16 | 2021-01-05 | 上海了物网络科技有限公司 | Image two-dimensional code and preparation method, analysis device and analysis method thereof |
CN112580382A (en) * | 2020-12-28 | 2021-03-30 | 哈尔滨工程大学 | Two-dimensional code positioning method based on target detection |
CN112949338A (en) * | 2021-03-16 | 2021-06-11 | 太原科技大学 | Two-dimensional bar code accurate positioning method combining deep learning and Hough transformation |
-
2022
- 2022-02-22 CN CN202210162962.1A patent/CN114528865B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109376830A (en) * | 2018-10-17 | 2019-02-22 | 京东方科技集团股份有限公司 | Two-dimensional code generation method and device |
US20200226440A1 (en) * | 2018-10-17 | 2020-07-16 | Boe Technology Group Co., Ltd. | Two-dimensional code image generation method and apparatus, storage medium and electronic device |
CN111523610A (en) * | 2020-05-06 | 2020-08-11 | 青岛联合创智科技有限公司 | Article identification method for efficient sample marking |
CN111861955A (en) * | 2020-06-22 | 2020-10-30 | 北京百度网讯科技有限公司 | Method and device for constructing image editing model |
CN111931783A (en) * | 2020-08-18 | 2020-11-13 | 创新奇智(重庆)科技有限公司 | Training sample generation method, machine-readable code identification method and device |
CN112183150A (en) * | 2020-10-16 | 2021-01-05 | 上海了物网络科技有限公司 | Image two-dimensional code and preparation method, analysis device and analysis method thereof |
CN112580382A (en) * | 2020-12-28 | 2021-03-30 | 哈尔滨工程大学 | Two-dimensional code positioning method based on target detection |
CN112949338A (en) * | 2021-03-16 | 2021-06-11 | 太原科技大学 | Two-dimensional bar code accurate positioning method combining deep learning and Hough transformation |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115310469A (en) * | 2022-10-12 | 2022-11-08 | 广东奥普特科技股份有限公司 | Bar code positioning model training method, positioning method, system, equipment and medium |
CN117036767A (en) * | 2023-04-10 | 2023-11-10 | 广东奥普特科技股份有限公司 | Two-dimensional code identification method, device, equipment and storage medium |
US12020114B1 (en) * | 2024-01-22 | 2024-06-25 | The DTX Company | Real-time comprehensive quick response (“QR”) code testing for reliable scanning |
Also Published As
Publication number | Publication date |
---|---|
CN114528865B (en) | 2024-02-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114528865B (en) | Training method and device of bar code detection model and bar code detection method and device | |
CN109800698B (en) | Icon detection method based on deep learning, icon detection system and storage medium | |
CN111680690B (en) | Character recognition method and device | |
CN112949338A (en) | Two-dimensional bar code accurate positioning method combining deep learning and Hough transformation | |
CN111598860A (en) | Lithium battery defect detection method based on yolov3 network embedded in self-attention door module | |
CN112084923A (en) | Semantic segmentation method for remote sensing image, storage medium and computing device | |
CN113392669B (en) | Image information detection method, detection device and storage medium | |
CN108932449B (en) | Bar code binarization method and system based on clustering | |
CN111680680B (en) | Target code positioning method and device, electronic equipment and storage medium | |
CN111209858A (en) | Real-time license plate detection method based on deep convolutional neural network | |
CN111626145B (en) | Simple and effective incomplete form identification and page-crossing splicing method | |
CN111523429A (en) | Deep learning-based steel pile identification method | |
CN112364709A (en) | Cabinet intelligent asset checking method based on code identification | |
CN114241469A (en) | Information identification method and device for electricity meter rotation process | |
CN113378642B (en) | Method for detecting illegal occupation buildings in rural areas | |
CN117315670B (en) | Water meter reading area detection method based on computer vision | |
CN115310469B (en) | Bar code positioning model training method, positioning method, system, equipment and medium | |
CN116912144A (en) | Data enhancement method based on discipline algorithm and channel attention mechanism | |
CN115909378A (en) | Document text detection model training method and document text detection method | |
CN111274863A (en) | Text prediction method based on text peak probability density | |
CN113657225B (en) | Target detection method | |
CN116051831A (en) | VSA-UNet-based ultraviolet image segmentation method for electrical equipment | |
CN113192018B (en) | Water-cooled wall surface defect video identification method based on fast segmentation convolutional neural network | |
CN115345932A (en) | Laser SLAM loop detection method based on semantic information | |
CN113486879A (en) | Image area suggestion frame detection method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |