Search

CN-121981964-A - Two-dimensional code position degree detection method, electronic equipment, storage medium and product

CN121981964ACN 121981964 ACN121981964 ACN 121981964ACN-121981964-A

Abstract

The application discloses a two-dimensional code position degree detection method, electronic equipment, a storage medium and a product, and relates to the technical field of image processing, wherein the method comprises the steps of obtaining a product image of a product to be detected, and determining a product template matched with the product image; detecting whether an initial two-dimensional code region representing a two-dimensional code in a product image is located in a reference ROI region of a product template and is not overlapped with a boundary of the reference ROI region, wherein the reference ROI region is an image region representing a code printing region, if the initial two-dimensional code region is located in the reference ROI region and is not overlapped with the boundary, determining a target region in the product image according to a preset pixel dynamic threshold value and a preset closed operation model, wherein the target region comprises an actual code printing region and/or an actual two-dimensional code region, and determining a two-dimensional code position detection result of a product to be detected according to the target region. The method and the device improve the accuracy of the position detection of the two-dimensional code.

Inventors

  • SUN CHUANLU
  • WANG XINFU

Assignees

  • 歌尔股份有限公司

Dates

Publication Date
20260505
Application Date
20251229

Claims (10)

  1. 1. The two-dimensional code position degree detection method is characterized by comprising the following steps of: Acquiring a product image of a product to be detected, and determining a product template matched with the product image; detecting whether an initial two-dimensional code region representing a two-dimensional code in the product image is located in a reference ROI region of the product template and does not overlap with a boundary of the reference ROI region, wherein the reference ROI region is an image region representing a code printing region; if the initial two-dimensional code region is positioned in the reference ROI region and is not overlapped with the side line, determining a target region in the product image according to a preset pixel dynamic threshold value and a preset closed operation model, wherein the target region comprises an actual code printing region and/or an actual two-dimensional code region; and determining a two-dimensional code position degree detection result of the product to be detected according to the target area.
  2. 2. The method for detecting the position of a two-dimensional code according to claim 1, wherein the step of determining the target area in the product image according to a preset pixel dynamic threshold and a preset closed operation model comprises the steps of: Determining pixel parameters of each pixel in the product image, and determining a first image area representing a coding area and/or a second image area representing a two-dimensional code area in the product image according to the pixel parameters and a preset pixel dynamic threshold; And performing closed operation processing on the first image area by using a preset closed operation model to obtain an actual code printing area, and/or performing closed operation processing on the second image area by using the preset closed operation model to obtain an actual two-dimensional code area.
  3. 3. The method for detecting the position of the two-dimensional code according to claim 2, wherein the step of determining the first image area representing the code printing area and/or the second image area representing the two-dimensional code area in the product image according to the pixel parameter and a preset pixel dynamic threshold value comprises the following steps: For each pixel in the product image, determining pixel parameter difference information between a pixel parameter of the pixel and a pixel parameter of a neighboring pixel of the pixel; if the pixel parameter difference information is larger than a preset pixel dynamic threshold value, determining the pixel as a target pixel; Determining a third image area containing all the target pixels in the product image, and filling morphological holes in the third image area to obtain a fourth image area, wherein the fourth image area is a first image area if the preset pixel dynamic threshold is a pixel dynamic threshold corresponding to the coding area, and is a second image area if the preset pixel dynamic threshold is a pixel dynamic threshold corresponding to the two-dimensional code area.
  4. 4. The method for detecting the position of the two-dimensional code according to claim 2, wherein the step of performing a closed operation process on the first image area by using a preset closed operation model to obtain an actual code printing area comprises the following steps: performing a closing operation on a product image containing the first image area by using a preset closing operation model to obtain a fifth image area in the product image, and detecting whether transformation information exists between the fifth image area and the first image area; If the transformation information exists, determining whether convexity corresponding to the fifth image area meets a preset convexity condition, wherein the preset convexity condition comprises that the convexity reaches a preset maximum value or the convexity shows a descending trend; and if so, taking the fifth image area as an actual coding area.
  5. 5. The two-dimensional code position degree detection method according to claim 4, wherein after the step of detecting whether there is transformation information between the fifth image area and the first image area, comprising: if the transformation information does not exist, carrying out parameter updating on the closed operation model, and carrying out closed operation on the product image containing the fifth image area by utilizing the closed operation model with the parameter updating to obtain a sixth image area in the product image; Detecting whether the convexity corresponding to the sixth image area meets a preset convexity condition; If the convexity corresponding to the sixth image area does not meet the preset convexity condition, carrying out parameter updating on the closed operation model updated by the parameters again; And executing the step of performing a closing operation on the product image including the fifth image area by using the closing operation model updated by the parameters according to the closing operation model updated by the parameters and the sixth image area until the convexity corresponding to the latest obtained image area meets the preset convexity condition, and taking the latest obtained image area as an actual coding area.
  6. 6. The two-dimensional code position degree detection method according to any one of claims 1 to 5, wherein the step of detecting whether an initial two-dimensional code region representing a two-dimensional code in the product image is located within a reference ROI region of the product template and does not overlap with a boundary of the reference ROI region includes: determining a reference ROI (region of interest) of the product template, wherein the reference ROI is a closed region formed by connecting central lines of rectangular regions at a plurality of different positions in the product template; Mapping the initial two-dimensional code region and the reference ROI region to the same coordinate system, and determining whether the center coordinates of the initial two-dimensional code region are positioned in the reference ROI region or not in the same coordinate system, and whether boundary vertex coordinates overlapped with the side line of the reference ROI region exist in all boundary vertex coordinates of the initial two-dimensional code region or not; if the center coordinates are located in the reference ROI area in the same coordinate system and there is no boundary vertex coordinate overlapping with a border of the reference ROI area in the boundary vertex coordinates, determining that the initial two-dimensional code area is located in the reference ROI area and does not overlap with the border of the reference ROI area.
  7. 7. The method for detecting the position of the two-dimensional code according to any one of claims 1 to 5, wherein the step of determining the detection result of the position of the two-dimensional code of the product to be detected according to the target area comprises at least one of the following steps: Responding to the target area only comprising an actual code printing area, and if the initial two-dimensional code printing area is positioned in the actual code printing area and is not overlapped with the edge of the actual code printing area, determining that the two-dimensional code position detection result comprises that the product to be detected is a product qualified in two-dimensional code position detection; Responding to the target area only comprising an actual two-dimensional code area, and if the actual two-dimensional code area is positioned in the reference ROI area and is not overlapped with the side line of the reference ROI area, determining that the two-dimensional code position detection result comprises that the product to be detected is a product qualified in two-dimensional code position detection; Responding to the target area including an actual code printing area and an actual two-dimensional code printing area, and if the actual two-dimensional code printing area is located in the actual code printing area and is not overlapped with the edge of the actual code printing area, determining that the two-dimensional code position degree detection result includes that the product to be detected is a product with qualified two-dimensional code position degree detection.
  8. 8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the two-dimensional code location detection method according to any one of claims 1 to 7.
  9. 9. A storage medium, characterized in that the storage medium is a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the steps of the two-dimensional code position degree detection method according to any one of claims 1 to 7.
  10. 10. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, implements the steps of the two-dimensional code position detection method according to any one of claims 1 to 7.

Description

Two-dimensional code position degree detection method, electronic equipment, storage medium and product Technical Field The present application relates to the field of image processing technologies, and in particular, to a two-dimensional code position detection method, an electronic device, a storage medium, and a computer program product. Background Product equipment (such as injection molding (such as plastic housing and parts)) needs to realize full life cycle tracking through the two-dimensional code, ensures quality control and anti-counterfeiting, so that the position degree (namely the two-dimensional code position degree) of the two-dimensional code of product equipment (hereinafter referred to as product) in a code printing area is required to be effectively controlled, at present, most of the two-dimensional code is manually controlled and detected by combining an experienced user with a two-dimensional code detection machine to grasp the two-dimensional code and the code printing area so as to determine whether the two-dimensional code is positioned in the code printing area, but the mode has certain defects, such as the fact that when the product is more, the two-dimensional code position degree of all the products cannot be accurately and effectively identified due to the influence of manual experience, and further the accuracy of two-dimensional code position degree detection of the product is poor. Therefore, how to improve the accuracy of the two-dimensional code position detection becomes a current urgent problem to be solved. The foregoing is provided merely for the purpose of facilitating understanding of the technical solutions of the present application and is not intended to represent an admission that the foregoing is prior art. Disclosure of Invention The application mainly aims to provide a two-dimensional code position degree detection method, electronic equipment, a storage medium and a computer program product, and aims to solve the technical problem of how to improve the accuracy of two-dimensional code position degree detection. In order to achieve the above purpose, the present application provides a two-dimensional code position degree detection method, which comprises the following steps: Acquiring a product image of a product to be detected, and determining a product template matched with the product image; detecting whether an initial two-dimensional code region representing a two-dimensional code in a product image is positioned in a reference ROI region of a product template and is not overlapped with a boundary of the reference ROI region, wherein the reference ROI region is an image region representing a code printing region; if the initial two-dimensional code region is positioned in the reference ROI region and is not overlapped with the boundary, determining a target region in the product image according to a preset pixel dynamic threshold value and a preset closed operation model, wherein the target region comprises an actual code printing region and/or an actual two-dimensional code region; And determining a two-dimensional code position detection result of the product to be detected according to the target area. Optionally, the step of determining the target area in the product image according to the preset pixel dynamic threshold and the preset closed operation model includes: determining pixel parameters of each pixel in the product image, and determining a first image area representing a coding area and/or a second image area representing a two-dimensional code area in the product image according to the pixel parameters and a preset pixel dynamic threshold; and performing closed operation processing on the first image area by using a preset closed operation model to obtain an actual code printing area, and/or performing closed operation processing on the second image area by using the preset closed operation model to obtain an actual two-dimensional code area. Optionally, the step of determining a first image area representing the coding area and/or a second image area representing the two-dimensional code area in the product image according to the pixel parameter and the preset pixel dynamic threshold value includes: for each pixel in the product image, determining pixel parameter difference information between a pixel parameter of the pixel and a pixel parameter of a neighboring pixel of the pixel; If the pixel parameter difference information is larger than the preset pixel dynamic threshold value, determining the pixel as a target pixel; Determining a third image area containing all target pixels in the product image, and filling morphological holes in the third image area to obtain a fourth image area, wherein the fourth image area is the first image area if the preset pixel dynamic threshold is a pixel dynamic threshold corresponding to the coding area, and the fourth image area is the second image area if the preset pixel dynamic threshold is a pixel d