Bar code defect detection method based on image segmentation recognition

CN116739017BActive Publication Date: 2026-09-08SUZHOU SHIYIN INTELLIGENT SYST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310502889.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2022-12-23
Filing Date
2023-05-06
Publication Date
2026-09-08
Estimated Expiration
2043-05-06

AI Technical Summary

Technical Problem

[0003]多数条形码由专门的条码打印机打印而成,条形码质量受到打印机的影响,有时会出现缺点、污点、缺线等问题

Benefits of technology

[0011] Compared with existing technologies, the beneficial effects of this invention are as follows: In the barcode defect detection method based on image segmentation and recognition of this invention, the barcode is first decoded by acquiring an image. After successful decoding, the coordinate position of the barcode in the image is obtained. Then, the target area where the barcode is located is calculated based on the coordinate position. Next, the target area is divided into multiple sub-regions, and each sub-region is decoded and detected sequentially. If all sub-regions are successfully decoded, a "no defect found" result is returned. If some sub-regions fail to decode, a "defect detected" result is returned, along with the coordinates of the defective sub-regions. Using this method, defect detection of barcodes can be performed, and defective areas can be accurately located, facilitating the selection of defective barcodes for subsequent processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116739017B_ABST
    Figure CN116739017B_ABST
Patent Text Reader

Abstract

This invention provides a barcode defect detection method based on image segmentation and recognition. First, an image is acquired and the barcode is decoded. Upon successful decoding, the coordinates of the barcode in the image are obtained. Then, the target region where the barcode is located is calculated based on the coordinates. Next, the target region is divided into multiple sub-regions, and each sub-region is decoded and detected sequentially. If all sub-regions are successfully decoded, a "no defect found" result is returned. If one or more sub-regions fail to decode, a "defect detected" result is returned, along with the coordinates of the defective sub-region. This method enables defect detection of barcodes and precise location of defective regions, facilitating the selection of defective barcodes for subsequent processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data recognition technology, and in particular to a method for detecting barcode defects based on image segmentation and recognition. Background Technology

[0002] A barcode is a graphic identifier that uses multiple black bars and spaces of varying widths arranged according to certain encoding rules to express a set of information. Barcodes can identify various types of information corresponding to items and are widely used in many fields such as commodity circulation, library management, postal management, and banking systems.

[0003] Most barcodes are printed by specialized barcode printers. The quality of barcodes is affected by the printer itself, sometimes resulting in defects, stains, missing lines, and other problems. These defects affect barcode quality, increase the difficulty of barcode recognition, hinder the retrieval of item information, waste resources, and reduce work efficiency. For example, in the logistics industry, defective barcodes may prevent scanning and identification of logistics information during subsequent transportation, impacting the flow and transport of goods. Therefore, defect detection of barcodes is crucial. Summary of the Invention

[0004] The purpose of this invention is to address the shortcomings of existing technologies by proposing a barcode defect detection method based on image segmentation and recognition. After successful decoding, the target area where the barcode is located is segmented and identified, and the defective area of ​​the barcode is accurately located, so as to select the defective barcodes for subsequent processing.

[0005] To achieve the above objectives, the present invention adopts the following technical solution:

[0006] A method for detecting barcode defects based on image segmentation and recognition includes the following steps:

[0007] Step S1: Obtain the barcode image and attempt to decode the barcode in the image. If the decoding is successful, proceed to step S2. If the decoding fails, return the "detection failed" result.

[0008] Step S2: Obtain the coordinates of the barcode in the image {(x1,y1), (x2,y2), (x3,y3), (x4,y4)} based on the decoding result;

[0009] Step S3: Calculate the target area where the barcode is located based on the coordinates of the barcode in the image, and label the coordinates of the target area as (x0, y0, length, width);

[0010] Step S4: Segment the target region into There are three sub-regions, each with a length of length pixels and a width of n (n|n∈{1,…,width}) pixels, and the coordinates of each sub-region are (x0,y). i The expression is: (length, n), where n is a divisor of width. Decode and detect each sub-region sequentially; if a sub-region is successfully decoded, it is determined that the sub-region is free of defects; if a sub-region fails to decode, it is determined that the sub-region contains defects; if all sub-regions are detected and none contain defects, return "No defects found"; if all sub-regions are detected and a defect is found, return "Defect detected" and the coordinates (x0, y0) of the defective sub-region. fail (,length,n).

[0011] Compared with existing technologies, the beneficial effects of this invention are as follows: In the barcode defect detection method based on image segmentation and recognition of this invention, the barcode is first decoded by acquiring an image. After successful decoding, the coordinate position of the barcode in the image is obtained. Then, the target area where the barcode is located is calculated based on the coordinate position. Next, the target area is divided into multiple sub-regions, and each sub-region is decoded and detected sequentially. If all sub-regions are successfully decoded, a "no defect found" result is returned. If some sub-regions fail to decode, a "defect detected" result is returned, along with the coordinates of the defective sub-regions. Using this method, defect detection of barcodes can be performed, and defective areas can be accurately located, facilitating the selection of defective barcodes for subsequent processing. Attached Figure Description

[0012] Figure 1 This is a flowchart of a barcode defect detection method based on image segmentation and recognition according to an embodiment of the present invention.

[0013] Figure 2 This is a schematic diagram showing the coordinate position of the barcode in the image during step 2 of the barcode defect detection method based on image segmentation and recognition according to an embodiment of the present invention.

[0014] Figure 3 This is a schematic diagram of the target region in step 3 of the barcode defect detection method based on image segmentation and recognition according to an embodiment of the present invention. Detailed Implementation

[0015] To provide a further understanding of the purpose, structure, features and functions of the present invention, detailed descriptions are provided below with reference to embodiments.

[0016] Please refer to the above. Figures 1 to 3 , Figure 1 This is a flowchart of a barcode defect detection method based on image segmentation and recognition according to an embodiment of the present invention. Figure 2This is a schematic diagram showing the coordinate position of the barcode in the image during step 2 of the barcode defect detection method based on image segmentation and recognition according to an embodiment of the present invention. Figure 3 This is a schematic diagram of the target region in step 3 of the barcode defect detection method based on image segmentation and recognition according to an embodiment of the present invention.

[0017] The present invention provides a barcode defect detection method based on image segmentation and recognition, comprising the following steps:

[0018] Step S1: Acquire the barcode image and attempt to decode it. If decoding is successful, proceed to Step S2; otherwise, return a "detection failed" result. In this step, if decoding is successful, subsequent steps will be used to check the integrity of the barcode. If a defect is detected, the defect will be precisely located for subsequent processing. If decoding fails, it indicates that the defective area of ​​the barcode may be large, affecting the information reading results.

[0019] Step S2: Obtain the coordinates of the barcode in the image {(x1,y1), (x2,y2), (x3,y3), (x4,y4)} based on the decoding result. In this step, (x1,y1), (x2,y2), (x3,y3), (x4,y4)} are obtained. t ,y t )(t|t∈{1,2,3,4}) are the coordinates of the pixels at the four corners of the barcode in the image.

[0020] Step S3: Calculate the target area where the barcode is located based on its coordinates in the image, and denote the coordinates of this target area as (x0, y0, length, width). In this step, (x0, y0) can be the coordinates of the bottom left pixel of the barcode within the target area, length is the length of the target area, and width is the width of the target area. x0 and y0 can be set appropriately according to the needs of the site.

[0021] Step S4: Segment the target region into There are three sub-regions, each with a length of length pixels and a width of n pixels (n | n ∈ {1, ..., width}). The coordinates of each sub-region are (x0, y0, ..., y0). i The expression is: (length, n), where n is a divisor of width. Decode and detect each sub-region sequentially; if a sub-region is successfully decoded, it is determined that the sub-region is free of defects; if a sub-region fails to decode, it is determined that the sub-region contains defects; if all sub-regions are detected and none contain defects, return "No defects found"; if all sub-regions are detected and a defect is found, return "Defect detected" and the coordinates (x0, y0) of the defective sub-region. fail(,length,n).

[0022] This invention employs image segmentation and recognition technology to divide the target area containing the barcode into multiple sub-regions and decode and detect each sub-region. This enables the verification of the barcode's integrity and precise location of defective areas, facilitating subsequent processing of defective barcodes.

[0023] Please refer to the above. Figure 2 and Figure 3 In one embodiment, the coordinates of the barcode in the image are {(x1,y1), (x2,y2), (x3,y3), (x4,y4)}, where the coordinates of the bottom left pixel of the barcode are (x1,y1), the coordinates of the bottom right pixel of the barcode are (x2,y2), the coordinates of the top right pixel of the barcode are (x3,y3), and the coordinates of the top left pixel of the barcode are (x4,y4). Correspondingly, in step S3, length = |x2-x1| or length = |x3-x4|, and width = |y4-y1| or width = |y3-y2|.

[0024] In one embodiment, the coordinates of the target area are (0,0,372,262), meaning the coordinates of the bottom left pixel of the barcode within the target area are (0,0). The target area has a length of 372 pixels and a width of 262 pixels. If n is set to 1, the target area will be divided into 262 sub-regions, each 372 pixels long and 1 pixel wide, with coordinates (0,0,372,262). i ,372,1),y i = i (i|i∈{0,1,…,261}). If n is set to 2, the target region will be divided into 131 sub-regions with a length of 372 pixels and a width of 2 pixels, and the coordinates of each sub-region are (0,y). i ,372,2),y i =2i (i|i∈{0,1,…,130}), and so on.

[0025] In summary, this invention provides a barcode defect detection method based on image segmentation and recognition. First, an image is acquired and the barcode is decoded. Upon successful decoding, the coordinates of the barcode in the image are obtained. Then, the target region where the barcode is located is calculated based on the coordinates. Next, the target region is divided into multiple sub-regions, and each sub-region is decoded and detected sequentially. If all sub-regions are successfully decoded, a "no defect found" result is returned. If decoding of a sub-region fails, it is determined that a defect exists in that sub-region, and a "defect detected" result is returned, along with the coordinates of the defective sub-region. Using this method, defect detection of barcodes can be performed, and defective regions can be accurately located, facilitating the selection of defective barcodes for subsequent processing.

[0026] The present invention has been described by the above-described embodiments; however, these embodiments are merely examples for implementing the present invention. It must be noted that the disclosed embodiments do not limit the scope of the present invention. Conversely, any modifications and refinements made without departing from the spirit and scope of the present invention are within the scope of patent protection of the present invention.

Claims

1. A barcode defect detection method based on image segmentation and recognition, characterized in that: Includes the following steps: Step S1: Obtain the barcode image and attempt to decode the barcode in the image. If the decoding is successful, proceed to step S2. If the decoding fails, return the "detection failed" result. Step S2: Obtain the coordinates of the barcode in the image based on the decoding result. ;in, These are the coordinates of the pixels at the four corners of the barcode in the image. ; Step S3: Calculate the target area where the barcode is located based on its coordinates in the image, and mark the coordinates of this target area as follows: ;in, It represents the coordinates of the pixel at the bottom left corner of the barcode within the target area. The pixel length of the target region. The pixel width of the target region; Step S4: Segment the target region into The length is pixels, width Sub-regions of pixels, each sub-region has coordinates of ,in, for divisors of , For the first The y-coordinate of the bottom left pixel of each sub-region within the target region. The algorithm sequentially decodes and detects each sub-region. If a sub-region is successfully decoded, it is determined that the sub-region is free of defects. If a sub-region fails to decode, it is determined that the sub-region contains defects. If all sub-regions are successfully detected and none contain defects, the algorithm returns "No defects found". If all sub-regions are successfully detected and a defect is found, the algorithm returns "Defect detected" and the coordinates of the defective sub-region. , This represents the y-coordinate of the bottom left pixel of the defective sub-region within the target region.

Citation Information

Patent Citations

  • Tire belted layer difference level and misalignment defect detection method based on semantic segmentation network

    CN115294033A

  • Bar code defect detection method based on logistics label

    CN115294121A