CN116993962B - Two-dimensional code detection method, device, equipment and readable storage medium - Google Patents

Two-dimensional code detection method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN116993962B
CN116993962B CN202310900164.9A CN202310900164A CN116993962B CN 116993962 B CN116993962 B CN 116993962B CN 202310900164 A CN202310900164 A CN 202310900164A CN 116993962 B CN116993962 B CN 116993962B
Authority
CN
China
Prior art keywords
dimensional code
model
code detection
picture
training set
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
CN202310900164.9A
Other languages
Chinese (zh)
Other versions
CN116993962A (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.)
Guangdong Southern Intelligent Media Technology Co ltd
Original Assignee
Guangdong Southern Intelligent Media Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Southern Intelligent Media Technology Co ltd filed Critical Guangdong Southern Intelligent Media Technology Co ltd
Priority to CN202310900164.9A priority Critical patent/CN116993962B/en
Publication of CN116993962A publication Critical patent/CN116993962A/en
Application granted granted Critical
Publication of CN116993962B publication Critical patent/CN116993962B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/22Image preprocessing by selection of a specific region containing or referencing a pattern; Locating or processing of specific regions to guide the detection or recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/774Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Multimedia (AREA)
  • General Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Databases & Information Systems (AREA)
  • Medical Informatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Molecular Biology (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Image Analysis (AREA)

Abstract

The application belongs to the technical field of image recognition, and discloses a two-dimensional code detection method, a device, equipment and a readable storage medium, wherein the method comprises the following steps: acquiring a preset source training set; preprocessing a preset source training set to obtain a preprocessed source training set picture; taking the preprocessed source training set picture and the corresponding labeled label as input, and training a two-dimensional code detection model based on a BP algorithm and Yolov algorithm to obtain a target two-dimensional code detection model; uploading a model file of the target two-dimensional code detection model to an intranet object storage server, and integrating the model file into springboot program services; packaging the two-dimensional code detection function into a universal service SDK tool package, and externally providing a two-dimensional code detection function in a HTTP interface mode; detecting whether a picture to be distributed has a two-dimensional code or not based on a two-dimensional code detection function; if the two-dimensional code exists, the picture to be distributed is intercepted. The method and the device improve the accuracy and efficiency of the two-dimensional code detection of the picture.

Description

Two-dimensional code detection method, device, equipment and readable storage medium
Technical Field
The present application relates to the field of image recognition technologies, and in particular, to a two-dimensional code detection method, device, apparatus, and readable storage medium.
Background
The two-dimensional code detection and identification is to read and present two-dimensional codes or bar code information of various picture articles and is widely applied to scenes such as commodity and sensitive information identification. The existing mode of applying the picture two-dimension code detection and identification to manuscript text picture detection has the defects that the accuracy and the efficiency of two-dimension code detection and positioning in an image are low, and the following defects exist: (1) Purchasing a third party manufacturer service without mastering the technology initiative; (2) The two-dimensional code identification precision is not high, the labeling and positioning are inaccurate, deviation exists, and the service requirement cannot be met; (3) Poor recognition effect for blurred or low-definition pictures; (4) General recognition, namely, personalized training is not performed aiming at the news consultation field, and the recognition effect is not guaranteed; (5) Through network transmission, the model is not on an own platform, the picture data is transmitted outwards, and the safety cannot be ensured; (6) The higher the picture quality is, the longer the identification time is, and the identification performance cannot be guaranteed; (7) The method is only limited to two-dimensional code recognition, and can not be rapidly expanded to similar scenes such as OCR recognition.
Disclosure of Invention
The application provides a two-dimension code detection method, a device, equipment and a readable storage medium, which improve the accuracy, efficiency and safety of detecting and positioning the two-dimension code of a picture in manuscript and reduce the detection threshold.
In a first aspect, an embodiment of the present application provides a two-dimensional code detection method, where the method includes:
Acquiring a preset source training set, wherein the source training set comprises pictures of partial missing of a two-dimensional code, rotation of the two-dimensional code, overturning of the two-dimensional code, distortion of the two-dimensional code, deformation of the two-dimensional code and personalized customization of the two-dimensional code;
preprocessing the pictures in a preset source training set to obtain preprocessed source training set pictures;
Taking the preprocessed source training set picture and the corresponding labeled label as input, and training a two-dimensional code detection model based on a BP algorithm and Yolov algorithm to obtain a target two-dimensional code detection model;
Uploading a model file of the target two-dimensional code detection model to an intranet object storage server, and integrating the model file into springboot program services;
Packaging the model files integrated to springboot program services into a general service SDK tool kit, and externally providing a two-dimension code detection function of a target two-dimension code detection model in a HTTP interface mode;
Detecting whether a picture to be distributed has a two-dimensional code or not based on a two-dimensional code detection function;
If the two-dimensional code exists, the picture to be distributed is intercepted.
Further, the pictures in the preset source training set are preprocessed by adopting Gaussian blur, gaussian noise, gray level and poisson noise combination, wherein the Gaussian noise is used for processing and cleaning the pictures in the source training set based on a clip function of a numpy base, and then the color space of the pictures in the source training set is changed based on a cv2 base.
Further, the step of training the two-dimensional code detection model based on the BP algorithm and Yolov algorithm by taking the preprocessed source training set picture and the corresponding labeled label as input to obtain the target two-dimensional code detection model comprises the following steps:
Dividing the processed source training set picture and the label corresponding to the label into a model training set and a model verification set according to a preset proportion;
Inputting a source training set picture in a model training set and a label corresponding to the label into a YOLOv m model for training with preset iteration times, and calculating and determining a loss value based on the label corresponding to the label and the model output result to perform back propagation adjustment on the YOLOv m model in training to obtain a plurality of YOLOv m models;
carrying out knowledge distillation on the YOLOv s model by adopting a YOLOv m model to obtain a plurality of YOLOv s models;
and carrying out ten-fold cross validation on the YOLOv s models by using a model validation set, and screening to obtain an optimal YOLOv s model serving as a target two-dimensional code detection model.
Further, after the step of uploading the model file of the target two-dimensional code detection model to the intranet object storage server and integrating the model file into springboot program services, the method further includes:
Pulling a model file on an intranet object storage server at regular time based on springboot program service;
When the target two-dimensional code detection model is updated, reloading and integrating a model file corresponding to the updated target two-dimensional code detection model on the intranet object storage server based on springboot program service;
And (3) re-executing the steps of packaging the model file integrated into springboot program service into a general service SDK tool kit while the two-dimension code detection function service is not interrupted, and externally providing the two-dimension code detection function of the target two-dimension code detection model in a HTTP interface mode.
Furthermore, the target two-dimensional code detection model is obtained by training in a python environment, and pytorch frames are selected as calculation frames of a BP algorithm and a YOLOv algorithm.
Further, before the step of detecting whether the two-dimensional code exists in the picture to be distributed based on the two-dimensional code detection function:
detecting whether the definition of the picture to be distributed exceeds a preset definition;
When the definition of the picture to be distributed exceeds the preset definition, automatically cutting the picture to be distributed to the preset size for two-dimensional code detection.
Further, the two-dimension code detection function service supports the detection of an input picture link address and an uploaded picture file; confidence parameters in the model file of the target two-dimensional code detection model can be adjusted.
In a second aspect, the present invention further provides a two-dimensional code detection device, where the device includes:
The acquisition module is used for acquiring a preset source training set, wherein the source training set comprises two-dimensional code partial missing, two-dimensional code rotation, two-dimensional code overturning, two-dimensional code distortion, two-dimensional code deformation and two-dimensional code personalized customized pictures;
The preprocessing module is used for preprocessing the pictures in the preset source training set to obtain preprocessed source training set pictures;
The model training module is used for taking the preprocessed source training set picture and the corresponding labeled label as input, and training the two-dimensional code detection model based on the BP algorithm and the Yolov algorithm to obtain a target two-dimensional code detection model;
The model file integration module is used for uploading a model file of the target two-dimensional code detection model to the intranet object storage server and integrating the model file into springboot program services;
The model function packaging module is used for packaging the model files integrated to springboot program services into a general service SDK tool kit and externally providing a two-dimension code detection function of the target two-dimension code detection model in a HTTP interface mode;
the detection module is used for detecting whether the picture to be distributed has the two-dimensional code or not based on the two-dimensional code detection function;
and the interception module is used for intercepting the pictures to be distributed if the two-dimensional code exists.
Further, the pictures in the preset source training set are preprocessed by adopting Gaussian blur, gaussian noise, gray level and poisson noise combination, wherein the Gaussian noise is used for processing and cleaning the pictures in the source training set based on a clip function of a numpy base, and then the color space of the pictures in the source training set is changed based on a cv2 base.
Further, the model training module is specifically configured to:
Dividing the processed source training set picture and the label corresponding to the label into a model training set and a model verification set according to a preset proportion;
Inputting a source training set picture in a model training set and a label corresponding to the label into a YOLOv m model for training with preset iteration times, and calculating and determining a loss value based on the label corresponding to the label and the model output result to perform back propagation adjustment on the YOLOv m model in training to obtain a plurality of YOLOv m models;
carrying out knowledge distillation on the YOLOv s model by adopting a YOLOv m model to obtain a plurality of YOLOv s models;
and carrying out ten-fold cross validation on the YOLOv s models by using a model validation set, and screening to obtain an optimal YOLOv s model serving as a target two-dimensional code detection model.
Further, the two-dimensional code detection device comprises a model heat updating module for:
Pulling a model file on an intranet object storage server at regular time based on springboot program service;
When the target two-dimensional code detection model is updated, reloading and integrating a model file corresponding to the updated target two-dimensional code detection model on the intranet object storage server based on springboot program service;
And (3) re-executing the steps of packaging the model file integrated into springboot program service into a general service SDK tool kit while the two-dimension code detection function service is not interrupted, and externally providing the two-dimension code detection function of the target two-dimension code detection model in a HTTP interface mode.
Furthermore, the target two-dimensional code detection model is obtained by training in a python environment, and pytorch frames are selected as calculation frames of a BP algorithm and a YOLOv algorithm.
Further, the two-dimensional code detection device comprises a picture slicing module for:
detecting whether the definition of the picture to be distributed exceeds a preset definition;
When the definition of the picture to be distributed exceeds the preset definition, automatically cutting the picture to be distributed to the preset size for two-dimensional code detection.
Further, the two-dimension code detection function service supports the detection of an input picture link address and an uploaded picture file; confidence parameters in the model file of the target two-dimensional code detection model can be adjusted.
In a third aspect, an embodiment of the present application further provides a two-dimensional code detection apparatus, where the two-dimensional code detection apparatus includes a processor, a memory, and a two-dimensional code detection program stored on the memory and executable by the processor, where the two-dimensional code detection program, when executed by the processor, implements the steps of the two-dimensional code detection method described above.
In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, where a two-dimensional code detection program is stored on the computer readable storage medium, where the two-dimensional code detection program, when executed by a processor, implements the steps of the two-dimensional code detection method described above.
In summary, compared with the prior art, the technical scheme provided by the embodiment of the application has the following beneficial effects:
According to the two-dimensional code detection method, device and equipment and the readable storage medium, BP and Yolov algorithm are utilized, self-grinding detection recognition is conducted on multiple complex conditions such as partial deletion, rotation, overturning, distortion, deformation and personalized customized base map of the two-dimensional code based on a neural network, various two-dimensional code occurrence scenes are integrated to conduct extraction and encapsulation, a general research and development SDK is integrated to provide a two-dimensional code detection function, accuracy, efficiency and safety of detecting and positioning of the two-dimensional code of a picture in a manuscript are improved, and a picture two-dimensional code detection threshold is reduced.
Drawings
Fig. 1 is a flow chart of a two-dimensional code detection method according to an embodiment of the present application;
Fig. 2 is a schematic functional block diagram of a two-dimensional code detection device according to an embodiment of the present application;
fig. 3 is a schematic hardware structure of a two-dimensional code detection device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Referring to fig. 1, an embodiment of the present application provides a two-dimensional code detection method, which specifically includes:
Step S10, a preset source training set is obtained, wherein the source training set comprises two-dimensional code partial missing, two-dimensional code rotation, two-dimensional code overturning, two-dimensional code distortion, two-dimensional code deformation and two-dimensional code personalized customized pictures;
step S20, preprocessing a preset source training set picture to obtain a preprocessed source training set picture;
step S30, training a two-dimensional code detection model based on a BP algorithm and Yolov algorithm by taking the preprocessed source training set picture and the corresponding labeled label as input to obtain a target two-dimensional code detection model;
step S40, uploading a model file of the target two-dimensional code detection model to an intranet object storage server, and integrating the model file into springboot program services;
step S50, packaging the model files integrated to springboot program services into a general service SDK tool kit, and externally providing a two-dimension code detection function of a target two-dimension code detection model in a HTTP interface mode;
Step S60, detecting whether a two-dimensional code exists in the picture to be distributed or not based on a two-dimensional code detection function;
and step S70, if the two-dimensional code exists, intercepting the picture to be distributed.
In this embodiment, the obtained pictures of the preset source training set are derived from the open source data set and the own picture data set of the internal news manuscript of the south intelligent media cloud platform, and include pictures of partial missing of the two-dimensional code, rotation of the two-dimensional code, overturning of the two-dimensional code, distortion of the two-dimensional code, deformation of the two-dimensional code, personalized customization of the two-dimensional code, and correspond to visual scenes such as two-dimensional code patches, front of the two-dimensional code, rotation of the two-dimensional code, bending of the two-dimensional code, regional illumination difference and the like, so that comprehensiveness of training data can be ensured.
After the pictures of the preset source training set are determined, as the existing known two-dimensional code scenes are limited, the fact that the actual scenes and conditions are more complex when the two-dimensional code detection is carried out based on the two-dimensional code recognition model is considered, the pictures in the source training set can be preprocessed to integrate and expand the training set data, and the picture samples in the training set are guaranteed to be closer to the pictures of the production scenes.
After the preprocessed source training set picture is obtained, taking the preprocessed source training set picture and the corresponding marked label into consideration of the service requirement of two-dimension code detection and identification in the news manuscript, training a two-dimension code detection model based on a BP algorithm and a Yolov algorithm to obtain a target two-dimension code detection model. The BP algorithm can continuously adjust the weight and the threshold of the Yolov algorithm model through back propagation, so that the sum of squares of errors of the Yolov algorithm model is minimum, and when the Yolov algorithm model is applied to a target task for detecting and identifying the two-dimensional code in the news manuscript, the detection speed is high, the detection precision is good, and the detection performance of the two-dimensional code is better.
The training of the determined target two-dimensional code detection model needs to be applied to the two-dimensional code detection service in manuscripts of the southern intelligent media cloud platform and the like, in this embodiment, a model file of the target two-dimensional code detection model is uploaded to an intranet object storage server (i.e., an OSS server) of the southern intelligent media cloud platform and the like, and is integrated to springboot program services, so that the target two-dimensional code detection model primarily has two-dimensional code recognition capability. And then the model file integrated to springboot program services is packaged into a general service SDK tool kit, and the two-dimension code detection function of the target two-dimension code detection model can be provided externally in a HTTP interface mode. When the method is used subsequently, only a dependence package for identifying the two-dimension code is required to be introduced, the two-dimension code detection function can be used for detecting whether the picture to be distributed has the two-dimension code or not, and when the two-dimension code exists, the picture to be distributed is intercepted and is not distributed and transmitted outwards, so that the possible system security risk is avoided, and the safety and reliability of the south intelligent media cloud platform and the like when the two-dimension code detection function is accessed can be ensured.
According to the scheme, BP and Yolov algorithms are utilized, based on a neural network, self-grinding detection recognition is carried out on multiple complex conditions such as partial missing, rotation, overturning, distortion, deformation, personalized customized base map and the like of the two-dimensional code, various two-dimensional code occurrence scenes are integrated to carry out question extraction packaging, the general research and development SDK is integrated to provide a two-dimensional code detection function, accuracy, efficiency and safety of detecting and positioning the two-dimensional code in an image are improved, and a picture two-dimensional code detection threshold is reduced.
Aiming at the existing scheme of applying the picture two-dimension code detection and identification to manuscript text picture detection, a third party manufacturer service is purchased, the defect of mastering the technology initiative is overcome, the whole process of the scheme of the embodiment is independently researched and developed, the model is trained automatically, and the technology initiative is mastered; aiming at the defects that the two-dimension code identification precision is not high, the labeling and positioning are inaccurate, deviation exists, and the service requirement cannot be met, the target two-dimension code detection model determined by adopting the BP algorithm and Yolov algorithm in the scheme of the embodiment has high identification precision, and the service requirement of the two-dimension code detection in manuscripts of the south intelligent media cloud platform is met; aiming at the defect of poor picture identification effect of blurring or low definition in the existing scheme, the target two-dimensional code detection model in the scheme of the embodiment supports identification of precise, blurring or low definition pictures; aiming at the defects that the conventional scheme is generally used for recognition, personalized training is not carried out aiming at the news consultation field, and the recognition effect cannot be guaranteed, the scheme of the embodiment aims at news information services, and an internal picture data set is adopted for multi-round targeted training, so that a target two-dimensional code detection model suitable for the news information services can be obtained; aiming at the defects that the existing scheme transmits the picture data through the network, the model is not in an own platform, the picture data is transmitted outwards, and the safety cannot be guaranteed, the target two-dimension code detection model of the scheme of the embodiment is stored in an internal platform, the picture is identified in the own platform, the picture is not transmitted outwards, the system is safe and reliable, the risk of content safety does not exist, the technology is autonomous and controllable, and the system is only packaged into a universal SDK tool kit, the two-dimension code identification capability is provided for the outside in an HTTP interface mode, the system is zero invasive, and the use safety can be ensured; aiming at the defects that the higher the picture quality is, the longer the identification time is, and the identification performance cannot be guaranteed in the existing scheme, the performance of the scheme is better than the common practice in the industry under the condition that the scheme is configured as 1.5 core cpu and 3GB memory; aiming at the defects that the existing scheme is limited to two-dimension code recognition and cannot be rapidly expanded to similar scenes such as OCR recognition, the scheme of the embodiment can be rapidly popularized and applied to other recognition scenes such as other object recognition and portrait detection based on picture two-dimension code recognition.
Further, in an embodiment, a combination of gaussian blur, gaussian noise, gray scale and poisson noise is adopted to preprocess a picture in a preset source training set, wherein the gaussian noise processes and cleans the picture in the source training set based on a clip function of numpy library, and then a color space of the picture in the source training set is changed based on a cv2 library.
In this embodiment, when a preset source training set is preprocessed, a combination of gaussian blur, gaussian noise, gray scale and poisson noise is adopted, and image noise affecting two-dimensional code detection and recognition can be removed by filtering and denoising the pictures in the source training set through gaussian blur, so that subsequent detection and recognition are facilitated. And because the two-dimensional code in the picture is detected and identified, and the image color does not need to be considered, gray processing can be performed, so that the subsequent process of detecting and identifying the two-dimensional code in the picture is simplified, and the detection difficulty is reduced. Meanwhile, small noise changes can be added to the image through Gaussian noise and poisson noise, the noise can represent dirt or slight missing on the image, the subsequent model is forced to learn the characteristic of robustness to the small changes in the input picture data, and even if the image in actual application is slightly different from training data, the model is more likely to correctly identify the image. The Gaussian noise is used for processing and cleaning the image based on a clip function of numpy libraries, then a cv2 library of OpenCV is used for changing the color space of the image, so that the image is more attached to a picture scene of a two-dimensional code of a south intelligent media cloud, and finally the processed source training set picture and the label are rewritten into a specified image and label catalog to be used as materials for subsequent training.
Through the preprocessing, the training set data are integrated and expanded, the picture sample in the training set is closer to the production scene picture, and the accuracy of the target two-dimensional code detection model determined by training is further improved.
Further, in an embodiment, the step S30 includes:
Dividing the processed source training set picture and the label corresponding to the label into a model training set and a model verification set according to a preset proportion;
Inputting a source training set picture in a model training set and a label corresponding to the label into a YOLOv m model for training with preset iteration times, and calculating and determining a loss value based on the label corresponding to the label and the model output result to perform back propagation adjustment on the YOLOv m model in training to obtain a plurality of YOLOv m models;
carrying out knowledge distillation on the YOLOv s model by adopting a YOLOv m model to obtain a plurality of YOLOv s models;
and carrying out ten-fold cross validation on the YOLOv s models by using a model validation set, and screening to obtain an optimal YOLOv s model serving as a target two-dimensional code detection model.
In this embodiment, the processed source training set pictures and the labels corresponding to the labels are divided into a model training set and a model verification set according to a preset proportion, wherein the preset proportion can be set to be 3:1 for performing multi-batch training, and if the number of pictures in the model training set is set to be 3072, the number of pictures in the model verification set is 1024. During each batch of training, 32 picture samples in the model training set and corresponding labeled labels can be selected as input, and input into a YOLOv m model for training with preset iteration times, wherein the preset iteration times can be set to be 100, and the picture size can be set to be 640 multiplied by 640. In training, a loss value is calculated and determined based on the label and the model output result of the corresponding label, and a YOLOv m model is adjusted in a back propagation mode to obtain a plurality of YOLOv m models. The learning rate when the BP algorithm performs back propagation to continuously adjust the weight and threshold parameters of the Yolov algorithm model can be set to 0.0001, the error square sum of the Yolov algorithm model is minimized through iterative learning, and the detection accuracy is continuously improved.
After a plurality of YOLOv m models are obtained, knowledge distillation can be carried out on YOLOv s models by adopting YOLOv m models to obtain a plurality of YOLOv s models, ten-fold cross validation is carried out on a plurality of YOLOv s models by adopting a model validation set, and an optimal YOLOv s model is obtained through multiple validation and screening and is used as a target two-dimensional code detection model. The YOLOv m model is a medium-sized model in the Yolov5 model, has better balance between detection speed and accuracy, is suitable for equipment with certain computing capacity, and the YOLOv s model is a minimum model in the Yolov5 model, has the highest detection speed, but has relatively lower accuracy, and is suitable for equipment with limited computing resources. Based on the balance consideration of computing resources, detection speed and detection accuracy, the two-dimensional code detection capability of the trained YOLOv m model is migrated to a YOLOv s model with a simpler structure through knowledge distillation, and the method and the device can be applied to services with limited computing resources and certain balance requirements on the detection speed and the detection accuracy, namely, the method and the device are correspondingly applied to services aiming at the detection of the two-dimensional code of the picture in the manuscript in the method and the device.
Further, in an embodiment, after the step S40, the method further includes:
Pulling a model file on an intranet object storage server at regular time based on springboot program service;
When the target two-dimensional code detection model is updated, reloading and integrating a model file corresponding to the updated target two-dimensional code detection model on the intranet object storage server based on springboot program service;
And (3) re-executing the steps of packaging the model file integrated into springboot program service into a general service SDK tool kit while the two-dimension code detection function service is not interrupted, and externally providing the two-dimension code detection function of the target two-dimension code detection model in a HTTP interface mode.
In this embodiment, after the image two-dimensional code detection capability is provided to the outside in the general SDK service manner, springboot program service will regularly pull the model file on the intranet object storage server, so as to cope with the situation that the model is updated frequently. When the target two-dimensional code detection model is updated, the retrained model file is uploaded to the intranet object storage server, and at the moment springboot program service reloads and integrates the model file corresponding to the updated target two-dimensional code detection model on the intranet object storage server. And (3) the step of packaging the model file integrated into springboot program service into a general service SDK tool kit, and providing the two-dimensional code detection function of the target two-dimensional code detection model outwards in a HTTP interface mode while the two-dimensional code detection function service is not interrupted, and providing the updated target two-dimensional code detection model of the two-dimensional code detection function. The latest model is regularly pulled through the remote calling technology, so that the model can be updated without stopping, and the flexibility of deployment of the target two-dimensional code detection model and the stability of the two-dimensional code detection service are improved on the basis of ensuring the safety of the model without invasiveness.
Further, in an embodiment, the target two-dimensional code detection model is obtained by training in a python environment, and a pytorch framework is selected as a calculation framework of the BP algorithm and the YOLOv algorithm.
In this embodiment, the target two-dimensional code detection model is obtained by training in a python environment, and the calculation frames of the BP algorithm and YOLOv algorithm are pytorch frames, which are very friendly to the user, can train own data sets conveniently, and compared with other frames such as Darknet frames, the pytorch frames are easier to put into production, are easy to configure the environment, and are also very fast when the corresponding algorithm performs model training. The model file corresponding to the generated target two-dimensional code detection model is a pt model file, and can be conveniently uploaded to an intranet object storage server.
Further, in an embodiment, before the step S60:
detecting whether the definition of the picture to be distributed exceeds a preset definition;
When the definition of the picture to be distributed exceeds the preset definition, automatically cutting the picture to be distributed to the preset size for two-dimensional code detection.
In this embodiment, the requirements of the detection speed and the detection precision are correspondingly considered, when the definition of the picture to be distributed is very high, for example, the picture with definition above 2k, if the picture is not processed, the detection and recognition time is extremely long, and the detection performance of the two-dimensional code cannot be guaranteed. In order to ensure the detection speed and the detection accuracy of the balanced high-resolution picture, the picture to be distributed can be automatically sliced under the condition that the image characteristics are not lost. Through repeated experiments, the optimal size 990px x 990px (px is a pixel) of the image detection target image slice is explored, before the step of detecting whether the two-dimensional code exists in the image to be distributed based on the two-dimensional code detection function, logic supporting automatic picture splitting identification is researched and developed in the packaging general SDK toolkit, whether the definition of the image to be distributed exceeds the preset definition is detected, and when the definition of the image to be distributed exceeds the preset definition, the image to be distributed is automatically split to the preset size for two-dimensional code detection. Through the processing of the mode, the method can be suitable for detecting the two-dimension code of the high-definition picture, supports the detection of the picture after the picture is segmented, and finally combines the detection results, so that the detection precision of the two-dimension code is effectively improved.
Further, in an embodiment, the two-dimensional code detection function service supports the detection of the input picture link address and the uploading picture file; confidence parameters in the model file of the target two-dimensional code detection model can be adjusted.
In this embodiment, the two-dimensional code detection function service supports the input of the picture link address url and the uploading of the picture file for detection, so that the two-dimensional code detection function service can be conveniently and rapidly applied to use in different scenes, and the use convenience of two-dimensional code detection is improved. The confidence coefficient parameters in the model file of the target two-dimensional code detection model can be adjusted, and the two-dimensional code recognition effect can be influenced by adjusting the confidence coefficient parameters, so that the accuracy requirements of different services are adapted.
The embodiment of the application also provides a two-dimensional code detection device.
Referring to fig. 2, a functional block diagram of a first embodiment of a two-dimensional code detection device is shown.
In this embodiment, the two-dimensional code detection device includes:
the acquisition module 10 is configured to acquire a preset source training set, where the source training set includes a two-dimensional code partial missing, a two-dimensional code rotation, a two-dimensional code turning, a two-dimensional code distortion, a two-dimensional code deformation, and a two-dimensional code personalized customized picture;
The preprocessing module 20 is configured to preprocess a picture in a preset source training set to obtain a preprocessed source training set picture;
The model training module 30 is configured to perform training of a two-dimensional code detection model based on a BP algorithm and Yolov algorithm by taking the preprocessed source training set picture and the corresponding labeled label as input, so as to obtain a target two-dimensional code detection model;
The model file integration module 40 is configured to upload a model file of the target two-dimensional code detection model to the intranet object storage server, and integrate the model file into springboot program services;
The model function packaging module 50 is configured to package a model file integrated into springboot program services into a universal service SDK toolkit, and externally provide a two-dimensional code detection function of the target two-dimensional code detection model in a HTTP interface manner;
the detection module 60 is configured to detect whether a two-dimensional code exists in a picture to be distributed based on a two-dimensional code detection function;
the interception module 70 is configured to intercept the picture to be distributed if the two-dimensional code exists.
Further, in an embodiment, a combination of gaussian blur, gaussian noise, gray scale and poisson noise is adopted to preprocess a picture in a preset source training set, wherein the gaussian noise processes and cleans the picture in the source training set based on a clip function of numpy library, and then a color space of the picture in the source training set is changed based on a cv2 library.
Further, in an embodiment, the model training module 30 is specifically configured to:
Dividing the processed source training set picture and the label corresponding to the label into a model training set and a model verification set according to a preset proportion;
Inputting a source training set picture in a model training set and a label corresponding to the label into a YOLOv m model for training with preset iteration times, and calculating and determining a loss value based on the label corresponding to the label and the model output result to perform back propagation adjustment on the YOLOv m model in training to obtain a plurality of YOLOv m models;
carrying out knowledge distillation on the YOLOv s model by adopting a YOLOv m model to obtain a plurality of YOLOv s models;
and carrying out ten-fold cross validation on the YOLOv s models by using a model validation set, and screening to obtain an optimal YOLOv s model serving as a target two-dimensional code detection model.
Further, in an embodiment, the two-dimensional code detection device includes a model thermal update module configured to:
Pulling a model file on an intranet object storage server at regular time based on springboot program service;
When the target two-dimensional code detection model is updated, reloading and integrating a model file corresponding to the updated target two-dimensional code detection model on the intranet object storage server based on springboot program service;
And (3) re-executing the steps of packaging the model file integrated into springboot program service into a general service SDK tool kit while the two-dimension code detection function service is not interrupted, and externally providing the two-dimension code detection function of the target two-dimension code detection model in a HTTP interface mode.
Further, in an embodiment, the target two-dimensional code detection model is obtained by training in a python environment, and a pytorch framework is selected as a calculation framework of the BP algorithm and the YOLOv algorithm.
Further, in an embodiment, the two-dimensional code detection device includes a picture slicing module, configured to:
detecting whether the definition of the picture to be distributed exceeds a preset definition;
When the definition of the picture to be distributed exceeds the preset definition, automatically cutting the picture to be distributed to the preset size for two-dimensional code detection.
Further, in an embodiment, the two-dimensional code detection function service supports the detection of the input picture link address and the uploading picture file; confidence parameters in the model file of the target two-dimensional code detection model can be adjusted.
The function implementation of each module in the two-dimensional code detection device corresponds to each step in the embodiment of the two-dimensional code detection method, and the function and implementation process of each module are not described in detail herein.
The embodiment of the application provides two-dimensional code detection equipment which can be equipment with a data processing function, such as a personal computer (personal computer, PC), a notebook computer, a server and the like.
Referring to fig. 3, fig. 3 is a schematic hardware structure of a two-dimensional code detection device according to an embodiment of the present application. In an embodiment of the present application, the two-dimensional code detection device may include a processor 1001 (e.g., a central processing unit Central Processing Unit, a CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein the communication bus 1002 is used to enable connected communications between these components; the user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard); the network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., wireless FIdelity WIreless-FICAT interface); the memory 1005 may be a high-speed random access memory (random access memory, RAM) or a stable memory (non-volatile memory), such as a disk memory, and the memory 1005 may alternatively be a storage device independent of the processor 1001. It will be appreciated by those skilled in the art that the hardware structure shown in the two-dimensional code detection of the figures is not limiting of the application and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
With continued reference to fig. 3, an operating system, a network communication module, a user interface module, and a two-dimensional code detection program may be included in the memory 1005 in fig. 3, which is a type of computer-readable storage medium. The processor 1001 may call the two-dimensional code detection program stored in the memory 1005, and execute the steps of the two-dimensional code detection method provided in the embodiment of the present application.
The method implemented when the two-dimensional code detection program is executed may refer to various embodiments of the two-dimensional code detection method of the present application, and will not be described herein.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (8)

1. The two-dimensional code detection method is characterized by comprising the following steps of:
Acquiring a preset source training set, wherein the source training set comprises pictures of partial missing of a two-dimensional code, rotation of the two-dimensional code, overturning of the two-dimensional code, distortion of the two-dimensional code, deformation of the two-dimensional code and personalized customization of the two-dimensional code;
preprocessing the pictures in a preset source training set to obtain preprocessed source training set pictures;
Taking the preprocessed source training set picture and the corresponding labeled label as input, and training a two-dimensional code detection model based on a BP algorithm and Yolov algorithm to obtain a target two-dimensional code detection model;
Uploading a model file of the target two-dimensional code detection model to an intranet object storage server, and integrating the model file into springboot program services;
Packaging the model files integrated to springboot program services into a general service SDK tool kit, and externally providing a two-dimension code detection function of a target two-dimension code detection model in a HTTP interface mode;
Pulling a model file on an intranet object storage server at regular time based on springboot program service;
When the target two-dimensional code detection model is updated, reloading and integrating a model file corresponding to the updated target two-dimensional code detection model on the intranet object storage server based on springboot program service;
The method comprises the steps of re-executing the two-dimension code detection function of encapsulating a model file integrated to springboot program services into a general service SDK tool kit and externally providing a target two-dimension code detection model in an HTTP interface mode while the two-dimension code detection function service is not interrupted;
detecting whether the definition of the picture to be distributed exceeds a preset definition;
when the definition of the picture to be distributed exceeds the preset definition, automatically segmenting the picture to be distributed to a preset size, and detecting a two-dimensional code, wherein the preset size is 990px;
Detecting whether a picture to be distributed has a two-dimensional code or not based on a two-dimensional code detection function;
If the two-dimensional code exists, the picture to be distributed is intercepted.
2. The method according to claim 1, characterized in that: and preprocessing the pictures in the preset source training set by adopting Gaussian blur, gaussian noise, gray level and poisson noise combination, wherein the Gaussian noise is used for processing and cleaning the pictures in the source training set based on a clip function of numpy library, and changing the color space of the pictures in the source training set based on a cv2 library.
3. The method according to claim 1, wherein the step of training the two-dimensional code detection model based on the BP algorithm and Yolov algorithm by taking the preprocessed source training set picture and the corresponding labeled label as input, and obtaining the target two-dimensional code detection model comprises:
Dividing the processed source training set picture and the label corresponding to the label into a model training set and a model verification set according to a preset proportion;
Inputting a source training set picture in a model training set and a label corresponding to the label into a YOLOv m model for training with preset iteration times, and calculating and determining a loss value based on the label corresponding to the label and the model output result to perform back propagation adjustment on the YOLOv m model in training to obtain a plurality of YOLOv m models;
carrying out knowledge distillation on the YOLOv s model by adopting a YOLOv m model to obtain a plurality of YOLOv s models;
and carrying out ten-fold cross validation on the YOLOv s models by using a model validation set, and screening to obtain an optimal YOLOv s model serving as a target two-dimensional code detection model.
4. The method according to claim 1, characterized in that: the target two-dimensional code detection model is obtained by training in a python environment, and pytorch frames are selected as calculation frames of a BP algorithm and a YOLOv algorithm.
5. The method according to claim 1, characterized in that: the two-dimensional code detection function service supports the input of a picture link address and the detection of an uploaded picture file; confidence parameters in the model file of the target two-dimensional code detection model can be adjusted.
6. A two-dimensional code detection device, characterized in that the device comprises:
The acquisition module is used for acquiring a preset source training set, wherein the source training set comprises two-dimensional code partial missing, two-dimensional code rotation, two-dimensional code overturning, two-dimensional code distortion, two-dimensional code deformation and two-dimensional code personalized customized pictures;
The preprocessing module is used for preprocessing the pictures in the preset source training set to obtain preprocessed source training set pictures;
The model training module is used for taking the preprocessed source training set picture and the corresponding labeled label as input, and training the two-dimensional code detection model based on the BP algorithm and the Yolov algorithm to obtain a target two-dimensional code detection model;
The model file integration module is used for uploading a model file of the target two-dimensional code detection model to the intranet object storage server and integrating the model file into springboot program services;
The model function packaging module is used for packaging the model files integrated to springboot program services into a general service SDK tool kit and externally providing a two-dimension code detection function of the target two-dimension code detection model in a HTTP interface mode;
The model thermal updating module is used for regularly pulling a model file on the intranet object storage server based on springboot program service; when the target two-dimensional code detection model is updated, reloading and integrating a model file corresponding to the updated target two-dimensional code detection model on the intranet object storage server based on springboot program service; the method comprises the steps of re-executing the two-dimension code detection function of encapsulating a model file integrated to springboot program services into a general service SDK tool kit and externally providing a target two-dimension code detection model in an HTTP interface mode while the two-dimension code detection function service is not interrupted;
the picture slicing module is used for detecting whether the definition of the picture to be distributed exceeds a preset definition; when the definition of the picture to be distributed exceeds the preset definition, automatically segmenting the picture to be distributed to a preset size, and detecting a two-dimensional code, wherein the preset size is 990px;
the detection module is used for detecting whether the picture to be distributed has the two-dimensional code or not based on the two-dimensional code detection function;
and the interception module is used for intercepting the pictures to be distributed if the two-dimensional code exists.
7. A two-dimensional code detection apparatus, characterized in that it comprises a processor, a memory, and a two-dimensional code detection program stored on the memory and executable by the processor, wherein the two-dimensional code detection program, when executed by the processor, implements the steps of the two-dimensional code detection method according to any one of claims 1 to 5.
8. A computer-readable storage medium, wherein a two-dimensional code detection program is stored on the computer-readable storage medium, wherein the two-dimensional code detection program, when executed by a processor, implements the steps of the two-dimensional code detection method according to any one of claims 1 to 5.
CN202310900164.9A 2023-07-20 2023-07-20 Two-dimensional code detection method, device, equipment and readable storage medium Active CN116993962B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310900164.9A CN116993962B (en) 2023-07-20 2023-07-20 Two-dimensional code detection method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310900164.9A CN116993962B (en) 2023-07-20 2023-07-20 Two-dimensional code detection method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN116993962A CN116993962A (en) 2023-11-03
CN116993962B true CN116993962B (en) 2024-04-26

Family

ID=88529398

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310900164.9A Active CN116993962B (en) 2023-07-20 2023-07-20 Two-dimensional code detection method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN116993962B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114693908A (en) * 2022-03-08 2022-07-01 东莞理工学院 Industrial two-dimensional code positioning method based on YOLOv5
CN114897536A (en) * 2021-12-23 2022-08-12 浙江大学 Commodity anti-counterfeiting tracing method based on RFID (radio frequency identification) label and block chain
CN115457254A (en) * 2022-08-31 2022-12-09 上海致景信息科技有限公司 Two-dimensional code positioning orthodontic method based on deep learning, medium and processor
CN115511802A (en) * 2022-09-14 2022-12-23 天津大学 Marine target detection system based on Springboot frame
CN116227556A (en) * 2023-03-16 2023-06-06 西南科技大学 Method, device, computer equipment and storage medium for acquiring target network model
CN116301876A (en) * 2022-09-08 2023-06-23 南方科技大学 DevOps development method for AI algorithm service

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114897536A (en) * 2021-12-23 2022-08-12 浙江大学 Commodity anti-counterfeiting tracing method based on RFID (radio frequency identification) label and block chain
CN114693908A (en) * 2022-03-08 2022-07-01 东莞理工学院 Industrial two-dimensional code positioning method based on YOLOv5
CN115457254A (en) * 2022-08-31 2022-12-09 上海致景信息科技有限公司 Two-dimensional code positioning orthodontic method based on deep learning, medium and processor
CN116301876A (en) * 2022-09-08 2023-06-23 南方科技大学 DevOps development method for AI algorithm service
CN115511802A (en) * 2022-09-14 2022-12-23 天津大学 Marine target detection system based on Springboot frame
CN116227556A (en) * 2023-03-16 2023-06-06 西南科技大学 Method, device, computer equipment and storage medium for acquiring target network model

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Cordova的北京市园林植物科普App研建;安乾;《硕士电子期刊》;论文第2.1、2.2、5.1节 *

Also Published As

Publication number Publication date
CN116993962A (en) 2023-11-03

Similar Documents

Publication Publication Date Title
US11810374B2 (en) Training text recognition systems
AU2020200058B2 (en) Image quality assessment and improvement for performing optical character recognition
CN108229591B (en) Neural network adaptive training method and apparatus, device, program, and storage medium
WO2018010657A1 (en) Structured text detection method and system, and computing device
US10810721B2 (en) Digital image defect identification and correction
US8861884B1 (en) Training classifiers for deblurring images
CN111767228B (en) Interface testing method, device, equipment and medium based on artificial intelligence
US10943107B2 (en) Simulating image capture
CN112906463A (en) Image-based fire detection method, device, equipment and storage medium
US11816522B1 (en) System and method for generating digital content within an augmented reality environment
US9374601B1 (en) Prevention of image artifact
CN111461101B (en) Method, device, equipment and storage medium for identifying work clothes mark
CN109118456B (en) Image processing method and device
CN111198815B (en) Compatibility testing method and device for user interface
CN112767354A (en) Defect detection method, device and equipment based on image segmentation and storage medium
CN113033677A (en) Video classification method and device, electronic equipment and storage medium
CN113837928A (en) Object color adjusting method and device, electronic equipment and storage medium
CN116993962B (en) Two-dimensional code detection method, device, equipment and readable storage medium
CN113516697A (en) Image registration method and device, electronic equipment and computer-readable storage medium
CN110210314B (en) Face detection method, device, computer equipment and storage medium
CN112784189A (en) Method and device for identifying page image
CN113642642A (en) Control identification method and device
CN112418217A (en) Method, apparatus, device and medium for recognizing characters
CN113592807B (en) Training method, image quality determining method and device and electronic equipment
Nguyen The Recognition Accuracy in the SSD Model

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