Identification code detection method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202611115197.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2046-07-27
AI Technical Summary
[0003]然而,在实际工业产线中,标识码往往直接形成于金属、芯片封装、电路板、喷涂件或曲面零件等不同材质表面,其成像质量受到标刻工艺、材料纹理、表面反光、油污粉尘、磨损腐蚀、阴影遮挡、低对比度、焦距变化、相机角度和光照不均等因素影响
[0016] The identification code detection method, apparatus, electronic device, and storage medium proposed in this application acquire image data containing identification codes by acquiring images of the device to be detected; perform identification code localization processing on the image data using a pre-trained identification code detection model to obtain candidate identification code images; perform decoding processing on the candidate identification code images to obtain decoding results; and, in response to the candidate identification code image triggering a failure state during localization or decoding processing, use the image data and the corresponding candidate identification code image as identification code training images to optimize the identification code detection model. Therefore, this application utilizes a pre-trained identifier detection model to perform identifier localization processing on image data, obtaining candidate identifier images, and then performs decoding processing based on the candidate identifier images to obtain decoding results. When a candidate identifier image triggers a failure state during localization or decoding processing, the image data and its corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model. This enables the identifier detection model to continuously learn from difficult samples encountered in the actual detection process, thereby effectively coping with interference caused by factors such as differences in marking processes, changes in material surfaces, fluctuations in lighting conditions, and dirt and wear in industrial settings, and improving the adaptability of the identifier detection model for identifier detection.
Smart Images

Figure CN122616577B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, electronic device and storage medium for detecting identification codes. Background Technology
[0002] Identification codes are often affixed to objects such as circuit boards, electronic components, and chip packages to achieve functions such as production traceability, quality control, and assembly error prevention. Industrial identification code recognition solutions typically employ fixed readers, traditional decoders, or machine vision algorithms for identification. The basic process usually includes steps such as image acquisition, code area localization, image enhancement, threshold segmentation or binarization, geometric correction, and decoding.
[0003] However, in actual industrial production lines, identification codes are often directly formed on the surfaces of different materials such as metal, chip packages, circuit boards, painted parts, or curved parts. Their image quality is affected by factors such as the marking process, material texture, surface reflection, oil and dust, wear and corrosion, shadows, low contrast, focal length variations, camera angle, and uneven lighting. These factors can lead to problems in the acquired identification code images, such as blurred module edges, partial missing parts, dirt occlusion, reduced contrast, geometric distortion, and background texture interference.
[0004] Therefore, overcoming interference and accurately identifying and parsing the identifier code has become an urgent technical problem to be solved. Summary of the Invention
[0005] The main objective of this application is to provide an identification code detection method, apparatus, electronic device, and storage medium, aiming to improve the adaptability of identification code detection.
[0006] To achieve the above objectives, a first aspect of this application proposes an identification code detection method, the method comprising: The device to be tested is subjected to image acquisition to obtain image data containing the identification code; The image data is processed by a pre-trained identifier detection model to locate the identifier, thereby obtaining candidate identifier images. The candidate identifier image is then decoded to obtain the decoding result; In response to the failure state triggered by the candidate identifier image in the localization or decoding process, the image data and the corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model.
[0007] In some embodiments, optimizing the identifier detection model by using the image data and the corresponding candidate identifier image as identifier training images includes: Synthetic training samples are constructed based on the training images of the identification code; wherein each of the synthetic training samples is configured with a corresponding pixel-level ground truth label; The synthetic training samples are added to a preset model training set for sample augmentation to obtain an augmented training set. The identification code detection model is optimized based on the expanded training set to obtain the optimized identification code detection model.
[0008] In some embodiments, constructing synthetic training samples based on the identification code training images includes: Obtain training images for the identifier codes, and obtain structural template images for various identifier code types; The structural template image is subjected to structural constraint feature extraction processing to obtain a geometric constraint feature matrix; wherein, the geometric constraint feature matrix represents the geometric layout structural information of the identification code; Based on the identification code training image, appearance feature extraction processing is performed to obtain an appearance style feature matrix; wherein, the appearance style feature matrix represents the surface texture information of the identification code training image; The geometric constraint feature matrix and the appearance style feature matrix are input into a pre-trained identifier code generation model to obtain multiple identifier code composite images; The geometric constraint feature matrix is used as the pixel-level ground truth label of the synthesized image of the identifier code to obtain the synthesized training sample.
[0009] In some embodiments, before inputting the geometric constraint feature matrix and the appearance style feature matrix into the pre-trained identifier generation model, the method includes pre-training the identifier generation model, including: Obtain a model training set and an original identifier code generation model; wherein the model training set includes multiple identifier code samples, and the identifier code generation model is configured with a structure control module and an appearance feature control module; The identification code sample is input into the original identification code generation model, the geometric constraint feature matrix of the identification code sample is extracted based on the structure control module, and the appearance style feature matrix of the identification code sample is extracted based on the appearance feature control module. Based on the extracted geometric constraint feature matrix and appearance style feature matrix, the identification code generation model is controlled to generate identification codes, resulting in a sample synthetic image; Visual feature comparison is performed between the synthesized image from the sample and the identification code sample to obtain difference data; The model parameters of the identifier generation model are updated and iterated based on the difference data until the preset training stopping condition is met.
[0010] In some embodiments, inputting the geometric constraint feature matrix and the appearance style feature matrix into a pre-trained identifier generation model includes: Keeping the geometric constraint feature matrix unchanged, perturbation processing is performed based on the appearance style feature matrix to generate a composite image of the identification code corresponding to multiple appearance styles of the same geometric constraint feature matrix; The appearance style feature matrix is applied to multiple geometric constraint feature matrices to generate a composite image of the identification code with multiple structures for the appearance style feature matrix.
[0011] In some embodiments, the step of perturbing the appearance style feature matrix to generate a composite image of multiple appearance styles corresponding to the same geometric constraint feature matrix includes: Obtain preset physical degradation control parameters; wherein, the physical degradation control parameters include at least one of the following: wear ratio of the composite image of the identification code, light reflection intensity, oil stain coverage area, or image blur kernel size; A style control guidance vector is generated based on the physical degradation control parameters, and the degradation control guidance vector is input into the identifier generation model to obtain multiple identifier composite images, so as to achieve continuous gradient adjustment of the degradation severity of the identifier composite image.
[0012] In some embodiments, the industrial identification code to be detected includes a one-dimensional barcode, a two-dimensional barcode, or a data matrix code, and the method further includes: When the industrial identification code to be detected is a one-dimensional barcode, the geometric layout structure information corresponding to the structural template image is used to characterize the stripe arrangement, stripe width and stripe interval; When the industrial identification code to be detected is a QR code or a data matrix code, the geometric layout structure information corresponding to the structural template image is used to characterize the module boundary, positioning pattern and dot matrix distribution.
[0013] To achieve the above objectives, a second aspect of this application provides an identification code detection device, the device comprising: The image acquisition module is used to acquire images of the device to be inspected and obtain image data containing the identification code. The identifier code localization module is used to perform identifier code localization processing on the image data using a pre-trained identifier code detection model to obtain candidate identifier code images; The identifier code decoding module is used to perform decoding processing based on the candidate identifier code image to obtain the decoding result; The update and optimization module is used to optimize the identification code detection model by using the image data and the corresponding candidate identification code image as identification code training images in response to the failure state triggered by the candidate identification code image in the positioning or decoding process.
[0014] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the identification code detection method described in the first aspect.
[0015] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the identification code detection method described in the first aspect.
[0016] The identification code detection method, apparatus, electronic device, and storage medium proposed in this application acquire image data containing identification codes by acquiring images of the device to be detected; perform identification code localization processing on the image data using a pre-trained identification code detection model to obtain candidate identification code images; perform decoding processing on the candidate identification code images to obtain decoding results; and, in response to the candidate identification code image triggering a failure state during localization or decoding processing, use the image data and the corresponding candidate identification code image as identification code training images to optimize the identification code detection model. Therefore, this application utilizes a pre-trained identifier detection model to perform identifier localization processing on image data, obtaining candidate identifier images, and then performs decoding processing based on the candidate identifier images to obtain decoding results. When a candidate identifier image triggers a failure state during localization or decoding processing, the image data and its corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model. This enables the identifier detection model to continuously learn from difficult samples encountered in the actual detection process, thereby effectively coping with interference caused by factors such as differences in marking processes, changes in material surfaces, fluctuations in lighting conditions, and dirt and wear in industrial settings, and improving the adaptability of the identifier detection model for identifier detection. Attached Figure Description
[0017] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a schematic flowchart of an identification code detection method according to an embodiment of this application; Figure 2 This is another flowchart illustrating the identification code detection method according to an embodiment of this application; Figure 3This is another flowchart illustrating the identification code detection method according to an embodiment of this application; Figure 4 This is another flowchart illustrating the identification code detection method according to an embodiment of this application; Figure 5 This is another flowchart illustrating the identification code detection method according to an embodiment of this application; Figure 6 This is another flowchart illustrating the identification code detection method according to an embodiment of this application; Figure 7 This is another flowchart illustrating the identification code detection method according to an embodiment of this application; Figure 8 This is a schematic diagram of the identification code detection device provided in the embodiments of this application; Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0019] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0021] In surface mount technology production lines and other industrial machine vision inspection systems, in addition to detecting defects such as missing components, incorrect parts, misalignment, and poor soldering, it is often necessary to detect, locate, segment, and identify industrial identification codes on objects such as circuit boards, electronic components, and chip packages to achieve functions such as production traceability, quality control, and assembly error prevention. Common industrial identification codes include one-dimensional barcodes, quick-response QR codes, data matrix codes, and other machine-readable industrial identification codes.
[0022] Traditional industrial code recognition solutions typically employ fixed readers, traditional decoders, or machine vision algorithms. The basic process usually includes image acquisition, code area localization, image enhancement, threshold segmentation or binarization, geometric correction, and decoding. For rule-based machine vision solutions, the system often relies on manually set light sources, exposure, thresholds, edge parameters, morphological parameters, template matching rules, or detection windows to determine the code area location and module structure. Under stable imaging conditions, good marking quality, and minimal background interference, these traditional solutions can complete code reading.
[0023] However, in actual industrial production lines, identification codes are often directly formed on the surfaces of different materials such as metal, chip packages, circuit boards, painted parts, or curved parts. Their image quality is affected by factors such as marking process, material texture, surface reflection, oil and dust, wear and corrosion, shadow occlusion, low contrast, focal length changes, camera angle, and uneven lighting. These factors can lead to problems such as blurred module edges, partial missing parts, dirt occlusion, reduced contrast, geometric distortion, and background texture interference in the acquired identification code images. For traditional barcode scanning or rule-based vision solutions, if the code area positioning, threshold segmentation, or geometric correction results are unstable, even if the back-end decoder has a certain error correction capability, insufficient input image quality may still result in missed reads, misreads, or decoding failures.
[0024] Based on this, embodiments of this application provide a method, apparatus, electronic device, and storage medium for detecting identification codes, aiming to improve the adaptability of detecting identification codes.
[0025] The identification code detection method, apparatus, electronic device and storage medium provided in the embodiments of this application are specifically described through the following embodiments. First, the identification code detection method in the embodiments of this application is described.
[0026] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0027] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0028] The identification code detection method provided in this application relates to the field of artificial intelligence technology. The identification code detection method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the identification code detection method, but is not limited to the above forms.
[0029] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0030] Figure 1 This is an optional flowchart illustrating the identification code detection method provided in an embodiment of this application. Figure 1 The method may include, but is not limited to, steps S101 to S104.
[0031] Step S101: Acquire an image of the device to be inspected to obtain image data containing the identification code; Step S102: Use a pre-trained identifier detection model to perform identifier localization processing on the image data to obtain candidate identifier images; Step S103: Decode the candidate identifier image to obtain the decoding result; Step S104: In response to the failure state triggered by the candidate identifier image in the localization or decoding process, the image data and the corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model.
[0032] In step S101 of some embodiments, an industrial camera or automated optical inspection equipment is used to acquire an image of the object to be inspected, obtaining image data containing the identification code. This step is the data entry point for the entire identification code detection process, and its design concept is to ensure the authenticity and integrity of the original image data, providing basic materials for subsequent positioning, decoding, and failure sample reprocessing.
[0033] The equipment to be inspected typically refers to automated optical inspection equipment deployed in production lines. Its image sensors capture optical images of surfaces such as circuit boards, electronic components, chip packages, or automotive electronic parts at a fixed frame rate. Identification codes, as the core carrier of product traceability, are attached to the surfaces of these objects in the form of barcodes, quick-response codes, or data matrix codes. Their imaging quality is affected by multiple factors, including the marking process, material texture, lighting conditions, and camera parameters.
[0034] In step S102 of some embodiments, a pre-trained identifier detection model is used to perform identifier localization processing on the acquired image data to obtain candidate identifier images. The pre-trained identifier detection model is typically built based on a deep convolutional neural network, whose network parameters are pre-optimized using a large number of labeled samples, enabling it to extract identifier region features from complex backgrounds. By performing feature extraction, region proposal, and classification on the input image, the spatial location information of the identifier in the image is output, and candidate identifier images are obtained by cropping based on this location information. The candidate identifier images, as intermediate products of the localization process, may contain structurally complete and clearly distinguishable standard identifiers, or they may contain low-quality identifiers affected by degradation factors.
[0035] In step S103 of some embodiments, decoding processing is performed based on the candidate identifier code image to obtain the decoding result. By calling a decoding algorithm that matches the identifier code encoding protocol, the identifier code in image form is converted into code value information that can be directly read by the information system, completing the conversion from physical optical signal to digital semantic information. The decoding process typically includes sub-processes such as image preprocessing, binarization, geometric correction, image seeker pattern recognition, data extraction, and error correction decoding. The execution entity can be a general-purpose decoding library or a dedicated industrial decoder. The decoding result, as the final output of the identifier code detection process, is used to characterize the recognition conclusion of the identifier code content. When the quality of the candidate identifier code image meets the reading requirements of the encoding protocol, the decoding result outputs a valid code value. When the image suffers from severe degradation that results in missing structural information or blurred boundaries, the decoding process may fail and return an error state.
[0036] In step S104 of some embodiments, in response to a failure state triggered by the candidate identifier image during the localization or decoding process, the image data and its corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model. The design concept of this step is to establish an automatic reflow mechanism for failed samples and a continuous model optimization mechanism. A failure state refers to an abnormal situation where the localization process fails to effectively extract the code area location, or the decoding process fails to correctly output the code value. The triggering reasons include degradation factors such as reflection, dirt, wear, low contrast, blurred edges, uneven printing or marking, and material texture interference affecting the identifier. By optimizing the identifier detection model, the model parameters are adjusted to adapt to identifier degradation, thereby improving the ability to handle similar failure situations in subsequent detection tasks.
[0037] Steps S101 to S104 as shown in the embodiments of this application involve acquiring image data containing identification codes by capturing images of the device to be detected; performing identification code localization processing on the image data using a pre-trained identification code detection model to obtain candidate identification code images; performing decoding processing on the candidate identification code images to obtain decoding results; and optimizing the identification code detection model by using the image data and the corresponding candidate identification code images as identification code training images in response to the candidate identification code images triggering a failure state during localization or decoding processing. Therefore, this application utilizes a pre-trained identifier detection model to perform identifier localization processing on image data, obtaining candidate identifier images, and then performs decoding processing based on the candidate identifier images to obtain decoding results. When a candidate identifier image triggers a failure state during localization or decoding processing, the image data and its corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model. This enables the identifier detection model to continuously learn from difficult samples encountered in the actual detection process, thereby effectively coping with interference caused by factors such as differences in marking processes, changes in material surfaces, fluctuations in lighting conditions, and dirt and wear in industrial settings, and improving the adaptability of the identifier detection model for identifier detection.
[0038] Please see Figure 2 In some embodiments, step S104 may include, but is not limited to, steps S201 to S203: Step S201: Construct synthetic training samples based on the training images with the identifier code; wherein each synthetic training sample is configured with a corresponding pixel-level ground truth label; Step S202: Add the synthetic training samples to the preset model training set for sample augmentation to obtain the augmented training set. Step S203: Optimize the identifier detection model based on the expanded training set to obtain the optimized identifier detection model.
[0039] In step S201 of some embodiments, synthetic training samples are constructed based on the identification code training images, and each synthetic training sample is configured with a corresponding pixel-level ground truth label.
[0040] The identification code training images are derived from samples that failed during localization or decoding processes, and their degradation features reflect complex interference patterns in real industrial scenarios. Synthetic training samples refer to data units that have undergone normalization and have a clear input-output correspondence. Their construction process involves preprocessing operations such as cropping, scale normalization, and format conversion of the original images.
[0041] Pixel-level ground truth labels refer to the annotation information that corresponds to each synthetic training sample at the pixel level. They are used to mark the precise boundaries between the identifier region and the background region, providing pixel-level supervision signals for the training of segmentation or detection models. By configuring pixel-level ground truth labels for each synthetic training sample, the annotation accuracy of the training data is ensured, enabling the model to learn the subtle differences between the identifier structure and the background, thereby improving the accuracy of identifier region localization.
[0042] By converting the returned failure samples into a standardized data format that can be directly used for supervised model training, the probability of failure in similar degradation scenarios is reduced in subsequent detection tasks, thus forming a closed-loop technology for continuous model performance evolution.
[0043] In step S202 of some embodiments, synthetic training samples are added to a preset model training set for sample augmentation to obtain an expanded training set. The design concept of this step is to overcome the problems of limited number of real failure samples and long collection cycle, and to achieve rapid expansion of the training set size through batch injection of synthetic data.
[0044] The pre-defined model training set refers to the benchmark dataset used by the code detection model during the pre-training or initial training phase. Its sample distribution typically covers standard code types under common imaging conditions. Sample augmentation can fuse and recombine newly constructed synthetic training samples with the original training samples, forming an augmented training set with more diverse sample types and more comprehensive coverage of degradation features. This increases the absolute amount of training data and introduces novel degradation modes missing from the original training set, enabling model training to be optimized for data spaces that more closely resemble actual industrial distributions.
[0045] In step S203 of some embodiments, the identifier detection model is optimized based on the expanded training set to obtain an optimized identifier detection model. The optimization process typically employs gradient descent algorithms, calculating the difference loss between the model's predicted output and the pixel-level ground truth labels, and then backpropagating to update the network weight parameters. The optimized identifier detection model inherits the basic recognition capabilities of the original model while enhancing its ability to discriminate degradation patterns represented by failed return samples. The identifier detection model can be redeployed into automated optical inspection equipment to replace or upgrade the pre-trained identifier detection model, thereby reducing the probability of failure triggering under similar degradation scenarios in subsequent detection tasks, forming a closed-loop technology for continuous model performance evolution.
[0046] Please see Figure 3 In some embodiments, step S201 may include, but is not limited to, steps S301 to S305: Step S301: Obtain the identification code training image and obtain structural template images of different identification code types; Step S302: Perform structural constraint feature extraction processing on the structural template image to obtain a geometric constraint feature matrix; wherein, the geometric constraint feature matrix represents the geometric layout structure information of the identifier code; Step S303: Perform appearance feature extraction processing on the identification code training image to obtain the appearance style feature matrix; wherein, the appearance style feature matrix represents the surface texture information of the identification code training image. Step S304: Input the geometric constraint feature matrix and the appearance style feature matrix into the pre-trained identifier code generation model to obtain multiple identifier code synthesized images; Step S305: Use the geometric constraint feature matrix as the pixel-level ground truth label of the synthesized image to obtain the synthesized training sample.
[0047] In step S301 of some embodiments, a training image for the identification code is acquired, along with structural template images of various identification code types. The training image originates from reflowed failed samples and carries degraded appearance information from real industrial environments, including complex degradation features such as reflection, dirt, wear, corrosion, low contrast, blurred edges, uneven printing, uneven marking, oil film coverage, and material texture interference. The structural template image refers to a clean identification code image that is unaffected by degradation and conforms to the encoding protocol specifications. Its geometric layout is clear and complete, providing a precise structural constraint benchmark for synthesis. "Various identification code types" means that the structural template images cover different encoding systems such as barcodes, fast response codes, and data matrix codes, or variations of the same encoding system with different code values, sizes, and row / column layouts. By introducing diverse structural templates, it is possible to generate synthetic samples with different structures but consistent appearance styles in batches while maintaining the degraded appearance features of a single sample, thereby significantly improving the structural coverage and diversity of the training data.
[0048] In step S302 of some embodiments, structural constraint feature extraction processing is performed on the structural template image to obtain a geometric constraint feature matrix. Multi-scale feature extraction is performed on the input structural template image based on a deep convolutional network to capture key geometric attributes of the identification code, such as module boundaries, stripe arrangement, dot matrix distribution, positioning patterns, and row and column structures. The geometric constraint feature matrix, as the output of the structural constraint feature extraction processing, is a tensor representation of structural information in the feature space, with each dimension corresponding to a specific level of spatial structural attributes. The geometric constraint feature matrix refers to the binarized or semantic spatial mask data derived from the structural template image. It marks the relationship between the identification code region and the background region with pixel-level precision, directly representing the geometric layout structural information of the identification code. The geometric constraint feature matrix can serve as one of the input sources for structural constraint feature extraction processing, and also as a source of pixel-level ground truth labels for the synthesized image in subsequent steps, playing a dual role as both a structural benchmark and a labeling benchmark in data flow.
[0049] In step S303 of some embodiments, appearance feature extraction processing is performed on the identification code training image to obtain an appearance style feature matrix. The identification code training image is mapped to a high-dimensional feature space using an image encoder, and then the features are statistically aggregated and style decoupled using a style resampling device or a decoupled cross-attention mechanism to extract low-level appearance statistics representing surface texture information. The appearance style feature matrix, as the output of the appearance feature extraction processing, encodes surface texture information such as material texture, color distribution, lighting conditions, reflective areas, dirt morphology, wear degree, corrosion features, and edge degradation patterns of the identification code training image, but does not include the geometric layout structure information of the identification code.
[0050] In step S304 of some embodiments, the geometric constraint feature matrix and the appearance style feature matrix are input into a pre-trained identifier generation model. While maintaining the geometric layout structure information corresponding to the geometric constraint feature matrix, the surface texture degradation information corresponding to the appearance style feature matrix is transferred to the geometric layout structure represented by the geometric constraint feature matrix, resulting in multiple synthesized identifier images. The design concept of this step is to achieve decoupling control between structure preservation and appearance transfer, enabling the synthesized image to simultaneously possess the geometric structure information and appearance style information represented by the geometric constraint feature matrix and the appearance style feature matrix.
[0051] In step S305 of some embodiments, the geometric constraint feature matrix is used as the pixel-level ground truth label of the synthesized identification code image to obtain the synthesized training sample. By keeping the geometric layout structure information corresponding to the geometric constraint feature matrix unchanged, the generated output synthesized identification code image is completely consistent with the input geometric constraint feature matrix in terms of geometric attributes such as coding structure, module boundaries, and dot matrix distribution. Therefore, the geometric constraint feature matrix can be directly reused as the pixel-level ground truth label of the synthesized identification code image without any modification or reprocessing. Finally, the synthesized identification code image and its corresponding geometric constraint feature matrix together form a complete synthesized training sample. The synthesized training sample can be directly entered into the supervised training process of the identification code detection model without additional manual annotation.
[0052] Please see Figure 4 In some embodiments, steps S401 to S405 may be included, but are not limited to, before step S304: Step S401: Obtain the model training set and the original identifier code generation model; wherein, the model training set includes multiple identifier code samples, and the identifier code generation model is configured with a structure control module and an appearance feature control module. Step S402: Input the identification code sample into the original identification code generation model, extract the geometric constraint feature matrix of the identification code sample based on the structure control module, and extract the appearance style feature matrix of the identification code sample based on the appearance feature control module. Step S403: Based on the extracted geometric constraint feature matrix and appearance style feature matrix, control the identification code generation model to generate identification codes, and obtain the sample synthetic image; Step S404: Compare the visual features of the synthesized image and the identification code sample to obtain the difference data; Step S405: Update and iterate the model parameters of the identifier generation model based on the difference data until the preset training stopping condition is met.
[0053] In step S401 of some embodiments, a model training set and an original identifier code generation model are obtained. The model training set includes multiple identifier code samples, which are typically composed of clean identifier code structure templates paired with real degraded identifier code images. These samples cover identifier code instances under different encoding standards, degradation types, and imaging conditions, and are used to support the generative model in learning the joint mapping relationship between structure preservation and appearance transfer. The original identifier code generation model refers to a basic generative network that has not been specifically optimized for industrial identifier code scenarios, and is configured with a structure control module and an appearance feature control module. The structure control module is responsible for extracting and encoding geometric layout structure information from the input conditions, while the appearance feature control module is responsible for extracting and encoding surface texture degradation information from the reference image. Both modules work together to modulate the latent space features of the basic generative backbone, providing the network foundation for the generation control that achieves decoupling of structure and appearance in subsequent steps.
[0054] In step S402 of some embodiments, the identifier sample is input into the original identifier generation model. The geometric constraint feature matrix of the identifier sample is extracted based on the structure control module, and the appearance style feature matrix of the identifier sample is extracted based on the appearance feature control module. The identifier sample serves as the common input to both branches, simultaneously inputting to the structure control module and the appearance feature control module. The structure control module can progressively abstract a high-level feature map representing the geometric layout structure information by performing multi-scale convolutional encoding and spatial downsampling on the identifier sample. This high-level feature map is then processed through channel compression and spatial aggregation to obtain the geometric constraint feature matrix.
[0055] The appearance feature control module extracts stylized statistics representing surface texture information by globally pooling and statistically aggregating the identification code samples. These statistics are then used for feature mapping and dimensional transformation to obtain the appearance style feature matrix. The two feature matrices are semantically orthogonal and spatially independent, ensuring that there is no crosstalk between structure control and appearance injection during the generation process.
[0056] In step S403 of some embodiments, the identifier generation model is controlled to generate identifiers based on the extracted geometric constraint feature matrix and appearance style feature matrix, resulting in a sample synthesized image. The appearance style feature matrix modulates the intermediate layer feature statistics of the basic generation backbone through adaptive normalization or cross-attention mechanisms, making the generated image visually approximate the degraded appearance of the original identifier sample. The sample synthesized image is the image generated by the identifier generation model from the input identifier sample under the current parameter state.
[0057] In step S404 of some embodiments, visual feature comparison is performed between the synthesized sample image and the identification code sample to obtain difference data. Visual feature comparison typically involves multi-scale comparison, calculating point-by-point differences between the synthesized sample image and the identification code sample at the pixel level, evaluating the degree of preservation of geometric layout structural information at the structural level, and statistically analyzing the transfer accuracy of surface texture information at the appearance level. The difference data, as the comprehensive output of visual feature comparison, is a weighted aggregation result of the above-mentioned multi-dimensional differences. Its numerical magnitude characterizes the degree of deviation between the generated result and the target expectation under the current model parameters, providing a clear optimization direction and gradient signal for subsequent parameter updates.
[0058] In step S405 of some embodiments, the model parameters of the identifier code generation model are updated iteratively based on the difference data until a preset training stopping condition is met. The update range of the model parameters is usually limited to the relevant parameters of the structure control module and the appearance feature control module. The update iteration refers to adjusting the network weights round by round according to a preset optimization algorithm. Each round of iteration includes four sub-steps: forward inference, loss calculation, backpropagation, and parameter update. The preset training stopping condition refers to the termination criteria for determining whether the training process has converged. It usually includes the number of iteration rounds reaching a preset upper limit, the difference data falling below a preset threshold, the validation set performance not improving for several consecutive rounds, or the parameter update magnitude being less than a preset tolerance. When the preset training stopping condition is met, the training process terminates, and the optimized identifier code generation model is obtained.
[0059] Please see Figure 5 In some embodiments, step S304 may include, but is not limited to, steps S501 to S502: Step S501: Keep the geometric constraint feature matrix unchanged, perform perturbation processing based on the appearance style feature matrix, and generate a composite image of multiple appearance styles corresponding to the same geometric constraint feature matrix; Step S502: Apply the appearance style feature matrix to multiple geometric constraint feature matrices to generate a composite image of identification codes with multiple structures for the appearance style feature matrix.
[0060] In step S501 of some embodiments, when generating the identifier code composite image, the geometric constraint feature matrix can be kept unchanged, and perturbation processing can be performed based on the appearance style feature matrix to generate identifier code composite images with multiple appearance styles corresponding to the same geometric constraint feature matrix.
[0061] The design concept of this step is to expand the appearance diversity under the condition of a single sample structure by randomly exploring and controlling the appearance space, thereby significantly improving the appearance coverage and distribution richness of the training data without increasing the cost of structural template collection.
[0062] The invariance of the geometric constraint feature matrix indicates that the input conditions of the structural control branches are fixed, ensuring that all generated outputs share a completely consistent coding structure, geometric layout, module boundaries, stripe arrangement, or dot matrix distribution, making structural consistency a rigid constraint for batch generation. The perturbation processing of the appearance style feature matrix refers to introducing controllable random noise, feature interpolation, or statistical shifts, etc., based on the original appearance feature representation. This allows the perturbed appearance feature matrix to produce subtle or significant appearance variations while maintaining a similar statistical distribution to the original degraded appearance. These appearance variations can manifest as local differences in dirt morphology, continuous changes in wear degree, random displacement of reflective areas, and redistribution of texture particles, thereby simulating the random manifestation of the same degradation type on different product individuals in an industrial setting.
[0063] Multi-style identifier code composite images refer to multiple composite identifier code images generated in batches through inference by an identifier code generation model, based on a combination of the same geometric constraint feature matrix and multiple perturbated appearance style feature matrices. Each composite identifier code image has the same identifier code structure but different degenerate appearances, and can be directly used as a training sample set with consistent structure and diverse appearances to enhance the adaptability of downstream identifier code detection models to the range of appearance variations under specific structural types.
[0064] In step S502 of some embodiments, when generating the identifier code composite image, the appearance style feature matrix can be applied to a variety of geometric constraint feature matrices to generate identifier code composite images with various structures for the appearance style feature matrix.
[0065] The design concept of this step is to expand the structural diversity under the condition of a single degenerate appearance by combining and traversing the structural space, thereby covering a wider range of identifier coding types and geometric variations.
[0066] The geometric constraint feature matrix can originate from different structural template images. These structural template images can belong to different code values, different sizes, or different error correction levels under the same identification code encoding system, or they can belong to completely different encoding systems such as barcodes, fast response codes, and data matrix codes. Each geometric constraint feature matrix independently represents the geometric layout structure information of the corresponding structural template, including encoding-specific attributes such as the number of module rows and columns, stripe width ratio, and positioning pattern position.
[0067] The application of appearance style feature matrices to multiple geometric constraint feature matrices refers to using the same appearance style feature matrix as a shared appearance condition, paired with different geometric constraint feature matrices as input to the identifier code generation model. During generation, the appearance feature control module inputs uniform appearance degradation characteristics, while the structure control branch applies differentiated geometric layout constraints, ensuring that each output identifier code composite image possesses the same degradation appearance style but with differentiated identifier code structures. The identifier code detection model can learn specific degradation appearance patterns while encountering rich structural variations, thereby avoiding overfitting to samples of a single structural type and improving the generalization detection capability for multi-variety and multi-specification industrial identifier codes.
[0068] Please see Figure 6 In some embodiments, step S501 may include, but is not limited to, steps S601 to S602: Step S601: Obtain preset physical degradation control parameters; wherein, the physical degradation control parameters include at least one of the following: wear ratio of the composite image of the identification code, light reflection intensity, oil stain coverage area, or image blur kernel size; Step S602: Generate style control guidance vectors based on physical degradation control parameters, and input the degradation control guidance vectors into the identifier code generation model to obtain multiple identifier code composite images, so as to realize continuous gradient adjustment of the degradation severity of the identifier code composite image.
[0069] In step S601 of some embodiments, preset physical degradation control parameters are obtained. The design concept of this step is to establish a mapping bridge between abstract appearance features and interpretable physical quantities, so that the degradation degree of the identifier code synthesized image can have the characteristics of being quantifiable, adjustable, and reproducible, thereby meeting the needs of fine division of degradation gradient of training data in industrial inspection scenarios.
[0070] Physical degradation control parameters refer to numerical control variables that characterize the degradation attributes of the synthesized image of the identification code in the form of physical dimensions or engineering indicators. Their value range and variation law directly correspond to the degradation evolution process in real industrial scenarios. Wear ratio refers to the relative degree of edge damage and area reduction of the identification code surface due to mechanical friction or chemical corrosion, expressed as a percentage or normalized decimal. Illumination reflectivity refers to the peak brightness or energy ratio of the highlight area formed on the identification code surface due to the angle of illumination of the light source or the reflective properties of the material. Oil stain coverage area refers to the absolute area or relative area ratio of the identification code area that is covered by oil film, dust or other contaminants. Image blur kernel size refers to the spatial scale of the point spread function caused by camera defocus, motion jitter or optical aberration, measured in pixels or standard deviation.
[0071] The aforementioned physical degradation control parameters can be configured individually or in combination. By adjusting the values of each parameter, the type and severity level of degradation can be precisely controlled during the synthesis and generation process.
[0072] In step S602 of some embodiments, a style control guidance vector is generated based on the physical degradation control parameters, and the style control guidance vector is input into the identifier code generation model to obtain multiple identifier code synthesized images, thereby achieving continuous gradient adjustment of the degradation severity of the identifier code synthesized images. The design concept of this step is to convert discrete physical degradation control parameters into continuously differentiable style control guidance vectors, enabling the identifier code generation model to generate training sample sequences covering the entire spectrum from slight degradation to severe degradation.
[0073] The generation process of style control guidance vectors typically includes two sub-steps: parameter encoding and vector mapping. Parameter encoding converts the values of each physical degradation control parameter into a feature representation with the same or compatible dimensions as the appearance style feature matrix. Vector mapping, through linear transformation or nonlinear mapping, fuses or modulates the encoded parameter features with the original appearance style feature matrix to form a guidance vector explicitly constrained by the physical degradation control parameters. Inputting the style control guidance vector into the identifier code generation model refers to inputting the guidance vector and the appearance style feature matrix together into the basic generation backbone through the extended interface or additional condition channel of the appearance feature control module. This allows the generation process to be simultaneously constrained by both the global statistical characteristics of the original appearance style and the local fine-tuning of the physical degradation control parameters. Multiple identifier code composite images refer to multiple identifier code composite images generated in batches based on the same geometric constraint feature matrix, the same appearance style feature matrix, and a series of continuously changing style control guidance vectors.
[0074] By traversing the range of physical degradation control parameters, the synthesized image of the identifier code exhibits a continuous gradient distribution in terms of degradation severity. The degradation differences between adjacent samples are subtle and controllable, enabling the downstream identifier code detection model to learn robust discrimination capabilities against gradual changes in degradation severity, rather than simply classifying discrete degradation types. Continuous gradient adjustment refers to the gradual change of the physical degradation control parameters within a preset range at a fixed or adaptive step size, resulting in a smooth transition of degradation attributes in the corresponding generated sample sequence. This adjustment method allows the training data to have adjustable sampling coverage in the degradation dimension, effectively supporting the model's accurate identification and stable detection of critical degradation states.
[0075] Please see Figure 7 In some embodiments, the industrial identification code to be detected includes a one-dimensional barcode, a two-dimensional barcode, or a data matrix code. Embodiments of this application may also include, but are not limited to, steps S701 to S702: Step S701: When the industrial identification code to be detected is a one-dimensional barcode, the geometric layout structure information corresponding to the structural template image is used to characterize the stripe arrangement, stripe width and stripe spacing. Step S702: When the industrial identification code to be detected is a QR code or a data matrix code, the geometric layout structure information corresponding to the structural template image is used to characterize the module boundary, positioning pattern and dot matrix distribution.
[0076] In step S701 of some embodiments, when the industrial identification code to be detected is a one-dimensional barcode, the geometric layout structure information corresponding to the structural template image is used to characterize the stripe arrangement, stripe width, and stripe spacing. To address the encoding specificity of one-dimensional barcodes, a geometric constraint characterization system matching its one-dimensional spatial structure is established to ensure that the structural control module can accurately capture and forcibly maintain the linear encoding characteristics of the one-dimensional barcode. As an identification code format extending along a single spatial dimension, the information carrying method of a one-dimensional barcode relies on the alternating arrangement of black bars and white spaces of different widths in the horizontal direction. Stripe arrangement refers to the sequence order of black bars and white spaces along the scanning direction, which directly corresponds to the binary mapping relationship of the encoded characters. Stripe width refers to the physical size of a single black bar or white space perpendicular to the scanning direction, and its proportional relationship follows the modulation specifications of a specific encoding protocol. Stripe spacing refers to the boundary spacing or equivalent module spacing between adjacent stripes, and its uniformity affects clock synchronization and decoding error tolerance during scanning and reading. The geometric layout information corresponding to the structural template image is extracted and encoded by the structural control module, which converts the above one-dimensional spatial attributes into the corresponding dimensions in the geometric constraint feature matrix. This ensures that the identifier generation model strictly maintains the correct sequence of stripe arrangement, the standard ratio of stripe width, and the uniform distribution of stripe intervals when synthesizing output, thereby ensuring that the synthesized training samples have decodeability and labeling reliability at the encoding level.
[0077] In step S702 of some embodiments, when the industrial identification code to be detected is a QR code or a data matrix code, the geometric layout structure information corresponding to the structural template image is used to characterize the module boundary, positioning pattern, and dot matrix distribution. The design concept of this step is to establish a geometric constraint representation system that matches the two-dimensional spatial structure of the QR code, addressing the encoding specificity of the two-dimensional matrix identification code. This enables the structural control module to accurately capture and forcibly maintain the matrix encoding features and image-finding mechanism of the two-dimensional identification code. As identification code formats distributed on a two-dimensional plane, QR codes and data matrix codes rely on a matrix pattern composed of regularly arranged dark and light modules to carry information. Module boundaries refer to the boundary contours between adjacent coding units, and their clarity directly affects the accuracy of module recognition and binarization segmentation. Positioning patterns refer to image-finding patterns or clock patterns embedded in specific locations within the code area, such as the three corner position detection patterns of a fast response code or the combination of solid and dashed edges of a data matrix code. Their spatial position and geometric shape are key bases for the decoder to identify the orientation and coordinate system of the code area. The dot matrix distribution refers to the row and column arrangement of the coding modules on a two-dimensional plane, including the total number of modules, the number of rows and columns, the interval pattern, and the relative positional relationship with the positioning pattern. Its regularity determines the foundation for the realization of coding capacity and error correction capability. The geometric layout structure information corresponding to the structural template image is extracted and spatially encoded by the multi-scale feature extraction of the structural control module, converting the above two-dimensional spatial attributes into the corresponding dimensions in the geometric constraint feature matrix. This ensures that the identifier code generation model strictly maintains the clear closure of module boundaries, the standard shape of the positioning pattern, and the regular array of dot matrix distribution during the synthesized output, thereby ensuring that the synthesized training samples have standard compatibility and annotation accuracy at the coding level.
[0078] Please see Figure 8 This application also provides an identification code detection device that can implement the above-described identification code detection method. The device includes: The image acquisition module is used to acquire images of the device to be inspected and obtain image data containing the identification code. The identifier code localization module is used to perform identifier code localization processing on image data using a pre-trained identifier code detection model to obtain candidate identifier code images; The identifier code decoding module is used to perform decoding processing based on the candidate identifier code image to obtain the decoding result; The update and optimization module is used to optimize the identification code detection model in response to the failure state triggered by the candidate identification code image in the localization or decoding process, by using the image data and the corresponding candidate identification code image as the identification code training image.
[0079] The specific implementation of the identification code detection device is basically the same as the specific implementation of the identification code detection method described above, and will not be repeated here.
[0080] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described identification code detection method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0081] Please see Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes: The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 902 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 902 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 using the identifier code detection method of the embodiments of this application. The input / output interface 903 is used to implement information input and output; The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904); The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.
[0082] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described identification code detection method.
[0083] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0084] The identification code detection method, apparatus, electronic device, and storage medium provided in this application embodiment acquire image data containing identification codes by acquiring images of the device to be detected; perform identification code localization processing on the image data using a pre-trained identification code detection model to obtain candidate identification code images; perform decoding processing on the candidate identification code images to obtain decoding results; and, in response to the candidate identification code image triggering a failure state in the localization or decoding processing, use the image data and the corresponding candidate identification code image as identification code training images to optimize the identification code detection model. Therefore, this application utilizes a pre-trained identifier detection model to perform identifier localization processing on image data, obtaining candidate identifier images, and then performs decoding processing based on the candidate identifier images to obtain decoding results. When a candidate identifier image triggers a failure state during localization or decoding processing, the image data and its corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model. This enables the identifier detection model to continuously learn from difficult samples encountered in the actual detection process, thereby effectively coping with interference caused by factors such as differences in marking processes, changes in material surfaces, fluctuations in lighting conditions, and dirt and wear in industrial settings, and improving the adaptability of the identifier detection model for identifier detection.
[0085] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0086] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0087] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0088] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0089] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0090] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0091] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. The coupling or direct coupling or communication connection between the shown or discussed units may be through some interfaces, or indirect coupling or communication connection between the apparatus or units, and may be electrical, mechanical, or other forms.
[0092] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0093] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0094] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0095] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method for detecting identification codes, characterized in that, The method includes: The device to be tested is subjected to image acquisition to obtain image data containing the identification code; The image data is processed by a pre-trained identifier detection model to locate the identifier, thereby obtaining candidate identifier images. The candidate identifier image is then decoded to obtain the decoding result; In response to the failure state triggered by the candidate identifier image in the positioning or decoding process, the image data and the corresponding candidate identifier image are used as identifier training images to optimize the identifier detection model; The step of using the image data and the corresponding candidate identifier image as identifier training images to optimize the identifier detection model includes: constructing synthetic training samples based on the identifier training images; wherein each synthetic training sample is configured with a corresponding pixel-level ground truth label. The step of constructing synthetic training samples based on the identification code training images includes: acquiring identification code training images and acquiring structural template images of various identification code types; performing structural constraint feature extraction processing on the structural template images to obtain a geometric constraint feature matrix; wherein the geometric constraint feature matrix represents the geometric layout structure information of the identification code; performing appearance feature extraction processing on the identification code training images to obtain an appearance style feature matrix; wherein the appearance style feature matrix represents the surface texture information of the identification code training images; inputting the geometric constraint feature matrix and the appearance style feature matrix into a pre-trained identification code generation model to obtain multiple synthetic identification code images; and using the geometric constraint feature matrix as the pixel-level ground truth label of the synthetic identification code images to obtain synthetic training samples. The step of inputting the geometric constraint feature matrix and the appearance style feature matrix into a pre-trained identifier generation model includes: keeping the geometric constraint feature matrix unchanged, performing perturbation processing based on the appearance style feature matrix to generate a composite identifier image with multiple appearance styles corresponding to the same geometric constraint feature matrix; and applying the appearance style feature matrix to multiple geometric constraint feature matrices to generate a composite identifier image with multiple structures for the appearance style feature matrix. The step of perturbation processing based on the appearance style feature matrix to generate composite images of multiple appearance styles corresponding to the same geometric constraint feature matrix includes: obtaining preset physical degradation control parameters; wherein, the physical degradation control parameters include at least one of the following: wear ratio, light reflection intensity, oil stain coverage area, or image blur kernel size of the composite image of the identification code; generating a style control guidance vector based on the physical degradation control parameters, and inputting the style control guidance vector into the identification code generation model to obtain multiple composite images of the identification code, so as to achieve continuous gradient adjustment of the degradation severity of the composite image of the identification code.
2. The method according to claim 1, characterized in that, The step of using the image data and the corresponding candidate identifier image as identifier training images to optimize the identifier detection model includes: The synthetic training samples are added to a preset model training set for sample augmentation to obtain an augmented training set. The identification code detection model is optimized based on the expanded training set to obtain the optimized identification code detection model.
3. The method according to claim 1, characterized in that, Before inputting the geometric constraint feature matrix and the appearance style feature matrix into the pre-trained identifier generation model, the method includes pre-training the identifier generation model, including: Obtain a model training set and an original identifier code generation model; wherein the model training set includes multiple identifier code samples, and the identifier code generation model is configured with a structure control module and an appearance feature control module; The identification code sample is input into the original identification code generation model, the geometric constraint feature matrix of the identification code sample is extracted based on the structure control module, and the appearance style feature matrix of the identification code sample is extracted based on the appearance feature control module. Based on the extracted geometric constraint feature matrix and appearance style feature matrix, the identification code generation model is controlled to generate identification codes, resulting in a sample synthetic image; Visual feature comparison is performed between the synthesized image from the sample and the identification code sample to obtain difference data; The model parameters of the identifier generation model are updated and iterated based on the difference data until the preset training stopping condition is met.
4. The method according to claim 1, characterized in that, The identification code includes a one-dimensional barcode, a two-dimensional barcode, or a data matrix code, and the method further includes: When the identification code is a one-dimensional barcode, the geometric layout structure information corresponding to the structural template image is used to characterize the stripe arrangement, stripe width, and stripe spacing; When the identification code is a QR code or a data matrix code, the geometric layout structure information corresponding to the structural template image is used to characterize the module boundary, positioning pattern and dot matrix distribution.
5. An identification code detection device, characterized in that, The device includes: The image acquisition module is used to acquire images of the device to be inspected and obtain image data containing the identification code. The identifier code localization module is used to perform identifier code localization processing on the image data using a pre-trained identifier code detection model to obtain candidate identifier code images; The identifier code decoding module is used to perform decoding processing based on the candidate identifier code image to obtain the decoding result; An update and optimization module is used to optimize the identification code detection model in response to a failure state triggered by the candidate identification code image during localization or decoding. This optimization uses the image data and the corresponding candidate identification code image as identification code training images. Specifically, optimizing the identification code detection model by using the image data and the corresponding candidate identification code image as identification code training images includes constructing synthetic training samples based on the identification code training images. Each synthetic training sample is configured with a corresponding pixel-level ground truth label. The step of constructing synthetic training samples based on the identification code training images includes: acquiring identification code training images and acquiring structural template images of various identification code types; performing structural constraint feature extraction processing on the structural template images to obtain a geometric constraint feature matrix; wherein the geometric constraint feature matrix represents the geometric layout structure information of the identification code; performing appearance feature extraction processing on the identification code training images to obtain an appearance style feature matrix; wherein the appearance style feature matrix represents the surface texture information of the identification code training images; inputting the geometric constraint feature matrix and the appearance style feature matrix into a pre-trained identification code generation model to obtain multiple synthetic identification code images; and using the geometric constraint feature matrix as the pixel-level ground truth label of the synthetic identification code images to obtain synthetic training samples. The step of inputting the geometric constraint feature matrix and the appearance style feature matrix into a pre-trained identifier generation model includes: keeping the geometric constraint feature matrix unchanged, performing perturbation processing based on the appearance style feature matrix to generate a composite identifier image with multiple appearance styles corresponding to the same geometric constraint feature matrix; and applying the appearance style feature matrix to multiple geometric constraint feature matrices to generate a composite identifier image with multiple structures for the appearance style feature matrix. The step of perturbation processing based on the appearance style feature matrix to generate composite images of multiple appearance styles corresponding to the same geometric constraint feature matrix includes: obtaining preset physical degradation control parameters; wherein, the physical degradation control parameters include at least one of the following: wear ratio, light reflection intensity, oil stain coverage area, or image blur kernel size of the composite image of the identification code; generating a style control guidance vector based on the physical degradation control parameters, and inputting the style control guidance vector into the identification code generation model to obtain multiple composite images of the identification code, so as to achieve continuous gradient adjustment of the degradation severity of the composite image of the identification code.
6. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the identification code detection method according to any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the identification code detection method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Information processing method, electronic equipment and information processing system
CN110969037A
Two-dimensional code recognition unlocking method suitable for entrance machine and related equipment
CN119251939A